Skip to content

Commit

Permalink
Merge pull request #25 from anikobartos/opswat_sandbox_check_fix
Browse files Browse the repository at this point in the history
OPSWAT Filescan Sandbox: Fixed missing header in check, add error handling
  • Loading branch information
battleoverflow committed Dec 20, 2023
2 parents a9e7d1e + fd47f0a commit 10bd859
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sandboxapi/opswat.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def check(self, item_id):
:rtype: bool
:return: Boolean indicating if a report is done or not.
"""
response = self._request("/api/scan/{flow_id}/report".format(flow_id=item_id))
response = self._request(
"/api/scan/{flow_id}/report".format(flow_id=item_id), headers=self.headers
)

if response.status_code == 404:
# unknown id
Expand All @@ -92,6 +94,11 @@ def check(self, item_id):
try:
if "allFinished" in response.json() and response.json()["allFinished"]:
return True
elif "allFinished" not in response.json():
raise sandboxapi.SandboxError(
"api error in check ({u}): {r}".format(
u=response.url, r=response.content
))

except ValueError as e:
raise sandboxapi.SandboxError(e)
Expand Down Expand Up @@ -151,7 +158,7 @@ def report(self, item_id, report_format="json"):
"filter=taskReference",
"filter=subtaskReferences",
"filter=allSignalGroups",
"filter=iocs"
"filter=iocs",
]

postfix = "&".join(filters)
Expand Down

0 comments on commit 10bd859

Please sign in to comment.