Skip to content

Commit

Permalink
Added allow rule + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cx-henriqueAlvelos committed Jul 21, 2023
1 parent cda265b commit 5fbbee8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
8 changes: 7 additions & 1 deletion assets/queries/common/passwords_and_secrets/regex_rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,13 @@
"id": "2f665079-c383-4b33-896e-88268c1fa258",
"name": "Generic Private Key",
"regex": "(?i)['\"]?private[_]?key['\"]?\\s*[:=]\\s*['\"]?([[A-Za-z0-9/~^_!@&%()=?*+-]+)['\"]?",
"specialMask": "(?i)['\"]?private[_]?key['\"]?\\s*[:=]\\s*"
"specialMask": "(?i)['\"]?private[_]?key['\"]?\\s*[:=]\\s*",
"allowRules": [
{
"description": "Avoiding bash variables",
"regex": "(?i)['\"]?\\$\\s*\\{[^\\s\\}]+\\}['\"]?"
}
]
},
{
"id": "baee238e-1921-4801-9c3f-79ae1d7b2cbc",
Expand Down
14 changes: 14 additions & 0 deletions assets/queries/common/passwords_and_secrets/test/negative56.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
stages:
- build

variables:
GIT_PRIVATE_KEY: $GIT_PRIVATE_KEY

job_build:
stage: build
script:
- if [[ -z "${GIT_PRIVATE_KEY:-}" ]]; then
echo "Missing GIT_PRIVATE_KEY variable!"
exit 1
fi
- echo "Private key is set."
14 changes: 14 additions & 0 deletions assets/queries/common/passwords_and_secrets/test/positive48.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
stages:
- build

variables:
GIT_PRIVATE_KEY: "heythisisaprivatekey!"

job_build:
stage: build
script:
- if [[ -z "${GIT_PRIVATE_KEY:-}" ]]; then
echo "Missing GIT_PRIVATE_KEY variable!"
exit 1
fi
- echo "Private key is set."

0 comments on commit 5fbbee8

Please sign in to comment.