intermediate commit
This commit is contained in:
@@ -104,9 +104,17 @@ if [[ "${#REPOS[@]}" -le 12 ]]; then
|
||||
fi
|
||||
|
||||
declare -a PY_ROOTS=()
|
||||
declare -a PY_PROD_ROOTS=()
|
||||
declare -a PY_TEST_ROOTS=()
|
||||
for repo in "${REPOS[@]}"; do
|
||||
[[ -d "$repo/src" ]] && PY_ROOTS+=("$repo/src")
|
||||
[[ -d "$repo/tests" ]] && PY_ROOTS+=("$repo/tests")
|
||||
if [[ -d "$repo/src" ]]; then
|
||||
PY_ROOTS+=("$repo/src")
|
||||
PY_PROD_ROOTS+=("$repo/src")
|
||||
fi
|
||||
if [[ -d "$repo/tests" ]]; then
|
||||
PY_ROOTS+=("$repo/tests")
|
||||
PY_TEST_ROOTS+=("$repo/tests")
|
||||
fi
|
||||
done
|
||||
|
||||
safe_name() {
|
||||
@@ -184,13 +192,25 @@ run_semgrep() {
|
||||
}
|
||||
|
||||
run_bandit() {
|
||||
[[ "${#PY_ROOTS[@]}" -gt 0 ]] || return 0
|
||||
bandit -r "${PY_ROOTS[@]}" -f json -o "$REPORTS_DIR/bandit.json"
|
||||
local status=0
|
||||
if [[ "${#PY_PROD_ROOTS[@]}" -gt 0 ]]; then
|
||||
bandit -r "${PY_PROD_ROOTS[@]}" -f json -o "$REPORTS_DIR/bandit.json" || status=1
|
||||
fi
|
||||
if [[ "${#PY_TEST_ROOTS[@]}" -gt 0 ]]; then
|
||||
bandit -r "${PY_TEST_ROOTS[@]}" -f json -o "$REPORTS_DIR/bandit-tests.json" || true
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
run_ruff_security() {
|
||||
[[ "${#PY_ROOTS[@]}" -gt 0 ]] || return 0
|
||||
ruff check --select S --output-format json "${PY_ROOTS[@]}" > "$REPORTS_DIR/ruff-security.json"
|
||||
local status=0
|
||||
if [[ "${#PY_PROD_ROOTS[@]}" -gt 0 ]]; then
|
||||
ruff check --select S --output-format json "${PY_PROD_ROOTS[@]}" > "$REPORTS_DIR/ruff-security.json" || status=1
|
||||
fi
|
||||
if [[ "${#PY_TEST_ROOTS[@]}" -gt 0 ]]; then
|
||||
ruff check --select S --output-format json "${PY_TEST_ROOTS[@]}" > "$REPORTS_DIR/ruff-security-tests.json" || true
|
||||
fi
|
||||
return "$status"
|
||||
}
|
||||
|
||||
run_gitleaks() {
|
||||
@@ -272,12 +292,39 @@ run_osv_scanner() {
|
||||
}
|
||||
|
||||
run_jscpd() {
|
||||
local ignored_paths
|
||||
ignored_paths=(
|
||||
"**/.git/**"
|
||||
"**/node_modules/**"
|
||||
"**/.venv/**"
|
||||
"**/dist/**"
|
||||
"**/build/**"
|
||||
"**/audit-reports/**"
|
||||
"**/package-lock.json"
|
||||
"**/package-lock.release.json"
|
||||
"**/package.json"
|
||||
"package.json"
|
||||
"**/generatedTranslations.ts"
|
||||
"**/docs/gitea-labels.json"
|
||||
"**/*.md"
|
||||
"**/*.md:*"
|
||||
"*.md"
|
||||
"*.md:*"
|
||||
"**/*.svg"
|
||||
"*.svg"
|
||||
".gitea/workflows/*.yml"
|
||||
"**/.gitea/workflows/*.yml"
|
||||
"**/backend/schema/*.schema.json"
|
||||
)
|
||||
local ignored_path_pattern
|
||||
ignored_path_pattern="$(printf '%s,' "${ignored_paths[@]}")"
|
||||
ignored_path_pattern="${ignored_path_pattern%,}"
|
||||
jscpd \
|
||||
--silent \
|
||||
--min-tokens 80 \
|
||||
--reporters json \
|
||||
--output "$REPORTS_DIR/jscpd" \
|
||||
--ignore "**/.git/**,**/node_modules/**,**/.venv/**,**/dist/**,**/build/**,**/audit-reports/**,**/package-lock.json,**/package-lock.release.json,**/generatedTranslations.ts,**/docs/gitea-labels.json" \
|
||||
--ignore "$ignored_path_pattern" \
|
||||
"${REPOS[@]}"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user