Skip to content

Commit 6d467c1

Browse files
authored
feat: change the source path usage for secrets detection (#32)
- Remove the environment mappings for the source path - Use the `working_directory` option, to set the source for the dir mode - Always execute the git mode in the working directory - Use `PWD` env to log the working directory during execution
1 parent 836d97c commit 6d467c1

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

src/commands/detect_secrets.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ parameters:
66
source:
77
type: string
88
default: '.'
9-
description: The path to the source for the scanning.
9+
description: >
10+
The path to the source for the scanning. Defaults to . (working directory).
11+
Only utilized in the "dir" mode. The "git" mode will always use the working directory.
1012
mode:
1113
type: enum
1214
enum: ['dir', 'git']
@@ -52,7 +54,6 @@ steps:
5254
- run:
5355
name: Detect secrets inside the Git repository
5456
environment:
55-
PARAM_STR_SOURCE: <<parameters.source>>
5657
PARAM_STR_BASE_REVISION: <<parameters.base_revision>>
5758
command: <<include(scripts/detect-secrets-git.sh)>>
5859
- when:
@@ -61,6 +62,5 @@ steps:
6162
steps:
6263
- run:
6364
name: Detect secrets inside the directory
64-
environment:
65-
PARAM_STR_SOURCE: <<parameters.source>>
65+
working_directory: <<parameters.source>>
6666
command: <<include(scripts/detect-secrets-dir.sh)>>

src/jobs/detect_secrets_dir.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ parameters:
77
source:
88
type: string
99
default: '.'
10-
description: The path to the directory to scan.
10+
description: The path to the directory to scan. Defaults to . (working directory).
1111
config:
1212
type: string
1313
default: ''

src/scripts/detect-secrets-dir.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
#!/bin/bash
22

3-
echo "Starting the directory scan at path '${PARAM_STR_SOURCE}'"
3+
echo "Starting the directory scan at path '${PWD}'"
44

55
set -x
6-
eval gitleaks dir "${GITLEAKS_ARGS}" "${PARAM_STR_SOURCE}"
6+
eval \
7+
gitleaks \
8+
dir \
9+
"${GITLEAKS_ARGS}" \
10+
.
711
set +x

src/scripts/detect-secrets-git.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
EVAL_GITLEAKS_ARGS=$(eval echo "${GITLEAKS_ARGS}")
43
LOG_OPTS=""
54

65
echo "Using '${GIT_BASE_BRANCH}' as the base branch"
@@ -35,8 +34,11 @@ else
3534

3635
fi
3736

38-
EVAL_GITLEAKS_ARGS="${EVAL_GITLEAKS_ARGS} --log-opts=${LOG_OPTS}"
39-
4037
set -x
41-
eval gitleaks git "${EVAL_GITLEAKS_ARGS}" "${PARAM_STR_SOURCE}"
38+
eval \
39+
gitleaks \
40+
git \
41+
"${GITLEAKS_ARGS}" \
42+
--log-opts="${LOG_OPTS}" \
43+
.
4244
set +x

0 commit comments

Comments
 (0)