Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/scripts/detect-secrets-dir.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash

echo "Starting the directory scan at path '$PARAM_STR_SOURCE'"
echo "Using exported Gitleaks args '$GITLEAKS_ARGS'"

set -x
eval gitleaks dir "$GITLEAKS_ARGS" "$PARAM_STR_SOURCE"
set +x
10 changes: 4 additions & 6 deletions src/scripts/detect-secrets-git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@

EVAL_GITLEAKS_ARGS=$(eval echo "${GITLEAKS_ARGS}")

echo "Starting the repository scan at path '$PARAM_STR_SOURCE'"
echo "Using exported Gitleaks args '$GITLEAKS_ARGS'"
echo "Using '$GIT_BASE_BRANCH' as the base branch"
echo "Using '$GIT_CURRENT_BRANCH' as the current branch"

if [[ "$GIT_BASE_BRANCH" = "$GIT_CURRENT_BRANCH" ]]; then
# Usually when changes are merged back into a long-lived branch, e.g. trunk
LOG_OPTS="$PARAM_STR_BASE_REVISION^..$CIRCLE_SHA1"

echo "The base branch is the current branch"

if [[ -z "$PARAM_STR_BASE_REVISION" ]] || ! git cat-file -e "$PARAM_STR_BASE_REVISION"; then
LOG_OPTS="HEAD~1^..$CIRCLE_SHA1"

echo "The base revision is empty or invalid"
echo "Using HEAD~1 as the base revision"
echo "Scanning using 'HEAD~1' as the base revision"

elif [[ "$PARAM_STR_BASE_REVISION" == "$CIRCLE_SHA1" ]]; then
LOG_OPTS=-1

echo "The base revision is the current revision"
echo "Scanning only last commit"

else
echo "Scanning using the provided base revision '$PARAM_STR_BASE_REVISION'"

fi

EVAL_GITLEAKS_ARGS="$GITLEAKS_ARGS --log-opts=$LOG_OPTS"

else
# Usually a short lived branch, that is a pull request
echo "The base branch is not the current branch"
echo "Scanning all the commits in the current branch '$GIT_CURRENT_BRANCH'"

EVAL_GITLEAKS_ARGS="$GITLEAKS_ARGS --log-opts=$GIT_BASE_BRANCH..$GIT_CURRENT_BRANCH"
Expand Down