muchdogesec / arango_cti_processor

A small script that creates relationships between common CTI knowledge-bases in STIX 2.1 format.
https://www.dogesec.com/
Apache License 2.0
3 stars 0 forks source link

Odd behaviour now occurring in tests #26

Closed himynamesdave closed 1 month ago

himynamesdave commented 2 months ago

The imported objects seems to be created 4 times. See expected result, and then the actual result (which is always exactly 4 times larger)

python3 -m unittest tests/test_1_0_capec_to_attack.py
======================================================================
FAIL: test_02_arango_cti_processor_note (tests.test_1_0_capec_to_attack.TestArangoDB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dgreenwood/Documents/repos/dogesec/arango_cti_processor/tests/test_1_0_capec_to_attack.py", line 80, in test_02_arango_cti_processor_note
    self.assertEqual(result_count, [346], f"Expected 346 documents, but found {result_count}.")
AssertionError: Lists differ: [1384] != [346]

First differing element 0:
1384
346

- [1384]
+ [346] : Expected 346 documents, but found [1384].

----------------------------------------------------------------------
Ran 11 tests in 59.146s
python3 -m unittest tests/test_2_0_capec_to_cwe.py
======================================================================
FAIL: test_02_arango_cti_processor_note (tests.test_2_0_capec_to_cwe.TestArangoDB)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dgreenwood/Documents/repos/dogesec/arango_cti_processor/tests/test_2_0_capec_to_cwe.py", line 73, in test_02_arango_cti_processor_note
    self.assertEqual(result_count, [1212], f"Expected 1212 documents, but found {result_count}.")
AssertionError: Lists differ: [4848] != [1212]

First differing element 0:
4848
1212

- [4848]
+ [1212] : Expected 1212 documents, but found [4848].
fqrious commented 2 months ago

not a bug, filtering doc._is_ref == false in the test fixes this

himynamesdave commented 2 months ago

But why are there old objects? The script has only run once at this point, and deletes any historic versions of objects first

fqrious commented 2 months ago

There are no old or odd objects, the filter you were using is wrong

himynamesdave commented 2 months ago

That's not correct @fqrious .

Take the test shown earlier

python3 -m unittest tests/test_1_0_capec_to_attack.py

the imported CAPEC file has 1212 objects (no relationships).

tests/files/stix-capec-v3_9.json