暫無描述

manage_tlps_routes.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # IRIS Source Code
  2. # Copyright (C) 2021 - Airbus CyberSecurity (SAS)
  3. # ir@cyberactionlab.net
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 3 of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. from flask import Blueprint
  19. from app.models.models import Tlp
  20. from app.blueprints.access_controls import ac_api_requires
  21. from app.blueprints.responses import response_error
  22. from app.blueprints.responses import response_success
  23. manage_tlp_type_rest_blueprint = Blueprint('manage_tlp_types_rest', __name__)
  24. @manage_tlp_type_rest_blueprint.route('/manage/tlp/list', methods=['GET'])
  25. @ac_api_requires()
  26. def list_tlp_types():
  27. lstatus = Tlp.query.all()
  28. return response_success("", data=lstatus)
  29. @manage_tlp_type_rest_blueprint.route('/manage/tlp/<int:cur_id>', methods=['GET'])
  30. @ac_api_requires()
  31. def get_tlp_type(cur_id):
  32. tlp_type = Tlp.query.filter(Tlp.tlp_id == cur_id).first()
  33. if not tlp_type:
  34. return response_error("Invalid TLP ID {type_id}".format(type_id=cur_id))
  35. return response_success("", data=tlp_type)