Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6.0.3 #2321

Merged
merged 28 commits into from
May 21, 2024
Merged

6.0.3 #2321

Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1d9ab10
updated yeti analyzer and connector to support new major
mlodic May 14, 2024
141a4c1
updated default pycti version
mlodic May 14, 2024
348343c
fixed MaxMind data extraction for the country flag
drosetti May 14, 2024
107c391
Fix pivot + file
0ssigeno May 15, 2024
14bf99e
healthcheck available for Plugins with `url` option by default (#2320)
mlodic May 15, 2024
2720315
Bump quark-engine from 24.4.1 to 24.5.1 in /requirements (#2313)
dependabot[bot] May 15, 2024
2bae69f
Bump jsonschema from 4.21.1 to 4.22.0 in /requirements (#2311)
dependabot[bot] May 15, 2024
9e5106e
Bump docutils from 0.20.1 to 0.21.2 in /requirements (#2312)
dependabot[bot] May 15, 2024
6145831
Revert "Bump docutils from 0.20.1 to 0.21.2 in /requirements (#2312)"
mlodic May 15, 2024
4997000
prettier
mlodic May 15, 2024
6aecd76
changes (#2322)
carellamartina May 16, 2024
2eb8c39
Phoneinfoga analyzer adjustment (#2324)
0ssigeno May 17, 2024
1a366c4
Fix serializer
0ssigeno May 17, 2024
2630701
Fix sender
0ssigeno May 17, 2024
6e1f59e
pcap_analyzers adjusts + new playbook for PCAP files + upgraded Suric…
mlodic May 17, 2024
80baf0d
fix custom analysis (#2323)
carellamartina May 20, 2024
e90b0c1
hudsonrock (#2327)
g4ze May 20, 2024
b884695
Update api_app/analyzers_manager/observable_analyzers/hudsonrock.py
mlodic May 20, 2024
877ead8
black
mlodic May 20, 2024
dde1dfd
Fixes frontend regex (#2329)
drosetti May 20, 2024
db6eb02
Cy cat#1479 (#2328)
g4ze May 20, 2024
a26f82f
updated changelog
mlodic May 20, 2024
2832bec
fix loading visualizer navbar (#2335)
carellamartina May 21, 2024
4227e96
--- (#2332)
dependabot[bot] May 21, 2024
ff42a0a
--- (#2334)
dependabot[bot] May 21, 2024
12802eb
--- (#2333)
dependabot[bot] May 21, 2024
b2b90f1
Speed up (#2336)
0ssigeno May 21, 2024
824b8f4
Revert "--- (#2333)"
mlodic May 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ Please delete options that are not relevant.
- [ ] I strictly followed the documentation ["How to create a Plugin"](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-add-a-new-plugin)
- [ ] [Usage](https://github.com/intelowlproject/IntelOwl/blob/master/docs/source/Usage.md) file was updated.
- [ ] [Advanced-Usage](https://github.com/intelowlproject/IntelOwl/blob/master/docs/source/Advanced-Usage.md) was updated (in case the plugin provides additional optional configuration).
- [ ] If the plugin requires mocked testing, `_monkeypatch()` was used in its class to apply the necessary decorators.
- [ ] I have dumped the configuration from Django Admin using the `dumpplugin` command and added it in the project as a data migration. (["How to share a plugin with the community"](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-share-your-plugin-with-the-community))
- [ ] If a File analyzer was added and it supports a mimetype which is not already supported, you added a sample of that type inside the archive `test_files.zip` and you added the default tests for that mimetype in [test_classes.py](https://github.com/intelowlproject/IntelOwl/blob/master/tests/analyzers_manager/test_classes.py).
- [ ] If you created a new analyzer and it is free (does not require API keys), please add it in the `FREE_TO_USE_ANALYZERS` playbook by following [this guide](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-modify-a-plugin).
- [ ] If you created a new analyzer and it is free (does not require any API key), please add it in the `FREE_TO_USE_ANALYZERS` playbook by following [this guide](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-modify-a-plugin).
- [ ] Check if it could make sense to add that analyzer/connector to other [freely available playbooks](https://intelowl.readthedocs.io/en/develop/Usage.html#list-of-pre-built-playbooks).
- [ ] I have provided the resulting raw JSON of a finished analysis and a screenshot of the results.
- [ ] 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.
- [ ] 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 external libraries/packages with restrictive licenses were used, they were added in the [Legal Notice](https://github.com/certego/IntelOwl/blob/master/.github/legal_notice.md) section.
- [ ] Linters (`Black`, `Flake`, `Isort`) gave 0 errors. If you have correctly installed [pre-commit](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-start-setup-project-and-development-instance), it does these checks and adjustments on your behalf.
Expand Down
4 changes: 2 additions & 2 deletions api_app/analyzers_manager/file_analyzers/docguard.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class DocGuardUpload(FileAnalyzer):
base_url = "https://api.docguard.io:8443/api"
url = "https://api.docguard.io:8443/api"
_api_key_name: str

def run(self):
Expand All @@ -31,7 +31,7 @@ def run(self):
if not binary:
raise AnalyzerRunException("File is empty")
response = requests.post(
self.base_url + "/FileAnalyzing/AnalyzeFile",
self.url + "/FileAnalyzing/AnalyzeFile",
headers=headers,
files={"file": (self.filename, binary)},
)
Expand Down
6 changes: 3 additions & 3 deletions api_app/analyzers_manager/file_analyzers/filescan.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FileScanUpload(FileAnalyzer):

max_tries: int = 30
poll_distance: int = 10
base_url = "https://www.filescan.io/api"
url = "https://www.filescan.io/api"
_api_key: str

def run(self):
Expand All @@ -31,7 +31,7 @@ def __upload_file_for_scan(self) -> int:
if not binary:
raise AnalyzerRunException("File is empty")
response = requests.post(
self.base_url + "/scan/file",
self.url + "/scan/file",
files={"file": (self.filename, binary)},
headers={"X-Api-Key": self._api_key},
)
Expand All @@ -41,7 +41,7 @@ def __upload_file_for_scan(self) -> int:

def __fetch_report(self, task_id: int) -> dict:
report = {}
url = f"{self.base_url}/scan/{task_id}/report"
url = f"{self.url}/scan/{task_id}/report"
params = {
"filter": [
"general",
Expand Down
12 changes: 11 additions & 1 deletion api_app/analyzers_manager/file_analyzers/hfinger.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@ class Hfinger(FileAnalyzer):
fingerprint_report_mode: int = 2

def run(self):
return hfinger_analyze(self.filepath, self.fingerprint_report_mode)
reports = dict()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
reports = dict()
reports = {}

Using dict literal syntax is simpler and computationally quicker. Explained here.

reports["extraction"] = hfinger_analyze(
self.filepath, self.fingerprint_report_mode
)
fingerprints = set()
for report in reports["extraction"]:
fingerprint = report.get("fingerprint", "")
if fingerprint:
fingerprints.add(fingerprint)
reports["fingerprints_summary"] = list(fingerprints)
return reports

@classmethod
def update(cls) -> bool:
Expand Down
6 changes: 3 additions & 3 deletions api_app/analyzers_manager/file_analyzers/malpedia_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ class MalpediaScan(FileAnalyzer):
Scan a binary against all YARA rules in Malpedia.
"""

base_url = "https://malpedia.caad.fkie.fraunhofer.de/api"
url = base_url + "/scan/binary"
url = "https://malpedia.caad.fkie.fraunhofer.de/api"
binary_url = url + "/scan/binary"

_api_key_name: str

Expand All @@ -23,7 +23,7 @@ def run(self):
# construct req
headers = {"Authorization": f"APIToken {self._api_key_name}"}
files = {"file": binary}
response = requests.post(self.url, headers=headers, files=files)
response = requests.post(self.binary_url, headers=headers, files=files)
response.raise_for_status()

result = response.json()
Expand Down
2 changes: 1 addition & 1 deletion api_app/analyzers_manager/file_analyzers/triage_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def run(self):
logger.info(f"triage md5 {self.md5} sending sample for analysis")
for _try in range(self.max_tries):
logger.info(f"triage md5 {self.md5} polling for result try #{_try + 1}")
self.response = self.session.post(self.base_url + "samples", files=files)
self.response = self.session.post(self.url + "samples", files=files)
if self.response.status_code == 200:
break
time.sleep(self.poll_distance)
Expand Down
8 changes: 3 additions & 5 deletions api_app/analyzers_manager/file_analyzers/unpac_me.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class UnpacMe(FileAnalyzer):
base_url: str = "https://api.unpac.me/api/v1/"
url: str = "https://api.unpac.me/api/v1/"

_api_key_name: str
private: bool
Expand Down Expand Up @@ -60,12 +60,10 @@ def run(self):
def _req_with_checks(self, url, files=None, post=False):
try:
if post:
r = requests.post(
self.base_url + url, files=files, headers=self.headers
)
r = requests.post(self.url + url, files=files, headers=self.headers)
else:
headers = self.headers if self.private == "private" else {}
r = requests.get(self.base_url + url, files=files, headers=headers)
r = requests.get(self.url + url, files=files, headers=headers)
r.raise_for_status()
except requests.exceptions.HTTPError as e:
logger.error(
Expand Down
8 changes: 4 additions & 4 deletions api_app/analyzers_manager/file_analyzers/virushee.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class VirusheeFileUpload(FileAnalyzer):

max_tries = 30
poll_distance = 10
base_url = "https://api.virushee.com"
url = "https://api.virushee.com"

_api_key_name: str

Expand All @@ -46,7 +46,7 @@ def run(self):

def __check_report_for_hash(self) -> Optional[dict]:
response_json = None
response = self.__session.get(f"{self.base_url}/file/hash/{self.md5}")
response = self.__session.get(f"{self.url}/file/hash/{self.md5}")
if response.status_code == 404: # hash not found in db
return response_json
response.raise_for_status()
Expand All @@ -57,13 +57,13 @@ def __check_report_for_hash(self) -> Optional[dict]:
def __upload_file(self, binary: bytes) -> str:
name_to_send = self.filename if self.filename else self.md5
files = {"file": (name_to_send, binary)}
response = self.__session.post(f"{self.base_url}/file/upload", files=files)
response = self.__session.post(f"{self.url}/file/upload", files=files)
response.raise_for_status()
return response.json()["task"]

def __poll_status_and_result(self, task_id: str) -> dict:
response_json = None
url = f"{self.base_url}/file/task/{task_id}"
url = f"{self.url}/file/task/{task_id}"
for chance in range(self.max_tries):
logger.info(f"Polling try#{chance+1}")
response = self.__session.get(url)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.db import migrations


def migrate(apps, schema_editor):
PythonModule = apps.get_model("api_app", "PythonModule")

pm = PythonModule.objects.get(
module="mmdb_server.MmdbServer",
base_path="api_app.analyzers_manager.observable_analyzers",
)
param = pm.parameters.get(name="base_url")
param.name = "url"
param.save()


def reverse_migrate(apps, schema_editor):
pass


class Migration(migrations.Migration):
dependencies = [
("analyzers_manager", "0086_analyzer_config_blint"),
]
operations = [
migrations.RunPython(migrate, reverse_migrate),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from django.db import migrations


def migrate(apps, schema_editor):
Parameter = apps.get_model("api_app", "Parameter")
PluginConfig = apps.get_model("api_app", "PluginConfig")
PythonModule = apps.get_model("api_app", "PythonModule")
pm = PythonModule.objects.get(
module="phoneinfoga_scan.Phoneinfoga",
base_path="api_app.analyzers_manager.observable_analyzers",
)
Parameter.objects.create(
name="googlecse_max_results",
type="int",
description="Number of Google results for [Phoneinfoga](https://sundowndev.github.io/phoneinfoga/)",
is_secret=False,
required=False,
python_module=pm,
)
p2 = Parameter.objects.create(
name="scanners",
type="list",
description="List of scanner names for [Phoneinfoga](https://sundowndev.github.io/phoneinfoga/). Available options are: `local,numverify,googlecse,ovh`",
is_secret=False,
required=False,
python_module=pm,
)
p3 = Parameter.objects.get(name="scanner_name", python_module=pm)
for config in pm.analyzerconfigs.all():
pcs = PluginConfig.objects.filter(analyzer_config=config, parameter=p3)
for pc in pcs:
pc.value = [pc.value]
pc.parameter = p2
pc.save()
p3.delete()
Parameter.objects.create(
name="all_scanners",
type="bool",
description="Set this to True to enable all available scanners. "
"If enabled, this overwrite the scanner param",
is_secret=False,
required=False,
python_module=pm,
)


class Migration(migrations.Migration):
atomic = False
dependencies = [
("analyzers_manager", "0087_alter_mmdbserver_param"),
]

operations = [migrations.RunPython(migrate, migrations.RunPython.noop)]
Loading
Loading