mmisp-lib 0.4.0__tar.gz → 0.6.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.
Files changed (132) hide show
  1. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/PKG-INFO +1 -1
  2. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/pyproject.toml +1 -1
  3. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/attributes.py +10 -31
  4. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/galaxies.py +2 -73
  5. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/galaxy_clusters.py +25 -9
  6. mmisp_lib-0.6.0/src/mmisp/api_schemas/galaxy_common.py +15 -0
  7. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/organisations.py +14 -11
  8. mmisp_lib-0.6.0/src/mmisp/api_schemas/servers.py +138 -0
  9. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/server.py +26 -2
  10. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/user.py +7 -0
  11. mmisp_lib-0.6.0/src/mmisp/db/print_changes.py +47 -0
  12. mmisp_lib-0.6.0/src/mmisp/lib/attributes.py +2340 -0
  13. mmisp_lib-0.6.0/src/mmisp/lib/galaxies.py +17 -0
  14. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/permissions.py +6 -0
  15. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/compatibility_helpers.py +16 -7
  16. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/fixtures.py +2 -2
  17. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/attribute_generator.py +1 -1
  18. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp_lib.egg-info/PKG-INFO +1 -1
  19. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp_lib.egg-info/SOURCES.txt +2 -0
  20. mmisp_lib-0.4.0/src/mmisp/api_schemas/servers.py +0 -79
  21. mmisp_lib-0.4.0/src/mmisp/db/print_changes.py +0 -58
  22. mmisp_lib-0.4.0/src/mmisp/lib/attributes.py +0 -1387
  23. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/LICENSE +0 -0
  24. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/README.md +0 -0
  25. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/setup.cfg +0 -0
  26. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/__init__.py +0 -0
  27. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/auth_keys.py +0 -0
  28. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/authentication.py +0 -0
  29. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/common.py +0 -0
  30. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/events.py +0 -0
  31. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/feeds.py +0 -0
  32. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/jobs.py +0 -0
  33. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/logs.py +0 -0
  34. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/noticelists.py +0 -0
  35. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/objects.py +0 -0
  36. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/py.typed +0 -0
  37. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/responses/__init__.py +0 -0
  38. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/responses/check_graph_response.py +0 -0
  39. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/responses/standard_status_response.py +0 -0
  40. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/roles.py +0 -0
  41. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/sharing_groups.py +0 -0
  42. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/sightings.py +0 -0
  43. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/statistics.py +0 -0
  44. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/tags.py +0 -0
  45. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/taxonomies.py +0 -0
  46. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/user_settings.py +0 -0
  47. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/users.py +0 -0
  48. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/warninglists.py +0 -0
  49. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/api_schemas/workflows.py +0 -0
  50. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/commandline_tool/__init__.py +0 -0
  51. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/commandline_tool/main.py +0 -0
  52. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/commandline_tool/organisation.py +0 -0
  53. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/commandline_tool/py.typed +0 -0
  54. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/commandline_tool/setup.py +0 -0
  55. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/commandline_tool/user.py +0 -0
  56. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/__init__.py +0 -0
  57. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/additional_properties.py +0 -0
  58. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/all_models.py +0 -0
  59. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/config.py +0 -0
  60. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/database.py +0 -0
  61. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/mixins.py +0 -0
  62. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/__init__.py +0 -0
  63. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/admin_setting.py +0 -0
  64. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/attribute.py +0 -0
  65. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/auth_key.py +0 -0
  66. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/event.py +0 -0
  67. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/feed.py +0 -0
  68. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/galaxy.py +0 -0
  69. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/galaxy_cluster.py +0 -0
  70. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/identity_provider.py +0 -0
  71. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/log.py +0 -0
  72. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/noticelist.py +0 -0
  73. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/object.py +0 -0
  74. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/organisation.py +0 -0
  75. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/role.py +0 -0
  76. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/sharing_group.py +0 -0
  77. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/sighting.py +0 -0
  78. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/tag.py +0 -0
  79. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/taxonomy.py +0 -0
  80. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/user_setting.py +0 -0
  81. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/warninglist.py +0 -0
  82. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/workflow.py +0 -0
  83. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/models/workflow_blueprint.py +0 -0
  84. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/mypy.py +0 -0
  85. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/db/py.typed +0 -0
  86. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/__init__.py +0 -0
  87. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/actions.py +0 -0
  88. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/attribute_search_filter.py +0 -0
  89. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/logging.py +0 -0
  90. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/py.typed +0 -0
  91. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/lib/uuid.py +0 -0
  92. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/plugins/py.typed +0 -0
  93. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/__init__.py +0 -0
  94. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/feed_generator.py +0 -0
  95. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/auth_key_generator.py +0 -0
  96. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/event_generator.py +0 -0
  97. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/galaxy_generator.py +0 -0
  98. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/identity_provider_generator.py +0 -0
  99. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/noticelist_generator.py +0 -0
  100. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/organisation_generator.py +0 -0
  101. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/role_generator.py +0 -0
  102. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/server_generator.py +0 -0
  103. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/sharing_group_generator.py +0 -0
  104. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/tag_generator.py +0 -0
  105. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/taxonomy_generator.py +0 -0
  106. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/user_generator.py +0 -0
  107. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/user_setting_generator.py +0 -0
  108. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/warninglist_generator.py +0 -0
  109. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/model_generators/workflow_generator.py +0 -0
  110. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/object_generator.py +0 -0
  111. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/sighting_generator.py +0 -0
  112. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/tag_generator.py +0 -0
  113. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/tests/generators/taxonomies_generator.py +0 -0
  114. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/util/__init__.py +0 -0
  115. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/util/crypto.py +0 -0
  116. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/util/models.py +0 -0
  117. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/util/partial.py +0 -0
  118. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/util/py.typed +0 -0
  119. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/util/uuid.py +0 -0
  120. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/__init__.py +0 -0
  121. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/execution.py +0 -0
  122. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/fastapi.py +0 -0
  123. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/graph.py +0 -0
  124. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/input.py +0 -0
  125. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/legacy.py +0 -0
  126. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/misp_core_format.py +0 -0
  127. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/modules.py +0 -0
  128. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp/workflows/py.typed +0 -0
  129. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp_lib.egg-info/dependency_links.txt +0 -0
  130. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp_lib.egg-info/requires.txt +0 -0
  131. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/src/mmisp_lib.egg-info/top_level.txt +0 -0
  132. {mmisp_lib-0.4.0 → mmisp_lib-0.6.0}/tests/test_commandline_tool.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mmisp-lib
