mirror of
https://github.com/snapotter-hq/SnapOtter.git
synced 2026-08-03 07:46:42 +02:00
chore: harden OpenSSF Scorecard from 4.3 to ~7.0 (#142)
Token-Permissions (0 -> 10): Set permissions: {} at workflow top level
across all 7 workflows, moved write scopes to per-job minimum.
SAST (0 -> 10): Added CodeQL workflow for JavaScript/TypeScript and
Python analysis on push, PR, and weekly schedule.
Vulnerabilities (0 -> ~8): Added 13 pnpm overrides to patch transitive
dependency vulnerabilities (38 -> 2 remaining, both in dev-only tools).
Pinned-Dependencies (5 -> 8-9): Pinned all Docker FROM images to SHA
digests, pinned pip-audit version in CI, pinned pip version in
Dockerfile.
This commit is contained in:
@@ -25,6 +25,9 @@ concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
name: Lint
|
||||
@@ -90,7 +93,7 @@ jobs:
|
||||
with:
|
||||
python-version: "3.11"
|
||||
|
||||
- run: pip install pip-audit
|
||||
- run: pip install "pip-audit==2.10.0"
|
||||
- name: Run pip-audit (ignoring CVEs blocked by dependency constraints)
|
||||
run: >-
|
||||
pip-audit -r packages/ai/python/requirements.txt
|
||||
|
||||
@@ -6,11 +6,7 @@ on:
|
||||
pull_request_target:
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
cla:
|
||||
@@ -18,6 +14,11 @@ jobs:
|
||||
(github.event_name == 'pull_request_target') ||
|
||||
(github.event_name == 'issue_comment' && github.event.comment.body == 'recheck')
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: write
|
||||
contents: read
|
||||
pull-requests: write
|
||||
statuses: write
|
||||
steps:
|
||||
- name: CLA Assistant
|
||||
uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 # v2.6.1
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
name: CodeQL
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: "30 6 * * 6"
|
||||
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze (${{ matrix.language }})
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
security-events: write
|
||||
contents: read
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [javascript-typescript, python]
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
|
||||
- uses: github/codeql-action/init@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
|
||||
- uses: github/codeql-action/autobuild@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3
|
||||
|
||||
- uses: github/codeql-action/analyze@7fd177fa680c9881b53cdab4d346d32574c9f7f4 # v3
|
||||
with:
|
||||
category: "/language:${{ matrix.language }}"
|
||||
@@ -2,14 +2,15 @@ name: Dependency Review
|
||||
|
||||
on: [pull_request]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
dependency-review:
|
||||
name: Review
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
- uses: actions/dependency-review-action@2031cfc080254a8a887f58cffee85186f0e49e48 # v4
|
||||
|
||||
@@ -11,6 +11,9 @@ concurrency:
|
||||
group: deploy-docs
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
|
||||
@@ -11,6 +11,9 @@ concurrency:
|
||||
group: deploy-landing
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy
|
||||
|
||||
@@ -6,12 +6,14 @@ on:
|
||||
paths: [.github/labels.yml]
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
steps:
|
||||
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
|
||||
- uses: EndBug/label-sync@52074158190acb45f3077f9099fea818aa43f97a # v2
|
||||
|
||||
@@ -3,17 +3,16 @@ name: Release
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
packages: write
|
||||
security-events: write
|
||||
permissions: {}
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: Semantic Release
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
issues: write
|
||||
pull-requests: write
|
||||
outputs:
|
||||
new_version: ${{ steps.check.outputs.version }}
|
||||
steps:
|
||||
@@ -73,6 +72,9 @@ jobs:
|
||||
docker:
|
||||
name: Build (${{ matrix.platform }})
|
||||
needs: release
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -154,6 +156,10 @@ jobs:
|
||||
name: Trivy Container Scan
|
||||
needs: [release, docker]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: read
|
||||
security-events: write
|
||||
steps:
|
||||
- name: Download amd64 digest
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
@@ -203,6 +209,9 @@ jobs:
|
||||
name: Create Multi-Arch Manifests
|
||||
needs: [release, docker, scan]
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- name: Download digests
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
|
||||
|
||||
+6
-6
@@ -10,7 +10,7 @@
|
||||
# Run on the native build platform to avoid QEMU crashes with esbuild on
|
||||
# Apple Silicon. The output (HTML/CSS/JS) is architecture-agnostic so it
|
||||
# is safe to build on arm64 and copy into the amd64 production layer.
|
||||
FROM --platform=$BUILDPLATFORM node:22-bookworm AS builder
|
||||
FROM --platform=$BUILDPLATFORM node:22-bookworm@sha256:e3ca095133ba41a0a73b009f19e4253f1a878e70bb9499f6a9d21b19d082bd91 AS builder
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
|
||||
@@ -47,7 +47,7 @@ RUN --mount=type=cache,id=turbo-cache,target=/app/.turbo \
|
||||
# on Apple Silicon when cross-compiling for linux/amd64.
|
||||
# caire imports gioui.org/app which requires CGO on Linux, so we use a
|
||||
# proper C cross-compiler instead of CGO_ENABLED=0.
|
||||
FROM --platform=$BUILDPLATFORM golang:1.23-bookworm AS caire-builder
|
||||
FROM --platform=$BUILDPLATFORM golang:1.23-bookworm@sha256:167053a2bb901972bf2c1611f8f52c44d5fe7e762e5cab213708d82c421614db AS caire-builder
|
||||
|
||||
ARG TARGETOS=linux
|
||||
ARG TARGETARCH
|
||||
@@ -110,12 +110,12 @@ RUN set -e; \
|
||||
# Stage 3: Platform-specific base images
|
||||
# Pin tags to specific major.minor for reproducible builds.
|
||||
# ============================================
|
||||
FROM node:22-bookworm AS base-linux-arm64
|
||||
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04 AS base-linux-amd64
|
||||
FROM node:22-bookworm@sha256:e3ca095133ba41a0a73b009f19e4253f1a878e70bb9499f6a9d21b19d082bd91 AS base-linux-arm64
|
||||
FROM nvidia/cuda:12.6.3-cudnn-runtime-ubuntu24.04@sha256:8aef630a54bc5c5146ae5ce68e6af5caa3df0fb690bb91544175c91f307e4356 AS base-linux-amd64
|
||||
|
||||
# Node.js donor: provides Node binaries for the CUDA amd64 image without
|
||||
# relying on NodeSource apt repos or Ubuntu mirrors (which are flaky on CI).
|
||||
FROM node:22-bookworm AS node-bins
|
||||
FROM node:22-bookworm@sha256:e3ca095133ba41a0a73b009f19e4253f1a878e70bb9499f6a9d21b19d082bd91 AS node-bins
|
||||
|
||||
# ============================================
|
||||
# Stage 4: Production runtime
|
||||
@@ -198,7 +198,7 @@ COPY --from=caire-builder /tmp/caire /usr/local/bin/caire
|
||||
# Uses pre-built manylinux wheels where available; gcc/g++ above covers the rest.
|
||||
RUN --mount=type=cache,target=/root/.cache/pip \
|
||||
python3 -m venv /opt/venv && \
|
||||
/opt/venv/bin/pip install --upgrade pip && \
|
||||
/opt/venv/bin/pip install --upgrade "pip==25.1.1" && \
|
||||
/opt/venv/bin/pip install \
|
||||
Pillow==11.1.0 \
|
||||
numpy==1.26.4 \
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Runs the full test suite (unit + integration)
|
||||
# ============================================
|
||||
|
||||
FROM node:22-bookworm
|
||||
FROM node:22-bookworm@sha256:e3ca095133ba41a0a73b009f19e4253f1a878e70bb9499f6a9d21b19d082bd91
|
||||
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.4 --activate
|
||||
|
||||
|
||||
+13
-1
@@ -79,7 +79,19 @@
|
||||
"license": "AGPL-3.0",
|
||||
"pnpm": {
|
||||
"overrides": {
|
||||
"fast-uri": ">=3.1.2"
|
||||
"fast-uri": ">=3.1.2",
|
||||
"handlebars": ">=4.7.9",
|
||||
"picomatch": ">=4.0.4",
|
||||
"lodash": ">=4.18.0",
|
||||
"lodash-es": ">=4.18.0",
|
||||
"brace-expansion": ">=5.0.5",
|
||||
"phin": ">=3.7.1",
|
||||
"follow-redirects": ">=1.16.0",
|
||||
"protobufjs": ">=7.5.6",
|
||||
"@protobufjs/utf8": ">=1.1.1",
|
||||
"postcss": ">=8.5.10",
|
||||
"vite": ">=6.4.2",
|
||||
"@fastify/static": ">=9.1.3"
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Generated
+349
-743
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user