Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update system test mapping and enhance attack chain assertions in sce… #583

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions system_test_mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,10 +619,10 @@
"Backend"
],
"target_repositories": [
"cadashboardbe",
"careportsreceiver",
"event-ingester-service",
"gateway"
"cadashboardbe-dummy",
"careportsreceiver-dummy",
"event-ingester-service-dummy",
"gateway-dummy"
],
"description": "",
"skip_on_environment": "",
Expand Down
7 changes: 5 additions & 2 deletions systest_utils/scenarios_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,25 @@ def check_attack_chains_results(self, result, expected):
expected: expected attack chains.
:exception Exception: if the content is not as expected.
"""

assert "response" in result, f"'response' key not found in the result"
assert len(result['response']['attackChains']) > 0, "No attack chains found, expecting attack chains"
found = False

expected_ac = expected['response']['attackChains'][0]
# Some example of assertion needed to recognize attack chain scenarios
for acid, ac in enumerate(result['response']['attackChains']):
if ac['name'] != self.attack_track:
continue

found = True
ac_node_result = result['response']['attackChains'][acid]['attackChainNodes']
ac_node_expected = expected['response']['attackChains'][acid]['attackChainNodes']
ac_node_expected = expected_ac['attackChainNodes']

# comparing the 'name' (type: attack track) of the attack chain
assert ac_node_result['name'] == ac_node_expected['name'], f"Attack chain name mismatch: result: {ac_node_result['name']} != expected: {ac_node_expected['name']}"

self.compare_nodes(ac_node_result, ac_node_expected)
break

assert found, f"Attack chain {self.attack_track} not found, expecting attack chains"

Expand Down
Loading