-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(output): Only fail secret scans when the secret is introduced #1010
base: main
Are you sure you want to change the base?
feat(output): Only fail secret scans when the secret is introduced #1010
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1010 +/- ##
==========================================
- Coverage 92.04% 92.04% -0.01%
==========================================
Files 181 181
Lines 7704 7740 +36
==========================================
+ Hits 7091 7124 +33
- Misses 613 616 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
455a373
to
ee9c949
Compare
policy_breaks = self.scan.policy_breaks | ||
if diff_kinds is not None and self.scan.is_diff: | ||
policy_breaks = [ | ||
policy_break | ||
for policy_break in self.scan.policy_breaks | ||
if policy_break.diff_kind in diff_kinds | ||
] | ||
return policy_breaks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can be slightly simplified to:
policy_breaks = self.scan.policy_breaks | |
if diff_kinds is not None and self.scan.is_diff: | |
policy_breaks = [ | |
policy_break | |
for policy_break in self.scan.policy_breaks | |
if policy_break.diff_kind in diff_kinds | |
] | |
return policy_breaks | |
if diff_kinds is not None and self.scan.is_diff: | |
return [ | |
policy_break | |
for policy_break in self.scan.policy_breaks | |
if policy_break.diff_kind in diff_kinds | |
] | |
return self.scan.policy_breaks |
@@ -70,6 +77,18 @@ def censor(self) -> None: | |||
def has_policy_breaks(self) -> bool: | |||
return self.scan.has_policy_breaks | |||
|
|||
def policy_breaks( | |||
self, *, diff_kinds: Optional[List[DiffKind]] = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nicer if diff_kinds was a set instead of a list, since we don't want to have duplicate kinds.
@@ -70,6 +77,18 @@ def censor(self) -> None: | |||
def has_policy_breaks(self) -> bool: | |||
return self.scan.has_policy_breaks | |||
|
|||
def policy_breaks( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming: this should be get_policy_breaks()
.
ee9c949
to
db52127
Compare
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
14567116 | Triggered | GitGuardian Test Token Checked | db52127 | tests/unit/cassettes/test_scan_file_secret-True.yaml | View secret |
14567116 | Triggered | GitGuardian Test Token Checked | db52127 | tests/unit/cassettes/test_scan_file_secret_with_validity.yaml | View secret |
14567116 | Triggered | GitGuardian Test Token Checked | db52127 | tests/unit/cassettes/test_scan_file_secret_with_validity.yaml | View secret |
14567116 | Triggered | GitGuardian Test Token Checked | db52127 | tests/unit/cassettes/test_scan_file_secret-True.yaml | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
Context
Related to SPI-526 and will close #1001
We want to only fail secret scans when the secret is introduced.
New fields have been added to the API to automatically detect if the content is a diff and if the secret has been added, deleted or in the context. (GitGuardian/py-gitguardian#122)
What has been done
Make use of the new fields to return success when no secret are added.
TODO:
Validation
PR check list
skip-changelog
label has been added to the PR.