Skip to content

Commit

Permalink
remove unneccessary part
Browse files Browse the repository at this point in the history
  • Loading branch information
anikobartos committed Oct 24, 2023
1 parent 1e5fdcd commit 0cfb8b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ Example::
OPSWAT Filescan Sandbox. You can use the Activation Key that you received
from your OPSWAT Sales Representative, and follow the instructions on the
`OPSWAT Licence Activation`_ page or you can create an API key on the
`OPSWAT Community Site`_ under API Key tab.
`OPSWAT Filescan Community Site`_ under API Key tab.

More details in the `OPSWAT Filescan Sandbox API documentation`_.

Expand Down Expand Up @@ -301,7 +301,7 @@ number of online analysis services.
.. _official Joe Sandbox library: https://github.com/joesecurity/joesandboxcloudapi
.. _official Falcon library: https://github.com/PayloadSecurity/VxAPI
.. _OPSWAT Licence Activation: https://docs.opswat.com/filescan/installation/license-activation
.. _OPSWAT Community Site: https://www.filescan.io/users/profile
.. _OPSWAT Filescan Community Site: https://www.filescan.io/users/profile
.. _OPSWAT Filescan Sandbox API documentation: https://docs.opswat.com/filescan/opswat-filescan
.. _malsub: https://github.com/diogo-fernan/malsub
.. _Triage public cloud: https://tria.ge/
Expand Down
22 changes: 12 additions & 10 deletions sandboxapi/opswat.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from __future__ import print_function

# import json
import sandboxapi
import sys
import time
Expand Down Expand Up @@ -28,14 +27,17 @@ def __init__(
self.headers = {"X-Api-Key": self.api_key}
self.verify_ssl = verify_ssl

# def analyze(self, handle, filename, password = None):
def analyze(self, handle, filename, password=None, is_private=False):
"""Submit a file for analysis.
:type handle: File handle
:param handle: Handle to file to upload for analysis.
:type filename: str
:param filename: File name.
:type password: str
:param password: Custom password, in case uploaded archive is protected.
:type is_private: boolean
:param is_private: If file should not be available for download by other users.
:rtype: str
:return: flow_id as a string
Expand Down Expand Up @@ -140,7 +142,10 @@ def report(self, item_id, report_format="json"):
:return: Dictionary representing the JSON parsed data or raw, for other
formats / JSON parsing failure.
"""


if report_format == "html":
return "Report Unavailable"

filters = [
"filter=general",
"filter=finalVerdict",
Expand All @@ -149,6 +154,7 @@ def report(self, item_id, report_format="json"):
"filter=taskReference",
"filter=subtaskReferences",
"filter=allSignalGroups",
"filter=iocs"
]

postfix = "&".join(filters)
Expand All @@ -158,9 +164,6 @@ def report(self, item_id, report_format="json"):

response = self._request(url_suffix, headers=self.headers)

if report_format == "html":
return "Report Unavailable"

try:
return response.json()
except ValueError:
Expand Down Expand Up @@ -199,7 +202,7 @@ def opswat_loop(opswat, filename):
if __name__ == "__main__":

def usage():
msg = "%s: <url> <api_key> <submit <fh> | available | report <id> | score <report> | analyze <fh>"
msg = "%s: <filescan_url> <api_key> <submit <file_path> | available | report <flow_id> | score <report> | analyze <file_path>"
print(msg % sys.argv[0])
sys.exit(1)

Expand All @@ -218,10 +221,9 @@ def usage():
else:
usage()

# instantiate OPSWAT Filescan Sandbox API interface.
opswat = OPSWATSandboxAPI(api_key)
opswat = OPSWATSandboxAPI(api_key, url)

if arg is None:
if arg is None and "available" not in cmd:
usage()

# process command line arguments.
Expand Down

0 comments on commit 0cfb8b8

Please sign in to comment.