Skip to content

Commit

Permalink
feat: add ignore reason to json output
Browse files Browse the repository at this point in the history
  • Loading branch information
gg-mmill committed Dec 17, 2024
1 parent 5d79826 commit 5e23fe8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ggshield/verticals/secret/output/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ class FlattenedPolicyBreak(BaseSchema):
incident_url = fields.String(required=True, dump_default="")
incident_details = fields.Nested(SecretIncidentSchema)
known_secret = fields.Bool(required=True, dump_default=False)
is_ignored = fields.Bool(required=False)
ignore_reason = fields.String(required=False)


class JSONResultSchema(BaseSchema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def serialized_policy_break(
if details is not None:
flattened_dict["incident_details"] = details

if policy_breaks[0].ignore_reason is not None:
flattened_dict["is_ignored"] = True
flattened_dict["ignore_reason"] = policy_breaks[0].ignore_reason

Check warning on line 137 in ggshield/verticals/secret/output/secret_json_output_handler.py

View check run for this annotation

Codecov / codecov/patch

ggshield/verticals/secret/output/secret_json_output_handler.py#L136-L137

Added lines #L136 - L137 were not covered by tests

for policy_break in policy_breaks:
flattened_dict["occurrences"].extend(
self.serialize_policy_break_matches(policy_break)
Expand Down
6 changes: 6 additions & 0 deletions ggshield/verticals/secret/secret_scan_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ def to_human_readable(self):
res += f"({self.detail})"

Check warning on line 52 in ggshield/verticals/secret/secret_scan_collection.py

View check run for this annotation

Codecov / codecov/patch

ggshield/verticals/secret/secret_scan_collection.py#L52

Added line #L52 was not covered by tests
return res

def to_machine_readable(self):
res = self.kind.name.lower()
if self.detail:
res += f"({self.detail})"
return res

Check warning on line 59 in ggshield/verticals/secret/secret_scan_collection.py

View check run for this annotation

Codecov / codecov/patch

ggshield/verticals/secret/secret_scan_collection.py#L56-L59

Added lines #L56 - L59 were not covered by tests


def compute_ignore_reason(
policy_break: PolicyBreak, secret_config: SecretConfig
Expand Down

0 comments on commit 5e23fe8

Please sign in to comment.