Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
0fec647
unit tests
pranjalg1331 Jun 3, 2025
1953a9b
unittests framework
pranjalg1331 Jun 5, 2025
637f207
cleanup
pranjalg1331 Jun 5, 2025
6081aa8
correct python error
pranjalg1331 Jun 5, 2025
336de9a
making class method
pranjalg1331 Jun 5, 2025
93a3bb9
mock location changed
pranjalg1331 Jun 11, 2025
68e285d
python deepsource
pranjalg1331 Jun 11, 2025
2ef7d63
abusix
pranjalg1331 Jun 12, 2025
ad59daa
file base class initial draft
pranjalg1331 Jun 18, 2025
fe55cdc
blint_scan test
pranjalg1331 Jun 18, 2025
c56aeec
boxjs
pranjalg1331 Jun 22, 2025
8543731
debloat
pranjalg1331 Jun 23, 2025
d6090d1
cleanup
pranjalg1331 Jun 23, 2025
017f301
updated base class
pranjalg1331 Jun 24, 2025
723cf45
python errors
pranjalg1331 Jun 25, 2025
d5652f8
added analyzer unit tests
pranjalg1331 Jun 28, 2025
4a919f7
new file analyzers
pranjalg1331 Jun 29, 2025
9ee88ba
checkphish
pranjalg1331 Jul 4, 2025
a3f19c8
greynoise_labs
pranjalg1331 Jul 4, 2025
57b80ce
ja4db
pranjalg1331 Jul 5, 2025
27e60aa
netlas
pranjalg1331 Jul 8, 2025
7936258
polyswarm
pranjalg1331 Jul 15, 2025
dd67338
thug_url
pranjalg1331 Jul 18, 2025
2d3c279
zoomeye
pranjalg1331 Jul 18, 2025
6ed8c10
file analyzers test+ base class improved
pranjalg1331 Jul 26, 2025
7549b46
commenting old tests
pranjalg1331 Jul 27, 2025
ca4d605
commenting old tests -2
pranjalg1331 Jul 27, 2025
97b72aa
commenting old tests -3
pranjalg1331 Jul 27, 2025
9c8be2f
add init
pranjalg1331 Jul 29, 2025
3fd01c5
trial workflow
pranjalg1331 Jul 29, 2025
b043889
correct error
pranjalg1331 Jul 29, 2025
a16b9e6
greynosise error
pranjalg1331 Jul 30, 2025
2aaec7f
greynosise error-2
pranjalg1331 Jul 30, 2025
08616b2
comment out
pranjalg1331 Jul 31, 2025
1a0f266
remove monkeypatch
pranjalg1331 Jul 31, 2025
1f9f7d2
remove monkeypatch from file_analyzers
pranjalg1331 Jul 31, 2025
36a884c
zippy_scan
pranjalg1331 Aug 3, 2025
be26d3f
yaraify test class
pranjalg1331 Aug 3, 2025
893f053
uncomment
pranjalg1331 Aug 3, 2025
783bc74
delete
pranjalg1331 Aug 3, 2025
ce8ff66
uncomment analyzer tests
pranjalg1331 Aug 3, 2025
f30dde0
new analyzer tests
pranjalg1331 Aug 5, 2025
830d0fb
clearing monkeppatch
pranjalg1331 Aug 6, 2025
3fed643
modify class to remove mock response in docker analyzers
pranjalg1331 Aug 6, 2025
1811b83
no changes to pr automation
pranjalg1331 Aug 6, 2025
bb555ed
test errors
pranjalg1331 Aug 11, 2025
bf40708
correct errors
pranjalg1331 Aug 11, 2025
b61e583
separated transactions tests
pranjalg1331 Aug 12, 2025
4064f35
hfinger
pranjalg1331 Aug 16, 2025
c241e5d
loggin improved
pranjalg1331 Aug 16, 2025
d3e9791
remove f
pranjalg1331 Aug 16, 2025
579b461
merge logs
pranjalg1331 Aug 16, 2025
6da72e5
deep python errors
pranjalg1331 Aug 16, 2025
8e4541d
pr template update
pranjalg1331 Aug 18, 2025
d1d3e7e
new analyzers + update pr template
pranjalg1331 Aug 18, 2025
c629178
update dir structure for integration tests
pranjalg1331 Aug 18, 2025
5d980ff
more tests
pranjalg1331 Aug 25, 2025
f061c19
lint
pranjalg1331 Aug 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Please delete options that are not relevant.
- [ ] Check if it could make sense to add that analyzer/connector to other [freely available playbooks](https://intelowlproject.github.io/docs/IntelOwl/usage/#list-of-pre-built-playbooks).
- [ ] I have provided the resulting raw JSON of a finished analysis and a screenshot of the results.
- [ ] If the plugin interacts with an external service, I have created an attribute called precisely `url` that contains this information. This is required for Health Checks (HEAD HTTP requests).
- [ ] If the plugin requires mocked testing, `_monkeypatch()` was used in its class to apply the necessary decorators.
- [ ] I have added that raw JSON sample to the `MockUpResponse` of the `_monkeypatch()` method. This serves us to provide a valid sample for testing.
- [ ] If a new analyzer has beed added, I have created a unittest for it in the appropriate dir. I have also mocked all the external calls, so that no real calls are being made while testing.
- [ ] I have added that raw JSON sample to the `get_mocker_response()` method of the unittest class. This serves us to provide a valid sample for testing.
- [ ] I have created the corresponding `DataModel` for the new analyzer following the [documentation](https://intelowlproject.github.io/docs/IntelOwl/contribute/#how-to-create-a-datamodel)
- [ ] I have inserted the copyright banner at the start of the file: ```# This file is a part of IntelOwl https://github.com/intelowlproject/IntelOwl # See the file 'LICENSE' for copying permission.```
- [ ] Please avoid adding new libraries as requirements whenever it is possible. Use new libraries only if strictly needed to solve the issue you are working for. In case of doubt, ask a maintainer permission to use a specific library.
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/pull_request_automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ jobs:
- name: Run test
run: |
docker exec intelowl_uwsgi coverage run manage.py test --keepdb tests
- name: Run async tests
run: |
docker exec intelowl_uwsgi coverage run manage.py test --keepdb async_tests

frontend-tests:
runs-on: ubuntu-latest
Expand Down
38 changes: 0 additions & 38 deletions api_app/analyzers_manager/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from django.conf import settings

from certego_saas.apps.user.models import User
from tests.mock_utils import MockUpResponse, if_mock_connections, patch

from ..choices import Classification, PythonModuleBasePaths
from ..classes import Plugin
Expand Down Expand Up @@ -487,43 +486,6 @@ def _docker_get(self):
raise AssertionError
return resp

@staticmethod
def mocked_docker_analyzer_get(*args, **kwargs):
return MockUpResponse(
{"key": "test", "returncode": 0, "report": {"test": "This is a test."}}, 200
)

@staticmethod
def mocked_docker_analyzer_post(*args, **kwargs):
return MockUpResponse({"key": "test", "status": "running"}, 202)

def _monkeypatch(self, patches: list = None):
"""
Here, `_monkeypatch` is an instance method and not a class method.
This is because when defined with `@classmethod`, we were getting the error
```
'_patch' object has no attribute 'is_local'
```
whenever multiple analyzers with same parent class were being called.
"""
if patches is None:
patches = []
# no need to sleep during tests
self.poll_distance = 0
patches.append(
if_mock_connections(
patch(
"requests.get",
side_effect=self.mocked_docker_analyzer_get,
),
patch(
"requests.post",
side_effect=self.mocked_docker_analyzer_post,
),
)
)
return super()._monkeypatch(patches)

def health_check(self, user: User = None) -> bool:
"""
basic health check: if instance is up or not (timeout - 10s)
Expand Down
45 changes: 0 additions & 45 deletions api_app/analyzers_manager/file_analyzers/artifacts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging

from api_app.analyzers_manager.classes import DockerBasedAnalyzer, FileAnalyzer
from tests.mock_utils import MockUpResponse

logger = logging.getLogger(__name__)

Expand All @@ -28,47 +27,3 @@ def run(self):
)
result = self._docker_run(req_data, req_files, analyzer_name=self.analyzer_name)
return result

# flake8: noqa
@staticmethod
def mocked_docker_analyzer_get(*args, **kwargs):
return MockUpResponse(
{
"report": {
"name": "APK_Artifacts",
"process_time": 5.07,
"status": "SUCCESS",
"end_time": "2024-08-27T10:03:15.563886Z",
"parameters": {},
"type": "analyzer",
"id": 72,
"report": {
"dex": ["classes.dex"],
"md5": "8a05a189e58ccd7275f7ffdf88c2c191",
"root": [],
"family": {
"name": "CryCrypto",
"match": 11.11,
"value": {
"intent": 33.33,
"permission": 0.0,
"application": 0.0,
},
},
"string": {"known": [], "base64": [], "telegram_id": []},
"library": [],
"network": {"ip": [], "url": [], "param": []},
"sandbox": [
"https://tria.ge/s?q=8a05a189e58ccd7275f7ffdf88c2c191",
"https://www.joesandbox.com/analysis/search?q=8a05a189e58ccd7275f7ffdf88c2c191",
"https://www.virustotal.com/gui/search/8a05a189e58ccd7275f7ffdf88c2c191",
"https://bazaar.abuse.ch/browse.php?search=md5:8a05a189e58ccd7275f7ffdf88c2c191",
"https://koodous.com/apks?search=8a05a189e58ccd7275f7ffdf88c2c191",
],
"version": "1.1.1",
"elapsed_time": 0.02,
},
}
},
200,
)
4 changes: 0 additions & 4 deletions api_app/analyzers_manager/file_analyzers/boxjs_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,3 @@ def run(self):
report["uris"] = list(set(report["uris"])) # uniq

return report

# disable mockup connections for this class
@classmethod
def _monkeypatch(cls, patches: list = None) -> None: ... # noqa: E704
29 changes: 0 additions & 29 deletions api_app/analyzers_manager/file_analyzers/cape_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

from api_app.analyzers_manager.classes import FileAnalyzer
from api_app.analyzers_manager.exceptions import AnalyzerRunException
from tests.mock_utils import MockUpResponse, if_mock_connections, patch

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -335,31 +334,3 @@ def __poll_for_result(
)

return results

@classmethod
def _monkeypatch(cls):
patches = [
if_mock_connections(
patch(
"requests.Session.get",
return_value=MockUpResponse(
{"error": False, "data": "completed"}, 200
),
),
patch(
"requests.Session.post",
return_value=MockUpResponse(
{
"error": False,
"data": {
"task_ids": [1234],
},
"errors": [],
"url": ["http://fake_url.com/submit/status/1234/"],
},
200,
),
),
)
]
return super()._monkeypatch(patches=patches)
7 changes: 0 additions & 7 deletions api_app/analyzers_manager/file_analyzers/clamav.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logging

from api_app.analyzers_manager.classes import DockerBasedAnalyzer, FileAnalyzer
from tests.mock_utils import MockUpResponse

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -46,9 +45,3 @@ def run(self):
logger.error(f"no detections extracted? {self.job_id}")

return {"detections": list(set(detections)), "raw_report": report}

@staticmethod
def mocked_docker_analyzer_get(*args, **kwargs):
return MockUpResponse(
{"key": "test", "returncode": 0, "report": "OK real_signature\n"}, 200
)
17 changes: 0 additions & 17 deletions api_app/analyzers_manager/file_analyzers/cuckoo_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from api_app.analyzers_manager.classes import FileAnalyzer
from api_app.analyzers_manager.exceptions import AnalyzerRunException
from tests.mock_utils import MockUpResponse, if_mock_connections, patch

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -261,19 +260,3 @@ def __cuckoo_retrieve_and_create_report(self):
logger.info(f"report generated for ({self.filename},{self.md5})")

return result

@classmethod
def _monkeypatch(cls):
patches = [
if_mock_connections(
patch(
"requests.Session.get",
return_value=MockUpResponse({"task": {"status": "reported"}}, 200),
),
patch(
"requests.Session.post",
return_value=MockUpResponse({}, 200),
),
)
]
return super()._monkeypatch(patches=patches)
Loading
Loading