Files
HashTool/.gitea/workflows/security.yml
T
poli0981andClaude Opus 5.5 cf839d8703 ci(security): the zizmor install command as a block scalar
":all: -r" on a plain scalar is a YAML mapping, so actionlint and zizmor
could not parse the workflow.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 11:04:26 +07:00

160 lines
6.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Security
# Gitea has no CodeQL, no dependency review and no code-scanning UI (ops runbook §1, migration decision D7). This
# workflow covers instead:
#
# vulnerable-packages NuGet packages with known advisories, transitive ones included (fails on any severity)
# licenses licences of the shipped projects' packages against eng/allowed-licenses.json
# workflow-lint zizmor, actionlint and shellcheck on .gitea/workflows/*.yml
# scan the ops repo's security.yml: gitleaks over the full history, Opengrep (C# and Python rules;
# report only, SARIF as an artifact), osv-scanner (lockfiles; this repo has none) and a
# NuGetAudit restore that fails on high/critical advisories
#
# Weekly as well, so a new advisory against unchanged dependencies turns it red: Monday 13:43 UTC = 20:43 Vietnam
# (this repo's slot in the ops repo's cron registry; the runner is the maintainer's PC and only runs 13:00–16:00 UTC).
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
- cron: "43 13 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: security-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
AVALONIA_TELEMETRY_OPTOUT: 1
jobs:
# `dotnet package list --vulnerable` always exits 0, so the JSON report is checked explicitly.
vulnerable-packages:
name: vulnerable-packages
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
- name: Restore
run: dotnet restore HashTool.slnx
- name: List vulnerable packages
run: |
dotnet package list --project HashTool.slnx --vulnerable --include-transitive --format json > vulnerable.json
jq -r '.projects[]? | .path as $p | .frameworks[]? | (.topLevelPackages[]?, .transitivePackages[]?)
| select((.vulnerabilities // []) | length > 0)
| "\($p): \(.id) \(.resolvedVersion) - \([.vulnerabilities[].severity] | join(", ")) \([.vulnerabilities[].advisoryurl] | join(" "))"' vulnerable.json \
| sort -u | tee vulnerable.txt
if [ -s vulnerable.txt ]; then
echo "::error::Vulnerable NuGet packages found (see above)."
exit 1
fi
echo "No known vulnerable packages."
# Only shipped projects are checked; test and benchmark tools are not redistributed.
licenses:
name: licenses
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-dotnet@0f4a354dd5547a28c70b7853dbd95d5b67886e73 # v6.1.0
with:
global-json-file: global.json
- name: Restore
run: |
dotnet tool restore
dotnet restore HashTool.slnx
- name: Check licenses
run: >-
dotnet nuget-license -ji eng/license-inputs.json -t
-a eng/allowed-licenses.json -o Markdown
# The linters without Docker: actionlint and shellcheck as release binaries at pinned versions, SHA-256 verified (the
# pins of the ops repo's ops-lint.yml), zizmor from the hash-locked .github/requirements-ci.txt. Renovate does not
# update the binaries: bump version and checksum together, by hand.
workflow-lint:
name: workflow-lint
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
env:
ACTIONLINT_VERSION: 1.7.12
ACTIONLINT_SHA256: 8aca8db96f1b94770f1b0d72b6dddcb1ebb8123cb3712530b08cc387b349a3d8 # actionlint_1.7.12_linux_amd64.tar.gz
SHELLCHECK_VERSION: v0.11.0
SHELLCHECK_SHA256: 8c3be12b05d5c177a04c29e3c78ce89ac86f1595681cab149b65b97c4e227198 # shellcheck-v0.11.0.linux.x86_64.tar.xz
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
with:
python-version: "3.12"
- name: Install zizmor
run: |
python -m pip install --quiet --require-hashes --only-binary :all: -r .github/requirements-ci.txt
# The files by name: zizmor only looks for .github/workflows by itself. Offline: its online audits ask GitHub's
# API about the actions, with a token this runner does not have. Any finding at medium or above fails.
- name: zizmor (workflow security audit)
run: zizmor --offline --min-severity medium --config .github/zizmor.yml .gitea/workflows/*.yml
- name: Install actionlint ${{ env.ACTIONLINT_VERSION }} + shellcheck ${{ env.SHELLCHECK_VERSION }}
run: |
set -euo pipefail
tmp="${RUNNER_TEMP:-/tmp}"
bin="$tmp/lint-bin"
mkdir -p "$bin"
curl -fsSL --retry 3 -o "$tmp/actionlint.tar.gz" \
"https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
echo "${ACTIONLINT_SHA256} $tmp/actionlint.tar.gz" | sha256sum -c -
tar -xzf "$tmp/actionlint.tar.gz" -C "$bin" actionlint
curl -fsSL --retry 3 -o "$tmp/shellcheck.tar.xz" \
"https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
echo "${SHELLCHECK_SHA256} $tmp/shellcheck.tar.xz" | sha256sum -c -
tar -xJf "$tmp/shellcheck.tar.xz" -C "$bin" --strip-components=1 "shellcheck-${SHELLCHECK_VERSION}/shellcheck"
echo "$bin" >> "$GITHUB_PATH"
# .github/actionlint.yaml ignores only the Gitea features actionlint does not know; everything else is an error.
- name: actionlint (workflow syntax and expressions)
run: |
actionlint -version
actionlint -color -config-file .github/actionlint.yaml \
-shellcheck "$(command -v shellcheck)" .gitea/workflows/*.yml
scan:
permissions:
contents: read
uses: poli0981/.github/.gitea/workflows/security.yml@c133a00dc7a0bd7bd68253d415758b408d615fa4 # ops v2026.11.4
with:
dotnet: true
dotnet-solution: HashTool.slnx
# eng/*.py: localisation, release notes, release and coverage checks.
python: true