Skip to content

Commit 89889f1

Browse files
feat: source_uuid to multiscan, when provided, the incidents will be created for the found secrets
1 parent be13fe7 commit 89889f1

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pygitguardian/client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ def multi_content_scan(
482482
ignore_known_secrets: Optional[bool] = None,
483483
*,
484484
all_secrets: Optional[bool] = None,
485+
source_uuid: Optional[str] = None,
485486
) -> Union[Detail, MultiScanResult]:
486487
"""
487488
multi_content_scan handles the /multiscan endpoint of the API.
@@ -495,6 +496,8 @@ def multi_content_scan(
495496
:param extra_headers: additional headers to add to the request
496497
:param ignore_known_secrets: indicates whether known secrets should be ignored
497498
:param all_secrets: indicates whether all secrets should be returned
499+
:param source_uuid: if provided, the source UUID will be used to identify the custom source, for which
500+
incidents will be created
498501
:return: Detail or ScanResult response and status code
499502
"""
500503
max_documents = self.secret_scan_preferences.maximum_documents_per_scan
@@ -520,6 +523,8 @@ def multi_content_scan(
520523
params["ignore_known_secrets"] = ignore_known_secrets
521524
if all_secrets is not None:
522525
params["all_secrets"] = all_secrets
526+
if source_uuid is not None:
527+
params["source_uuid"] = source_uuid
523528

524529
resp = self.post(
525530
endpoint="multiscan",

tests/test_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,13 @@ def test_scan_parameters(client: GGClient, all_secrets):
557557
@responses.activate
558558
@pytest.mark.parametrize("ignore_known_secrets", (None, True, False))
559559
@pytest.mark.parametrize("all_secrets", (None, True, False))
560-
def test_multiscan_parameters(client: GGClient, ignore_known_secrets, all_secrets):
560+
@pytest.mark.parametrize("source_uuid", (None, "test-source-uuid"))
561+
def test_multiscan_parameters(
562+
client: GGClient,
563+
ignore_known_secrets: Optional[bool],
564+
all_secrets: Optional[bool],
565+
source_uuid: Optional[str],
566+
) -> None:
561567
"""
562568
GIVEN a ggclient
563569
WHEN calling multi_content_scan with parameters
@@ -569,6 +575,8 @@ def test_multiscan_parameters(client: GGClient, ignore_known_secrets, all_secret
569575
to_match["ignore_known_secrets"] = ignore_known_secrets
570576
if all_secrets is not None:
571577
to_match["all_secrets"] = all_secrets
578+
if source_uuid is not None:
579+
to_match["source_uuid"] = source_uuid
572580

573581
mock_response = responses.post(
574582
url=client._url_from_endpoint("multiscan", "v1"),
@@ -601,6 +609,7 @@ def test_multiscan_parameters(client: GGClient, ignore_known_secrets, all_secret
601609
[{"filename": FILENAME, "document": DOCUMENT}],
602610
ignore_known_secrets=ignore_known_secrets,
603611
all_secrets=all_secrets,
612+
source_uuid=source_uuid,
604613
)
605614

606615
assert mock_response.call_count == 1

0 commit comments

Comments
 (0)