-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #115 from GitGuardian/garancegourdel/scrt-4759-opt…
…imize-files-to-scan-on-merge-commits feat(incidents): implement models and client for /incidents/secrets/
- Loading branch information
Showing
5 changed files
with
484 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
....d/20240823_170420_fnareoh_scrt_4759_optimize_files_to_scan_on_merge_commits.md
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,3 @@ | ||
### Added | ||
|
||
- Added `GGClient.retrieve_secret_incident()` to retrieve the incident associated with a secret (see https://api.gitguardian.com/docs#tag/Secret-Incidents/operation/retrieve-incidents) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -616,6 +616,88 @@ def test_multiscan_parameters( | |
assert mock_response.call_count == 1 | ||
|
||
|
||
@responses.activate | ||
def test_retrieve_secret_incident(client: GGClient): | ||
""" | ||
GIVEN a ggclient | ||
WHEN calling retrieve_secret_incident with parameters | ||
THEN the parameters are passed in the request | ||
""" | ||
|
||
mock_response = responses.get( | ||
url=client._url_from_endpoint("incidents/secrets/3759", "v1"), | ||
status=200, | ||
match=[matchers.query_param_matcher({"with_occurrences": 20})], | ||
json={ | ||
"id": 3759, | ||
"date": "2019-08-22T14:15:22Z", | ||
"detector": { | ||
"name": "slack_bot_token", | ||
"display_name": "Slack Bot Token", | ||
"nature": "specific", | ||
"family": "apikey", | ||
"detector_group_name": "slackbot_token", | ||
"detector_group_display_name": "Slack Bot Token", | ||
}, | ||
"secret_hash": "Ri9FjVgdOlPnBmujoxP4XPJcbe82BhJXB/SAngijw/juCISuOMgPzYhV28m6OG24", | ||
"hmsl_hash": "05975add34ddc9a38a0fb57c7d3e676ffed57080516fc16bf8d8f14308fedb86", | ||
"gitguardian_url": "https://dashboard.gitguardian.com/workspace/1/incidents/3899", | ||
"regression": False, | ||
"status": "IGNORED", | ||
"assignee_id": 309, | ||
"assignee_email": "[email protected]", | ||
"occurrences_count": 4, | ||
"secret_presence": { | ||
"files_requiring_code_fix": 1, | ||
"files_pending_merge": 1, | ||
"files_fixed": 1, | ||
"outside_vcs": 1, | ||
"removed_outside_vcs": 0, | ||
"in_vcs": 3, | ||
"removed_in_vcs": 0, | ||
}, | ||
"ignore_reason": "test_credential", | ||
"triggered_at": "2019-05-12T09:37:49Z", | ||
"ignored_at": "2019-08-24T14:15:22Z", | ||
"ignorer_id": 309, | ||
"ignorer_api_token_id": "fdf075f9-1662-4cf1-9171-af50568158a8", | ||
"resolver_id": 395, | ||
"resolver_api_token_id": "fdf075f9-1662-4cf1-9171-af50568158a8", | ||
"secret_revoked": False, | ||
"severity": "high", | ||
"validity": "valid", | ||
"resolved_at": None, | ||
"share_url": "https://dashboard.gitguardian.com/share/incidents/11111111-1111-1111-1111-111111111111", | ||
"tags": ["FROM_HISTORICAL_SCAN", "SENSITIVE_FILE"], | ||
"feedback_list": [ | ||
{ | ||
"created_at": "2021-05-20T12:40:55.662949Z", | ||
"updated_at": "2021-05-20T12:40:55.662949Z", | ||
"member_id": 42, | ||
"email": "[email protected]", | ||
"answers": [ | ||
{ | ||
"type": "boolean", | ||
"field_ref": "actual_secret_yes_no", | ||
"field_label": "Is it an actual secret?", | ||
"boolean": True, | ||
} | ||
], | ||
} | ||
], | ||
"occurrences": None, | ||
}, | ||
) | ||
|
||
result = client.retrieve_secret_incident(3759) | ||
|
||
assert mock_response.call_count == 1 | ||
assert result.id == 3759 | ||
assert result.detector.name == "slack_bot_token" | ||
assert result.ignore_reason == "test_credential" | ||
assert result.secret_revoked is False | ||
|
||
|
||
@responses.activate | ||
def test_rate_limit(): | ||
""" | ||
|
Oops, something went wrong.