diff --git a/.github/CI-CD.md b/.github/CI-CD.md index a936eb9..e340632 100644 --- a/.github/CI-CD.md +++ b/.github/CI-CD.md @@ -10,7 +10,7 @@ locally. The deployment section is for maintainers with production access. ## CI (what runs on your PR) -Every pull request runs [`ci.yml`](workflows/ci.yml). Six jobs run in parallel, +Every pull request runs [`ci.yml`](workflows/ci.yml). Jobs run in parallel, so you get all the failures at once instead of one at a time. | Job | What it checks | @@ -21,6 +21,40 @@ so you get all the failures at once instead of one at a time. | **Build images** | All four Dockerfiles still build | | **Validate compose** | Both `docker-compose` files are well-formed | | **Secret scan** | No credentials committed anywhere in history | +| **Dependency audit (report only)** | High-severity npm advisories in the committed pnpm workspace lockfile | + +### Source and dependency scanning + +[`codeql.yml`](workflows/codeql.yml) analyzes JavaScript/TypeScript, Python and +GitHub Actions on pull requests to `main`, pushes to `main` and every Tuesday. +It can also be started manually from the Actions tab. These languages use +CodeQL's `none` build mode, so analysis does not install dependencies, execute +package scripts or require application credentials. Only the analysis job has +`security-events: write`; it uploads results to **Security → Code scanning**. + +The dependency-audit job runs `pnpm audit --audit-level=high` directly against +the committed lockfile, without installing packages. It deliberately reports +findings without blocking CI while the initial baseline is triaged. A green CI +run therefore does **not** mean the dependency audit found no advisories; read +that step's output. Keep the existing build, test and secret-scan gates intact. + +[`dependabot.yml`](dependabot.yml) checks the root npm/pnpm workspace and +`apps/genAI` pip requirements weekly. Development-only npm version updates are +grouped to reduce noise. Version-update PR limits do not disable security +updates. Alerts and security-update settings are controlled by the repository +owner, not by this file. The current Python requirements are unpinned: this +configuration is not proof of a fully resolved Python dependency baseline or +that a future pip security-update PR has opened. + +For the first scans, distinguish genuine findings from false positives and +record affected direct/transitive dependencies and available fixes. Do not add +blanket ignores or claim a clean baseline from a successful workflow alone. +Report exploitable source vulnerabilities privately using [SECURITY.md](../SECURITY.md), +and coordinate fixes with other assigned work before changing shared files. +Public third-party advisories can be tracked in a normal follow-up; make the +audit a gate only after the maintainer agrees how to handle the baseline. +The [initial dependency triage](security-baseline.md) records the measured +baseline, existing bot fixes and remaining remediation decisions. ### Reproducing a failure locally diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c2dc4f7 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,17 @@ +version: 2 +updates: + - package-ecosystem: npm + directory: / + schedule: + interval: weekly + open-pull-requests-limit: 3 + groups: + development-dependencies: + dependency-type: development + patterns: ['*'] + + - package-ecosystem: pip + directory: /apps/genAI + schedule: + interval: weekly + open-pull-requests-limit: 2 diff --git a/.github/security-baseline.md b/.github/security-baseline.md new file mode 100644 index 0000000..183e93f --- /dev/null +++ b/.github/security-baseline.md @@ -0,0 +1,68 @@ +# Initial dependency-audit triage + +Observed 2026-11-25 22:57 UTC against main `dc7a83c` and pnpm 9.0.0, Node 22. The lockfile SHA-256 is `79905560a909a29ff2e4667dfbeb97ce3a7a56e28ae7b90600e5be0fcb68abdf`. No dependency or lockfile change is included here. + +| Scope | Low | Moderate | High | Critical | Advisory records | +| --- | ---: | ---: | ---: | ---: | ---: | +| Workspace | 14 | 132 | 86 | 1 | 216 | +| `--prod` dependency selection | 10 | 110 | 54 | 1 | 165 | + +The registry metadata counts affected dependency entries; advisory records can cover multiple versions or paths and are not a count of exploitable application bugs. `--prod` excludes declared development dependencies, but Prisma CLI and some build tooling are themselves declared regular dependencies, so this is not proof that every remaining package is deployed or reachable. + +## Triage decisions + +- **Existing bot fixes:** Dependabot has already opened [#263](https://github.com/TheCodeHeist-Coder/Rexial/pull/263) for `nodemailer` and [#264](https://github.com/TheCodeHeist-Coder/Rexial/pull/264) for `zod`. Review those changes rather than opening duplicate upgrade PRs. These are evidence that npm security updates are operating; they do not prove pip updates are operating. +- **Critical transitive entry:** [`proxy-addr` GHSA-jqcg-44mw-7w3h](https://github.com/advisories/GHSA-jqcg-44mw-7w3h) is reported at 2.0.7 through `apps/admin-server > express > proxy-addr`; the advisory lists 2.0.8 as patched. Prioritize a compatible dependency update and regression tests. The installed-version match is confirmed; application exploitability has not been demonstrated here. +- **Tooling versus service code:** Prisma-related `hono`, `@hono/node-server`, `effect` and `mysql2` findings come through the Prisma toolchain, not direct application imports of those packages. Vite/Vitest/ESLint findings need build/dev-server context rather than being assumed to expose the production API. They remain tracked, not suppressed. +- **Direct application packages:** Review the remaining `axios`, `react-router`, `ws` and other direct-package advisories against their deployed usage and patched versions. Do not equate registry severity with demonstrated reachability. +- **Transitive fixes:** The table identifies the first parents reported by pnpm. Update the appropriate parent or use an explicitly reviewed compatible resolution, then rerun tests and both audit selections. No transitive advisory is declared permanently accepted or unfixable without checking the parent constraint. +- **Python:** `apps/genAI/requirements*.txt` is currently unpinned. A Dependabot configuration entry is useful, but does not establish resolved installed versions, a clean Python baseline, or a successfully opened pip security update. Establish compatible constraints/resolution separately before claiming that coverage. +- **Gate:** Keep this first audit report-only. Agree on remediation and any narrowly justified temporary exceptions before making high severity a required gate. Do not introduce a blanket ignore. + +## Complete module inventory + +Counts below are advisory records from the captured registry response, not distinct CVEs. All modules remain in the remediation inventory. “Direct” means declared in a workspace manifest, not proven runtime reachability. + +| Module | Records | Highest severity | In `--prod` selection | Dependency relationship | +| --- | ---: | --- | --- | --- | +| `@babel/core` | 1 | low | no | Transitive via `apps/frontend>eslint-plugin-react-hooks` | +| `@hono/node-server` | 4 | high | yes | Transitive via `packages/db>prisma` | +| `@humanfs/node` | 1 | moderate | no | Transitive via `apps/frontend>eslint` | +| `@vitest/mocker` | 2 | moderate | no | Transitive via `apps/frontend>vitest`, `apps/http-server>vitest` | +| `ajv` | 1 | moderate | no | Transitive via `packages/eslint-config>eslint` | +| `axios` | 34 | high | yes | Direct: `apps/frontend:dependencies` | +| `baseline-browser-mapping` | 1 | moderate | no | Transitive via `apps/frontend>eslint-plugin-react-hooks` | +| `body-parser` | 2 | high | yes | Transitive via `apps/admin-server>express` | +| `brace-expansion` | 22 | high | yes | Transitive via `apps/frontend>eslint`, `apps/frontend>typescript-eslint`, `packages/eslint-config>typescript-eslint` | +| `browserslist` | 2 | high | no | Transitive via `apps/frontend>eslint-plugin-react-hooks` | +| `deepmerge-ts` | 1 | high | yes | Transitive via `packages/db>prisma` | +| `defu` | 1 | high | yes | Transitive via `packages/db>prisma` | +| `effect` | 2 | high | yes | Transitive via `packages/db>prisma` | +| `esbuild` | 1 | low | yes | Transitive via | +| `flatted` | 2 | high | no | Transitive via `apps/frontend>eslint` | +| `follow-redirects` | 1 | moderate | yes | Transitive via `apps/frontend>axios` | +| `form-data` | 1 | high | yes | Transitive via `apps/frontend>axios` | +| `hono` | 43 | high | yes | Transitive via `packages/db>prisma` | +| `joi` | 6 | high | no | Transitive via `apps/http-server>wait-on` | +| `js-yaml` | 5 | high | no | Transitive via `apps/frontend>eslint`, `packages/eslint-config>eslint` | +| `lodash` | 2 | high | yes | Transitive via `packages/db>prisma` | +| `minimatch` | 7 | high | yes | Transitive via `apps/frontend>typescript-eslint`, `packages/eslint-config>eslint`, `packages/eslint-config>typescript-eslint` | +| `mysql2` | 2 | high | yes | Transitive via `packages/db>prisma` | +| `nanoid` | 3 | high | yes | Transitive via `apps/admin>vite` | +| `nodemailer` | 18 | high | yes | Direct: `apps/http-server:dependencies` | +| `path-to-regexp` | 2 | high | yes | Transitive via `apps/admin-server>express` | +| `picomatch` | 4 | high | yes | Transitive via `apps/admin>vite`, `apps/http-server>ts-node-dev` | +| `postcss` | 4 | high | yes | Transitive via `apps/admin>vite` | +| `proxy-addr` | 1 | critical | yes | Transitive via `apps/admin-server>express` | +| `qs` | 4 | moderate | yes | Transitive via `apps/admin-server>express` | +| `react-router` | 10 | high | yes | Direct: `apps/frontend:dependencies` | +| `source-map-js` | 1 | high | yes | Transitive via `apps/admin>vite` | +| `turbo` | 2 | moderate | no | Direct: `.:devDependencies` | +| `undici` | 8 | high | no | Transitive via `apps/frontend>jsdom` | +| `uuid` | 1 | moderate | yes | Direct: `apps/http-server:dependencies` | +| `valibot` | 1 | moderate | yes | Transitive via `packages/db>prisma` | +| `vite` | 10 | high | yes | Direct: `apps/frontend:devDependencies`, `apps/admin:devDependencies` | +| `ws` | 2 | high | yes | Direct: `apps/ws-server:dependencies` | +| `zod` | 1 | high | yes | Direct: `apps/http-server:dependencies` | + +CodeQL source findings are a separate scan and require their own triage. Follow [SECURITY.md](../SECURITY.md) for exploitable source findings; do not publish a live exploit in the PR or this baseline. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1e250b..f00843a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,29 @@ env: DATABASE_URL: postgresql://postgres:postgres@localhost:5432/rexial_ci jobs: + dependency-audit: + name: Dependency audit (report only) + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - uses: pnpm/action-setup@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + # Reads the committed workspace lockfile without running install scripts. + # Triage the initial baseline before making this a merge gate. + - name: Report high-severity dependency advisories + run: pnpm audit --audit-level=high + continue-on-error: true + lint-and-types: name: Lint & type-check runs-on: ubuntu-latest diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..11b4c40 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,44 @@ +name: CodeQL + +on: + pull_request: + branches: [main] + push: + branches: [main] + schedule: + - cron: '17 4 * * 2' + workflow_dispatch: + +concurrency: + group: codeql-${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: Analyze ${{ matrix.language }} + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + actions: read + security-events: write + strategy: + fail-fast: false + matrix: + language: [actions, javascript-typescript, python] + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + # These languages need no build or dependency installation to analyze. + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + build-mode: none + + - name: Analyze sources + uses: github/codeql-action/analyze@v4 + with: + category: '/language:${{ matrix.language }}'