GitGuardian / ggshield

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

Fix with-incident-details option #1003

Closed pierrelalanne closed 8 hours ago

pierrelalanne commented 23 hours ago

The Fix

If no default value is defined for the option with-incident-details, the behavior of ggshield can be misleading and actually bugged. Indeed, each command or subcommand uses the decorator "add_secret_scan_common_options" to collect values of several command options. This lets the user place the option --with-incident-details at several level in the command line.

If they do so, the command or subcommand that does not have the flag will set the value to False which can prevent the option from working correctly. For instance: ggshield secret scan --with-incident-details path dummy.py => The option is set to False in the end because the path subcommand does not have the option defined. ggshield secret scan path --with-incident-details dummy.py => The optiton is set to True, because defined in the path subcommand.

We make the option default to None. This does not override the value defined earlier in the command line.

Remarks

  1. Let me know if the comment or the commit is too verbose.
codecov[bot] commented 8 hours ago

Codecov Report

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

Project coverage is 91.97%. Comparing base (b96eb05) to head (71ec8ea). Report is 2 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1003 +/- ## ========================================== - Coverage 91.99% 91.97% -0.02% ========================================== Files 181 181 Lines 7655 7655 ========================================== - Hits 7042 7041 -1 - Misses 613 614 +1 ``` | [Flag](https://app.codecov.io/gh/GitGuardian/ggshield/pull/1003/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/1003/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GitGuardian) | `91.97% <ø> (-0.02%)` | :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.