forked from Yelp/detect-secrets
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from IBM/test_new_ghe_token
Update GHE plugin token regex
- Loading branch information
Showing
5 changed files
with
68 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
VERSION = '0.13.1+ibm.55.dss' | ||
VERSION = '0.13.1+ibm.56.dss' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,10 @@ | |
|
||
|
||
class GheDetector(RegexBasedDetector): | ||
""" Scans for GitHub Enterprise credentials """ | ||
""" Scans for GitHub Enterprise credentials generated both before (see forty_hex var) and | ||
after (see new_ghe_token var) this update: | ||
https://docs.github.com/en/[email protected]/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats | ||
""" | ||
|
||
secret_type = 'GitHub Enterprise Credentials' | ||
denylist = None | ||
|
@@ -33,6 +36,10 @@ def __init__(self, ghe_instance=DEFAULT_GHE_INSTANCE, *args, **kwargs): | |
api_endpoint = r'(?:{ghe_instance}|api.{ghe_instance})'\ | ||
.format(ghe_instance=self.ghe_instance) | ||
forty_hex = r'(?:(?<=\W)|(?<=^))([0-9a-f]{40})(?:(?=\W)|(?=$))' | ||
# References: | ||
# https://docs.github.com/en/[email protected]/authentication/keeping-your-account-and-data-secure/about-authentication-to-github#githubs-token-formats | ||
# ref. https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/ | ||
new_ghe_token = (r'(ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9_]{36}') | ||
b64_encoded_token = r'(?:(?<=\W)|(?<=^))([A-Za-z0-9+/]{55}=)(?:(?=\W)|(?=$))' | ||
opt_username = r'(?:[a-zA-Z0-9-]+:|)' | ||
self.denylist = [ | ||
|
@@ -65,6 +72,7 @@ def __init__(self, ghe_instance=DEFAULT_GHE_INSTANCE, *args, **kwargs): | |
b64_encoded_token=b64_encoded_token, | ||
), flags=re.IGNORECASE, | ||
), | ||
re.compile(new_ghe_token), | ||
] | ||
|
||
def verify(self, token, *args, **kwargs): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# on python 3.6.0 (xenial) | ||
pip>=21.1 | ||
urllib3>=1.26.4 | ||
coverage>=6.0b1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters