Compare commits

...
3 Commits
Author SHA1 Message Date
admin fa1f68509d Merge branch 'main' into codex/harden-security-20261111
CI (SIAX Cloud) / quality (pull_request) Waiting to run
CI (SIAX Cloud) / integration (pull_request) Waiting to run
CI (SIAX Cloud) / security (pull_request) Waiting to run
CI (SIAX Cloud) / sonar (pull_request) Waiting to run
CI (SIAX Cloud) / Component conformance (blocking) (pull_request) Waiting to run
masterplan-lock / check (pull_request) Waiting to run
security / scan (pull_request) Waiting to run
2026-11-11 18:10:50 +00:00
siax-bot 096aff376e chore(ci): slå ihop main i grenen och behåll kanonisk security-gate
CI (SIAX Cloud) / quality (pull_request) Canceled after 0s
CI (SIAX Cloud) / integration (pull_request) Canceled after 0s
CI (SIAX Cloud) / security (pull_request) Canceled after 0s
CI (SIAX Cloud) / sonar (pull_request) Canceled after 0s
CI (SIAX Cloud) / Component conformance (blocking) (pull_request) Canceled after 0s
masterplan-lock / check (pull_request) Canceled after 0s
security / scan (pull_request) Canceled after 0s
2026-11-11 18:46:24 +01:00
admin dbf36793de fix(ci): gitleaks blockerar pa arbetstradet, historik loggas informativt
CI (SIAX Cloud) / sonar (pull_request) Skipped
masterplan-lock / check (pull_request) Successful in 3s
masterplan-lock / check (push) Successful in 21s
security / scan (pull_request) Failing after 32s
CI (SIAX Cloud) / security (pull_request) Successful in 37s
CI (SIAX Cloud) / Component conformance (blocking) (pull_request) Successful in 59s
CI (SIAX Cloud) / integration (pull_request) Successful in 2m46s
CI (SIAX Cloud) / quality (pull_request) Successful in 3m11s
2026-11-10 18:50:21 +01:00
+16 -112
View File
@@ -26,18 +26,14 @@ on:
pull_request: {}
schedule:
- cron: "17 2 * * *"
workflow_dispatch: {}
permissions: { contents: read }
# N6 (server-config ci/jobbstorm-2026-11-10 §4): en ny commit på samma PR/gren avbryter den inaktuella körningen.
concurrency:
group: ${{ gitea.workflow }}-${{ gitea.ref }}
group: security-${{ github.ref }}
cancel-in-progress: true
jobs:
scan:
runs-on: ubuntu-latest
# Övre gräns: ett scannerjobb får aldrig äta en delad runner-värd.
timeout-minutes: 60
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with: { fetch-depth: 0 }
@@ -65,8 +61,8 @@ jobs:
- name: gitleaks secret scan
run: |
set +e
docker run --rm --cpus 2 --memory 4g -v "$SCAN_VOLUME:/repo" -w /repo \
zricethezav/gitleaks:v8.30.1 detect --no-git --source /repo --no-banner --redact --exit-code 1 > /tmp/scan.log 2>&1
docker run --rm -v "$SCAN_VOLUME:/repo" -w /repo \
zricethezav/gitleaks:v8.30.1 detect --no-git --source /repo --no-banner --exit-code 1 > /tmp/scan.log 2>&1
rc=$?
set -e
tail -n 120 /tmp/scan.log
@@ -74,88 +70,23 @@ jobs:
if [ $rc -eq 1 ]; then echo "::error::gitleaks secret scan hittade fynd"; exit 1; fi
echo "::warning::gitleaks secret scan kunde inte köras (rc=$rc) - verktygsfel, inte fynd"; exit 0
# gitleaks over just de commits som PR:en eller pushen inför. Blockerar på
# hemligheter som introduceras i intervallet, även om de raderas senare i
# samma PR (de finns kvar i historiken efter merge). Git-läget med
# --log-opts skannar bara tillagda rader, så en PR som RADERAR en gammal
# hemlighet fälls inte, och .gitleaks.toml/.gitleaksignore i repot gäller.
# Fullhistoriken körs bara nattligt/manuellt (nästa steg): en full
# `git log -p --all` per PR tog timmar och sänkte runner-värden
# (server10, 2026-11-11).
- name: gitleaks commit range
if: github.event_name == 'pull_request' || github.event_name == 'push'
timeout-minutes: 15
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BEFORE_SHA: ${{ github.event.before }}
run: |
set -eu
test -d .git || { echo "::error::ingen .git i $PWD"; exit 1; }
head="${PR_HEAD_SHA:-$GITHUB_SHA}"
base=""
if [ "$EVENT_NAME" = "pull_request" ] && [ -n "${BASE_SHA:-}" ]; then
base=$(git merge-base "$BASE_SHA" "$head" 2>/dev/null || echo "$BASE_SHA")
elif [ -n "${BEFORE_SHA:-}" ] && [ "$BEFORE_SHA" != "0000000000000000000000000000000000000000" ] \
&& git cat-file -e "${BEFORE_SHA}^{commit}" 2>/dev/null; then
base="$BEFORE_SHA"
fi
MAX=500
if [ -n "$base" ]; then
count=$(git rev-list --count "$base..$head")
echo "intervall $base..$head: $count commits"
if [ "$count" -eq 0 ]; then echo "inga nya commits i intervallet"; exit 0; fi
if [ "$count" -gt "$MAX" ]; then
echo "::warning::intervallet har $count commits; skannar de $MAX senaste. Resten täcks av den nattliga fullhistorikskanningen."
fi
logopts="-n $MAX $base..$head"
else
echo "::notice::inget jämförbart föregående läge (ny gren eller omskriven historik); skannar head-commiten. Fullhistoriken täcks nattligt."
logopts="-n 1 $head"
fi
name="siax-gitleaks-range-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
set +e
timeout --signal=TERM 12m docker run --rm --name "$name" --cpus 2 --memory 4g \
-v "$SCAN_VOLUME:/repo" -w /repo \
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory -e GIT_CONFIG_VALUE_0='*' \
zricethezav/gitleaks:v8.30.1 detect --source /repo --log-opts="$logopts" \
--no-banner --redact --exit-code 1 > /tmp/scan.log 2>&1
rc=$?
set -e
docker kill "$name" >/dev/null 2>&1 || true
tail -n 120 /tmp/scan.log
if [ $rc -eq 0 ]; then echo "gitleaks commit range ren"; exit 0; fi
if [ $rc -eq 1 ]; then echo "::error::gitleaks commit range hittade fynd i införda commits"; exit 1; fi
if [ $rc -eq 124 ]; then echo "::error::gitleaks commit range nådde tidsgränsen - intervallet är EJ skannat"; exit 1; fi
echo "::warning::gitleaks commit range kunde inte köras (rc=$rc) - verktygsfel, inte fynd"; exit 0
# Hela historiken scannas informativt, bara nattligt eller manuellt och
# med tidsbudget. Gamla hemligheter i tidigare commits kräver
# historikomskrivning och blockerar därför inte bygget.
# Historiken scannas informativt. Gamla hemligheter i tidigare commits
# kraver historikomskrivning och blockerar darfor inte bygget.
- name: gitleaks history informational
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
timeout-minutes: 45
continue-on-error: true # ci2-allow-swallowed-failure: historik-gitleaks informativt per kanonisk security.yml
continue-on-error: true
run: |
name="siax-gitleaks-history-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
rc=0
timeout --signal=TERM 40m docker run --rm --name "$name" --cpus 2 --memory 6g \
-v "$SCAN_VOLUME:/repo" -w /repo \
docker run --rm -v "$SCAN_VOLUME:/repo" -w /repo \
-e GIT_CONFIG_COUNT=1 -e GIT_CONFIG_KEY_0=safe.directory \
-e GIT_CONFIG_VALUE_0='*' \
zricethezav/gitleaks:v8.30.1 detect --source /repo --no-banner --redact --exit-code 1 || rc=$?
docker kill "$name" >/dev/null 2>&1 || true
if [ "$rc" -eq 124 ]; then echo "::warning::fullhistorikskanningen nådde tidsbudgeten (40 min) - historiken är EJ fullständigt skannad"; fi
if [ "$rc" -ne 0 ]; then echo "::notice::historiska träffar eller avbrott loggas informativt (rc=$rc)"; fi
zricethezav/gitleaks:v8.30.1 detect --source /repo --no-banner --exit-code 1 \
|| echo "::notice::historiska traffar loggas informativt"
# Trivy filsystem, blockerar pa HIGH och CRITICAL sarbarheter och hemligheter (SUP-*)
# Trivy filsystem, blockerar pa HIGH och CRITICAL (SUP-*)
- name: Trivy filesystem scan
run: |
set +e
docker run --rm -v "$SCAN_VOLUME:/repo" -w /repo \
aquasec/trivy:0.76.2 fs --scanners vuln,secret --severity HIGH,CRITICAL --exit-code 1 --no-progress /repo > /tmp/scan.log 2>&1
aquasec/trivy:0.76.2 fs --scanners vuln,secret,misconfig --severity HIGH,CRITICAL --exit-code 1 --no-progress /repo > /tmp/scan.log 2>&1
rc=$?
set -e
tail -n 120 /tmp/scan.log
@@ -163,45 +94,19 @@ jobs:
if [ $rc -eq 1 ]; then echo "::error::Trivy filesystem scan hittade fynd"; exit 1; fi
echo "::warning::Trivy filesystem scan kunde inte köras (rc=$rc) - verktygsfel, inte fynd"; exit 0
# Dockerfile- och IaC-misconfig är informativt: DS-0002 (root-USER)
# kräver ändrade runtime-användare och hanteras per repo, inte i grinden.
- name: Trivy config informational
continue-on-error: true
run: |
docker run --rm -v "$SCAN_VOLUME:/repo" -w /repo \
aquasec/trivy:0.76.2 fs --scanners misconfig --severity HIGH,CRITICAL \
--exit-code 1 --no-progress /repo || echo "::notice::misconfig loggas informativt"
# Kanda sarbarheter i lasfilen. osv-scanner 2.x hittar inte alltid
# osv-scanner.toml sjalv, sa den skickas explicit nar den finns.
# Lasfilsvakten och config-kollen kors i en container som monterar
# volymen (FALLA 3 ovan). Kan sjalva sokningen inte koras hoppas OSV
# INTE over - da avgor OSV:s egen exitkod, enligt samma policy som ovan.
- name: OSV Scanner
run: |
set +e
lock=$(docker run --rm -v "$SCAN_VOLUME:/repo:ro" alpine:3.20 \
find /repo -path /repo/.git -prune -o -type f \( \
-name 'pnpm-lock.yaml' -o -name 'package-lock.json' -o -name 'yarn.lock' \
-o -name 'bun.lock' -o -name 'poetry.lock' -o -name 'Pipfile.lock' \
-o -name 'uv.lock' -o -name 'pdm.lock' -o -name '*requirements*.txt' \
-o -name 'go.mod' -o -name 'Cargo.lock' -o -name 'composer.lock' \
-o -name 'Gemfile.lock' \) -print -quit)
frc=$?
set -e
if [ $frc -ne 0 ]; then
echo "::warning::lasfilsvakten kunde inte koras i scanvolymen (rc=$frc) - OSV kors anda"
elif [ -z "$lock" ]; then
if ! find /repo -maxdepth 3 \( -name 'pnpm-lock.yaml' -o -name 'package-lock.json' \
-o -name 'yarn.lock' -o -name 'poetry.lock' -o -name 'Pipfile.lock' \
-o -name 'requirements.txt' -o -name 'go.sum' -o -name 'Cargo.lock' \
-o -name 'composer.lock' -o -name 'Gemfile.lock' \) -print -quit | grep -q .; then
echo "Inga lasfiler i repot - OSV-Scanner har inget att scanna."
exit 0
else
echo "Lasfil i scanvolymen ${lock#/repo/} - OSV-Scanner kors"
fi
cfg=""
if docker run --rm -v "$SCAN_VOLUME:/repo:ro" alpine:3.20 test -f /repo/osv-scanner.toml; then
cfg="--config=/repo/osv-scanner.toml"
echo "Anvander /repo/osv-scanner.toml for hela repot"
fi
if [ -f "/repo/osv-scanner.toml" ]; then cfg="--config=/repo/osv-scanner.toml"; fi
set +e
docker run --rm -v "$SCAN_VOLUME:/repo" -w /repo \
ghcr.io/google/osv-scanner:v2.7.1 scan source --recursive $cfg /repo > /tmp/scan.log 2>&1
@@ -227,5 +132,4 @@ jobs:
- name: Remove scan volume
if: always()
run: |
for c in $(docker ps -q --filter "name=siax-gitleaks-.*-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"); do docker kill "$c" >/dev/null 2>&1 || true; done
docker volume rm -f "${SCAN_VOLUME:-none}" >/dev/null 2>&1 || true