GitGuardian / ggshield

Find and fix 400+ types of hardcoded secrets and 70+ types of infrastructure-as-code misconfigurations.
https://gitguardian.com
MIT License
1.65k stars 147 forks source link

Add support for custom remediation messages #928

Closed fnareoh closed 2 months ago

fnareoh commented 3 months ago

Context

This MR adds the display of custom remediation messages defined in the gitguardian plateform.

What has been done

This MR relies on the changes on pygitguardian https://github.com/GitGuardian/py-gitguardian/pull/111

And for a custom remediation message to be display in ggshield the instance has to expose the messages through the metadata endpoint (see internal MR).

Validation

This version of ggshield should be compatible with versions of the app that do not yet expose the remediation messages (current staging for example) with the metadata endpoint and a version that does (review app of the MR that exposes to the public api).

Set the right instance for example using the env variable GITGUARDIAN_INSTANCE and GITGUARDIAN_API_KEY the try the ggshield secret scan pre-commit after leaking a secret and ggshield secret scan pre-push after commiting a secret but I am not sure how to test the pre-receive :(

PR check list

codecov-commenter commented 2 months ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.13%. Comparing base (ae78adc) to head (835e596). Report is 3 commits behind head on main.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #928 +/- ## ========================================== - Coverage 91.18% 91.13% -0.06% ========================================== Files 176 176 Lines 7252 7240 -12 ========================================== - Hits 6613 6598 -15 - Misses 639 642 +3 ``` | [Flag](https://app.codecov.io/gh/GitGuardian/ggshield/pull/928/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GitGuardian) | Coverage Δ | | |---|---|---| | [unittests](https://app.codecov.io/gh/GitGuardian/ggshield/pull/928/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GitGuardian) | `91.13% <100.00%> (-0.06%)` | :arrow_down: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GitGuardian#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.