Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #78 from Skyscanner/ghtokens
Browse files Browse the repository at this point in the history
Add detection for new Github personal access token format
  • Loading branch information
adeptex authored Aug 25, 2021
2 parents d84c436 + 6e3c1f4 commit 270da04
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions tests/fixtures/gitkeys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
compliant:
name: GHP_THISISASTRINGTHATHASTHESAMELENASTOKE

noncompliant:
name: ghp_fK8UXjzPM1Lzf356hwgGym4JAfnHARDcoded
2 changes: 1 addition & 1 deletion tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def test_cli_info():
with patch("sys.stdout", mock_print):
cli_info()
result = mock_print.getvalue()
assert "available rules" in result
assert "available rule IDs" in result
for rule_id in WhisperRules().rules.keys():
assert rule_id in result

Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ def test_detection_by_key(src, expected):
("java.properties", 3),
("webhooks.yml", 3),
("creditcards.yml", 3),
("gitkeys.yml", 1),
],
)
def test_detection_by_value(src, count):
Expand Down
2 changes: 1 addition & 1 deletion whispers/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
VERSION = (1, 5, 1)
VERSION = (1, 5, 2)

__version__ = ".".join(map(str, VERSION))
2 changes: 1 addition & 1 deletion whispers/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def cli_info():
rule_ids = list(WhisperRules().rules.keys())
rule_ids.sort()
cli_parser().print_help()
print("\navailable rules:")
print("\navailable rule IDs:")
for rule_id in rule_ids:
print(f" {rule_id}")

Expand Down
7 changes: 7 additions & 0 deletions whispers/rules/gitkeys.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
github:
description: Github personal access token
message: Github token
severity: CRITICAL
value:
regex: ^ghp_[a-zA-Z0-9]{36}$
ignorecase: False

0 comments on commit 270da04

Please sign in to comment.