Skip to content
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
3 changes: 3 additions & 0 deletions nightfall/findings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Finding:
row_range (Range): The row in which a finding was detected, if it was in a tabular document. Index starts at 1.
column_range (Range): The column(s) in which a finding was detected, if it was in a tabular document. Index starts at 1.
commit_hash (str): The hash of the commit in which the finding was detected, if known.
commit_author(str): The author of the commit in which the finding was detected, if known.
matched_detection_rule_uuids (List[str]): The list of detection rule UUIDs that contained a detector that
triggered a match.
matched_detection_rules (List[str]): The list of inline detection rules that contained a detector that triggered
Expand All @@ -51,6 +52,7 @@ class Finding:
row_range: Optional[Range]
column_range: Optional[Range]
commit_hash: str
commit_author: str
matched_detection_rule_uuids: List[str]
matched_detection_rules: List[str]

Expand All @@ -69,6 +71,7 @@ def from_dict(cls, resp: dict) -> "Finding":
_range_or_none(resp["location"]["rowRange"]),
_range_or_none(resp["location"]["columnRange"]),
resp["location"].get("commitHash", ""),
resp["location"].get("commitAuthor", ""),
resp["matchedDetectionRuleUUIDs"],
resp["matchedDetectionRules"]
)
Expand Down
10 changes: 5 additions & 5 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def finding_orderer(f):
"Credit Card Number",
result[0][0].detector_uuid,
Confidence.VERY_LIKELY,
Range(0, 19), Range(0, 19), None, None, "",
Range(0, 19), Range(0, 19), None, None, "", "",
[], ["Inline Detection Rule #1"])
assert result[0][1] == Finding(
"489-36-8350",
Expand All @@ -66,7 +66,7 @@ def finding_orderer(f):
"US_SOCIAL_SECURITY_NUMBER",
result[0][1].detector_uuid,
Confidence.VERY_LIKELY,
Range(46, 57), Range(46, 57), None, None, "",
Range(46, 57), Range(46, 57), None, None, "", "",
[], ["Inline Detection Rule #1"])
assert len(redactions) == 1
assert redactions[0] == "491👀-👀👀👀👀-👀👀👀👀-👀👀👀👀 is my credit card number, [REDACTED] ssn"
Expand Down Expand Up @@ -334,7 +334,7 @@ def test_scan_text():
"Credit Card Number",
result[0][0].detector_uuid,
Confidence.VERY_LIKELY,
Range(0, 19), Range(0, 19), None, None, "",
Range(0, 19), Range(0, 19), None, None, "", "",
[], ["Inline Detection Rule #1"])
assert result[0][1] == Finding(
"489-36-8350",
Expand All @@ -343,7 +343,7 @@ def test_scan_text():
"",
result[0][1].detector_uuid,
Confidence.VERY_LIKELY,
Range(46, 57), Range(46, 57), Range(2,4), Range(1,1), "",
Range(46, 57), Range(46, 57), Range(2,4), Range(1,1), "", "",
[], ["Inline Detection Rule #1"])
assert len(redactions) == 1
assert redactions[0] == "491👀-👀👀👀👀-👀👀👀👀-👀👀👀👀 is my credit card number, [REDACTED] ssn"
Expand Down Expand Up @@ -432,7 +432,7 @@ def test_scan_text_with_policy_uuids():
"Credit Card Number",
result[0][0].detector_uuid,
Confidence.VERY_LIKELY,
Range(0, 19), Range(0, 19), None, None, "",
Range(0, 19), Range(0, 19), None, None, "", "",
["0d8efd7b-b87a-478b-984e-9cf5534a46bc"], [])
assert len(redactions) == 1
assert redactions[0] == "491👀-👀👀👀👀-👀👀👀👀-👀👀👀👀 is my credit card number, [REDACTED] ssn"
Expand Down