Skip to content

Commit 872b113

Browse files
mlodicdrosetti0ssigenocarellamartinafgibertoni
authored
Merge pull request #2041 from intelowlproject/develop
* added book icon * Fix md Signed-off-by: 0ssigeno <[email protected]> * Adjusted toasts (#2015) * adjusted toast * fix test --------- Co-authored-by: Daniele Rosetti <[email protected]> * updated flare-floss to v3 * updated flare-floss to v3.0.1 * fixed the doc about contribute * fixed unresponsive scan page form with large files * changed social button popover trigger * fixed order problem in visualizer tabs * fixed PR template * fixed PR template * Frontend - HealthCheck and Pull buttons (#2025) * added healthcheck and pull button * test draft * frontend tests * adjusted toasts * added rule to short variable names (#2026) * added rule to short variable names * fix * fixed rules * fixed rules * added todo comment * fix * added note * fixed short var names * fixes * fix * fix * fix * comment * #1990 DNS0 /names Analyzer (#2024) * First not tested prototype * Added _monkeypatch() skeleton * Fixed a wrong condition in parameter validation * Added config() function to prepare data for request * Added hasattr() check for attributes * First successful run - Added check on existence of API parameter - Added authorization header - Added checks on parameters existence * Fix _api_name parameter check * Fixed parameter configuration * Removed unused if statement * Added support for UNIX timestamps and relative dates * Renamed dns0 service to separate services * Completed checks for not set parameters * Added checks of existence for all parameters * Added default Accept format header * Simplified regex to match single relative date * Fixed date check by forcing format * Modified _api_key to be non required * Made _api_key optional to support 10 free queries/day * Added /rrsets API * Moved files into separate dns0/ folder * Created module structure and base file * Extracted a common Mixin and applied to subclasses * Resolved performance issue flagged by deepsource * Added absolute import path * Substituted dateutils with dateparser and updated requirements * Updated Usage.md * Added explanation in Advanced-Usage.md * Fix dump Signed-off-by: 0ssigeno <[email protected]> * Black Signed-off-by: 0ssigeno <[email protected]> * Added analyzer config migrations * Added new analyzers to FREE_TO_USE_ANALYZERS playbook * Removed dns query type check * Removed unused variable 'query' * Added explicit default value in 'limit' parameter * Added DNS0 api docs reference * Solved deepsource warnings * Added custom user agent * Removed DNS0_rrsets_data * Solved deepsource warning * Added example JSON data * Generalization of ids Signed-off-by: 0ssigeno <[email protected]> * Fix dumpplugin migration generation Signed-off-by: 0ssigeno <[email protected]> * Excluding id Signed-off-by: 0ssigeno <[email protected]> * Excluding id in migration Signed-off-by: 0ssigeno <[email protected]> * Added default parameter in test * Added link to the DNS0 doc in plugin description * Fix pipeline test #1 * Fix pipeline test n2 * Fix pipeline test n3 * Fix pipeline test n4 * Fix pipeline test n5 * Fix pipeline test n6 * Fix pipeline test n7 * Fix pipeline test n8 * Fix pipeline test n9 * Fix pipeline test n10 * Fix pipeline test n11 * Fix pipeline test n12 * Fix pipeline test n13 * Fix pipeline test n14 * Fix pipeline test n15 * Fix pipeline test n16 * Fix pipeline test n17 * Removed unused q parameter --------- Signed-off-by: 0ssigeno <[email protected]> Co-authored-by: 0ssigeno <[email protected]> * Bump actions/setup-python from 4.7.0 to 5.0.0 (#2022) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4.7.0 to 5.0.0. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](actions/setup-python@v4.7.0...v5.0.0) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump google-cloud-webrisk from 1.12.0 to 1.13.0 in /requirements (#2018) Bumps [google-cloud-webrisk](https://github.com/googleapis/google-cloud-python) from 1.12.0 to 1.13.0. - [Release notes](https://github.com/googleapis/google-cloud-python/releases) - [Changelog](https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-documentai/CHANGELOG.md) - [Commits](googleapis/google-cloud-python@google-cloud-webrisk-v1.12.0...google-cloud-webrisk-v1.13.0) --- updated-dependencies: - dependency-name: google-cloud-webrisk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Corner case migration Signed-off-by: 0ssigeno <[email protected]> * More logs Signed-off-by: 0ssigeno <[email protected]> * Fix Signed-off-by: 0ssigeno <[email protected]> * incremented logs in most used apis * Elastic bi (#2036) * Elastic bi Signed-off-by: 0ssigeno <[email protected]> * Elastic bi + fix elastic package Signed-off-by: 0ssigeno <[email protected]> * Update api_app/queryset.py Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com> * Fix Signed-off-by: 0ssigeno <[email protected]> * Index template Signed-off-by: 0ssigeno <[email protected]> * Fixes Signed-off-by: 0ssigeno <[email protected]> --------- Signed-off-by: 0ssigeno <[email protected]> Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com> * changelog + docs + bump + django doctor + deepsource * Bump github/codeql-action from 2 to 3 (#2033) Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3. - [Release notes](https://github.com/github/codeql-action/releases) - [Commits](github/codeql-action@v2...v3) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump authlib from 1.2.0 to 1.3.0 in /requirements (#2031) Bumps [authlib](https://github.com/lepture/authlib) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/lepture/authlib/releases) - [Changelog](https://github.com/lepture/authlib/blob/master/docs/changelog.rst) - [Commits](authlib/authlib@v1.2.0...v1.3.0) --- updated-dependencies: - dependency-name: authlib dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fixed permissions and log files for ClamAV * Added IP and subdomain support for DNS0_rrsets_data (#2042) * Added IP support for DNS0_rrsets_data analyzer * Added include_subdomain parameter * Typo * Restore original state * Added alter migration to add a new supported type and new parameter * fix deepsource --------- Signed-off-by: 0ssigeno <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Daniele Rosetti <[email protected]> Co-authored-by: 0ssigeno <[email protected]> Co-authored-by: Martina Carella <[email protected]> Co-authored-by: Daniele Rosetti <[email protected]> Co-authored-by: fgibertoni <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Simone Berni <[email protected]> Co-authored-by: code-review-doctor[bot] <72320148+code-review-doctor[bot]@users.noreply.github.com>
2 parents abad9cc + aefb8bb commit 872b113

File tree

125 files changed

+2941
-1022
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+2941
-1022
lines changed

.github/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,24 @@
22

33
[**Upgrade Guide**](https://intelowl.readthedocs.io/en/latest/Installation.md#update-to-the-most-recent-version)
44

5+
## [v5.2.2](https://github.com/intelowlproject/IntelOwl/releases/tag/v5.2.2)
6+
7+
This release has been done mainly to adjusts a broken database migration introduced in the previous release.
8+
9+
**Main Improvements**
10+
* Added new analyzers for [DNS0](https://docs.dns0.eu/) PassiveDNS data
11+
* Added the chance to collect metrics ([Business Intelligence](https://intelowl.readthedocs.io/en/develop/Advanced-Configuration.html#business-intelligence) regarding Plugins Usage and send it to an ElasticSearch instance.
12+
* Added new buttons to test ["Healthcheck" and "Pull" operations](https://intelowl.readthedocs.io/en/latest/Usage.html#special-plugins-operations) for each Plugin (A feature introduced in the previous version)
13+
14+
**Other improvements**
15+
* Various generic fixes and adjustments in the GUI
16+
* dependencies upgrades
17+
* adjusted contribution guides
18+
519
## [v5.2.1](https://github.com/intelowlproject/IntelOwl/releases/tag/v5.2.1)
620

21+
!!! This release has been found with a broken database migration !!! Please upgrade to v5.2.2 to fix the problem.
22+
723
**General improvements**
824
* Incremented wait time of containers' healthchecks to avoid to break clean installations
925
* Improvements to the "Scan page":

.github/pull_request_template.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ Please delete options that are not relevant.
1919
- [ ] A new plugin (analyzer, connector, visualizer, playbook, pivot or ingestor) was added or changed, in which case:
2020
- [ ] I strictly followed the documentation ["How to create a Plugin"](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-add-a-new-plugin)
2121
- [ ] [Usage](https://github.com/intelowlproject/IntelOwl/blob/master/docs/source/Usage.md) file was updated.
22-
- [ ] [Advanced-Usage](./Advanced-Usage.md) was updated (in case the plugin provides additional optional configuration).
22+
- [ ] [Advanced-Usage](https://github.com/intelowlproject/IntelOwl/blob/master/docs/source/Advanced-Usage.md) was updated (in case the plugin provides additional optional configuration).
2323
- [ ] If the plugin requires mocked testing, `_monkeypatch()` was used in its class to apply the necessary decorators.
24-
- [ ] I have dumped the configuration from Django Admin using the `dumpplugin` command and added it in the project as a data migration. [Doc](["How to create a Plugin"](https://intelowl.readthedocs.io/en/latest/Contribute.html#how-to-add-a-new-plugin))
24+
- [ ] 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))
2525
- [ ] 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).
26-
- [ ] 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 in `playbook_config.json`.
26+
- [ ] 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).
2727
- [ ] 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).
2828
- [ ] I have provided the resulting raw JSON of a finished analysis and a screenshot of the results.
2929
- [ ] 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.
3030
- [ ] 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.
3131
- [ ] I have added tests for the feature/bug I solved (see `tests` folder). All the tests (new and old ones) gave 0 errors.
32-
- [ ] If changes were made to an existing model/serializer/view, the docs were updated and regenerated (check [CONTRIBUTE.md](./Contribute.md)).
32+
- [ ] If changes were made to an existing model/serializer/view, the docs were updated and regenerated (check [CONTRIBUTE.md](https://github.com/intelowlproject/IntelOwl/blob/master/docs/source/Contribute.md)).
3333
- [ ] If the GUI has been modified:
3434
- [ ] I have a provided a screenshot of the result in the PR.
3535
- [ ] I have created new frontend tests for the new component or updated existing ones.

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
fetch-depth: 2
4545

4646
- name: Set up Python
47-
uses: actions/setup-python@v4.7.0
47+
uses: actions/setup-python@v5.0.0
4848
with:
4949
python-version: '3.9'
5050

@@ -65,7 +65,7 @@ jobs:
6565
6666
# Initializes the CodeQL tools for scanning.
6767
- name: Initialize CodeQL
68-
uses: github/codeql-action/init@v2
68+
uses: github/codeql-action/init@v3
6969
with:
7070
languages: python
7171
# Override the default behavior so that the action doesn't attempt
@@ -93,4 +93,4 @@ jobs:
9393
# make release
9494

9595
- name: Perform CodeQL Analysis
96-
uses: github/codeql-action/analyze@v2
96+
uses: github/codeql-action/analyze@v3

.github/workflows/pull_request_automation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
uses: actions/[email protected]
3838

3939
- name: Set up Python
40-
uses: actions/setup-python@v4.7.0
40+
uses: actions/setup-python@v5.0.0
4141
with:
4242
python-version: 3.9
4343

.github/workflows/scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ jobs:
6767

6868
# Upload the results to GitHub's code scanning dashboard.
6969
- name: "Upload to code-scanning"
70-
uses: github/codeql-action/upload-sarif@807578363a7869ca324a79039e6db9c843e0e100 # v2.1.27
70+
uses: github/codeql-action/upload-sarif@03e7845b7bfcd5e7fb63d1ae8c61b0e791134fab # v2.22.11
7171
with:
7272
sarif_file: results.sarif

.github/workflows/sphinx_build_on_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
steps:
1515
- uses: actions/[email protected]
1616
- name: Set up Python
17-
uses: actions/setup-python@v4.7.0
17+
uses: actions/setup-python@v5.0.0
1818
with:
1919
python-version: 3.9
2020
- name: Install docs requirements
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
from django.db import migrations
2+
from django.db.models.fields.related_descriptors import (
3+
ForwardManyToOneDescriptor,
4+
ForwardOneToOneDescriptor,
5+
ManyToManyDescriptor,
6+
)
7+
8+
plugin = {
9+
"name": "DNS0_names",
10+
"python_module": {
11+
"module": "dns0.dns0_names.DNS0Names",
12+
"base_path": "api_app.analyzers_manager.observable_analyzers",
13+
},
14+
"description": "Run advanced searches on billions of current and historical domain names. [API](https://docs.dns0.eu/dns-api/names).",
15+
"disabled": False,
16+
"soft_time_limit": 60,
17+
"routing_key": "default",
18+
"health_check_status": True,
19+
"type": "observable",
20+
"docker_based": False,
21+
"maximum_tlp": "RED",
22+
"observable_supported": ["url", "domain", "generic"],
23+
"supported_filetypes": [],
24+
"run_hash": False,
25+
"run_hash_type": "",
26+
"not_supported_filetypes": [],
27+
"health_check_task": None,
28+
"model": "analyzers_manager.AnalyzerConfig",
29+
}
30+
31+
params = [
32+
{
33+
"name": "api_key",
34+
"type": "str",
35+
"description": "",
36+
"is_secret": True,
37+
"required": False,
38+
"python_module": {
39+
"module": "dns0.dns0_names.DNS0Names",
40+
"base_path": "api_app.analyzers_manager.observable_analyzers",
41+
},
42+
},
43+
{
44+
"name": "root",
45+
"type": "bool",
46+
"description": "Limit results to root domains.",
47+
"is_secret": False,
48+
"required": False,
49+
"python_module": {
50+
"module": "dns0.dns0_names.DNS0Names",
51+
"base_path": "api_app.analyzers_manager.observable_analyzers",
52+
},
53+
},
54+
{
55+
"name": "fuzzy",
56+
"type": "list",
57+
"description": "Apply fuzziness to q. Accepts a comma-separated list of fuzzy algorithms, or all to apply them all.",
58+
"is_secret": False,
59+
"required": False,
60+
"python_module": {
61+
"module": "dns0.dns0_names.DNS0Names",
62+
"base_path": "api_app.analyzers_manager.observable_analyzers",
63+
},
64+
},
65+
{
66+
"name": "from",
67+
"type": "str",
68+
"description": "Limit results to names seen after this date.",
69+
"is_secret": False,
70+
"required": False,
71+
"python_module": {
72+
"module": "dns0.dns0_names.DNS0Names",
73+
"base_path": "api_app.analyzers_manager.observable_analyzers",
74+
},
75+
},
76+
{
77+
"name": "to",
78+
"type": "str",
79+
"description": "Limit results to names seen before this date.",
80+
"is_secret": False,
81+
"required": False,
82+
"python_module": {
83+
"module": "dns0.dns0_names.DNS0Names",
84+
"base_path": "api_app.analyzers_manager.observable_analyzers",
85+
},
86+
},
87+
{
88+
"name": "not_before",
89+
"type": "str",
90+
"description": "Limit results to names not seen before this date.",
91+
"is_secret": False,
92+
"required": False,
93+
"python_module": {
94+
"module": "dns0.dns0_names.DNS0Names",
95+
"base_path": "api_app.analyzers_manager.observable_analyzers",
96+
},
97+
},
98+
{
99+
"name": "sort",
100+
"type": "str",
101+
"description": "Available sorts are first_seen (the default) or last_seen. Both are descending sorts (most recent first).",
102+
"is_secret": False,
103+
"required": False,
104+
"python_module": {
105+
"module": "dns0.dns0_names.DNS0Names",
106+
"base_path": "api_app.analyzers_manager.observable_analyzers",
107+
},
108+
},
109+
{
110+
"name": "format",
111+
"type": "str",
112+
"description": "Available formats are json and dig. Default format is based on the Accept HTTP header.",
113+
"is_secret": False,
114+
"required": False,
115+
"python_module": {
116+
"module": "dns0.dns0_names.DNS0Names",
117+
"base_path": "api_app.analyzers_manager.observable_analyzers",
118+
},
119+
},
120+
{
121+
"name": "limit",
122+
"type": "int",
123+
"description": "Limit the number of results.",
124+
"is_secret": False,
125+
"required": False,
126+
"python_module": {
127+
"module": "dns0.dns0_names.DNS0Names",
128+
"base_path": "api_app.analyzers_manager.observable_analyzers",
129+
},
130+
},
131+
{
132+
"name": "offset",
133+
"type": "int",
134+
"description": "Used for pagination.",
135+
"is_secret": False,
136+
"required": False,
137+
"python_module": {
138+
"module": "dns0.dns0_names.DNS0Names",
139+
"base_path": "api_app.analyzers_manager.observable_analyzers",
140+
},
141+
},
142+
]
143+
144+
values = []
145+
146+
147+
def _get_real_obj(Model, field, value):
148+
if (
149+
type(getattr(Model, field))
150+
in [ForwardManyToOneDescriptor, ForwardOneToOneDescriptor]
151+
and value
152+
):
153+
other_model = getattr(Model, field).get_queryset().model
154+
# in case is a dictionary, we have to retrieve the object with every key
155+
if isinstance(value, dict):
156+
real_vals = {}
157+
for key, real_val in value.items():
158+
real_vals[key] = _get_real_obj(other_model, key, real_val)
159+
value = other_model.objects.get_or_create(**real_vals)[0]
160+
# it is just the primary key serialized
161+
else:
162+
value = other_model.objects.get(pk=value)
163+
return value
164+
165+
166+
def _create_object(Model, data):
167+
mtm, no_mtm = {}, {}
168+
for field, value in data.items():
169+
if type(getattr(Model, field)) is ManyToManyDescriptor:
170+
mtm[field] = value
171+
else:
172+
value = _get_real_obj(Model, field, value)
173+
no_mtm[field] = value
174+
try:
175+
o = Model.objects.get(**no_mtm)
176+
except Model.DoesNotExist:
177+
o = Model(**no_mtm)
178+
o.full_clean()
179+
o.save()
180+
for field, value in mtm.items():
181+
attribute = getattr(o, field)
182+
attribute.set(value)
183+
184+
185+
def migrate(apps, schema_editor):
186+
Parameter = apps.get_model("api_app", "Parameter")
187+
PluginConfig = apps.get_model("api_app", "PluginConfig")
188+
python_path = plugin.pop("model")
189+
Model = apps.get_model(*python_path.split("."))
190+
_create_object(Model, plugin)
191+
for param in params:
192+
_create_object(Parameter, param)
193+
for value in values:
194+
_create_object(PluginConfig, value)
195+
196+
197+
def reverse_migrate(apps, schema_editor):
198+
python_path = plugin.pop("model")
199+
Model = apps.get_model(*python_path.split("."))
200+
Model.objects.get(name=plugin["name"]).delete()
201+
202+
203+
class Migration(migrations.Migration):
204+
dependencies = [
205+
("api_app", "0051_pythonmodule_health_check_schedule_and_more"),
206+
("analyzers_manager", "0051_analyzerreport_parameters"),
207+
]
208+
209+
operations = [migrations.RunPython(migrate, reverse_migrate)]

0 commit comments

Comments
 (0)