name: Security on: push: branches: [main] pull_request: branches: [main] schedule: - cron: "0 3 * * 1" permissions: contents: read jobs: gitleaks: name: Gitleaks Secret Scanner runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # 针对 PR:使用原生逻辑 - name: Setup PR commits & Run Gitleaks if: github.event_name == 'pull_request' run: | git fetch --no-tags --prune --depth=1 origin \ "+${{ github.event.pull_request.base.sha }}:refs/remotes/origin/pr-base" git remote add pr-head "https://github.com/${{ github.event.pull_request.head.repo.full_name }}.git" git fetch --no-tags --prune --depth=1 pr-head \ "+${{ github.event.pull_request.head.sha }}:refs/remotes/pr-head/current" docker run --rm \ -v "$PWD:/repo" \ -w /repo \ zricethezav/gitleaks:v8.24.3 \ detect --source . --redact -v --exit-code=2 \ --log-opts="--no-merges refs/remotes/origin/pr-base..refs/remotes/pr-head/current" # 针对 Push 和 Schedule:使用官方 Action - name: Run Gitleaks Action if: github.event_name != 'pull_request' uses: gitleaks/gitleaks-action@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITLEAKS_ENABLE_UPLOAD_ARTIFACT: true GITLEAKS_ENABLE_SUMMARY: true continue-on-error: true pip-audit: name: Python Dependency Audit runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install uv uses: astral-sh/setup-uv@v3 - name: Export requirements run: uv export --frozen --no-dev --format requirements-txt -o /tmp/req.txt - name: Run pip-audit run: | uvx pip-audit -r /tmp/req.txt --progress-spinner off \ --ignore-vuln PYSEC-2026-161 echo "Dependency audit passed"