stix2arango 1.1.2__tar.gz → 1.1.3__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.

Potentially problematic release.


This version of stix2arango might be problematic. Click here for more details.

Files changed (108) hide show
  1. {stix2arango-1.1.2 → stix2arango-1.1.3}/PKG-INFO +1 -1
  2. {stix2arango-1.1.2 → stix2arango-1.1.3}/pyproject.toml +1 -1
  3. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/services/arangodb_service.py +2 -2
  4. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/stix2arango/stix2arango.py +2 -2
  5. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/utils.py +1 -5
  6. stix2arango-1.1.3/tests/src/test_arango_service.py +61 -0
  7. stix2arango-1.1.3/tests/src/test_utils.py +168 -0
  8. {stix2arango-1.1.2 → stix2arango-1.1.3}/.env.example +0 -0
  9. {stix2arango-1.1.2 → stix2arango-1.1.3}/.env.markdown +0 -0
  10. {stix2arango-1.1.2 → stix2arango-1.1.3}/.github/workflows/create-release.yml +0 -0
  11. {stix2arango-1.1.2 → stix2arango-1.1.3}/.github/workflows/run-tests.yml +0 -0
  12. {stix2arango-1.1.2 → stix2arango-1.1.3}/.gitignore +0 -0
  13. {stix2arango-1.1.2 → stix2arango-1.1.3}/LICENSE +0 -0
  14. {stix2arango-1.1.2 → stix2arango-1.1.3}/README.md +0 -0
  15. {stix2arango-1.1.2 → stix2arango-1.1.3}/docs/README.md +0 -0
  16. {stix2arango-1.1.2 → stix2arango-1.1.3}/docs/stix2arango.png +0 -0
  17. {stix2arango-1.1.2 → stix2arango-1.1.3}/requirements.txt +0 -0
  18. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/__init__.py +0 -0
  19. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/__main__.py +0 -0
  20. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/config.py +0 -0
  21. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/services/__init__.py +0 -0
  22. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/services/version_annotator.py +0 -0
  23. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/stix2arango/__init__.py +0 -0
  24. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/stix2arango/bundle_loader.py +0 -0
  25. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango/templates/marking-definition.json +0 -0
  26. {stix2arango-1.1.2 → stix2arango-1.1.3}/stix2arango.py +0 -0
  27. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/README.md +0 -0
  28. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/custom-sco-original.json +0 -0
  29. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/custom-sco-updated.json +0 -0
  30. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/custom-sdo-original.json +0 -0
  31. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/custom-sdo-updated.json +0 -0
  32. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/duplicate-objects-all-properties-same.json +0 -0
  33. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/duplicate-objects-properties-different.json +0 -0
  34. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/embedded-ref-object-removed.json +0 -0
  35. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/embedded-ref-object-updated.json +0 -0
  36. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/embedded-ref-object.json +0 -0
  37. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/embedded-ref-sdo-sco-sro-smo.json +0 -0
  38. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/nested-embedded-ref.json +0 -0
  39. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/non-standard-embedded-relationship.json +0 -0
  40. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sco-original.json +0 -0
  41. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sco-updated.json +0 -0
  42. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sigma-rule-bundle-another.json +0 -0
  43. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sigma-rule-bundle-condensed-original.json +0 -0
  44. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sigma-rule-bundle-condensed-update-1.json +0 -0
  45. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sigma-rule-bundle-condensed-update-2.json +0 -0
  46. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sigma-rule-bundle-yet-another.json +0 -0
  47. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sigma-rule-bundle.json +0 -0
  48. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/smo-embedded-ref-1.json +0 -0
  49. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/smo-embedded-ref-2.json +0 -0
  50. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/smo-original.json +0 -0
  51. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/smo-updated-2.json +0 -0
  52. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/smo-updated.json +0 -0
  53. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/source-object-does-not-exist.json +0 -0
  54. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sro-original.json +0 -0
  55. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/sro-updated.json +0 -0
  56. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/target-object-does-not-exist.json +0 -0
  57. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/update_with_diff_modified_times_1.json +0 -0
  58. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/files/stix2arango/update_with_diff_modified_times_2.json +0 -0
  59. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/requirements.txt +0 -0
  60. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/__init__.py +0 -0
  61. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/base_test.py +0 -0
  62. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_00-basic-import-logic-with-embedded.py +0 -0
  63. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_01-basic-import-no-embedded.py +0 -0
  64. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_02-basic-import-no-stix2arango_note.py +0 -0
  65. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_03-import-with-no-update-detected.py +0 -0
  66. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_04-update-detected-because-of-stix2arango-note.py +0 -0
  67. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_05-update-detected-because-of-modified-time-change.py +0 -0
  68. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_06-update-detected-because-of-modified-time-change-not-in-order.py +0 -0
  69. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_07-test-default-imported-objects.py +0 -0
  70. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_08-duplicate-objects-in-bundle-all-identical.py +0 -0
  71. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_09-duplicate-objects-but-diff-times-in-bundle.py +0 -0
  72. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_10-updating-object-no-modified-time.py +0 -0
  73. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_11-custom-sdos.py +0 -0
  74. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_12-custom-scos.py +0 -0
  75. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_13-updating-smos.py +0 -0
  76. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_14-non-standard-embedded-relationship.py +0 -0
  77. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_15-testing-when-sro-target-not-in-collection.py +0 -0
  78. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_16-testing-when-sro-source-not-in-collection.py +0 -0
  79. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_17-testing-update-of-embedded-refs.py +0 -0
  80. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_18-testing-nested-embedded-ref.py +0 -0
  81. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_19_update_with_diff_created_times.py +0 -0
  82. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_20-embedded-sro-update-for-sdo.py +0 -0
  83. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_21-embedded-sro-update-for-sco.py +0 -0
  84. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_22-embedded-sro-update-for-smo.py +0 -0
  85. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_23-embedded-sro-removed.py +0 -0
  86. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_24-test-hidden-properties.py +0 -0
  87. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_25-ignore-embedded-rels-smo.py +0 -0
  88. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/full_tests/test_26-ignore-embedded-rels-sro.py +0 -0
  89. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/test_bundle_loader.py +0 -0
  90. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/src/test_stix2arango.py +0 -0
  91. {stix2arango-1.1.2 → stix2arango-1.1.3}/tests/tests.env +0 -0
  92. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/README.md +0 -0
  93. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_atlas.py +0 -0
  94. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_attack_enterprise.py +0 -0
  95. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_attack_ics.py +0 -0
  96. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_attack_mobile.py +0 -0
  97. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_capec.py +0 -0
  98. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_cwe.py +0 -0
  99. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_disarm.py +0 -0
  100. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_locations.py +0 -0
  101. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_sigma_rules.py +0 -0
  102. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_tlp.py +0 -0
  103. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cti_processor/insert_archive_yara_rules.py +0 -0
  104. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cve_processor/README.md +0 -0
  105. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cve_processor/insert_archive_cve.py +0 -0
  106. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/arango_cve_processor/manager.py +0 -0
  107. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/stix2arango/add_ref_types.py +0 -0
  108. {stix2arango-1.1.2 → stix2arango-1.1.3}/utilities/stix2arango/update_taxii_index_with_date_transform.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: stix2arango
