-
Notifications
You must be signed in to change notification settings - Fork 455
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 #157 from justineyster/artifactory-detector
Adds artifactory credential detector to plugins
- Loading branch information
Showing
8 changed files
with
80 additions
and
0 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from __future__ import absolute_import | ||
|
||
import re | ||
|
||
from .base import RegexBasedDetector | ||
|
||
|
||
class ArtifactoryDetector(RegexBasedDetector): | ||
|
||
secret_type = 'Artifactory Credentials' | ||
|
||
blacklist = [ | ||
# artifactory tokens begin with AKC | ||
re.compile(r'(\s|=|"|^)AKC\w{10,}'), # api token | ||
# artifactory encrypted passwords begin with AP6 | ||
re.compile(r'(\s|=|"|^)AP6\w{10,}'), # password | ||
] |
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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from __future__ import absolute_import | ||
|
||
import pytest | ||
|
||
from detect_secrets.plugins.artifactory import ArtifactoryDetector | ||
|
||
|
||
class TestArtifactoryDetector(object): | ||
|
||
@pytest.mark.parametrize( | ||
'payload, should_flag', | ||
[ | ||
('AP6xxxxxxxxxx', True), | ||
('AKCxxxxxxxxxx', True), | ||
(' AP6xxxxxxxxxx', True), | ||
(' AKCxxxxxxxxxx', True), | ||
('=AP6xxxxxxxxxx', True), | ||
('=AKCxxxxxxxxxx', True), | ||
('\"AP6xxxxxxxxxx\"', True), | ||
('\"AKCxxxxxxxxxx\"', True), | ||
('X-JFrog-Art-Api: AKCxxxxxxxxxx', True), | ||
('X-JFrog-Art-Api: AP6xxxxxxxxxx', True), | ||
('artifactoryx:_password=AKCxxxxxxxxxx', True), | ||
('artifactoryx:_password=AP6xxxxxxxxxx', True), | ||
('testAKCwithinsomeirrelevantstring', False), | ||
('testAP6withinsomeirrelevantstring', False), | ||
('X-JFrog-Art-Api: $API_KEY', False), | ||
('X-JFrog-Art-Api: $PASSWORD', False), | ||
('artifactory:_password=AP6xxxxxxxx', False), | ||
('artifactory:_password=AKCxxxxxxxx', False), | ||
], | ||
) | ||
def test_analyze_string(self, payload, should_flag): | ||
logic = ArtifactoryDetector() | ||
|
||
output = logic.analyze_string(payload, 1, 'mock_filename') | ||
assert len(output) == int(should_flag) |
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