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
42 changes: 42 additions & 0 deletions changelog.d/20260123_190818_kp2681_add_custom_tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Removed

- A bullet item for the Removed category.

-->

### Added

- Capture secret incident `custom_tags` dictionaries when calling `retrieve_secret_incident`.
<!--

### Changed

- A bullet item for the Changed category.

-->

<!--
### Deprecated

- A bullet item for the Deprecated category.

-->
<!--
### Fixed

- A bullet item for the Fixed category.

-->
<!--
### Security

- A bullet item for the Security category.

-->
12 changes: 10 additions & 2 deletions pygitguardian/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,11 +931,18 @@ class Answer(Base, FromDictMixin):
class Feedback(Base, FromDictMixin):
created_at: datetime
updated_at: datetime
member_id: int
member_id: Optional[int]
email: str
answers: List[Answer]


@dataclass
class CustomTag(Base, FromDictMixin):
id: str
key: str
value: str


@dataclass
class SecretIncidentStats(Base, FromDictMixin):
total: int
Expand Down Expand Up @@ -1078,8 +1085,9 @@ class SecretIncident(Base, FromDictMixin):
resolved_at: Optional[datetime]
share_url: Optional[str]
tags: List[str]
feedback_list: List[Feedback]
occurrences: Optional[List[SecretOccurrence]]
feedback_list: List[Feedback]
custom_tags: Optional[List[CustomTag]]

def __repr__(self) -> str:
return (
Expand Down
35 changes: 35 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
CreateTeamInvitation,
CreateTeamMember,
CreateTeamMemberParameters,
CustomTag,
DeleteMemberParameters,
Detail,
HoneytokenResponse,
Expand Down Expand Up @@ -744,6 +745,23 @@ def test_retrieve_secret_incident(client: GGClient):
"resolved_at": None,
"share_url": "https://dashboard.gitguardian.com/share/incidents/11111111-1111-1111-1111-111111111111",
"tags": ["FROM_HISTORICAL_SCAN", "SENSITIVE_FILE"],
"custom_tags": [
{
"id": "9df8c1c9-7367-4c77-a0f0-9f2d4b22bdda",
"key": "commiter",
"value": "leaky mcgee",
},
{
"id": "1aa3ae34-f9f0-42e1-a687-9fed877a9037",
"key": "confrence",
"value": "grrcon",
},
{
"id": "2cade8a1-71ff-46d2-bbe3-c2bf71437ae7",
"key": "confrence test",
"value": "hacktivity",
},
],
Comment thread
alexpasmantier marked this conversation as resolved.
"feedback_list": [
{
"created_at": "2021-05-20T12:40:55.662949Z",
Expand Down Expand Up @@ -771,6 +789,23 @@ def test_retrieve_secret_incident(client: GGClient):
assert result.detector.name == "slack_bot_token"
assert result.ignore_reason == "test_credential"
assert result.secret_revoked is False
assert result.custom_tags == [
CustomTag(
id="9df8c1c9-7367-4c77-a0f0-9f2d4b22bdda",
key="commiter",
value="leaky mcgee",
),
CustomTag(
id="1aa3ae34-f9f0-42e1-a687-9fed877a9037",
key="confrence",
value="grrcon",
),
CustomTag(
id="2cade8a1-71ff-46d2-bbe3-c2bf71437ae7",
key="confrence test",
value="hacktivity",
),
]


@responses.activate
Expand Down
Loading