Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 73 additions & 11 deletions .github/actions/dependency-security/action.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
name: Dependency Security
description: Full dependency inventory, HIGH/CRITICAL gate, and installed mitigation checks
description: >
Full dependency inventory, a HIGH/CRITICAL gate on the shipped set (#1398), toolchain-only
findings reported without blocking, and installed mitigation checks
runs:
using: composite
steps:
- name: Install Trivy
uses: ./.github/actions/install-trivy

- name: Audit all locked dependencies
# `uv export` (the wheel's runtime closure) and the script's PyYAML need uv and the
# locked runtime environment. `--no-install-project` avoids building the wheel here.
- name: Set up uv
if: ${{ !cancelled() }}
shell: bash
run: python3 scripts/dependency_security.py --output-dir "$RUNNER_TEMP/dependency-security"
uses: astral-sh/setup-uv@68559e99cc807c1eb7e9238fd43a15bba460eec2 # v10.3.3
with:
enable-cache: false

- name: Publish dependency inventory and findings
- name: Install the locked runtime environment for the gate script
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dependency-security-${{ github.run_attempt }}
path: ${{ runner.temp }}/dependency-security/
if-no-files-found: error
shell: bash
run: uv sync --locked --no-dev --no-install-project

- name: Set up Node.js for mitigation checks
- name: Set up Node.js for mitigation checks and the shipped bundles
if: ${{ !cancelled() }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
Expand Down Expand Up @@ -48,3 +50,63 @@ runs:
fi
done
exit "$result"

# The recorder's own tests (worker bundles, externals, injected helpers) run with the
# same `node --test` runner as the braces checks, before it is trusted below.
- name: Test the shipped-set recorder
if: ${{ !cancelled() }}
shell: bash
run: node --test scripts/test-shipped-packages.mjs

# The shipped set is measured from the real builds: each bundler plugin records the npm
# packages it bundled under <project>/.shipped/. If a build fails, or records nothing,
# the gate script below reports an error and the job fails (it never defaults to
# "nothing shipped, so pass").
- name: Build the shipped bundles (records what each one bundles)
if: ${{ !cancelled() }}
shell: bash
env:
HUSKY: "0"
run: |
set -euo pipefail
npm run build --prefix web
npm run build:all --prefix cao_mcp_apps
npm run build --prefix docusaurus

# The new-with-a-fix tier compares this change's lockfiles with the PR base, and ignore
# entries are dated from git history (a shallow clone cannot date them), so the gate
# needs full history and, on a pull request, the base commit. Without them the gate
# script exits 2 (fail closed). Push and schedule runs have no base and skip the
# base comparison with a warning.
- name: Fetch history and the pull request base
if: ${{ !cancelled() }}
shell: bash
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
set -euo pipefail
set -- --no-tags
if [ "$(git rev-parse --is-shallow-repository)" = "true" ]; then
set -- "$@" --unshallow
fi
set -- "$@" origin
if [ -n "${BASE_SHA:-}" ]; then
set -- "$@" "$BASE_SHA"
fi
git fetch "$@"

- name: Audit all locked dependencies, gate the shipped set
if: ${{ !cancelled() }}
shell: bash
env:
# Empty outside pull requests; the script then skips the base comparisons.
CAO_DEPSEC_BASE_REV: ${{ github.event.pull_request.base.sha }}
run: uv run --no-sync python scripts/dependency_security.py --output-dir "$RUNNER_TEMP/dependency-security"

- name: Publish dependency inventory and findings
if: ${{ !cancelled() }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dependency-security-${{ github.run_attempt }}
path: ${{ runner.temp }}/dependency-security/
if-no-files-found: error
87 changes: 87 additions & 0 deletions .github/dependency-security/policy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"schema": 1,
"_comment": "Read only by scripts/dependency_security.py. Lists what the build MUST have recorded and what Trivy MUST have parsed; editing it changes what the gate trusts, so review it like the gate itself.",
"expected_outputs": [
{
"project": "web",
"config": "web",
"lockfile": "web/package-lock.json",
"output_dir": "src/cli_agent_orchestrator/web_ui"
},
{
"project": "cao_mcp_apps",
"config": "agent",
"lockfile": "cao_mcp_apps/package-lock.json",
"output_dir": "src/cli_agent_orchestrator/ext_apps/apps_static"
},
{
"project": "cao_mcp_apps",
"config": "dashboard",
"lockfile": "cao_mcp_apps/package-lock.json",
"output_dir": "src/cli_agent_orchestrator/ext_apps/apps_static"
},
{
"project": "cao_mcp_apps",
"config": "event-stream",
"lockfile": "cao_mcp_apps/package-lock.json",
"output_dir": "src/cli_agent_orchestrator/ext_apps/apps_static"
},
{
"project": "cao_mcp_apps",
"config": "graph",
"lockfile": "cao_mcp_apps/package-lock.json",
"output_dir": "src/cli_agent_orchestrator/ext_apps/apps_static"
},
{
"project": "docusaurus",
"config": "client",
"lockfile": "docusaurus/package-lock.json",
"output_dir": null
},
{
"project": "docusaurus",
"config": "server",
"lockfile": "docusaurus/package-lock.json",
"output_dir": null
}
],
"sentinels": {
"web/package-lock.json": [
"react"
],
"cao_mcp_apps/package-lock.json": [
"react",
"sigma"
],
"docusaurus/package-lock.json": [
"react",
"@docusaurus/core"
],
"uv.lock": [
"fastapi"
],
"tui/Cargo.lock": [
"serde",
"ratatui"
]
},
"html_writers": {
"docusaurus/package-lock.json": [
"remark-*",
"rehype-*",
"@mdx-js/*",
"mdast-*",
"hast-*",
"micromark*",
"unified",
"unist-*",
"vfile*",
"estree-util-*",
"prismjs",
"prism-react-renderer",
"@docusaurus/mdx-loader",
"*react-helmet-async",
"@docusaurus/react-loadable"
]
}
}
Loading
Loading