3
- Version: 1.1.2
3
+ Version: 1.1.3
4
4
  Summary: stix2arango is a command line tool that takes a group of STIX 2.1 objects in a bundle and inserts them into ArangoDB. It can also handle updates to existing objects in ArangoDB imported in a bundle.
5
5
  Project-URL: Homepage, https://github.com/muchdogesec/stix2arango
6
6
  Project-URL: Issues, https://github.com/muchdogesec/stix2arango/issues
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stix2arango"
7
- version = "1.1.2"
7
+ version = "1.1.3"
8
8
  authors = [
9
9
  { name = "dogesec" }
10
10
  ]
@@ -63,7 +63,7 @@ class ArangoDBService:
63
63
 
64
64
  if self.db.has_graph(self.ARANGO_GRAPH):
65
65
  self.cti2stix_graph = self.db.graph(self.ARANGO_GRAPH)
66
- elif create:
66
+ elif create_db:
67
67
  self.cti2stix_graph = self.db.create_graph(self.ARANGO_GRAPH)
68
68
 
69
69
  self.collections: dict[str, StandardCollection] = {}
@@ -199,7 +199,7 @@ class ArangoDBService:
199
199
 
200
200
  @staticmethod
201
201
  def fix_edge_ref(_id):
202
- c, _, _key = _id.partition('/')
202
+ c, _, _key = _id.rpartition('/')
203
203
  if not c:
