Skip to content

Commit a088db3

Browse files
Merge branch 'main' into feature/gitleaks
Signed-off-by: rtrofimenkov-ssdlc <[email protected]>
2 parents 8f4aa00 + 23120e5 commit a088db3

File tree

3 files changed

+24
-15
lines changed

3 files changed

+24
-15
lines changed

cve_scan/action.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ runs:
123123
--retry-all-errors \
124124
${DD_URL}/api/v2/reimport-scan/ \
125125
-H "accept: application/json" \
126-
-H "Content-Type: multipart/form-data" \
127126
-H "Authorization: Token ${DD_TOKEN}" \
128127
-F "auto_create_context=True" \
129128
-F "minimum_severity=Info" \

gitleaks/action.yml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ inputs:
55
scan_mode:
66
description: "Scan mode: full | diff"
77
required: false
8-
default: "full"
8+
default: "diff"
99
gitleaks_version:
1010
description: "Gitleaks version to install"
1111
required: false
@@ -93,7 +93,7 @@ runs:
9393
exit 0
9494
fi
9595
96-
mapfile -t FILES < <(git diff --name-only --diff-filter=AMR "${BASE_SHA}...${HEAD_SHA}")
96+
mapfile -t FILES < <(git diff --name-only --diff-filter=AMR "${BASE_SHA}" "${HEAD_SHA}")
9797
if (( ${#FILES[@]} == 0 )); then
9898
echo "No changed files."
9999
echo "src_dir=" >> "$GITHUB_OUTPUT"
@@ -112,7 +112,7 @@ runs:
112112
echo '{}' > "$PATCH_JSON"
113113
114114
while IFS= read -r file; do
115-
HUNKS="$(git diff --unified=0 "${BASE_SHA}...${HEAD_SHA}" -- "$file" \
115+
HUNKS="$(git diff --unified=0 "${BASE_SHA}" "${HEAD_SHA}" -- "$file" \
116116
| awk '/^@@/ {print}' \
117117
| sed -n 's/.*+\([0-9]\+\),\([0-9]\+\).*/\1 \2/p')"
118118
@@ -163,8 +163,6 @@ runs:
163163
- name: Filter findings by added lines (patch)
164164
if: ${{ inputs.scan_mode == 'diff' }}
165165
shell: bash
166-
env:
167-
SRC_DIR: ${{ steps.prpatch.outputs.src_dir }}
168166
run: |
169167
set -euo pipefail
170168
PATCH_MAP_PATH="${{ steps.prpatch.outputs.patch_map }}"
@@ -176,19 +174,16 @@ runs:
176174
fi
177175
178176
MAP_JSON="$(cat "${PATCH_MAP_PATH}")"
179-
SRC_PREFIX="${SRC_DIR%/}/"
180177
181-
jq --argjson map "${MAP_JSON}" --arg src "${SRC_PREFIX}" '
178+
jq --argjson map "${MAP_JSON}" '
182179
def arr: if type=="object" and has("findings") then .findings
183180
elif type=="array" then . else [] end;
184-
def strip($p; s): if s|startswith($p) then s[($p|length):] else s end;
185-
186181
arr
187182
| map(
188183
. as $f
189-
| (strip($src; ($f.File // $f.file // $f.Target // $f.Location.File // ""))) as $rel
184+
| ($f.File // $f.file // $f.Target // $f.Location.File // "") as $file
190185
| ($f.StartLine // $f.Line // $f.Location.StartLine // 0) as $line
191-
| if ($map[$rel] // []) as $ranges
186+
| if ($map[$file] // empty) as $ranges
192187
| any($ranges[]; $line >= .[0] and $line <= .[1])
193188
then $f else empty end
194189
)

svace_analyze/action.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,21 @@ runs:
294294
fi
295295
}
296296
297+
get_svace_bin() {
298+
proj="${1}"
299+
svace_version=$(send "cat ${proj}/.svace-dir/svace-dir.version | awk 'FNR==3{print}'")
300+
301+
svace_bin="/opt/svace-${svace_version}/bin/svace"
302+
if [[ $(send "[[ -x ${svace_bin} ]] && echo true || echo false") == true ]]; then
303+
echo "${svace_bin}"
304+
else
305+
echo "svace"
306+
error "\"${svace_bin}\" is not executable on analyze server. Using default."
307+
fi
308+
}
309+
297310
if [[ $(send "[[ -d /${SVACE_ANALYZE_DIR}/${CI_COMMIT_HASH} ]] && echo true || echo false") == false ]]; then
298-
echo "::warning file=$(realpath "$0")::Specified commit directory doesn't exists on analyze server." && exit 0
311+
echo "::warning file=$(realpath "$0")::Specified commit directory doesn't exists on analyze server." && exit 1
299312
fi
300313
301314
projects=$(send "find /${SVACE_ANALYZE_DIR}/${CI_COMMIT_HASH} \\( -type d -iname .svace-dir -o -iname *.tar.gz \\) -exec dirname {} \\;")
@@ -312,10 +325,12 @@ runs:
312325
313326
if [[ $(send "[[ -d ${proj}/.svace-dir ]] && echo true || echo false") == true ]]; then
314327
define_import_params import_project import_branch
328+
svace_bin=$(get_svace_bin "${proj}")
329+
info "Using svace binary: $svace_bin"
315330
316331
info "Start analyzing project \"${svacer_proj}\" ..."
317-
send "svace config --svace-dir ${proj} THREAD_NUMBER auto"
318-
send "svace analyze --set-config SKIP_UNREACHABLE_PROCEDURE_ANALYSIS=${SKIP_UNREACHABLE_PROCEDURE_ANALYSIS} --quiet --svace-dir ${proj}"
332+
send "${svace_bin} config --svace-dir ${proj} THREAD_NUMBER auto"
333+
send "${svace_bin} analyze --set-config SKIP_UNREACHABLE_PROCEDURE_ANALYSIS=${SKIP_UNREACHABLE_PROCEDURE_ANALYSIS} --quiet --svace-dir ${proj}"
319334
success "Analysis completed successfully!"
320335
321336
info "Start archiving project \"${svacer_proj}\" ..."

0 commit comments

Comments
 (0)