3
- Version: 0.4.0
3
+ Version: 0.6.0
4
4
  Requires-Python: >=3.11.0
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mmisp-lib"
3
- version = "0.4.0"
3
+ version = "0.6.0"
4
4
  description = ""
5
5
  authors = []
6
6
  readme = "README.md"
@@ -165,29 +165,24 @@ class RestoreAttributeResponse(BaseModel):
165
165
 
166
166
  class GetDescribeTypesAttributes(BaseModel):
167
167
  sane_defaults: dict = {}
168
- for k, v in to_ids.items():
168
+ for _k, _v in to_ids.items():
169
169
  sane_defaults.update(
170
170
  {
171
- k: {
172
- "default_category": default_category[k],
173
- "to_ids": v,
171
+ _k: {
172
+ "default_category": default_category[_k],
173
+ "to_ids": "1" if _v else "0",
174
174
  }
175
175
  }
176
176
  )
177
177
 
178
178
  types: list[str] = list(mapper_val_safe_clsname.keys())
179
-
180
179
  categories: list[str] = [member.value for member in AttributeCategories]
181
-
182
180
  category_type_mappings: dict = inverted_categories
183
181
 
184
182
 
185
183
  class GetDescribeTypesResponse(BaseModel):
186
184
  result: GetDescribeTypesAttributes
187
185
 
188
- class Config:
189
- orm_mode = True
190
-
191
186
 
192
187
  class GetAttributeAttributes(BaseModel):
193
188
  id: str
@@ -414,28 +409,12 @@ class AddAttributeBody(BaseModel):
414
409
 
415
410
  GetAttributeStatisticsTypesResponseAttrs = {x: Field(default=None) for x in mapper_val_safe_clsname.keys()}
416
411
  GetAttributeStatisticsTypesResponseAttrs["__annotations__"] = {x: str | None for x in mapper_val_safe_clsname.keys()}
417
- GetAttributeStatisticsTypesResponse = type(
412
+ GetAttributeStatisticsTypesResponse = type( # type: ignore
418
413
  "GetAttributeStatisticsTypesResponse", (BaseModel,), GetAttributeStatisticsTypesResponseAttrs
419
414
  )
420
415
 
421
-
422
- class GetAttributeStatisticsCategoriesResponse(BaseModel):
423
- antivirus_detection: str = Field(alias="Antivirus detection")
424
- artifacts_dropped: str = Field(alias="Artifacts dropped")
425
- attribution: str = Field(alias="Attribution")
426
- external_analysis: str = Field(alias="External analysis")
427
- financial_fraud: str = Field(alias="Financial fraud")
428
- internal_reference: str = Field(alias="Internal reference")
429
- network_activity: str = Field(alias="Network activity")
430
- other: str = Field(alias="Other")
431
- payload_delivery: str = Field(alias="Payload delivery")
432
- payload_installation: str = Field(alias="Payload installation")
433
- payload_type: str = Field(alias="Payload type")
434
- persistence_mechanism: str = Field(alias="Persistence mechanism")
435
- person: str = Field(alias="Person")
436
- social_network: str = Field(alias="Social network")
437
- support__tool: str = Field(alias="Support Tool")
438
- targeting_data: str = Field(alias="Targeting data")
439
-
440
- class Config:
441
- orm_mode = True
416
+ GetAttributeStatisticsCategoriesResponseAttrs = {x.value: Field(default=None) for x in AttributeCategories}
417
+ GetAttributeStatisticsCategoriesResponseAttrs["__annotations__"] = {x.value: str | None for x in AttributeCategories}
418
+ GetAttributeStatisticsCategoriesResponse = type( # type: ignore
419
+ "GetAttributeStatisticsCategoriesResponse", (BaseModel,), GetAttributeStatisticsCategoriesResponseAttrs
420
+ )
@@ -2,8 +2,8 @@ from typing import List
2
2
 
3
3
  from pydantic import BaseModel
4
4
 
5
- import mmisp.api_schemas.organisations
6
- from mmisp.api_schemas.events import AddEditGetEventGalaxyClusterRelation, GetAllEventsGalaxyClusterGalaxy
5
+ from mmisp.api_schemas.galaxy_clusters import GetGalaxyClusterResponse
6
+ from mmisp.api_schemas.galaxy_common import GetAllSearchGalaxiesAttributes
7
7
 
8
8
 
9
9
  class SearchGalaxiesBody(BaseModel):
@@ -38,31 +38,6 @@ class ExportGalaxyGalaxyElement(BaseModel):
38
38
  value: str
39
39
 
40
40
 
41
- class GetGalaxyClusterResponse(BaseModel):
42
- id: str | None = None
43
- uuid: str | None = None
44
- collection_uuid: str
45
- type: str
46
- value: str
47
- tag_name: str
48
- description: str
49
- galaxy_id: str
50
- source: str
51
- authors: list[str]
52
- version: str
53
- distribution: str
54
- sharing_group_id: str
55
- org_id: str
56
- orgc_id: str
57
- default: bool
58
- locked: bool
59
- extends_uuid: str
60
- extends_version: str
61
- published: bool
62
- deleted: bool
63
- GalaxyElement: list[ExportGalaxyGalaxyElement]
64
-
65
-
66
41
  class ImportGalaxyBody(BaseModel):
67
42
  GalaxyCluster: GetGalaxyClusterResponse
68
43
  Galaxy: ImportGalaxyGalaxy
@@ -71,20 +46,6 @@ class ImportGalaxyBody(BaseModel):
71
46
  orm_mode = True
72
47
 
73
48
 
74
- class GetAllSearchGalaxiesAttributes(BaseModel):
75
- id: str
76
- uuid: str
77
- name: str
78
- type: str
79
- description: str
80
- version: str
81
- icon: str
82
- namespace: str
83
- kill_chain_order: str | None = None
84
- enabled: bool
85
- local_only: bool
86
-
87
-
88
49
  class GetAllSearchGalaxiesResponse(BaseModel):
89
50
  Galaxy: GetAllSearchGalaxiesAttributes
90
51
 
@@ -115,38 +76,6 @@ class GalaxySchema(BaseModel):
115
76
  orm_mode = True
116
77
 
117
78
 
118
- class ExportGalaxyClusterResponse(BaseModel):
119
- id: str
120
- uuid: str
121
- collection_uuid: str
122
- type: str
123
- value: str
124
- tag_name: str
125
- description: str
126
- galaxy_id: str
127
- source: str
128
- authors: list[str]
129
- version: str
130
- distribution: str
131
- sharing_group_id: str
132
- org_id: str
133
- orgc_id: str
134
- default: bool
135
- locked: bool
136
- extends_uuid: str
137
- extends_version: str
138
- published: bool
139
- deleted: bool
140
- GalaxyElement: list[ExportGalaxyGalaxyElement]
141
- Galaxy: GetAllEventsGalaxyClusterGalaxy
142
- GalaxyClusterRelation: list[AddEditGetEventGalaxyClusterRelation] = []
143
- Org: mmisp.api_schemas.organisations.Organisation
144
- Orgc: mmisp.api_schemas.organisations.Organisation
145
-
146
- class Config:
147
- orm_mode = True
148
-
149
-
150
79
  class ExportGalaxyAttributes(BaseModel):
151
80
  default: bool
152
81
  custom: bool | None = None
@@ -1,10 +1,17 @@
1
+ from datetime import datetime
2
+
1
3
  from pydantic import BaseModel
2
4
 
3
- from mmisp.api_schemas.events.add_edit_get_event_response import AddEditGetEventGalaxyClusterRelation
4
- from mmisp.api_schemas.events.get_all_events_response import GetAllEventsGalaxyClusterGalaxy
5
- from mmisp.api_schemas.galaxies import ExportGalaxyGalaxyElement, GetAllSearchGalaxiesAttributes
6
- from mmisp.api_schemas.organisations import GetOrganisationResponse
7
- from mmisp.api_schemas.organisations.organisation import Organisation
5
+ from mmisp.api_schemas.events import AddEditGetEventGalaxyClusterRelation, GetAllEventsGalaxyClusterGalaxy
6
+ from mmisp.api_schemas.galaxy_common import GetAllSearchGalaxiesAttributes
7
+ from mmisp.api_schemas.organisations import GetOrganisationResponse, Organisation
8
+
9
+
10
+ class ExportGalaxyGalaxyElement(BaseModel):
11
+ id: str | None = None
12
+ galaxy_cluster_id: str | None = None
13
+ key: str
14
+ value: str
8
15
 
9
16
 
10
17
  class GetGalaxyClusterResponse(BaseModel):
@@ -25,14 +32,23 @@ class GetGalaxyClusterResponse(BaseModel):
25
32
  orgc_id: str
26
33
  default: bool
27
34
  locked: bool
28
- extends_uuid: str
35
+ extends_uuid: str | None = None
29
36
  extends_version: str
30
37
  published: bool
31
38
  deleted: bool
32
- Galaxy: GetAllSearchGalaxiesAttributes
39
+ Galaxy: GetAllSearchGalaxiesAttributes | None = None
33
40
  GalaxyElement: list[ExportGalaxyGalaxyElement]
34
- Org: GetOrganisationResponse
35
- Orgc: GetOrganisationResponse
41
+ GalaxyClusterRelation: list = []
42
+ RelationshipInbound: list = []
43
+ Org: GetOrganisationResponse | None = None
44
+ Orgc: GetOrganisationResponse | None = None
45
+
46
+
47
+ class GalaxyClusterResponse(BaseModel):
48
+ GalaxyCluster: GetGalaxyClusterResponse
49
+
50
+ class Config:
51
+ json_encoders = {datetime: lambda v: v.strftime("%Y-%m-%d %H:%M:%S")}
36
52
 
37
53
 
38
54
  class ExportGalaxyClusterResponse(BaseModel):
@@ -0,0 +1,15 @@
1
+ from pydantic import BaseModel
2
+
3
+
4
+ class GetAllSearchGalaxiesAttributes(BaseModel):
5
+ id: str
6
+ uuid: str
7
+ name: str
8
+ type: str
9
+ description: str
10
+ version: str
11
+ icon: str
12
+ namespace: str
13
+ kill_chain_order: str | None = None
14
+ enabled: bool
15
+ local_only: bool
@@ -3,17 +3,20 @@ from datetime import datetime
3
3
  from pydantic import BaseModel
4
4
 
5
5
 
6
- class Organisation(BaseModel):
7
- id: str
8
- name: str
6
+ class BaseOrganisation(BaseModel):
7
+ id: str | None = None
8
+ name: str | None = None
9
+ nationality: str | None = None
10
+ sector: str | None = None
11
+ type: str | None = None
12
+ uuid: str | None = None
13
+
14
+
15
+ class Organisation(BaseOrganisation):
9
16
  date_created: datetime
10
17
  date_modified: datetime
11
18
  description: str | None = None
12
- type: str
13
- nationality: str | None = None
14
- sector: str | None = None
15
19
  created_by: str
16
- uuid: str
17
20
  contacts: str | None = None
18
21
  local: bool
19
22
  """organisation gains access to the local instance, otherwise treated as external"""
@@ -27,14 +30,14 @@ class Organisation(BaseModel):
27
30
  class GetOrganisationResponse(BaseModel):
28
31
  id: str
29
32
  name: str
33
+ nationality: str | None = None
34
+ sector: str | None = None
35
+ type: str | None = None
36
+ uuid: str | None = None
30
37
  date_created: datetime
31
38
  date_modified: datetime
32
39
  description: str | None = None
33
- type: str | None = None
34
- nationality: str | None = None
35
- sector: str | None = None
36
40
  created_by: str
37
- uuid: str | None = None
38
41
  contacts: str | None = None
39
42
  local: bool
40
43
  restricted_to_domain: str | None = None
@@ -0,0 +1,138 @@
1
+ from pydantic import BaseModel, Json
2
+
3
+ from mmisp.api_schemas.organisations import BaseOrganisation
4
+
5
+
6
+ class NOT_Filter(BaseModel):
7
+ NOT: list
8
+
9
+
10
+ class OR_NOT_Filter(BaseModel):
11
+ OR: list
12
+ NOT: list
13
+
14
+
15
+ class PullRulesFilter(BaseModel):
16
+ tags: OR_NOT_Filter
17
+ orgs: OR_NOT_Filter
18
+ type_attributes: NOT_Filter
19
+ type_objects: NOT_Filter
20
+ url_params: str
21
+
22
+
23
+ class PushRulesFilter(BaseModel):
24
+ tags: OR_NOT_Filter
25
+ orgs: OR_NOT_Filter
26
+
27
+
28
+ default_pull_rules = PullRulesFilter(
29
+ tags=OR_NOT_Filter(OR=[], NOT=[]),
30
+ orgs=OR_NOT_Filter(OR=[], NOT=[]),
31
+ type_attributes=NOT_Filter(NOT=[]),
32
+ type_objects=NOT_Filter(NOT=[]),
33
+ url_params="",
34
+ )
35
+ default_push_rules = PushRulesFilter(
36
+ tags=OR_NOT_Filter(OR=[], NOT=[]),
37
+ orgs=OR_NOT_Filter(OR=[], NOT=[]),
38
+ )
39
+
40
+
41
+ class AddServer(BaseModel):
42
+ url: str
43
+ name: str
44
+ remote_org_id: int
45
+ authkey: str
46
+ org_id: int | None = None
47
+ priority: int = 5
48
+ internal: bool = False
49
+ push: bool = False
50
+ pull: bool = False
51
+ pull_rules: Json[PullRulesFilter] | PullRulesFilter = default_pull_rules
52
+ push_rules: Json[PushRulesFilter] | PushRulesFilter = default_push_rules
53
+ push_galaxy_clusters: bool = False
54
+ caching_enabled: bool = False
55
+ unpublish_event: bool = False
56
+ publish_without_email: bool = False
57
+ self_signed: bool = False
58
+ skip_proxy: bool = False
59
+
60
+
61
+ class EditServer(BaseModel):
62
+ name: str
63
+ url: str
64
+ priority: int
65
+ authkey: str
66
+ remote_org_id: int
67
+ internal: bool
68
+ push: bool
69
+ pull: bool
70
+ pull_rules: Json[PullRulesFilter] | PullRulesFilter = default_pull_rules
71
+ push_rules: Json[PushRulesFilter] | PushRulesFilter = default_push_rules
72
+ push_galaxy_clusters: bool
73
+ caching_enabled: bool
74
+ unpublish_event: bool
75
+ publish_without_email: bool
76
+ self_signed: bool
77
+ skip_proxy: bool
78
+
79
+
80
+ class ServerResponseBase(BaseModel):
81
+ id: int
82
+ name: str
83
+ url: str
84
+ # authkey: str
85
+ org_id: int | None = None
86
+ push: bool
87
+ pull: bool
88
+ cert_file: str | None
89
+ client_cert_file: str | None
90
+ lastpulledid: int | None
91
+ lastpushedid: int | None
92
+ organization: None
93
+ pull_analyst_data: bool
94
+ pull_rules: str
95
+ push_analyst_data: bool
96
+ push_rules: str
97
+ remove_missing_tags: bool
98
+ push_sightings: bool | None = None
99
+ push_galaxy_clusters: bool | None = None
100
+ pull_galaxy_clusters: bool | None = None
101
+ remote_org_id: int
102
+ publish_without_email: bool | None = None
103
+ unpublish_event: bool | None = None
104
+ self_signed: bool
105
+ internal: bool | None = None
106
+ skip_proxy: bool | None = None
107
+ caching_enabled: bool | None = None
108
+ priority: int | None = None
109
+
110
+
111
+ class ServerResponse(ServerResponseBase):
112
+ cache_timestamp: bool = False
113
+
114
+
115
+ class AddServerServer(ServerResponseBase):
116
+ authkey: str
117
+
118
+
119
+ class AddServerResponse(BaseModel):
120
+ Server: AddServerServer
121
+
122
+
123
+ class RemoveServer(BaseModel):
124
+ id: str
125
+ sharing_group_id: str
126
+ server_id: str
127
+ all_orgs: bool
128
+
129
+
130
+ class GetRemoteServer(BaseModel):
131
+ Server: ServerResponse
132
+ Organisation: BaseOrganisation
133
+ RemoteOrg: BaseOrganisation
134
+ User: list
135
+
136
+
137
+ class ServersGetVersion(BaseModel):
138
+ pass
@@ -1,4 +1,5 @@
1
1
  from sqlalchemy import Boolean, Integer, String, Text
2
+ from sqlalchemy.orm import relationship
2
3
 
3
4
  from mmisp.db.mypy import Mapped, mapped_column
4
5
 
@@ -18,8 +19,10 @@ class Server(Base):
18
19
  push_sightings: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
19
20
  push_galaxy_clusters: Mapped[bool] = mapped_column(Boolean, default=False)
20
21
  pull_galaxy_clusters: Mapped[bool] = mapped_column(Boolean, default=False)
21
- lastpulledid: Mapped[int] = mapped_column(Integer)
22
- lastpushedid: Mapped[int] = mapped_column(Integer)
22
+ push_analyst_data: Mapped[bool] = mapped_column(Boolean, default=False)
23
+ pull_analyst_data: Mapped[bool] = mapped_column(Boolean, default=False)
24
+ last_pulled_id: Mapped[int] = mapped_column("lastpulledid", Integer)
25
+ last_pushed_id: Mapped[int] = mapped_column("lastpushedid", Integer)
23
26
  organization: Mapped[str] = mapped_column(String(10), default=None)
24
27
  remote_org_id: Mapped[int] = mapped_column(Integer, nullable=False, index=True)
25
28
  publish_without_email: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
@@ -33,3 +36,24 @@ class Server(Base):
33
36
  skip_proxy: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
34
37
  caching_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
35
38
  priority: Mapped[int] = mapped_column(Integer, nullable=False, default=0, index=True)
39
+ remove_missing_tags: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
40
+
41
+ organisation = relationship(
42
+ "Organisation",
43
+ primaryjoin="Server.org_id == Organisation.id",
44
+ lazy="raise_on_sql",
45
+ foreign_keys="Server.org_id",
46
+ ) # type:ignore[assignment,var-annotated]
47
+ remote_organisation = relationship(
48
+ "Organisation",
49
+ primaryjoin="Server.remote_org_id == Organisation.id",
50
+ lazy="raise_on_sql",
51
+ foreign_keys="Server.remote_org_id",
52
+ ) # type:ignore[assignment,var-annotated]
53
+ users = relationship(
54
+ "User",
55
+ primaryjoin="Server.id == User.server_id",
56
+ foreign_keys="User.server_id",
57
+ back_populates="server",
58
+ lazy="raise_on_sql",
59
+ )
@@ -48,3 +48,10 @@ class User(Base):
48
48
 
49
49
  # Relationships
50
50
  org = relationship("Organisation", back_populates="users", lazy="raise_on_sql")
51
+ server = relationship(
52
+ "Server",
53
+ primaryjoin="Server.id == User.server_id",
54
+ foreign_keys="User.server_id",
55
+ back_populates="users",
56
+ lazy="raise_on_sql",
57
+ )
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python3
2
+
3
+ """
4
+ USAGE:
5
+ - Run `python -m mmisp.db.print_changes`
6
+ """
7
+
8
+ import asyncio
9
+ import pprint
10
+ from collections import defaultdict
11
+
12
+ from alembic.autogenerate import compare_metadata
13
+ from alembic.migration import MigrationContext
14
+ from sqlalchemy import MetaData
15
+
16
+ import mmisp.db.all_models # noqa
17
+
18
+ from .database import Base, sessionmanager
19
+
20
+ metadata = MetaData()
21
+
22
+
23
+ def create_diff(conn) -> list: # noqa
24
+ mc = MigrationContext.configure(conn)
25
+ diff = compare_metadata(mc, Base.metadata) # type:ignore[attr-defined]
26
+ return diff
27
+
28
+
29
+ async def print_changes() -> None:
30
+ changes = defaultdict(list)
31
+ sessionmanager.init()
32
+ assert sessionmanager._engine is not None
33
+ async with sessionmanager._engine.begin() as connection:
34
+ assert connection is not None
35
+ diff = await connection.run_sync(create_diff)
36
+ for elem in diff:
37
+ if isinstance(elem, list):
38
+ for inner_elem in elem:
39
+ changes[inner_elem[0]].append(inner_elem)
40
+ else:
41
+ changes[elem[0]].append(elem)
42
+ pprint.pprint(changes, indent=2, width=20)
43
+ for k, v in changes.items():
44
+ print(k, len(v))
45
+
46
+
47
+ asyncio.run(print_changes())