204
204
  c = "missing_collection"
205
205
  return f"{c}/{_key}"
@@ -80,9 +80,9 @@ class Stix2Arango:
80
80
  self.file = file
81
81
  self._is_large_file = is_large_file
82
82
  self.note = stix2arango_note or ""
83
- self.identity_ref = utils.load_file_from_url(config.STIX2ARANGO_IDENTITY)
83
+ self.identity_ref = utils.load_file_from_url(config.STIX2ARANGO_IDENTITY).copy()
84
84
  self.default_ref_objects = [
85
- utils.load_file_from_url(link)
85
+ utils.load_file_from_url(link).copy()
86
86
  for link in config.MARKING_DEFINITION_REFS + config.IDENTITY_REFS
87
87
  ]
88
88
  self.bundle_id = bundle_id
@@ -8,7 +8,7 @@ import json
8
8
  import hashlib
9
9
  import os
10
10
  from . import config
11
- from datetime import datetime
11
+ from datetime import UTC, datetime
12
12
 
13
13
  module_logger = logging.getLogger("data_ingestion_service")
14
14
  from arango.database import StandardDatabase
@@ -67,10 +67,6 @@ def create_relationship_obj(
67
67
  relationship_object["_bundle_id"] = bundle_id
68
68
  relationship_object["_file_name"] = os.path.basename(arango_obj.file or "")
69
69
  relationship_object["_stix2arango_note"] = arango_obj.note
70
- relationship_object["_record_created"] = datetime.now().strftime(
71
- "%Y-%m-%dT%H:%M:%S.%f"
72
- )
73
- relationship_object["_record_modified"] = relationship_object["_record_created"]
74
70
  relationship_object["_is_ref"] = True
75
71
  relationship_object["type"] = "relationship"
76
72
  relationship_object["spec_version"] = "2.1"
@@ -0,0 +1,61 @@
1
+
2
+
3
+ import pytest
4
+ from stix2arango import config
5
+ from stix2arango.services.arangodb_service import ArangoDBService
6
+ from stix2arango.stix2arango.stix2arango import Stix2Arango
7
+ import arango.exceptions
8
+ from unittest.mock import patch, MagicMock
9
+
10
+
11
+ def test_get_db_name():
12
+ assert ArangoDBService.get_db_name("test") == 'test_database'
13
+ assert ArangoDBService.get_db_name("test_database") == 'test_database'
14
+
15
+ @pytest.fixture(scope='module')
16
+ def service():
17
+ s = ArangoDBService('test_s2a_arango_service', [], [], host_url=Stix2Arango.ARANGODB_URL, username=config.ARANGODB_USERNAME, password=config.ARANGODB_PASSWORD, create_db=True)
18
+ yield s
19
+ s.sys_db.delete_database('test_s2a_arango_service_database')
20
+
21
+
22
+ def test_init_creates_graph(service):
23
+ assert service.db.has_graph('test_s2a_arango_service_graph')
24
+
25
+
26
+ def test_create_db(service):
27
+ service.create_database('test_s2a_arango_service2')
28
+ assert service.sys_db.has_database('test_s2a_arango_service2')
29
+ service.create_database('test_s2a_arango_service2')
30
+ service.sys_db.delete_database('test_s2a_arango_service2')
31
+
32
+ def test_create_collection(service):
33
+ assert service.create_collection('ss_vertex_collection').info()['name'] == 'ss_vertex_collection', "created collection must have the passed name"
34
+ assert service.create_collection('ss_vertex_collection').info()['name'] == 'ss_vertex_collection', "recreating should not throw error"
35
+
36
+ def test_execute_raw_query(service):
37
+ c = service.create_collection('execute_raw_query')
38
+ c.insert_many([{"a": 1}, {"a": 2}, {"a": 3}])
39
+ assert service.execute_raw_query("FOR d IN @@collection FILTER d.a >= 2 RETURN d.a", bind_vars={'@collection': c.name}) == [2, 3]
40
+ with pytest.raises(arango.exceptions.AQLQueryExecuteError):
41
+ service.execute_raw_query("FOR d IN @@collection FILTER d.a >= 2 RETURN d.a")
42
+
43
+ def test_fix_edge_ref():
44
+ assert ArangoDBService.fix_edge_ref('nothing') == "missing_collection/nothing"
45
+ assert ArangoDBService.fix_edge_ref('abcd/nothing') == "abcd/nothing"
46
+
47
+ def test_transactional_resets_db(service):
48
+ db = service.db
49
+ with patch('arango.database.TransactionDatabase.commit_transaction') as mock_commit, service.transactional():
50
+ pass
51
+ assert service.db == db, "db not reset to original after context exit"
52
+ mock_commit.assert_called_once()
53
+
54
+
55
+ def test_transactional_resets_db__on_failure(service):
56
+ db = service.db
57
+ with patch('arango.database.TransactionDatabase.abort_transaction') as mock_abort, pytest.raises(Exception), service.transactional():
58
+ raise Exception("must raise")
59
+ assert service.db == db, "db not reset to original after context exit"
60
+ mock_abort.assert_called_once()
61
+
@@ -0,0 +1,168 @@
1
+ from datetime import datetime
2
+ from unittest.mock import MagicMock, patch
3
+ import pytest
4
+ from stix2arango import utils
5
+ from stix2arango.config import STIX2ARANGO_IDENTITY
6
+
7
+
8
+ def test_load_file_from_url():
9
+ assert utils.load_file_from_url(STIX2ARANGO_IDENTITY) == {
10
+ "type": "identity",
11
+ "spec_version": "2.1",
12
+ "id": "identity--72e906ce-ca1b-5d73-adcd-9ea9eb66a1b4",
13
+ "created_by_ref": "identity--9779a2db-f98c-5f4b-8d08-8ee04e02dbb5",
14
+ "created": "2020-01-01T00:00:00.000Z",
15
+ "modified": "2020-01-01T00:00:00.000Z",
16
+ "name": "stix2arango",
17
+ "description": "https://github.com/muchdogesec/stix2arango",
18
+ "identity_class": "system",
19
+ "sectors": ["technology"],
20
+ "contact_information": "https://www.dogesec.com/contact/",
21
+ "object_marking_refs": [
22
+ "marking-definition--94868c89-83c2-464b-929b-a1a8aa3c8487",
23
+ "marking-definition--97ba4e8b-04f6-57e8-8f6e-3a0f0a7dc0fb",
24
+ ],
25
+ }
26
+
27
+ with pytest.raises(Exception):
28
+ utils.load_file_from_url("https://gogle.cm/ojkskja")
29
+
30
+
31
+ def test_remove_duplicates():
32
+ assert (
33
+ len(
34
+ utils.remove_duplicates(
35
+ [
36
+ {
37
+ "id": "all-the-same",
38
+ },
39
+ {
40
+ "id": "all-the-same",
41
+ },
42
+ {"id": "all-the-same", "a": 1},
43
+ {"id": "all-the-same", "a": 1, "_is_latest": True},
44
+ {"id": "all-the-same", "a": 2, "b": 1},
45
+ {"id": "all-the-same", "a": 2, "b": 1, "c": 1},
46
+ {"id": "all-the-same", "a": 2, "b": 1, "c": 1, "_is": 8},
47
+ ]
48
+ )
49
+ )
50
+ == 4
51
+ )
52
+
53
+
54
+ def test_get_embedded_refs():
55
+ assert utils.get_embedded_refs(
56
+ {
57
+ "abc_ref": "ref1",
58
+ "abcd_refs": ["ref1", "ref2"],
59
+ "abcde": [{"abcdef_ref": "ref7"}, {"abcd_efgh_ref": "ref8"}],
60
+ }
61
+ ) == [
62
+ ("abc", ["ref1"]),
63
+ ("abcd", ["ref1", "ref2"]),
64
+ ("abcde-abcdef", ["ref7"]),
65
+ ("abcde-abcd-efgh", ["ref8"]),
66
+ ]
67
+
68
+
69
+ def test_get_vertex_and_edge_collection_names():
70
+ assert utils.get_vertex_and_edge_collection_names("ade") == (
71
+ "ade_vertex_collection",
72
+ "ade_edge_collection",
73
+ )
74
+ assert utils.get_vertex_and_edge_collection_names("ade_edge_collection") == (
75
+ "ade_vertex_collection",
76
+ "ade_edge_collection",
77
+ )
78
+ assert utils.get_vertex_and_edge_collection_names("ade_vertex_collection") == (
79
+ "ade_vertex_collection",
80
+ "ade_edge_collection",
81
+ )
82
+
83
+
84
+ def test_create_relationship__no_targets():
85
+ assert utils.create_relationship_obj(None, None, None, None, None, None) == []
86
+
87
+
88
+ def test_create_relationships():
89
+ obj = {
90
+ "created": "2024-01-01T00:00:00.000000",
91
+ "modified": "2024-01-02T00:00:00.000000",
92
+ "object_marking_refs": ["marking--xyz"],
93
+ }
94
+
95
+ source = "indicator--source"
96
+ targets = ["malware--target1", "software--target--2"]
97
+ relationship = "indicates"
98
+ insert_statement = []
99
+ bundle_id = "bundle--xyz"
100
+ extra_data = {"confidence": 80, "labels": ["example"]}
101
+ arango_obj = MagicMock()
102
+ arango_obj.identity_ref = {"id": "identity--abcd"}
103
+ arango_obj.core_collection_vertex = "vertices"
104
+ arango_obj.file = "/some/path/file.txt"
105
+ arango_obj.note = "This is a note"
106
+
107
+ utils.create_relationship_obj(
108
+ obj=obj,
109
+ source=source,
110
+ targets=targets,
111
+ relationship=relationship,
112
+ insert_statement=insert_statement,
113
+ bundle_id=bundle_id,
114
+ arango_obj=arango_obj,
115
+ extra_data=extra_data,
116
+ )
117
+
118
+ assert len(insert_statement) == 2
119
+ assert insert_statement == [
120
+ {
121
+ "relationship_type": "indicates",
122
+ "created": "2024-01-01T00:00:00.000000",
123
+ "modified": "2024-01-02T00:00:00.000000",
124
+ "object_marking_refs": ["marking--xyz"],
125
+ "id": "relationship--8a86537f-d4bb-55bc-b06d-ddeabbd9899d",
126
+ "created_by_ref": "identity--abcd",
127
+ "source_ref": "indicator--source",
128
+ "target_ref": "malware--target1",
129
+ "_from": "vertices/indicator--source",
130
+ "_to": "vertices/malware--target1",
131
+ "_bundle_id": "bundle--xyz",
132
+ "_file_name": "file.txt",
133
+ "_stix2arango_note": "This is a note",
134
+ "_is_ref": True,
135
+ "type": "relationship",
136
+ "spec_version": "2.1",
137
+ "external_references": {
138
+ "source_name": "stix2arango",
139
+ "description": "embedded-relationship",
140
+ },
141
+ "confidence": 80,
142
+ "labels": ["example"],
143
+ },
144
+ {
145
+ "relationship_type": "indicates",
146
+ "created": "2024-01-01T00:00:00.000000",
147
+ "modified": "2024-01-02T00:00:00.000000",
148
+ "object_marking_refs": ["marking--xyz"],
149
+ "id": "relationship--fda071b0-e1e8-5831-a707-850f1b1a5a0e",
150
+ "created_by_ref": "identity--abcd",
151
+ "source_ref": "indicator--source",
152
+ "target_ref": "software--target--2",
153
+ "_from": "vertices/indicator--source",
154
+ "_to": "vertices/software--target--2",
155
+ "_bundle_id": "bundle--xyz",
156
+ "_file_name": "file.txt",
157
+ "_stix2arango_note": "This is a note",
158
+ "_is_ref": True,
159
+ "type": "relationship",
160
+ "spec_version": "2.1",
161
+ "external_references": {
162
+ "source_name": "stix2arango",
163
+ "description": "embedded-relationship",
164
+ },
165
+ "confidence": 80,
166
+ "labels": ["example"],
167
+ },
168
+ ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes