GitGuardian / ggshield

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

Simplify patch handling #906

Closed agateau-gg closed 1 month ago

agateau-gg commented 1 month ago

Context

While reviewing #905 I thought it was a bit sad that we had to add a field just for backward-compatibility, so I dived into what could be done to get rid of some of the patch special-cases cruft.

What has been done

Line.content now always contains the full line, including the patch symbol.

This simplifies a bunch of things:

If you look at the snapshot diff you will see two things.

First, patch output is more correct: the second @ at the end of the @@ ... @@ lines does not miss anymore.

For multiline secrets, the detector left "arm" (the |___ symbol) starts one character earlier (see the snapshot diffs). This might be fixable but I don't think it's a problem.

Validation

Tests still pass.

PR check list

agateau-gg commented 1 month ago

You set this PR to your original fix branch, instead of garancegourdel/refacto-output-handlers-to-remove-scanable-from-result is that intentional ?

Oups, I missed that the branch had been created. Going to rebase.

You have functional test failing because they capture a new generic secret in the snapshot.

Should be good now 🤞🏻.