Нема описа

evidence_storage.py 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 app.datamgmt.case.case_rfiles_db import add_rfile
  19. from app.models.models import CaseReceivedFile
  20. class EvidenceStorage(object):
  21. @staticmethod
  22. def is_evidence_registered(case_id, sha256):
  23. data = CaseReceivedFile.query.filter(
  24. CaseReceivedFile.case_id == case_id,
  25. CaseReceivedFile.file_hash == sha256
  26. ).first()
  27. return True if data else False
  28. @staticmethod
  29. def add_evidence(case_id, filename, description, size, sha256, date_added, user_id):
  30. evidence = CaseReceivedFile()
  31. evidence.file_description = description
  32. evidence.filename = filename
  33. evidence.file_size = size
  34. evidence.file_hash = sha256
  35. return add_rfile(evidence, case_id, user_id)