Skip to content

Commit

Permalink
Make azdev scan continuing on signle file failure
Browse files Browse the repository at this point in the history
  • Loading branch information
evelyn-ys committed Dec 20, 2024
1 parent 29ed992 commit dcc37be
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $files = $(git diff --cached --name-only --diff-filter=AM $against)

foreach ($file in $files) {
# Check if the file contains secrets
$detected = $(azdev scan -f $file | ConvertFrom-Json).secrets_detected
$detected = $(azdev scan -f $file --continue-on-failure | ConvertFrom-Json).secrets_detected
if ($detected -eq "True") {
Write-Host "Detected secrets from $file. Please run the following command to mask it:" -ForegroundColor Red
Write-Host "+++++++++++++++++++++++++++++++++++++++++++++++++++++++" -ForegroundColor Red
Expand Down
2 changes: 1 addition & 1 deletion .githooks/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fi
has_secrets=0
for FILE in `git diff --cached --name-only --diff-filter=AM $against` ; do
# Check if the file contains secrets
detected=$(azdev scan -f "$FILE" | python -c "import sys, json; print(json.load(sys.stdin)['secrets_detected'])")
detected=$(azdev scan -f "$FILE" --continue-on-failure | python -c "import sys, json; print(json.load(sys.stdin)['secrets_detected'])")
if [ "$detected" = "True" ]; then
printf "\033[0;31mDetected secrets from %s, Please run the following command to mask it:\033[0m\n" "$FILE"
printf "\033[0;31m+++++++++++++++++++++++++++++++++++++++++++++++++++++++\033[0m\n"
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,7 @@ jobs:
IFS=$'\n'
for FILE in `git diff --name-only --diff-filter=AM origin/$(System.PullRequest.TargetBranch)` ; do
echo $FILE
detected=$(azdev scan -f "$FILE" | python -c "import sys, json; print(json.load(sys.stdin)['secrets_detected'])")
detected=$(azdev scan -f "$FILE" --continue-on-failure | python -c "import sys, json; print(json.load(sys.stdin)['secrets_detected'])")
if [ $detected == 'True' ]; then
printf "\033[0;31mDetected secrets from %s, You can run 'azdev mask' to remove secrets.\033[0m\n" "$FILE"
secret_files+=$FILE
Expand Down
28 changes: 0 additions & 28 deletions scripts/git_hooks/pre-commit

This file was deleted.

0 comments on commit dcc37be

Please sign in to comment.