-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/1.17-release-notes
- Loading branch information
Showing
14 changed files
with
86 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from bits.definitions import BitDefinition | ||
from octopoes.models.ooi.findings import FindingType | ||
|
||
BIT = BitDefinition( | ||
id="default-findingtype-risk", | ||
consumes=FindingType, | ||
parameters=[], | ||
module="bits.default_findingtype_risk.default_findingtype_risk", | ||
min_scan_level=0, | ||
) |
17 changes: 17 additions & 0 deletions
17
octopoes/bits/default_findingtype_risk/default_findingtype_risk.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from collections.abc import Iterator | ||
from typing import Any | ||
|
||
from octopoes.models import OOI | ||
from octopoes.models.ooi.findings import FindingType, RiskLevelSeverity | ||
|
||
|
||
def run(input_ooi: FindingType, additional_oois: list, config: dict[str, Any]) -> Iterator[OOI]: | ||
value_set = False | ||
if not input_ooi.risk_severity: | ||
input_ooi.risk_severity = RiskLevelSeverity.PENDING | ||
value_set = True | ||
if not input_ooi.risk_score: | ||
input_ooi.risk_score = 0 | ||
value_set = True | ||
if value_set: | ||
yield input_ooi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from bits.default_findingtype_risk.default_findingtype_risk import run as run_default_findingtype_risk | ||
|
||
from octopoes.models.ooi.findings import KATFindingType, RiskLevelSeverity | ||
|
||
|
||
def test_default_findingtype_risk_pending(): | ||
test_finding_type = KATFindingType(id="KAT-TEST") | ||
|
||
assert test_finding_type.risk_severity is None | ||
assert test_finding_type.risk_score is None | ||
|
||
results = list(run_default_findingtype_risk(test_finding_type, [], {})) | ||
|
||
expected_result = results[0] | ||
assert isinstance(expected_result, KATFindingType) | ||
assert expected_result.risk_severity == RiskLevelSeverity.PENDING, "Risk Severity None should default to pending" | ||
assert expected_result.risk_score == 0, "Risk Score None should default to 0" | ||
|
||
|
||
def test_default_findingtype_risk_unkown(): | ||
test_finding_type = KATFindingType(id="KAT-TEST", risk_severity=RiskLevelSeverity.UNKNOWN, risk_score=5) | ||
|
||
results = list(run_default_findingtype_risk(test_finding_type, [], {})) | ||
|
||
assert results == [], "Bit should not output anything when risk_severity or risk_score are set" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters