Skip to content

Commit 39929a6

Browse files
martinmrevanfuller
andauthored
Add commit author to Python SDK (#48)
* Add commit author to Python SDK Fixes PLAT-2228 * Fix tests * Update nightfall/findings.py Co-authored-by: Evan Fuller <[email protected]> Co-authored-by: Evan Fuller <[email protected]>
1 parent 1cb3ad3 commit 39929a6

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

nightfall/findings.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class Finding:
3434
row_range (Range): The row in which a finding was detected, if it was in a tabular document. Index starts at 1.
3535
column_range (Range): The column(s) in which a finding was detected, if it was in a tabular document. Index starts at 1.
3636
commit_hash (str): The hash of the commit in which the finding was detected, if known.
37+
commit_author(str): The author of the commit in which the finding was detected, if known.
3738
matched_detection_rule_uuids (List[str]): The list of detection rule UUIDs that contained a detector that
3839
triggered a match.
3940
matched_detection_rules (List[str]): The list of inline detection rules that contained a detector that triggered
@@ -51,6 +52,7 @@ class Finding:
5152
row_range: Optional[Range]
5253
column_range: Optional[Range]
5354
commit_hash: str
55+
commit_author: str
5456
matched_detection_rule_uuids: List[str]
5557
matched_detection_rules: List[str]
5658

@@ -69,6 +71,7 @@ def from_dict(cls, resp: dict) -> "Finding":
6971
_range_or_none(resp["location"]["rowRange"]),
7072
_range_or_none(resp["location"]["columnRange"]),
7173
resp["location"].get("commitHash", ""),
74+
resp["location"].get("commitAuthor", ""),
7275
resp["matchedDetectionRuleUUIDs"],
7376
resp["matchedDetectionRules"]
7477
)

tests/test_api.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def finding_orderer(f):
5757
"Credit Card Number",
5858
result[0][0].detector_uuid,
5959
Confidence.VERY_LIKELY,
60-
Range(0, 19), Range(0, 19), None, None, "",
60+
Range(0, 19), Range(0, 19), None, None, "", "",
6161
[], ["Inline Detection Rule #1"])
6262
assert result[0][1] == Finding(
6363
"489-36-8350",
@@ -66,7 +66,7 @@ def finding_orderer(f):
6666
"US_SOCIAL_SECURITY_NUMBER",
6767
result[0][1].detector_uuid,
6868
Confidence.VERY_LIKELY,
69-
Range(46, 57), Range(46, 57), None, None, "",
69+
Range(46, 57), Range(46, 57), None, None, "", "",
7070
[], ["Inline Detection Rule #1"])
7171
assert len(redactions) == 1
7272
assert redactions[0] == "491👀-👀👀👀👀-👀👀👀👀-👀👀👀👀 is my credit card number, [REDACTED] ssn"
@@ -334,7 +334,7 @@ def test_scan_text():
334334
"Credit Card Number",
335335
result[0][0].detector_uuid,
336336
Confidence.VERY_LIKELY,
337-
Range(0, 19), Range(0, 19), None, None, "",
337+
Range(0, 19), Range(0, 19), None, None, "", "",
338338
[], ["Inline Detection Rule #1"])
339339
assert result[0][1] == Finding(
340340
"489-36-8350",
@@ -343,7 +343,7 @@ def test_scan_text():
343343
"",
344344
result[0][1].detector_uuid,
345345
Confidence.VERY_LIKELY,
346-
Range(46, 57), Range(46, 57), Range(2,4), Range(1,1), "",
346+
Range(46, 57), Range(46, 57), Range(2,4), Range(1,1), "", "",
347347
[], ["Inline Detection Rule #1"])
348348
assert len(redactions) == 1
349349
assert redactions[0] == "491👀-👀👀👀👀-👀👀👀👀-👀👀👀👀 is my credit card number, [REDACTED] ssn"
@@ -432,7 +432,7 @@ def test_scan_text_with_policy_uuids():
432432
"Credit Card Number",
433433
result[0][0].detector_uuid,
434434
Confidence.VERY_LIKELY,
435-
Range(0, 19), Range(0, 19), None, None, "",
435+
Range(0, 19), Range(0, 19), None, None, "", "",
436436
["0d8efd7b-b87a-478b-984e-9cf5534a46bc"], [])
437437
assert len(redactions) == 1
438438
assert redactions[0] == "491👀-👀👀👀👀-👀👀👀👀-👀👀👀👀 is my credit card number, [REDACTED] ssn"

0 commit comments

Comments
 (0)