@@ -231,7 +231,7 @@ jobs:
231231
232232 hooks_equivalence_gate :
233233 needs : [changes]
234- if : ${{ github.repository_owner != 'xiaojiou176-open' && (github. event_name == 'workflow_dispatch' || needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' || needs.changes.outputs.automation == 'true' || needs.changes.outputs.ci_gatechain == 'true') }}
234+ if : ${{ github.event_name == 'workflow_dispatch' || needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' || needs.changes.outputs.automation == 'true' || needs.changes.outputs.ci_gatechain == 'true' }}
235235 runs-on : ubuntu-latest
236236 steps :
237237 - name : Pre-checkout workspace sanitize
@@ -311,9 +311,12 @@ jobs:
311311 with :
312312 mode : post
313313
314- security :
314+ trivy_fs :
315315 needs : [changes]
316+ if : ${{ github.event_name == 'workflow_dispatch' || needs.changes.outputs.backend == 'true' || needs.changes.outputs.frontend == 'true' || needs.changes.outputs.automation == 'true' || needs.changes.outputs.ci_gatechain == 'true' }}
316317 runs-on : ubuntu-latest
318+ permissions :
319+ contents : read
317320 steps :
318321 - name : Pre-checkout workspace sanitize
319322 shell : bash
@@ -346,16 +349,61 @@ jobs:
346349 with :
347350 fetch-depth : 0
348351 - uses : ./.github/actions/workspace-sanitize
349- - name : Secret scan (history audit, strict when license configured)
350- if : ${{ vars.GITLEAKS_LICENSE != '' }}
351- uses : gitleaks/gitleaks-action@dcedce43c6f43de0b836d1fe38946645c9c638dc # v2
352- env :
353- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
354- GITLEAKS_LICENSE : ${{ vars.GITLEAKS_LICENSE }}
355- - name : Skip history secret scan (no GITLEAKS_LICENSE configured)
356- if : ${{ vars.GITLEAKS_LICENSE == '' }}
352+ - name : Trivy filesystem scan
353+ uses : aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1 # v0.35.0
354+ with :
355+ scan-type : fs
356+ scan-ref : .
357+ format : table
358+ exit-code : " 1"
359+ ignore-unfixed : true
360+ vuln-type : library
361+ severity : HIGH,CRITICAL
362+ - name : Upload failure bundle artifact
363+ if : ${{ failure() || cancelled() }}
364+ uses : ./.github/actions/failure-bundle
365+ - uses : ./.github/actions/workspace-sanitize
366+ if : ${{ always() }}
367+ with :
368+ mode : post
369+
370+ security :
371+ needs : [changes]
372+ runs-on : ubuntu-latest
373+ steps :
374+ - name : Pre-checkout workspace sanitize
375+ shell : bash
357376 run : |
358- echo "security history audit skipped: missing GITLEAKS_LICENSE repository variable"
377+ set -euo pipefail
378+ workspace="${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is required}"
379+ home_dir="${HOME:-}"
380+ case "$workspace" in
381+ /|/.|/..|"")
382+ echo "::error::refusing dangerous workspace path: $workspace"
383+ exit 1
384+ ;;
385+ esac
386+ if [[ -n "$home_dir" && "$workspace" == "$home_dir" ]]; then
387+ echo "::error::refusing workspace equal to HOME: $workspace"
388+ exit 1
389+ fi
390+ if [[ -d "$workspace" ]]; then
391+ if command -v sudo >/dev/null 2>&1; then
392+ sudo chown -R "$(id -u):$(id -g)" "$workspace" || true
393+ sudo bash -lc 'shopt -s dotglob nullglob; rm -rf -- "$1"/* "$1"/.[!.]* "$1"/..?*' _ "$workspace" || true
394+ sudo mkdir -p "$workspace" || true
395+ sudo chown "$(id -u):$(id -g)" "$workspace" || true
396+ else
397+ chmod -R u+rwX "$workspace" || true
398+ find "$workspace" -mindepth 1 -maxdepth 1 -exec rm -rf -- {} + || true
399+ fi
400+ fi
401+ - uses : actions/checkout@64ffef1ea610c4052efefeb955034987fb104bc4 # v4
402+ with :
403+ fetch-depth : 0
404+ - uses : ./.github/actions/workspace-sanitize
405+ - name : Secret scan (history audit, repo-owned gate)
406+ run : bash scripts/ci/gitleaks-history-gate.sh
359407 - name : Upload failure bundle artifact
360408 if : ${{ failure() || cancelled() }}
361409 uses : ./.github/actions/failure-bundle
0 commit comments