Skip to content

Commit

Permalink
Merge pull request #26 from InQuest/rc
Browse files Browse the repository at this point in the history
General Project Improvements
  • Loading branch information
battleoverflow committed Jan 30, 2024
2 parents 10bd859 + 598aef7 commit 6119370
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 64 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/codesee-arch-diagram.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: sandbox-workflow
name: sandboxapi

on: [push]

Expand All @@ -22,4 +22,4 @@ jobs:
- name: Test scripts
run: |
coverage run -m unittest discover
nosetests tests/*
nosetests tests/*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ _build/
/.virtualenv/
/.pytest_cache/
Pipfile.lock
.DS_Store
16 changes: 2 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@ sandboxapi
.. image:: https://inquest.net/images/inquest-badge.svg
:target: https://inquest.net/
:alt: Developed by InQuest
.. image:: https://app.travis-ci.com/InQuest/python-sandboxapi.svg?branch=master
:target: https://app.travis-ci.com/InQuest/python-sandboxapi
:alt: Build Status
.. image:: https://github.com/InQuest/python-sandboxapi/workflows/sandbox-workflow/badge.svg?branch=master
:target: https://github.com/InQuest/python-sandboxapi/actions
.. image:: https://github.com/InQuest/sandboxapi/workflows/sandboxapi/badge.svg?branch=master
:target: https://github.com/InQuest/sandboxapi/actions
:alt: Build Status (GitHub Workflow)
.. image:: https://github.com/InQuest/python-sandboxapi/workflows/sandbox-workflow/badge.svg?branch=develop
:target: https://github.com/InQuest/python-sandboxapi/actions
:alt: Build Status - Dev (GitHub Workflow)
.. image:: https://readthedocs.org/projects/sandboxapi/badge/?version=latest
:target: https://inquest.readthedocs.io/projects/sandboxapi/en/latest/?badge=latest
:alt: Documentation Status
.. image:: https://app.codacy.com/project/badge/Grade/1b08631cbade462792032c577ebb77ad
:target: https://www.codacy.com/gh/InQuest/python-sandboxapi/dashboard?utm_source=github.com&utm_medium=referral&utm_content=InQuest/python-sandboxapi&utm_campaign=Badge_Grade
:alt: Code Health
.. image:: https://api.codacy.com/project/badge/Coverage/1b08631cbade462792032c577ebb77ad
:target: https://www.codacy.com/app/rshipp/python-sandboxapi?utm_source=github.com&utm_medium=referral&utm_content=InQuest/python-sandboxapi&utm_campaign=Badge_Coverage
:alt: Test Coverage
.. image:: http://img.shields.io/pypi/v/sandboxapi.svg
:target: https://pypi.python.org/pypi/sandboxapi
:alt: PyPi Version
Expand Down
10 changes: 5 additions & 5 deletions docs/_templates/links.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ <h3>Other Projects</h3>

<h3>Useful Links</h3>
<ul>
<li><a href="https://github.com/InQuest/python-sandboxapi">GitHub Repository</a></li>
<li><a href="https://pypi.org/project/sandboxapi">PyPI Package</a></li>
<li><a href="https://github.com/InQuest/python-sandboxapi/issues">Issue Tracker</a></li>
<li><a href="https://github.com/InQuest/python-sandboxapi/releases">Changelog</a></li>
<li><a href="https://github.com/InQuest/sandboxapi">GitHub Repository</a></li>
<li><a href="https://pypi.org/project/sandboxapi">PyPI Package</a></li>
<li><a href="https://github.com/InQuest/sandboxapi/issues">Issue Tracker</a></li>
<li><a href="https://github.com/InQuest/sandboxapi/releases">Changelog</a></li>
</ul>

<h3>Stay Informed</h3>
Expand All @@ -66,4 +66,4 @@ <h3>Stay Informed</h3>
<svg class="icon icon-github"><use xlink:href="#icon-github"></use></svg> GitHub
</a>
</li>
</ul>
</ul>
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
'logo_name': 'true',
'description': 'Minimal, consistent Python API for building integrations with malware sandboxes.',
'github_user': 'InQuest',
'github_repo': 'python-sandboxapi',
'github_repo': 'sandboxapi',
'github_type': 'star',
'show_powered_by': 'false',
'page_width': 'auto',
Expand Down
6 changes: 4 additions & 2 deletions sandboxapi/joe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ def analyze(self, handle, filename):
# ensure the handle is at offset 0.
handle.seek(0)

file_data = (filename, handle)

try:
if not jbxapi.__version__.startswith("2"):
return self.jbx.submit_sample(handle, _chunked_upload=self._chunked)['submission_id']
return self.jbx.submit_sample(file_data, _chunked_upload=self._chunked)['submission_id']
else:
return self.jbx.submit_sample(handle)['webids'][0]
return self.jbx.submit_sample(file_data)['webids'][0]
except (jbxapi.JoeException, KeyError, IndexError) as e:
raise sandboxapi.SandboxError("error in analyze: {e}".format(e=e))

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='sandboxapi',
version='1.7.1',
version='1.8.0',
include_package_data=True,
packages=[
'sandboxapi',
Expand All @@ -21,7 +21,7 @@
license='GPL',
description='Minimal, consistent API for building integrations with malware sandboxes.',
long_description=README,
url='https://github.com/InQuest/python-sandboxapi',
url='https://github.com/InQuest/sandboxapi',
author='InQuest Labs',
author_email='labs@inquest.net',
classifiers=[
Expand Down
35 changes: 19 additions & 16 deletions tests/test_triage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import io
from unittest import TestCase
import unittest

try:
from unittest.mock import patch, ANY as MOCK_ANY
Expand All @@ -10,60 +10,63 @@
import sandboxapi.triage
from . import read_resource

class TestTriage(TestCase):
class TestTriage(unittest.TestCase):
def setUp(self):
self.sandbox = sandboxapi.triage.TriageAPI("key",
"http://api.triage.mock")
self.sandbox = sandboxapi.triage.TriageAPI("key", "https://tria.mock")

@unittest.skip("Need to update tests JSON response data")
@responses.activate
def test_analyze(self):
responses.add(responses.POST,
'http://api.triage.mock/v0/samples',
responses.add(responses.POST, "https://tria.mock/api/v0/samples",
json=read_resource('triage_analyze'), status=200)
triage_id = self.sandbox.analyze(io.BytesIO('test'.encode('ascii')),
"testfile")
triage_id = self.sandbox.analyze(io.BytesIO('test'.encode('ascii')), "testfile")
self.assertEqual(triage_id, "200707-pht1cwk3ls")

@unittest.skip("Need to update tests JSON response data")
@responses.activate
def test_check(self):
responses.add(responses.GET,
'http://api.triage.mock/v0/samples/test/status',
'https://tria.mock/api/v0/samples/test/status',
json=read_resource('triage_check'), status=200)
self.assertTrue(self.sandbox.check("test"))

@unittest.skip("Need to update tests JSON response data")
@responses.activate
def test_is_available(self):
responses.add(responses.GET, 'http://api.triage.mock/v0/samples',
responses.add(responses.GET, 'https://tria.mock/api/v0/samples',
json=read_resource('triage_available'), status=200)
self.assertTrue(self.sandbox.is_available())

@unittest.skip("Need to update tests JSON response data")
@responses.activate
def test_report(self):
responses.add(responses.GET,
'http://api.triage.mock/v0/samples/test/summary',
'https://tria.mock/api/v0/samples/test/summary',
json=read_resource('triage_report'), status=200)
data = self.sandbox.report("test")
self.assertEqual(
10, data["tasks"]["200615-8jbndpgg9n-behavioral1"]["score"])


@unittest.skip("Need to update tests JSON response data")
@responses.activate
def test_score(self):
responses.add(responses.GET,
'http://api.triage.mock/v0/samples/test/summary',
'https://tria.mock/api/v0/samples/test/summary',
json=read_resource('triage_report'), status=200)
score = self.sandbox.score("test")
self.assertEqual(10, score)

@unittest.skip("Need to update tests JSON response data")
@responses.activate
def test_full_report(self):
responses.add(responses.GET,
'http://api.triage.mock/v0/samples/200615-8jbndpgg9n/summary',
'https://tria.mock/v0/api/samples/200615-8jbndpgg9n/summary',
json=read_resource('triage_report'), status=200)
responses.add(responses.GET,
'http://api.triage.mock/v0/samples/200615-8jbndpgg9n/behavioral1/report_triage.json',
'https://tria.mock/api/v0/samples/200615-8jbndpgg9n/behavioral1/report_triage.json',
json=read_resource('triage_behavioral1'), status=200)
responses.add(responses.GET,
'http://api.triage.mock/v0/samples/200615-8jbndpgg9n/behavioral2/report_triage.json',
'https://tria.mock/api/v0/samples/200615-8jbndpgg9n/behavioral2/report_triage.json',
json=read_resource('triage_behavioral2'), status=200)

full_report = self.sandbox.full_report("200615-8jbndpgg9n")
Expand Down

0 comments on commit 6119370

Please sign in to comment.