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

Adding Grafana tokens rule #116

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/fixtures/grafanatokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

compliant:


noncompliant:
grafana_api_key: eyJrIjoiR0ZXZmt1UFc0OEpIOGN5RWdUalBJTllUTk83VlhtVGwiLCJuIjoiYXBpa2V5Y3VybCIsIhardcoded==
grafana_service_account_token: glsa_Q0tTx59W5f7LXgxiM4MjJs7hardcoded_e5c6b96d
grafana_cloud_api_key: eyJrIjoiZjJlZThiNDMwZGQ0ZDhjNjJhYmQwZWY3NDgxYzhjNjRiNzZkNjYyMiIsIm4iOiJ0ZXN0LWtleSIsImlkIjhardcoded=
grafana_cloud_api_token: glc_eyJrIjoiZjI0YzZkNGEwZDBmZmZjMmUzNTU2ODcxMmY0ZWZlNTQ1NTljMDFjOCIsIm4iOiJteXRva2VuIiwhardcoded
1 change: 1 addition & 0 deletions tests/unit/test_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_detection_by_key(src, expected):
("webhooks.yml", 3),
("creditcards.yml", 3),
("gitkeys.yml", 5),
("grafanatokens.yml", 4),
],
)
def test_detection_by_value(src, count):
Expand Down
23 changes: 23 additions & 0 deletions whispers/rules/grafana.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
grafana-cloud-api:
description: Values formatted like Grafana Cloud API Token
message: Grafana Cloud API Token
severity: BLOCKER
value:
regex: ^glc_[A-Za-z0-9+/]{32,}$
ignorecase: False

grafana-api:
description: Values formatted like Grafana API Key
message: Grafana API Key
severity: BLOCKER
value:
regex: ^eyJrIjoi[A-Za-z0-9]{70,}={0,2}$
ignorecase: False

grafana-cloud-api:
description: Values formatted like Grafana Service Account Token
message: Grafana Service Account Token
severity: BLOCKER
value:
regex: ^glsa_[A-Za-z0-9]{32}_[A-Fa-f0-9]{8}$
ignorecase: False