-
Notifications
You must be signed in to change notification settings - Fork 481
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
New Artifactory / Slack Patterns #195
Conversation
detect_secrets/plugins/slack.py
Outdated
@@ -10,8 +10,16 @@ | |||
|
|||
class SlackDetector(RegexBasedDetector): | |||
|
|||
secret_type = 'Slack Token' | |||
secret_type = 'Slack Token / Webhook' |
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.
This is going to be a non-backwards compatible change.
Are you sure you want to do this?
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.
(Backwards compatibility aside)
I think we may want to make a different plugin, I say this because we should only have 1 verify
method once #194 is merged, and verifying token's vs. webhooks is different.
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.
I'm fine with having the same plugin.
In the verify
method, we can do:
def verify(self, token):
if token.startswith('https://hooks.slack.com'):
# do logic
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.
As far as backwards compatibility, I don't mind but there may be a user that does. Slack isn't one of the noisier plugins so I'd say this is okay :) What do you think @domanchi?
(To explain better, the reason this breaks backwards compatibility is because all of a user's old acknowledged Slack tokens will be re-alerted on, because the "hashed_secret" value will change.)
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.
I'm in favor of the slightly less descriptive, but more compatible decision to keep secret_type
. IMO, adding the clarity that it also catches webhooks is less important.
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.
I would agree with @domanchi on more compatible approach.
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.
No objection here. I'll leave the type as it was.
re.compile(r'(\s|=|:|"|^)AP6\w{10,}'), # password | ||
re.compile(r'(\s|=|:|"|^)AKC[a-zA-Z0-9]{10,}'), # api token | ||
# artifactory encrypted passwords begin with AP[A-Z] | ||
re.compile(r'(\s|=|:|"|^)AP[\dABCDEF][a-zA-Z0-9]{8,}'), # password |
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.
cc @justineyster just as a heads up
The modifications in this PR are twofold: 1. Add ability to detect Slack Webhooks 2. Improved the artifactory password regex to catch passwords of different lengths and rotated passwords (Third char increments after user rotates password). Restore slack token secret type
90dd6d7
to
b34dda6
Compare
I've returned the secret type and rebased master. Let me know if there are further changes you want :) |
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.
✅🛳
* Fix Artifactory validation failure case Closes git-defenders/detect-secrets-discuss#207 * update tests * Catch 401 and 403
* Fix Artifactory validation failure case Closes git-defenders/detect-secrets-discuss#207 * update tests * Catch 401 and 403
The modifications in this PR are twofold: