GitGuardian / ggshield

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

More refactoring of patch parser #798

Closed agateau-gg closed 9 months ago

agateau-gg commented 9 months ago

This PR finishes removing the Commit.files property, which is currently responsible for loading whole commits in memory.

Changes in a Commit are no longer represented as StringScannable instances. Instead there is a dedicated class, CommitScannable. Using a dedicated class gives more control over the path and url properties.

Finally, I added some test to validate the JSON output because my changes in CommitInformation initially introduced new fields in the extra_info object. This was because all of CommitInformation was being turned into a dict and put in extra_info. Now we only store selected fields.

Best reviewed commit by commit.

codecov-commenter commented 9 months ago

Codecov Report

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

Comparison is base (a976b98) 91.90% compared to head (649bbf2) 91.97%.

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #798 +/- ## ========================================== + Coverage 91.90% 91.97% +0.06% ========================================== Files 155 156 +1 Lines 6499 6553 +54 ========================================== + Hits 5973 6027 +54 Misses 526 526 ``` | [Flag](https://app.codecov.io/gh/GitGuardian/ggshield/pull/798/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/798/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=GitGuardian) | `91.97% <100.00%> (+0.06%)` | :arrow_up: | 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.