mmisp-lib 0.7.4__tar.gz → 0.8.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/PKG-INFO +2 -2
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/pyproject.toml +4 -1
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/events.py +13 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/galaxies.py +9 -14
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/galaxy_common.py +10 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/commandline_tool/main.py +13 -4
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/config.py +7 -2
- mmisp_lib-0.8.0/src/mmisp/db/lib.py +17 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/galaxy.py +15 -2
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/log.py +68 -33
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/workflow.py +31 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/logger.py +30 -1
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/fixtures.py +24 -2
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/galaxy_generator.py +8 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/execution.py +10 -21
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp_lib.egg-info/PKG-INFO +2 -2
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp_lib.egg-info/SOURCES.txt +2 -1
- mmisp_lib-0.8.0/src/mmisp_lib.egg-info/entry_points.txt +2 -0
- mmisp_lib-0.7.4/src/mmisp/lib/logging.py +0 -58
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/LICENSE +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/README.md +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/setup.cfg +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/attributes.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/auth_keys.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/authentication.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/common.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/feeds.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/galaxy_clusters.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/jobs.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/logs.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/noticelists.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/objects.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/organisations.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/responses/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/responses/check_graph_response.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/responses/standard_status_response.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/roles.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/server.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/servers.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/shadow_attribute.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/sharing_groups.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/sightings.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/statistics.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/tags.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/taxonomies.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/user_settings.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/users.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/warninglists.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/api_schemas/workflows.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/commandline_tool/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/commandline_tool/organisation.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/commandline_tool/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/commandline_tool/setup.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/commandline_tool/user.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/additional_properties.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/all_models.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/database.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/mixins.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/admin_setting.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/attribute.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/auth_key.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/blocklist.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/correlation.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/event.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/feed.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/galaxy_cluster.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/identity_provider.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/noticelist.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/object.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/organisation.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/post.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/role.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/server.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/shadow_attribute.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/sharing_group.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/sighting.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/tag.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/taxonomy.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/threat_level.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/user.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/user_setting.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/warninglist.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/models/workflow_blueprint.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/mypy.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/print_changes.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/db/uuid_type.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/actions.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/attribute_search_filter.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/attributes.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/distribution.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/fallbacks.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/galaxies.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/galaxy_clusters.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/permissions.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/serialisation_helper.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/lib/uuid.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/enrichment/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/enrichment/data.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/enrichment/enrichment_plugin.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/exceptions.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/models/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/models/attribute.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/plugin_info.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/plugin_type.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/plugins/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/compatibility_helpers.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/attribute_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/feed_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/attribute_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/auth_key_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/correlation_exclusions_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/correlation_value_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/default_correlation_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/event_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/identity_provider_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/noticelist_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/object_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/organisation_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/over_correlating_value_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/post_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/role_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/server_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/shadow_attribute_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/sharing_group_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/sighting_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/tag_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/taxonomy_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/user_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/user_setting_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/warninglist_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/workflow_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/object_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/sighting_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/tag_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/taxonomies_generator.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/util/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/util/crypto.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/util/models.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/util/partial.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/util/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/util/uuid.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/__init__.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/fastapi.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/graph.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/input.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/legacy.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/misp_core_format.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/modules.py +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/workflows/py.typed +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp_lib.egg-info/dependency_links.txt +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp_lib.egg-info/requires.txt +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp_lib.egg-info/top_level.txt +0 -0
- {mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/tests/test_commandline_tool.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "mmisp-lib"
|
3
|
-
version = "0.
|
3
|
+
version = "0.8.0"
|
4
4
|
description = ""
|
5
5
|
authors = []
|
6
6
|
readme = "README.md"
|
@@ -45,6 +45,9 @@ dev = [
|
|
45
45
|
"build",
|
46
46
|
]
|
47
47
|
|
48
|
+
[project.scripts]
|
49
|
+
mmisp-db = "mmisp.commandline_tool.main:main"
|
50
|
+
|
48
51
|
[tool.setuptools.package-data]
|
49
52
|
"mmisp.lib" = ["py.typed"]
|
50
53
|
"mmisp.api_schemas" = ["py.typed"]
|
@@ -4,6 +4,7 @@ from typing import Any, Type
|
|
4
4
|
from pydantic import BaseModel, PositiveInt, conint, validator
|
5
5
|
|
6
6
|
from mmisp.api_schemas.organisations import Organisation
|
7
|
+
from mmisp.lib.distribution import DistributionLevels
|
7
8
|
|
8
9
|
|
9
10
|
class GetAllEventsGalaxyClusterGalaxy(BaseModel):
|
@@ -18,6 +19,12 @@ class GetAllEventsGalaxyClusterGalaxy(BaseModel):
|
|
18
19
|
enabled: bool
|
19
20
|
local_only: bool
|
20
21
|
kill_chain_order: str | None = None
|
22
|
+
created: datetime | str
|
23
|
+
modified: datetime | str
|
24
|
+
org_id: int
|
25
|
+
orgc_id: int
|
26
|
+
default: bool
|
27
|
+
distribution: DistributionLevels
|
21
28
|
|
22
29
|
|
23
30
|
class AddEditGetEventGalaxyClusterMeta(BaseModel):
|
@@ -167,6 +174,12 @@ class AddEditGetEventGalaxy(BaseModel):
|
|
167
174
|
enabled: bool
|
168
175
|
local_only: bool
|
169
176
|
kill_chain_order: str | None = None
|
177
|
+
created: datetime | str
|
178
|
+
modified: datetime | str
|
179
|
+
org_id: int
|
180
|
+
orgc_id: int
|
181
|
+
default: bool
|
182
|
+
distribution: DistributionLevels
|
170
183
|
GalaxyCluster: list[AddEditGetEventGalaxyCluster] = []
|
171
184
|
|
172
185
|
|
@@ -1,10 +1,13 @@
|
|
1
|
+
from datetime import datetime
|
1
2
|
from typing import Any, List
|
2
3
|
|
3
4
|
from pydantic import BaseModel
|
4
5
|
|
5
6
|
from mmisp.api_schemas.common import TagAttributesResponse
|
6
7
|
from mmisp.api_schemas.events import AddEditGetEventGalaxyClusterRelation, GetAllEventsGalaxyClusterGalaxy
|
8
|
+
from mmisp.api_schemas.galaxy_common import GetAllSearchGalaxiesAttributes
|
7
9
|
from mmisp.api_schemas.organisations import Organisation
|
10
|
+
from mmisp.lib.distribution import DistributionLevels
|
8
11
|
|
9
12
|
|
10
13
|
class SearchGalaxiesBody(BaseModel):
|
@@ -72,20 +75,6 @@ class ImportGalaxyBody(BaseModel):
|
|
72
75
|
orm_mode = True
|
73
76
|
|
74
77
|
|
75
|
-
class GetAllSearchGalaxiesAttributes(BaseModel):
|
76
|
-
id: int
|
77
|
-
uuid: str
|
78
|
-
name: str
|
79
|
-
type: str
|
80
|
-
description: str
|
81
|
-
version: str
|
82
|
-
icon: str
|
83
|
-
namespace: str
|
84
|
-
kill_chain_order: str | None = None
|
85
|
-
enabled: bool
|
86
|
-
local_only: bool
|
87
|
-
|
88
|
-
|
89
78
|
class GetAllSearchGalaxiesResponse(BaseModel):
|
90
79
|
Galaxy: GetAllSearchGalaxiesAttributes
|
91
80
|
|
@@ -111,6 +100,12 @@ class GalaxySchema(BaseModel):
|
|
111
100
|
icon: str
|
112
101
|
namespace: str
|
113
102
|
kill_chain_order: List[str]
|
103
|
+
created: datetime | str
|
104
|
+
modified: datetime | str
|
105
|
+
org_id: int
|
106
|
+
orgc_id: int
|
107
|
+
default: bool
|
108
|
+
distribution: DistributionLevels
|
114
109
|
|
115
110
|
class Config:
|
116
111
|
orm_mode = True
|
@@ -1,5 +1,9 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
|
1
3
|
from pydantic import BaseModel
|
2
4
|
|
5
|
+
from mmisp.lib.distribution import DistributionLevels
|
6
|
+
|
3
7
|
|
4
8
|
class GetAllSearchGalaxiesAttributes(BaseModel):
|
5
9
|
id: int
|
@@ -13,3 +17,9 @@ class GetAllSearchGalaxiesAttributes(BaseModel):
|
|
13
17
|
kill_chain_order: str | None = None
|
14
18
|
enabled: bool
|
15
19
|
local_only: bool
|
20
|
+
created: datetime | str
|
21
|
+
modified: datetime | str
|
22
|
+
org_id: int
|
23
|
+
orgc_id: int
|
24
|
+
default: bool
|
25
|
+
distribution: DistributionLevels
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import fire
|
2
2
|
|
3
|
+
import mmisp.db.all_models # noqa
|
3
4
|
from mmisp.commandline_tool import organisation, setup, user
|
4
5
|
from mmisp.db.database import sessionmanager
|
5
6
|
|
@@ -7,12 +8,15 @@ from mmisp.db.database import sessionmanager
|
|
7
8
|
# and organisations and changing their details.
|
8
9
|
|
9
10
|
|
10
|
-
async def setup_db() -> str:
|
11
|
+
async def setup_db(create_init_values: bool = True) -> str:
|
11
12
|
"""setup"""
|
12
13
|
sessionmanager.init()
|
13
14
|
await sessionmanager.create_all()
|
14
|
-
|
15
|
-
|
15
|
+
|
16
|
+
if create_init_values:
|
17
|
+
async with sessionmanager.session() as session:
|
18
|
+
await setup.setup(session)
|
19
|
+
|
16
20
|
await sessionmanager.close()
|
17
21
|
return "Database setup"
|
18
22
|
|
@@ -163,7 +167,8 @@ async def delete_user(email: str) -> str:
|
|
163
167
|
return "User deleted with email: {} ".format(email)
|
164
168
|
|
165
169
|
|
166
|
-
|
170
|
+
def main() -> None:
|
171
|
+
"""Main entrypoint for mmisp-db"""
|
167
172
|
fire.Fire(
|
168
173
|
{
|
169
174
|
"setup": setup_db,
|
@@ -177,3 +182,7 @@ if __name__ == "__main__":
|
|
177
182
|
"delete-user": delete_user,
|
178
183
|
}
|
179
184
|
)
|
185
|
+
|
186
|
+
|
187
|
+
if __name__ == "__main__":
|
188
|
+
main()
|
@@ -22,6 +22,7 @@ class DatabaseConfig:
|
|
22
22
|
DEBUG: bool
|
23
23
|
RETRY_SLEEP: int
|
24
24
|
MAX_RETRIES: int
|
25
|
+
DB_LOGLEVEL: str | None = None
|
25
26
|
|
26
27
|
|
27
28
|
load_dotenv(getenv("ENV_FILE", ".env"))
|
@@ -32,8 +33,12 @@ config: DatabaseConfig = DatabaseConfig(
|
|
32
33
|
DEBUG=bool(getenv("DEBUG", False)),
|
33
34
|
RETRY_SLEEP=int(getenv("DB_RETRY", 5)),
|
34
35
|
MAX_RETRIES=int(getenv("DB_MAX_RETRIES", 100)),
|
36
|
+
DB_LOGLEVEL=getenv("DB_LOGLEVEL", None),
|
35
37
|
)
|
36
38
|
sqlalchemy_logger = logging.getLogger("sqlalchemy.engine")
|
37
|
-
sqlalchemy_logger.setLevel(logging.
|
39
|
+
sqlalchemy_logger.setLevel(logging.WARNING)
|
38
40
|
if config.DEBUG:
|
39
|
-
sqlalchemy_logger.setLevel(logging.
|
41
|
+
sqlalchemy_logger.setLevel(logging.INFO)
|
42
|
+
|
43
|
+
if config.DB_LOGLEVEL is not None:
|
44
|
+
sqlalchemy_logger.setLevel(config.DB_LOGLEVEL)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import logging
|
2
|
+
|
3
|
+
from sqlalchemy import func
|
4
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
5
|
+
from sqlalchemy.sql import Select
|
6
|
+
|
7
|
+
logger = logging.getLogger("mmisp")
|
8
|
+
|
9
|
+
|
10
|
+
async def get_count_from_select(db: AsyncSession, query: Select) -> int:
|
11
|
+
logger.debug("Get count from query: %s", query)
|
12
|
+
count_query = (
|
13
|
+
query.with_only_columns(func.count(), maintain_column_froms=True).order_by(None).limit(None).offset(None)
|
14
|
+
)
|
15
|
+
logger.debug("Resulted count query: %s", count_query)
|
16
|
+
result = await db.execute(count_query)
|
17
|
+
return result.scalar()
|
@@ -1,13 +1,16 @@
|
|
1
|
-
from
|
1
|
+
from datetime import datetime
|
2
|
+
|
3
|
+
from sqlalchemy import Boolean, DateTime, Integer, String, Text
|
2
4
|
from sqlalchemy.orm import relationship
|
3
5
|
|
6
|
+
from mmisp.db.mixins import DictMixin, UpdateMixin
|
4
7
|
from mmisp.db.mypy import Mapped, mapped_column
|
5
8
|
from mmisp.lib.uuid import uuid
|
6
9
|
|
7
10
|
from ..database import Base
|
8
11
|
|
9
12
|
|
10
|
-
class Galaxy(Base):
|
13
|
+
class Galaxy(Base, DictMixin, UpdateMixin):
|
11
14
|
__tablename__ = "galaxies"
|
12
15
|
|
13
16
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, nullable=False)
|
@@ -23,6 +26,16 @@ class Galaxy(Base):
|
|
23
26
|
enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
|
24
27
|
local_only: Mapped[bool] = mapped_column(Boolean, default=False)
|
25
28
|
|
29
|
+
default: Mapped[bool] = mapped_column(Boolean, default=False)
|
30
|
+
|
31
|
+
org_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
32
|
+
orgc_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
33
|
+
|
34
|
+
created: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
35
|
+
modified: Mapped[datetime] = mapped_column(DateTime, nullable=False)
|
36
|
+
|
37
|
+
distribution: Mapped[int] = mapped_column(Integer, nullable=False)
|
38
|
+
|
26
39
|
galaxy_clusters = relationship(
|
27
40
|
"GalaxyCluster",
|
28
41
|
back_populates="galaxy",
|
@@ -1,33 +1,68 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Self
|
3
|
+
|
4
|
+
from sqlalchemy import DateTime, Integer, String, Text
|
5
|
+
|
6
|
+
from mmisp.db.mypy import Mapped, mapped_column
|
7
|
+
|
8
|
+
from ..database import Base
|
9
|
+
|
10
|
+
|
11
|
+
class Log(Base):
|
12
|
+
"""
|
13
|
+
A python class representation of the database model for logs in MISP.
|
14
|
+
|
15
|
+
Further explanation for some of the central attributes of the database model:
|
16
|
+
- Action: Describes the action that was logged, e.g. a login or workflow execution
|
17
|
+
- Change: A string-representation of the changes made to the logged object or of
|
18
|
+
central information about the logged object.
|
19
|
+
"""
|
20
|
+
|
21
|
+
__tablename__ = "logs"
|
22
|
+
|
23
|
+
id: Mapped[int] = mapped_column(Integer, primary_key=True, nullable=False)
|
24
|
+
title: Mapped[str] = mapped_column(Text, nullable=True)
|
25
|
+
created: Mapped[datetime] = mapped_column(DateTime, nullable=False, default=datetime.utcnow)
|
26
|
+
model: Mapped[str] = mapped_column(String(80), nullable=False)
|
27
|
+
model_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
28
|
+
action: Mapped[str] = mapped_column(String(20), nullable=False)
|
29
|
+
user_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
30
|
+
change: Mapped[str] = mapped_column(Text, nullable=True)
|
31
|
+
email: Mapped[str] = mapped_column(String(255), nullable=False)
|
32
|
+
org: Mapped[str] = mapped_column(String(255), nullable=False)
|
33
|
+
description: Mapped[str] = mapped_column(Text, nullable=True)
|
34
|
+
ip: Mapped[str] = mapped_column(String(45), nullable=True)
|
35
|
+
|
36
|
+
def __init__(
|
37
|
+
self: Self,
|
38
|
+
*,
|
39
|
+
model: str,
|
40
|
+
model_id: int,
|
41
|
+
action: str,
|
42
|
+
user_id: int,
|
43
|
+
email: str,
|
44
|
+
org: str,
|
45
|
+
title: str | None = None,
|
46
|
+
change: str | None = None,
|
47
|
+
description: str | None = None,
|
48
|
+
ip: str | None = None,
|
49
|
+
created: datetime | None = None,
|
50
|
+
**kwargs,
|
51
|
+
) -> None:
|
52
|
+
if created is None:
|
53
|
+
created = datetime.now()
|
54
|
+
if isinstance(created, float):
|
55
|
+
created = datetime.fromtimestamp(created)
|
56
|
+
super().__init__(
|
57
|
+
title=title,
|
58
|
+
created=created,
|
59
|
+
model=model,
|
60
|
+
model_id=model_id,
|
61
|
+
action=action,
|
62
|
+
user_id=user_id,
|
63
|
+
change=change,
|
64
|
+
email=email,
|
65
|
+
org=org,
|
66
|
+
description=description,
|
67
|
+
ip=ip,
|
68
|
+
)
|
@@ -1,3 +1,6 @@
|
|
1
|
+
import logging
|
2
|
+
from functools import cached_property
|
3
|
+
from typing import Self
|
1
4
|
from uuid import uuid4 as _uuid4
|
2
5
|
|
3
6
|
from sqlalchemy import Boolean, Integer, String
|
@@ -7,6 +10,7 @@ from mmisp.db.mypy import Mapped, mapped_column
|
|
7
10
|
from ...workflows.graph import WorkflowGraph
|
8
11
|
from ...workflows.legacy import JSONGraphType
|
9
12
|
from ..database import Base
|
13
|
+
from .log import Log
|
10
14
|
|
11
15
|
|
12
16
|
def uuid() -> str:
|
@@ -36,3 +40,30 @@ class Workflow(Base):
|
|
36
40
|
trigger_id: Mapped[str] = mapped_column(String(191), nullable=False, index=True)
|
37
41
|
debug_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=0)
|
38
42
|
data: Mapped[WorkflowGraph] = mapped_column(JSONGraphType, nullable=False, default=0)
|
43
|
+
|
44
|
+
def __init__(self: Self, *args, **kwargs) -> None:
|
45
|
+
super().__init__(*args, **kwargs)
|
46
|
+
|
47
|
+
@cached_property
|
48
|
+
def _logger(self: Self) -> logging.LoggerAdapter:
|
49
|
+
_logger = logging.LoggerAdapter(
|
50
|
+
logging.getLogger(f"mmisp.workflows.{self.name}"),
|
51
|
+
extra=dict(
|
52
|
+
dbmodel=Log,
|
53
|
+
model="Workflow",
|
54
|
+
model_id=self.id,
|
55
|
+
action="execute_workflow",
|
56
|
+
user_id=0,
|
57
|
+
email="SYSTEM",
|
58
|
+
org="SYSTEM",
|
59
|
+
description="",
|
60
|
+
change="",
|
61
|
+
ip="",
|
62
|
+
),
|
63
|
+
)
|
64
|
+
if self.debug_enabled:
|
65
|
+
_logger.setLevel(logging.DEBUG)
|
66
|
+
return _logger
|
67
|
+
|
68
|
+
def get_logger(self: Self) -> logging.LoggerAdapter:
|
69
|
+
return self._logger
|
@@ -3,8 +3,10 @@ import logging
|
|
3
3
|
from contextvars import ContextVar
|
4
4
|
from typing import Self, TypeVar
|
5
5
|
|
6
|
+
from sqlalchemy.ext.asyncio import AsyncSession
|
7
|
+
|
6
8
|
request_log: ContextVar[list] = ContextVar("request_log")
|
7
|
-
|
9
|
+
db_log: ContextVar[list] = ContextVar("db_log")
|
8
10
|
|
9
11
|
|
10
12
|
T = TypeVar("T")
|
@@ -56,20 +58,47 @@ class InMemoryContextHandler(logging.Handler):
|
|
56
58
|
request_log.get([]).append(self.format(record))
|
57
59
|
|
58
60
|
|
61
|
+
class InMemoryDBLogContextHandler(logging.Handler):
|
62
|
+
def emit(self: Self, record: logging.LogRecord) -> None:
|
63
|
+
if hasattr(record, "dbmodel"):
|
64
|
+
dbmodel_class = getattr(record, "dbmodel")
|
65
|
+
instance = dbmodel_class(
|
66
|
+
title=self.format(record),
|
67
|
+
**record.__dict__,
|
68
|
+
)
|
69
|
+
db_log.get([]).append(instance)
|
70
|
+
|
71
|
+
|
59
72
|
def print_request_log() -> None:
|
60
73
|
print(*request_log.get([]), sep="\n")
|
61
74
|
|
62
75
|
|
76
|
+
async def save_db_log(db: AsyncSession) -> None:
|
77
|
+
db.add_all(db_log.get([]))
|
78
|
+
await db.flush()
|
79
|
+
|
80
|
+
|
63
81
|
def reset_request_log() -> None:
|
64
82
|
request_log.set([])
|
65
83
|
|
66
84
|
|
85
|
+
def reset_db_log() -> None:
|
86
|
+
db_log.set([])
|
87
|
+
|
88
|
+
|
67
89
|
# Set up the logger
|
68
90
|
logger = logging.getLogger("mmisp")
|
69
91
|
in_memory_handler = InMemoryContextHandler()
|
92
|
+
in_memory_db_log_handler = InMemoryDBLogContextHandler()
|
70
93
|
log_formatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s")
|
94
|
+
dblog_formatter = logging.Formatter("%(message)s")
|
71
95
|
in_memory_handler.setFormatter(log_formatter)
|
96
|
+
in_memory_db_log_handler.setFormatter(dblog_formatter)
|
72
97
|
logger.addHandler(in_memory_handler)
|
98
|
+
logger.addHandler(in_memory_db_log_handler)
|
99
|
+
|
100
|
+
# adapter
|
101
|
+
|
73
102
|
|
74
103
|
sqlalchemy_logger = logging.getLogger("sqlalchemy.engine")
|
75
104
|
sqlalchemy_logger.addHandler(in_memory_handler)
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import asyncio
|
2
|
+
from datetime import datetime
|
2
3
|
|
3
4
|
import pytest
|
4
5
|
import pytest_asyncio
|
@@ -11,6 +12,7 @@ from mmisp.db.models.attribute import Attribute
|
|
11
12
|
from mmisp.db.models.galaxy import Galaxy
|
12
13
|
from mmisp.db.models.galaxy_cluster import GalaxyCluster, GalaxyElement
|
13
14
|
from mmisp.db.models.tag import Tag
|
15
|
+
from mmisp.lib.distribution import DistributionLevels
|
14
16
|
from mmisp.lib.galaxies import galaxy_tag_name
|
15
17
|
from mmisp.util.crypto import hash_secret
|
16
18
|
from mmisp.util.uuid import uuid
|
@@ -28,7 +30,6 @@ from .generators.model_generators.correlation_value_generator import (
|
|
28
30
|
)
|
29
31
|
from .generators.model_generators.default_correlation_generator import generate_default_correlation
|
30
32
|
from .generators.model_generators.event_generator import generate_event
|
31
|
-
from .generators.model_generators.galaxy_generator import generate_galaxy
|
32
33
|
from .generators.model_generators.object_generator import generate_object
|
33
34
|
from .generators.model_generators.organisation_generator import generate_organisation
|
34
35
|
from .generators.model_generators.over_correlating_value_generator import (
|
@@ -496,7 +497,18 @@ async def server(db, instance_owner_org):
|
|
496
497
|
|
497
498
|
@pytest_asyncio.fixture
|
498
499
|
async def galaxy(db):
|
499
|
-
galaxy =
|
500
|
+
galaxy = Galaxy(
|
501
|
+
name="test galaxy",
|
502
|
+
type="test type",
|
503
|
+
description="test",
|
504
|
+
version="version",
|
505
|
+
kill_chain_order="test kill_chain_order",
|
506
|
+
org_id=0,
|
507
|
+
orgc_id=0,
|
508
|
+
distribution=DistributionLevels.ALL_COMMUNITIES,
|
509
|
+
created=datetime.now(),
|
510
|
+
modified=datetime.now(),
|
511
|
+
)
|
500
512
|
|
501
513
|
db.add(galaxy)
|
502
514
|
await db.commit()
|
@@ -567,6 +579,11 @@ async def test_default_galaxy(db, galaxy_default_cluster_one_uuid, galaxy_defaul
|
|
567
579
|
uuid=uuid(),
|
568
580
|
enabled=True,
|
569
581
|
local_only=False,
|
582
|
+
org_id=0,
|
583
|
+
orgc_id=0,
|
584
|
+
distribution=DistributionLevels.ALL_COMMUNITIES,
|
585
|
+
created=datetime.now(),
|
586
|
+
modified=datetime.now(),
|
570
587
|
)
|
571
588
|
|
572
589
|
db.add(galaxy)
|
@@ -679,6 +696,11 @@ async def test_galaxy(db, instance_owner_org, galaxy_cluster_one_uuid, galaxy_cl
|
|
679
696
|
uuid=uuid(),
|
680
697
|
enabled=True,
|
681
698
|
local_only=False,
|
699
|
+
org_id=instance_owner_org.id,
|
700
|
+
orgc_id=instance_owner_org.id,
|
701
|
+
distribution=DistributionLevels.ALL_COMMUNITIES,
|
702
|
+
created=datetime.now(),
|
703
|
+
modified=datetime.now(),
|
682
704
|
)
|
683
705
|
|
684
706
|
db.add(galaxy)
|
{mmisp_lib-0.7.4 → mmisp_lib-0.8.0}/src/mmisp/tests/generators/model_generators/galaxy_generator.py
RENAMED
@@ -1,4 +1,7 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
|
1
3
|
from mmisp.db.models.galaxy import Galaxy
|
4
|
+
from mmisp.lib.distribution import DistributionLevels
|
2
5
|
|
3
6
|
|
4
7
|
def generate_galaxy() -> Galaxy:
|
@@ -8,4 +11,9 @@ def generate_galaxy() -> Galaxy:
|
|
8
11
|
description="test",
|
9
12
|
version="version",
|
10
13
|
kill_chain_order="test kill_chain_order",
|
14
|
+
org_id=0,
|
15
|
+
orgc_id=0,
|
16
|
+
distribution=DistributionLevels.ALL_COMMUNITIES,
|
17
|
+
created=datetime.now(),
|
18
|
+
modified=datetime.now(),
|
11
19
|
)
|
@@ -15,7 +15,6 @@ from ..db.models.organisation import Organisation
|
|
15
15
|
from ..db.models.role import Role
|
16
16
|
from ..db.models.user import User
|
17
17
|
from ..db.models.workflow import Workflow
|
18
|
-
from ..lib.logging import ApplicationLogger
|
19
18
|
from .graph import Module, Trigger, VerbatimWorkflowInput
|
20
19
|
from .input import WorkflowInput
|
21
20
|
from .modules import ModuleLogic
|
@@ -45,7 +44,6 @@ async def walk_nodes(
|
|
45
44
|
input: WorkflowInput,
|
46
45
|
current_node: Module,
|
47
46
|
workflow: Workflow,
|
48
|
-
logger: ApplicationLogger,
|
49
47
|
db: AsyncSession,
|
50
48
|
jinja2_engine: Environment,
|
51
49
|
) -> Tuple[bool, List[str]]:
|
@@ -59,8 +57,6 @@ async def walk_nodes(
|
|
59
57
|
input: Workflow payload for `current_node`.
|
60
58
|
current_node: Node to resume execution with.
|
61
59
|
workflow: Workflow entity. Used for logging.
|
62
|
-
logger: Application logger to write debug messages and errors
|
63
|
-
from the execution.
|
64
60
|
db: Database session.
|
65
61
|
jinja2_engine: Instantiated templating engine to substitute placeholders
|
66
62
|
in module configuration with values from the payload.
|
@@ -85,13 +81,12 @@ async def walk_nodes(
|
|
85
81
|
current_config[config_key] = [_render(v) for v in value]
|
86
82
|
result, next_node = await current_node.exec(input, db)
|
87
83
|
except Exception as e:
|
88
|
-
|
84
|
+
workflow.get_logger().error(f"Error while executing module {current_node.id}. Error: {e}")
|
89
85
|
return False, []
|
90
86
|
|
91
87
|
success_type = "partial-success" if not result and not isinstance(current_node, ModuleLogic) else "success"
|
92
88
|
|
93
|
-
|
94
|
-
workflow,
|
89
|
+
workflow.get_logger().debug(
|
95
90
|
f"Executed node `{current_node.id}`\n"
|
96
91
|
+ f"Node `{current_node.id}` from Workflow `{workflow.name}` ({workflow.id}) executed "
|
97
92
|
+ f"successfully with status: {success_type}",
|
@@ -105,7 +100,7 @@ async def walk_nodes(
|
|
105
100
|
|
106
101
|
# At this stage we don't do any cycle detection, but assume that only
|
107
102
|
# valid graphs w/o cycles in it were saved by the API.
|
108
|
-
return await walk_nodes(input, next_node, workflow,
|
103
|
+
return await walk_nodes(input, next_node, workflow, db, jinja2_engine)
|
109
104
|
|
110
105
|
|
111
106
|
async def create_virtual_root_user(db: AsyncSession) -> User:
|
@@ -141,7 +136,7 @@ async def workflow_by_trigger_id(trigger: str, db: AsyncSession) -> Workflow | N
|
|
141
136
|
|
142
137
|
|
143
138
|
async def execute_workflow(
|
144
|
-
workflow: Workflow, user: User, input: VerbatimWorkflowInput, db: AsyncSession
|
139
|
+
workflow: Workflow, user: User, input: VerbatimWorkflowInput, db: AsyncSession
|
145
140
|
) -> Tuple[bool, List[str]]:
|
146
141
|
"""
|
147
142
|
Provides the functionality for executing a workflow, which consists of traversing
|
@@ -169,7 +164,6 @@ async def execute_workflow(
|
|
169
164
|
workflow: The Graph representation of the workflow to be executed.
|
170
165
|
input: Initial payload for the workflow.
|
171
166
|
db: SQLAlchemy session.
|
172
|
-
logger: Application logger to notify about errors or (if debug is enabled) execution steps.
|
173
167
|
"""
|
174
168
|
|
175
169
|
if not workflow.enabled:
|
@@ -188,8 +182,7 @@ async def execute_workflow(
|
|
188
182
|
|
189
183
|
if len(unsupported_modules_id) != 0:
|
190
184
|
unsupported_modules_str = ", ".join(unsupported_modules_id)
|
191
|
-
|
192
|
-
workflow,
|
185
|
+
workflow.get_logger().error(
|
193
186
|
"Workflow was not executed, because it contained unsupported modules with the following IDs: "
|
194
187
|
+ unsupported_modules_str,
|
195
188
|
)
|
@@ -198,9 +191,7 @@ async def execute_workflow(
|
|
198
191
|
+ unsupported_modules_str
|
199
192
|
]
|
200
193
|
|
201
|
-
|
202
|
-
workflow, f"Started executing workflow for trigger `{trigger.name}` ({workflow.id})"
|
203
|
-
)
|
194
|
+
workflow.get_logger().debug(f"Started executing workflow for trigger `{trigger.name}` ({workflow.id})")
|
204
195
|
|
205
196
|
next_step = next(iter(trigger.outputs.values()), None)
|
206
197
|
# Nothing to do.
|
@@ -211,7 +202,7 @@ async def execute_workflow(
|
|
211
202
|
roaming_data = await trigger.normalize_data(db, input)
|
212
203
|
except Exception as e:
|
213
204
|
await db.rollback()
|
214
|
-
|
205
|
+
workflow.get_logger().error(f"Error while normalizing data for trigger. Error: \n{e}")
|
215
206
|
return False, [f"Internal error: {e}"]
|
216
207
|
|
217
208
|
input = WorkflowInput(
|
@@ -222,17 +213,15 @@ async def execute_workflow(
|
|
222
213
|
|
223
214
|
await _increase_workflow_execution_count(db, workflow.id)
|
224
215
|
|
225
|
-
result = await walk_nodes(
|
226
|
-
input, _as_module(next_step[0][1]), workflow, logger, db, Environment(loader=BaseLoader())
|
227
|
-
)
|
216
|
+
result = await walk_nodes(input, _as_module(next_step[0][1]), workflow, db, Environment(loader=BaseLoader()))
|
228
217
|
|
229
218
|
if result[0]:
|
230
219
|
outcome = "success"
|
231
220
|
else:
|
232
221
|
outcome = "blocked" if trigger.blocking else "failure"
|
233
222
|
|
234
|
-
|
235
|
-
|
223
|
+
workflow.get_logger().debug(
|
224
|
+
f"Finished executing workflow for trigger `{trigger.name}` ({workflow.id}). Outcome: {outcome}"
|
236
225
|
)
|
237
226
|
|
238
227
|
if not result[0]:
|