diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5de1bea9a..40cdbb037 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,9 +1,17 @@ version: 2 updates: + # Cooldowns do not delay Dependabot security updates. - package-ecosystem: "uv" directory: "/" schedule: interval: "weekly" + groups: + uv-minor-and-patch: + update-types: + - "minor" + - "patch" + cooldown: + default-days: 3 commit-message: prefix: "chore(deps)" @@ -11,6 +19,8 @@ updates: directory: "/website" schedule: interval: "weekly" + cooldown: + default-days: 3 commit-message: prefix: "chore(deps)" @@ -18,14 +28,23 @@ updates: directory: "/" schedule: interval: "weekly" + groups: + github-actions-minor-and-patch: + update-types: + - "minor" + - "patch" + cooldown: + default-days: 3 commit-message: prefix: "chore(deps)" - # npm updates require running `npm --prefix ui run build` and committing built assets (checked by CI drift job) + # npm updates require rebuilding the committed UI with `npm --prefix ui run build` as described in docs/development/ci.md (Dependency updates); CI checks for drift - package-ecosystem: "npm" directory: "/ui" schedule: interval: "weekly" + cooldown: + default-days: 3 open-pull-requests-limit: 2 groups: ui-dependencies: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc409bd5f..ff589f8a4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -284,7 +284,7 @@ jobs: - run: uv run --no-sync ruff format --check - run: uv run --no-sync pyright - run: uvx --from actionlint-py==1.7.12.25 actionlint - - run: uvx zizmor@1.32.0 --offline --min-severity medium .github/workflows + - run: uvx zizmor@1.32.0 --offline --min-severity low .github/workflows # Dogfood: the example's fixed route must pass `pytest --sharpit`, its planted N+1 must fail it. - run: uv run --no-sync python -c "import os, sys; os.makedirs(sys.argv[1], exist_ok=True)" "${{ runner.temp }}/speed" # the speed plugins write here - run: uv run --no-sync python -m pytest examples/fastapi_sqla/tests_gate -k fixed --sharpit --sharpit-junit=sharpit-junit.xml -p scripts.pytest_speed.fixture_timer --fixture-times="${{ runner.temp }}/speed/ft-fixed.jsonl" -p scripts.pytest_speed.rebuild_log --rebuild-log="${{ runner.temp }}/speed/rb-fixed.json" --junitxml="${{ runner.temp }}/junit-fixed.xml" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dcb42d49c..02b5c3d60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,7 +11,40 @@ permissions: contents: read jobs: + sbom: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + with: + persist-credentials: false + + - uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 + with: + enable-cache: false + + - name: Generate the runtime dependency SBOM + env: + TAG: ${{ github.ref_name }} + run: | + version="${TAG#v}" + mkdir -p "$RUNNER_TEMP/sbom" + uv export --frozen --no-dev --no-default-groups --no-emit-project --format requirements.txt \ + -o "$RUNNER_TEMP/sharpit-${version}-requirements.txt" + uvx --from cyclonedx-bom==9.0.2 cyclonedx-py requirements \ + "$RUNNER_TEMP/sharpit-${version}-requirements.txt" --spec-version 1.5 \ + --output-file "$RUNNER_TEMP/sbom/sharpit-${version}.cdx.json" + + - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: release-sbom + path: ${{ runner.temp }}/sbom/sharpit-*.cdx.json + if-no-files-found: error + retention-days: 1 + publish: + needs: sbom runs-on: ubuntu-latest permissions: contents: write # the GitHub Release @@ -64,6 +97,11 @@ jobs: exit 1 fi + - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: release-sbom + path: ${{ runner.temp }}/sbom + - name: Smoke-test the wheel run: | uv venv "$RUNNER_TEMP/smoke" --python 3.12 @@ -77,5 +115,6 @@ jobs: files: | dist/*.whl dist/*.tar.gz + ${{ runner.temp }}/sbom/*.cdx.json generate_release_notes: true prerelease: ${{ steps.kind.outputs.prerelease == 'true' }} diff --git a/.github/workflows/security-audit.yml b/.github/workflows/security-audit.yml new file mode 100644 index 000000000..da623e251 --- /dev/null +++ b/.github/workflows/security-audit.yml @@ -0,0 +1,54 @@ +name: security-audit +on: + schedule: + - cron: "17 5 * * 2" + workflow_dispatch: + pull_request: + paths: + - uv.lock + - ui/package-lock.json + - website/requirements.txt + +permissions: {} + +jobs: + dependencies: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: 24 + - name: Export and audit locked Python dependencies + run: | + uv export --frozen --all-extras --all-groups --no-emit-project -o /tmp/sharpit-requirements.txt + uvx --from pip-audit==2.10.1 pip-audit -r /tmp/sharpit-requirements.txt --no-deps --disable-pip + uvx --from pip-audit==2.10.1 pip-audit -r website/requirements.txt --no-deps --disable-pip + - name: Audit locked npm dependencies + working-directory: ui + run: npm audit --audit-level=high + + zizmor: + runs-on: ubuntu-latest + if: github.event_name != 'pull_request' + permissions: + contents: read + security-events: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + - uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0 + - name: Audit workflows with zizmor + run: uvx zizmor@1.32.0 --format sarif .github/workflows > zizmor.sarif || true # Findings produce SARIF and a non-zero status. + env: + GH_TOKEN: ${{ github.token }} + - uses: github/codeql-action/upload-sarif@915412ff23e8b7659517e607487dbeae018f2934 # v4.39.5 + with: + sarif_file: zizmor.sarif + category: zizmor diff --git a/AGENTS.md b/AGENTS.md index 1d85a4ca6..1c71803f0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -166,7 +166,7 @@ to loosen. Change a rule only in that test and here, in the same PR, with the re - **Port BootUI, do not reinvent** (owner, 2026-11-12: "whatever we can directly port from BootUI we should; we don't need to recreate anything, just rewrite and adapt"). Before writing any code for a feature, read BootUI's own source for it at the pinned tag, in a BootUI clone, not this repo (`git -C show v2.3.0:` for 0.6.0; - `v2.4.0` for 0.7.0; `v2.5.0` for 0.8.0), and translate it: same structure, order of checks, thresholds, user-facing texts (env names + `v2.4.0` for 0.7.0; `v2.5.0` for 0.8.0 to 0.10.0; `v2.6.0` for 0.11.0), and translate it: same structure, order of checks, thresholds, user-facing texts (env names adapted) and tests (`# ported:`). Adapt only where Python/FastAPI/SQLAlchemy forces it or an owner ruling differs; each adaptation is one deviation row, with its reason, in the lane's matrix fragment (`docs/reference/matrix-updates/.tsv`). Never design from a summary of BootUI: read the lines. The safety model diff --git a/SECURITY.md b/SECURITY.md index ba4bd6fb0..329ac78ab 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -15,8 +15,7 @@ Security updates are provided only for the latest release on PyPI: Please report suspected security vulnerabilities privately. **Do not post vulnerability details in public issues or discussions.** -- Once enabled on the repository, report privately via GitHub's "Report a vulnerability" button under the **Security** tab. -- Until private vulnerability reporting is enabled, please open a GitHub issue titled `"Security contact request"` containing **NO details**, and the maintainer will reply with a private channel to share details securely. +- Report privately using GitHub's "Report a vulnerability" button under the **Security** tab. The maintainer acknowledges reports within 7 days. ## Network Egress and Trust Boundaries @@ -34,6 +33,7 @@ sharpit enforces strict safety invariants: - Whole scans have a 60-second default deadline (`SHARPIT_VULNERABILITIES_SCAN_TIMEOUT`); each network request is capped by the remaining scan time. - **Fails closed**: If network requests to OSV or EPSS fail or time out, the scan reports the failure gracefully without compromising security or crashing the host application. - **Client address**: The trusted-source decision rests on the ASGI client address and the request's forwarding and client-address headers; the ASGI client address must be the real peer. +- **Cross-site requests**: An `Origin` header must be a serialized `http` or `https` origin (`scheme://host[:port]`, no path, trailing slash, query, fragment or userinfo, no surrounding whitespace, port at most 65535), and its host must be the request's `Host`; an unreadable, empty or `null` origin is refused on every method. On an API path the origin must equal the request's own scheme, host and port. A write that carries `Sec-Fetch-Site` must send `same-origin` or `none`; `same-site`, `cross-site`, an empty value and any unknown value are refused. Every refusal is a 403 with the cross-site message, and a request whose own origin cannot be formed never passes the API-path comparison. ### Request input reaching commands and file paths diff --git a/docs/decisions/004-dependency-audit-tooling.md b/docs/decisions/004-dependency-audit-tooling.md new file mode 100644 index 000000000..0877cf429 --- /dev/null +++ b/docs/decisions/004-dependency-audit-tooling.md @@ -0,0 +1,24 @@ +# Dependency audit tooling + +## Status + +Implemented in the weekly security audit workflow and on pull requests that change a dependency lock or the website requirements. + +## Decision + +OWASP Dependency-Check is not adopted for dependency auditing. Its [file type analyzer list](https://dependency-check.github.io/DependencyCheck/analyzers/index.html) does not include `uv.lock`. Its Python-related analyzers are “Pip”, which scans `requirements.txt` files, and “Python”, which scans Python source files and package metadata. Both appear under Experimental Analyzers; the documentation says these analyzers are experimental because of higher false positive and false negative rates. + +Python dependency coverage comes from `pip-audit` over a requirements file exported from `uv.lock`, plus `website/requirements.txt`. npm dependency coverage comes from `npm audit` on `ui/package-lock.json`. CodeQL uses the `extended` query suite for code analysis, and zizmor audits GitHub Actions workflows. + +## Rationale + +Dependency-Check cannot directly consume the project’s Python lock file, and its documented Python analyzer only recognizes requirements files and package metadata. Exporting the frozen uv lock gives `pip-audit` the resolved dependency set without asking it to resolve dependencies. npm’s own audit command consumes the committed lock file directly. CodeQL and zizmor cover source-code and workflow risks outside package advisory matching. + +## Consequences + +The Python audit workflow must keep its export flags aligned with the project’s locked extras and groups and must use `pip-audit` without dependency resolution. The website requirements file is audited separately. npm audit reports high and critical findings as failures. Dependency-Check remains unconfigured; its experimental Python analyzers are not treated as lock-file coverage. + +## Enforced by + +- `.github/workflows/security-audit.yml` audits the frozen Python export, the website requirements, the npm lock, and the workflow files. +- `tests/test_ci_layout.py` pins the dependency audit triggers and commands; `src/sharpit/cli/docs_catalog.py` includes this decision in the bundled documentation catalog. diff --git a/docs/decisions/README.md b/docs/decisions/README.md index 22123f4a1..1ddb24ada 100644 --- a/docs/decisions/README.md +++ b/docs/decisions/README.md @@ -6,3 +6,4 @@ Each record states the decision, its status, and the code or tests that enforce - [Baseline entry owner](baseline-owner.md) explains when a baselined test-runtime finding is reported fixed or inconclusive. - [WSGI request target validation](wsgi-request-target.md) describes how the WSGI adapter checks the original request target and Host header. - [Request values in memory](003-request-values-in-memory.md) records the bounded, request-lifetime matching used by the security-sinks sensor. +- [Dependency audit tooling](004-dependency-audit-tooling.md) records the decision not to adopt OWASP Dependency-Check and the package and workflow audit coverage. diff --git a/docs/development/ci.md b/docs/development/ci.md index 8554a274a..44bbcaeab 100644 --- a/docs/development/ci.md +++ b/docs/development/ci.md @@ -80,6 +80,23 @@ full matrix runs on every merge before anything ships. of that branch, which refreshes the base analysis the PR scans compare against (a stale one made each PR's Python sensor re-parse ~848 files). Every push is its own concurrency group (`run_id`), so none cancels another. +## Dependency updates + +At the start of each release wave, list open Dependabot pull requests with `gh pr list --author "app/dependabot"`. +Land them one at a time. Main protection requires an up-to-date branch and auto-merge is off: merge `origin/main` into +the Dependabot branch, push it, wait for CI, then merge the pull request. + +Complete per-bump fixes before merging: + +- A code-scan action bump also updates the scanner cache key + `sonar-${{ runner.os }}-vX.Y.Z` in `.github/workflows/ci.yml`. The key is pinned by + `test_the_sonar_scanner_cache_is_keyed_and_pinned`. +- An npm bump rebuilds `src/sharpit/ui/static` with `cd ui && npm ci --ignore-scripts && npm run build`, then commits the + built assets. + +A maintainer commit on a Dependabot branch is signed off. A failed DCO check is fixed with a signed remediation commit, +never a force-push. When every Dependabot pull request fails the same shards, check `main` first. + ## CodeQL on release pull requests The classic branch protection rule for `release/*` enables CodeQL default setup on pull requests into version diff --git a/docs/reference/BOOTUI-2.6.0-DELTA.md b/docs/reference/BOOTUI-2.6.0-DELTA.md new file mode 100644 index 000000000..cd59ee669 --- /dev/null +++ b/docs/reference/BOOTUI-2.6.0-DELTA.md @@ -0,0 +1,57 @@ +# BootUI 2.6.0 static fixture delta + +The static capture uses BootUI tag `v2.6.0` at commit `6efc78d31c08baae0fca7d33b00d464e9970bed6`, released on 2026-11-27. The fixtures are generated with `scripts/capture_bootui.py --version 2.6.0` from the BootUI source tree. + +## Captured fixture changes + +| Fixture | BootUI 2.5.0 | BootUI 2.6.0 | Source or reason | +|---|---:|---:|---| +| Panels | 65 | 65 | `BootUiPanels.java`; the panel catalogue is unchanged. | +| Tools | 116 | 116 | `bootui-cli/src/main/resources/bootui-tools.json`; names, input schemas and action flags are unchanged. Several descriptions changed; the remaining sharpit gaps are recorded in `tests/parity/tools_status.json`. | +| Route contracts | 85 reads, 78 actions, 269 starter mappings | 85 reads, 78 actions, 269 starter mappings | `BootUiApiContractCatalog.java`; route counts are unchanged. The GitHub report contract adds `repositoryContext` as an object. This response-key addition is read from `BootUiApiContractCatalog.java` at v2.6.0 because the route capture does not record response keys; `tests/parity/routes_status.json` keeps `GET /sharpit/api/github` as `partial` against the 2.3.0 golden. | +| Properties | 212 | 219 | `BootUiProperties.java` and generated configuration metadata; adds seven activity persistence and memory scan properties listed below. Four existing descriptions also change: `bootui.activity.persistence.instance-id` is now described as a legacy Live Activity partition key, alongside changes to `bootui.activity.persistence.table-name`, `bootui.github.max-api-calls`, and `bootui.github.max-security-alerts`. | +| Rule identifiers | 688 | 692 | The captured union adds `HIB-FETCH-010`, `HIB-QUERY-010`, `SEC-AUTHZ-006`, and `SPRING-WIRING-012`; no identifiers are removed. `rule-ids-diff.json` records 0 documentation-only and 32 Java-only identifiers. | +| Test inventory | 1,144 classes, 11,204 methods | 1,206 classes, 12,210 methods | Captured from the tagged Java test sources. | + +The new properties are `bootui.activity.persistence.application-id`, `bootui.activity.persistence.hot-max-entries`, `bootui.activity.persistence.max-pending-bytes`, `bootui.activity.persistence.max-pending-entries`, `bootui.activity.persistence.namespace-id`, `bootui.activity.persistence.reader-archive-cross-namespace`, and `bootui.memory.include-histogram`. The persistence settings relate to durable activity history; the histogram setting controls JVM memory scanning. + +The `GET /github` report gains the `repositoryContext` object, which carries the selected remote and sanitized origin/upstream repository identities. This addition is read from `BootUiApiContractCatalog.java` at v2.6.0 because the route capture does not record response keys. Wave 1 implements `repositoryContext` in `src/sharpit/engine/collectors/github/dashboard.py`; `tests/parity/routes_status.json` continues to record `GET /sharpit/api/github` as `partial` against the 2.3.0 golden because the test workspace is a git checkout (`unavailableReason` is `null`) and the 2.3.0 golden predates `repositoryContext`. `POST /github/refresh` remains the action route. The captured route inventory and starter mapping count do not change. + +## JSON specifications + +| BootUI source file | v2.5.0 to v2.6.0 change | Sharpit disposition | +|---|---|---| +| `bootui-cli/src/main/resources/bootui-tools.json` | 116 tools; names, input schemas and action flags are unchanged. Descriptions change for `get_live_activity` (including `queryHelp`), `memory_scan`, and `get_spring_data_repositories`. The latter tool's summary changes as well. | `get_live_activity` retains sharpit's wording until Task 3.13 of the 0.11.0 plan (`docs/superpowers/plans/2026-12-05-sharpit-0.11.0/PLAN.md`) adds durable history. The `memory_scan` and `get_spring_data_repositories` rows have status `missing`; each reason classifies the tool as not applicable in `tests/parity/tools_status.json`. | +| `.github/actions/bootui/default-policy.json`; `examples/ci/bootui-policy.json` | Both retain `schemaVersion: 1`; no diff. | No change required. | +| `plugins/bootui/plugin.json` | The version changes from `2.5.0` to `2.6.0`; other fields are unchanged. | Version metadata only. | +| `plugins/bootui/mcp.json`; `plugins/bootui/.claude-plugin/plugin.json` | No diff. | No change required. | +| `bootui-conformance/src/main/resources/io/github/jdubois/bootui/conformance/expected-panels-*.json`; `bootui-spring-boot-starter/src/main/resources/META-INF/additional-spring-configuration-metadata.json` | No diff. | No change required. | +| `bootui-conformance/src/main/java/io/github/jdubois/bootui/conformance/BootUiApiContractCatalog.java` | The GitHub report response contract adds `repositoryContext: OBJECT`. | Implemented in `src/sharpit/engine/collectors/github/dashboard.py`; `tests/parity/routes_status.json` retains `partial` against the 2.3.0 golden. | + +The JSON comparison confirms the planned changes with one additional detail: `get_spring_data_repositories` changes both its summary and description. No names, schemas, action flags, policy schemas, MCP configuration, plugin integration metadata, panel lists, or additional Spring configuration metadata change. + +## Status changes + +The tools, properties and routes parity tests now use the 2.6.0 fixtures. Seven new property rows are classified as missing in `tests/parity/properties_status.json`; their `reason` fields identify the task that will address or classify each gap. Six activity persistence rows are tracked by Task 3.13; the JVM-only memory histogram property is classified as n-a by Task 2.13 of the 0.11.0 plan (`docs/superpowers/plans/2026-12-05-sharpit-0.11.0/PLAN.md`). Three tool-description rows are recorded in `tests/parity/tools_status.json`: `get_live_activity` remains partial until Task 3.13, while `memory_scan` and `get_spring_data_repositories` have status `missing`; each reason classifies the tool as not applicable under Task 0.1 of the 0.11.0 plan (`docs/superpowers/plans/2026-12-05-sharpit-0.11.0/PLAN.md`). + +The existing fixture inventory test remains pinned to its explicit version set because its version-specific count assertions do not cover the 2.6.0 inventory. + +## Wave 1 status + +Wave 1 implements the BootUI 2.6.0 safety, GitHub, and vulnerability assessment changes below; deviations and `n-a` items are recorded in `docs/reference/matrix-updates/0.11.0-*.tsv` and summarized in `docs/reference/PARITY.md`. + +| Row | Area | Status | Sharpit implementation | +|---|---|---|---| +| S1 | Serialized origin and cross-site guard | partial | `src/sharpit/engine/guard.py` (`_parse_origin`, `extract_origin_host`, `_is_cross_site`) enforces strict serialized `http`/`https` origins and the `Sec-Fetch-Site` allow-list on unsafe methods; sharpit keeps its every-method `Origin` and `Sec-Fetch-Site: cross-site` scope, requires full origin on API paths regardless of `Sec-Fetch-Site`, and marks `rawHostAvailable` `n-a` (`0.11.0-guard.tsv`). | +| S4 | Proxy-rewritten client address stays untrusted | matched | `src/sharpit/engine/guard.py` (`is_trusted_source`) denies trust whenever any forwarding or client-address header is present, pinned by `tests/fastapi/test_install.py::test_xff_spoof_through_uvicorn_proxy_headers` and `tests/fastapi/test_client_address_headers.py`. | +| S11 | Value-free inactivity log | partial | `src/sharpit/engine/activation.py` (`ActivationStatus.inactivity`, `inactivity_message`) and `src/sharpit/fastapi/install.py` (`_log_inactivity`, `_existing_handle`) log fixed inactivity texts and levels without configured values; adapted for `SHARPIT_*` names, reloading dev-server wording, and warning counts while inactive (`0.11.0-activation.tsv`). | +| Detector | GitHub remote detector and credential host hardening | partial | `src/sharpit/engine/collectors/github/detector.py` (256 KiB config / 8 KiB metadata / 64-level walk bounds, query/fragment rejection, percent-decoding, two-segment validation, `Remotes`) and `src/sharpit/engine/collectors/github/token.py` (`_has_control_chars`); unsafe `gitdir:`/`commondir` pointer stop, URI grammar, and control-character adaptations recorded in `0.11.0-github.tsv`. | +| S8 | Refresh bound to consented target identity | matched | `src/sharpit/engine/collectors/github/selection.py` (`parse_refresh_selection`, `validate_expected_target`) and `src/sharpit/engine/collectors/github/dashboard.py` (`GitHubDashboard.refresh`) validate paired `expectedHost`/`expectedRepository` and return an uncached `ERROR` report without calling the client or reading credentials when the detected repository differs. | +| S10 | GitHub `remote=origin\|upstream` selection and caches | matched | `src/sharpit/engine/collectors/github/detector.py` (`detect_remotes`), `selection.py`, `dashboard.py`, and `src/sharpit/fastapi/routes/github.py` support `remote=origin\|upstream` with independent per-target caches while keeping MCP (`get_github_dashboard`), CLI (`sharpit github`), and Overview/Scorecard on `origin`. | +| C1 | `GitHubRepositoryContextDto` (`repositoryContext`) | matched | `src/sharpit/engine/collectors/github/dashboard.py` (`_context`, `_remote_dto`, `_with_context`) emits `repositoryContext` last on every report without userinfo or mutating cached reports. | +| C2 | GitHub selection and refresh 400 validation | partial | `src/sharpit/engine/collectors/github/selection.py` and `src/sharpit/fastapi/routes/github.py` validate query-string parameters ahead of detection and I/O with BootUI's three exact messages in sharpit's `{"error": msg}` 400 body (`0.11.0-github.tsv`). | +| C3 | GitHub alert pagination and totals | matched | `src/sharpit/engine/collectors/github/pagination.py` (`AlertPagination`, `PaginationError`) and `src/sharpit/engine/collectors/github/client.py` (`_AlertSection`, `_repository_id`) implement numbered/cursor traversal, SHA-256 page digests, canonical repository-id aliases, baseline call budget reservation, cross-page Dependabot alert detail capping, and `UNAVAILABLE` lower bounds; 30 s deadline and link-parser adaptations in `0.11.0-github.tsv`. | +| G1 | Per-target GitHub cache matches `fullName` and `apiBaseUrl` | matched | `src/sharpit/engine/collectors/github/dashboard.py` (`_matches_cached_repository`) matches both `fullName` and `apiBaseUrl`. | +| G4 | GitHub response decoding and per-section invalid JSON | matched | `src/sharpit/engine/collectors/github/client.py` (`_parse`, `_parse_number`, `_parse_object`, `_Response.success`, `send`, `_copilot`) decodes UTF-8 with replacement, rejects blank/non-container/trailing-token/NaN/Infinity/over-limit JSON per section, preserves header scopes on rate-limit `ERROR`, marks optional section failures `PARTIAL`, and preserves HTTP 204 `NO_DATA` for Copilot. | +| C4 | Vulnerabilities: unassessed advisory candidates | partial | `src/sharpit/engine/collectors/vulns/assessment.py`, `service.py`, `src/sharpit/engine/tools.py`, and `ui/src/views/Vulnerabilities.svelte` match `DependencyAssessmentDto` and `"Not assessed"` UI state; `get_vulnerabilities_report` `advisories` summary, `METADATA_ONLY` candidate-ID suppression, and `vulnerabilities_scan` returning full `DependenciesReport` are adapted in `0.11.0-vulns.tsv`. | + diff --git a/docs/reference/BOOTUI-CONTRACT-MVP.md b/docs/reference/BOOTUI-CONTRACT-MVP.md index 775812deb..24991a0ca 100644 --- a/docs/reference/BOOTUI-CONTRACT-MVP.md +++ b/docs/reference/BOOTUI-CONTRACT-MVP.md @@ -381,7 +381,10 @@ DependencyCoverageDto { status: "UNAVAILABLE"|"COMPLETE"|"INCOMPLETE", archivesF archivesUnidentified: int, unidentifiedArchives: str[], unidentifiedArchivesTruncated: bool } DependencyDto { groupId: str, artifactId: str, version: str, packageName: str /* "groupId:artifactId" */, source: str, vulnerabilityCount: int /* active only */, highestSeverity: str /* active only; "NONE" if none */, - vulnerabilities: DependencyVulnerabilityDto[], assessment: {queryComplete: bool, detailAssessmentComplete: bool} } + vulnerabilities: DependencyVulnerabilityDto[], assessment: DependencyAssessmentDto } +DependencyAssessmentDto { queryComplete: bool, detailAssessmentComplete: bool, + unassessedAdvisoryIds: str[] /* <=100, <=240 chars, no ISO control chars */, + unassessedAdvisoryCount: int /* all distinct unassessed candidates, including omitted IDs */ } DependencyVulnerabilityDto { id: str, summary: str|null, details: str|null, severity: str, score: float|null, aliases: str[] /* <=20 */, references: str[] /* <=20, ADVISORY then FIX types first */, fixedVersions: str[] /* <=10 */, fixAvailable: bool, epssScore: float|null /* 0..1 */, epssPercentile: float|null /* 0..1 */, @@ -392,7 +395,7 @@ AdvisorEvidenceDto { usable: bool, coverageComplete: bool, limitations: str[] } - Conformance requires `scanningEnabled`, `total`, `vulnerable`, `severityCounts`, `scan` and `dependencies`. - `AdvisorEvidenceDto` is defined in `DTO/AdvisorEvidenceDto.java`. `unknown()` is used when status is not SCANNED or PARTIAL. - [AMBIG] `DependenciesReport.status()` is a derived accessor, not a record component, so Jackson probably does **not** emit a top-level `status`. Use `scan.status`. -- `assessment.detailAssessmentComplete` implies `queryComplete`. The default is `(false,false)`. +- `assessment.detailAssessmentComplete` implies `queryComplete`, and unassessed candidates require `detailAssessmentComplete=false` (`unassessedAdvisoryCount >= len(unassessedAdvisoryIds)`). The default is `(false, false, [], 0)`. - Python mapping: - [JVM] `groupId`/`artifactId`/`packageName "g:a"` and `ecosystem: "Maven"` become PyPI. Set `groupId` = `""` or `"pypi"`, `artifactId` = the normalized dist name, and `packageName` = the dist name. Keep the field names so the UI does not change. - `coverage.archives*` (jar identification) becomes "installed distributions with/without metadata". [JVM] @@ -580,7 +583,7 @@ Argument normalization: | get_beans | QUERY_LIMIT | beans | no | `BeanList` = `beans(query, classification=null, offset=null, limit)` | | get_mappings | QUERY_LIMIT | mappings | no | `MappingsReport` (flat) | | get_loggers | QUERY_LIMIT | loggers | no | `LoggersReport` | -| get_vulnerabilities_report | NONE | vulnerabilities | no | `DependenciesReport` (cached or inventory; no network) | +| get_vulnerabilities_report | QUERY_LIMIT | vulnerabilities | no | compacted `DependenciesReport` + `advisories` summary + `page` (cached or inventory; no network) | | vulnerabilities_scan | NONE | vulnerabilities | **yes** | runs the OSV scan (same as REST POST), returns `DependenciesReport` | Upstream has 89 tools in `ENG/McpToolCatalog.java`; 15 are Spring-only (graalvm, crac, transactions, conditions, startup, data, spring-security, jms, devtools, http-sessions). @@ -632,9 +635,11 @@ McpToolInfo { name: str, description: str, panel: str, action: bool, panelEnable - the auto-detected container gateway, when `trust-container-gateway` is `AUTO` and running in a container, or when it is `ON` - Otherwise: 403 `"BootUI is restricted to loopback requests. Set bootui.allow-non-localhost=true to override, add a trusted source range to bootui.trusted-proxies, or (when running in a container) set bootui.trust-container-gateway=AUTO to trust the auto-detected container gateway."` - **Host check** (always on, against DNS rebinding). If a `Host` header is present, its parsed host must be in {`localhost`, `127.0.0.1`, `::1`, `0:0:0:0:0:0:0:1`} or `bootui.allowed-hosts`. An unparseable Host is rejected. Message: `"BootUI rejected an unrecognized Host header. Add it to bootui.allowed-hosts to allow this hostname."` - - **Cross-site write check** (always on). For methods other than GET, HEAD and OPTIONS, either of these gives a 403 `"BootUI rejected a cross-site request to a state-changing endpoint."`: - - `Sec-Fetch-Site: cross-site` - - an `Origin` whose host differs from the `Host` header (`Origin: null` counts as a mismatch) + - **Cross-site write check** (always on). For methods other than GET, HEAD and OPTIONS, any of these gives a 403 `"BootUI rejected a cross-site request to a state-changing endpoint."` (BootUI 2.6.0, `LocalhostGuard.isCrossSiteWrite`): + - a `Sec-Fetch-Site` other than `same-origin` or `none`, compared case-insensitively (`same-site`, `cross-site`, an empty value and an unknown value are refused) + - a present `Origin` that is not a serialized `http` or `https` origin, or whose host differs from the `Host` header. A serialized origin is `scheme://host[:port]`: a path (a trailing slash included), query, fragment or userinfo, a trailing colon, a port above 65535 and the opaque `null` origin all make it unreadable. An empty `Origin` is present, not absent. + - with `Sec-Fetch-Site: same-origin` the check ends there, so a development proxy may change the upstream port; without it the origin's scheme and effective port (80 for `http`, 443 for `https` when omitted) must equal the request's own. + - sharpit applies the `Origin` and `Sec-Fetch-Site: cross-site` checks to every method, applies the `Sec-Fetch-Site` allow-list to writes only (a same-site navigation GET still loads the shell), and on an API path always requires the request's own scheme, host and port, whatever `Sec-Fetch-Site` says (`docs/reference/matrix-updates/0.11.0-guard.tsv`). - Reject body: `{"error":""}`. 3. `ApiAuthenticationFilter` (API paths only, always registered): - A trusted source (passed the loopback/proxy/gateway test) needs **no token**. @@ -752,6 +757,30 @@ Sources: `bootui-cli/src/main/java/io/github/jdubois/bootui/cli/*`, `ENG/cli/*`, --- +## 12. GitHub (2.6.0 remote selection and target identity) +Sources: `ENG/github/GitHubDashboardService.java`, `AC/web/GitHubController.java`, `DTO/GitHubDashboardReport.java`, `DTO/GitHubRepositoryContextDto.java`, `DTO/GitHubRemoteDto.java`. + +- `GET /bootui/api/github?remote=origin|upstream`: + - `remote` is optional and defaults to `"origin"`. Unknown query keys are ignored; case aliases (`Remote`), duplicate `remote` values, blank values, or any value other than `"origin"` / `"upstream"` return 400 `{"error": "GitHub remote must be origin or upstream"}`. +- `POST /bootui/api/github/refresh?remote=origin|upstream&expectedHost=&expectedRepository=`: + - Reads query string parameters only. + - Validates `remote` first (same 400 message), then rejects any query key outside `{remote, expectedHost, expectedRepository}` with 400 `{"error": "GitHub refresh query is invalid"}`. + - `expectedHost` (`[A-Za-z0-9.-]{1,253}`) and `expectedRepository` (`[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+`) must be present together or both omitted, single and non-blank, otherwise 400 `{"error": "GitHub refresh target identity is invalid"}`. + - When the detected `Repository` differs (case-sensitively) from `expectedHost` or `expectedRepository`, returns an uncached `ERROR` report (`connected=false`, `message="The configured GitHub repository changed after page permission was granted."`, `refreshedAt=now`) without calling the GitHub client or reading credentials. +- `GitHubDashboardReport` emits `repositoryContext` as its last key on every response: + ``` + GitHubRepositoryContextDto { + selectedRemote: "origin" | "upstream", + origin: GitHubRemoteDto|null, + upstream: GitHubRemoteDto|null, + upstreamUnavailableReason: str|null + } + GitHubRemoteDto { name: str, fullName: str, host: str, htmlUrl: str } + ``` +- MCP (`get_github_dashboard`), CLI (`sharpit github`), and the Scorecard stay on `"origin"` with `selectedRemote: "origin"` and an unchanged empty input schema (`additionalProperties: false`). + +--- + ## Spring/JVM-only items the porter can drop - `/mappings` raw actuator descriptor; `api/conditions`; Spring `@ConfigurationProperties` metadata (`propertySuggestions` can be `[]`); config overrides (optional for MVP). - DevTools-classpath activation (replace with a dev-server signal); Quarkus launch-mode activation. diff --git a/docs/reference/PARITY.md b/docs/reference/PARITY.md index cc4dc00c9..67e3649db 100644 --- a/docs/reference/PARITY.md +++ b/docs/reference/PARITY.md @@ -421,3 +421,28 @@ the 0.10.0 lane fragments in `docs/reference/matrix-updates/` (57 entries): | baseline-owner | gate:baseline-inconclusive-kept-on-rewrite | n-a | BootUI's comparison reads two recorded runs and writes nothing (SideEffectComparison.java:57-205), so it has no rewrite to keep an entry through; sharpit's --sharpit-write-baseline with --sharpit-baseline keeps every inconclusive entry, also while an advisor entry is carried, so an entry is never dropped on evidence the run did not have | | baseline-owner | gate:baseline-pending-owner | adapted | BootUI does not report a key new or gone while its owner's work is still pending or absence is unknown, counts those keys and marks the sensor PARTIAL with a note (SideEffectComparison.java:99-101, 122-123, 139-169); sharpit has no pending owner, because the baseline is compared after the session ends, when every test's phases are reported, and an owner whose deciding attempt did not complete is inconclusive with the reason 'its test did not complete' | | baseline-owner | gate:baseline-change-order | adapted | BootUI sorts changes by change kind, sensor, count descending, owner and target, and returns at most MAX_ROWS of them with the total (SideEffectComparison.java:184-203); sharpit sorts inconclusiveFindings by fingerprint and lists every entry beside the inconclusive count, because the entries are bounded by the committed baseline file and every inconclusive entry is one the rewrite keeps | + +## 0.11.0 against BootUI 2.6.0: deviations + +Every deviation, partial implementation, adapted behavior, gap, or not-applicable item recorded across +the 0.11.0 lane fragments in `docs/reference/matrix-updates/` (17 entries): + +| Lane | Key | Status | Reason | +|---|---|---|---| +| guard | guard.cross-site.sec-fetch-site | adapted | BootUI 2.6.0 checks the cross-site rules on unsafe methods only. sharpit keeps its every-method scope for Origin and Sec-Fetch-Site: cross-site, applies the allow-list (same-origin, none; case-insensitive, ASCII only) to unsafe methods only so a same-site navigation GET still loads the shell, and refuses a present but empty Origin as cross-site on every method | +| guard | guard.cross-site.api-path-origin | adapted | On an API path a present Origin must equal the request's own scheme, host and effective port even when Sec-Fetch-Site is same-origin, where BootUI accepts the same-origin assertion across ports; the shell and assets keep BootUI's rule (spec section 14, row 35, unchanged). A request whose own origin cannot be formed (no usable Host) stays cross-site where that comparison applies | +| guard | guard.raw-host | n-a | BootUI rawHostAvailable guards Spring forwarded-host metadata that the servlet container may hide; the ASGI adapters read only the Host header, so there is no second source to fail closed on | +| guard | guard.origin.port-digits | adapted | A port of more than five digits or above 65535 makes an Origin, or the request's own Host used in the full-origin comparison, unreadable before int() is called (a long digit run raises ValueError in Python 3.12+); the request is cross-site. A value such as http://localhost:0000080, which java.net.URI reads as port 80, is therefore refused (stricter). The Host allow-list does not refuse an oversized port, as BootUI's isPortSuffix does not | +| guard | guard.origin.host-charset | adapted | java.net.URI reads an Origin host containing an underscore or tilde (http://my_host:8080) as a registry-based authority with no host, so BootUI refuses it; sharpit reads the host with the same character set as the Host header, which accepts those characters, so such an origin is compared with the Host header instead. The host must still be localhost, a loopback address or an allowed host for the request to reach the comparison | +| activation | inactivity:log-texts | adapted | BootUI 2.6.0 (BootUiShellGuardAutoConfiguration.java:66-76) logs fixed inactivity texts. sharpit logs the same texts and levels with BootUI replaced by sharpit, the bootui.* properties replaced by the SHARPIT_* variables and Spring Boot DevTools replaced by a reloading development server, because sharpit has no Spring properties and detects reload through the development server. | +| activation | inactivity:warnings-count | adapted | BootUI logs neither the configuration warnings nor their number while it is inactive. While sharpit is inactive it logs one WARNING with the number of configuration warnings (omitted when there are none) instead of the warnings themselves, because the count keeps an invalid setting visible without printing its value. The count leaves out the invalid SHARPIT_ENABLED warning, which the fixed text already reports, so an invalid SHARPIT_ENABLED logs one record as in BootUI. | +| github | github.detector.unc-pointer | adapted | An unsafe gitdir pointer (UNC, backslash-rooted, /\, or NUL) stops the walk before any filesystem call on its target, so an enclosing repository cannot be selected. An unsafe commondir target is refused and only the worktree config is read. An empty gitdir pointer resolves to the .git file's own folder and stops there; its config is absent. A .git symlink or junction, a relative pointer through a symlinked directory, and a mapped network drive letter are not covered. | +| github | github.token.control-chars | adapted | BootUI trims and accepts a token host containing a Unicode Cc character other than ASCII whitespace padding. sharpit refuses such characters in the remote host and in GH_HOST before matching, so a credential is never bound to a different host. | +| github | github.detector.uri-characters | adapted | BootUI's URI.create rejects \\, "<>^`{\|}, a second @, and malformed percent escapes; Python urlsplit accepts them, so sharpit rejects them explicitly. Unbracketed hosts follow Java server-authority hostname grammar, with valid dotted IPv4 and one trailing dot; ports must contain digits only and have no TCP range limit. Bracketed IPv6 retains its existing handling. | +| github | op:github.refresh.alert-pagination-deadline | adapted | sharpit enforces a 30 s overall refresh deadline; when the deadline expires mid-traversal, the alert section stops with the time-limit UNAVAILABLE reason and observed lower bound without making further requests (BootUI has no overall refresh deadline). | +| github | op:github.refresh.alert-link-parser | adapted | BootUI relies on Java URI.create, ASCII regex semantics, URLDecoder, URLEncoder, and 32-bit int arithmetic; sharpit compiles LINK and page regexes with re.ASCII and fullmatch, explicitly rejects raw fragments, spaces, control and disallowed URI characters, @ in netloc, malformed percent escapes, and out-of-range page numbers and alert counts, and encodes cursors with quote_plus(v, safe="*").replace("~", "%7E"). | +| github | route:GET /github; POST /github/refresh | adapted | BootUI Spring throws ResponseStatusException(BAD_REQUEST, msg) (default Spring error JSON omits message) and Quarkus throws BadRequestException (empty 400 body); sharpit returns 400 {"error": msg} carrying only the three fixed selection messages, matching contract §1. | +| github | op:github.refresh.query-only | adapted | Spring @RequestParam MultiValueMap binds both query string and application/x-www-form-urlencoded form parameters; sharpit reads query string parameters only (matching BootUI UI client requests). | +| vulns | mcp:get_vulnerabilities_report.advisories.unassessedCandidates | adapted | get_vulnerabilities_report orders candidate-only dependencies after findings and before clean rows, cuts per-dependency unassessedAdvisoryIds to 3 (query matches first), and emits the top-level advisories object (listed, omitted, detailsOmitted, perDependency, unassessedCandidates, candidateIdsListed, candidateIdsOmitted, hint). Differences from BootUI: the hint is reworded to describe sharpit's actual view (5 advisories per dependency with masked details so detailsOmitted is 0, 3 items per alias/reference/fixedVersions list, and no exact-query expansion); the view drops clean dependencies when there is no query (BootUI lists them last, McpAgentViews.java 565, 772-775); page.total counts the filtered dependency list rather than all report dependencies. | +| vulns | mcp:get_vulnerabilities_report.advisories.metadataOnlyCandidateIds | adapted | Under METADATA_ONLY exposure, candidate IDs pass through mask_text and are dropped when it returns None (candidateIdsListed=0, unassessedAdvisoryIds=[]); unassessedAdvisoryCount and unassessedCandidates remain exact. Advisory IDs are not masked, as before; BootUI retains candidate IDs because it lacks METADATA_ONLY text suppression (safety model: fails closed). | +| vulns | mcp:vulnerabilities_scan.summary | adapted | BootUI returns McpScanSummaries.vulnerabilities with unassessedAdvisoryCandidates; sharpit keeps returning the full DependenciesReport from vulnerabilities_scan so existing MCP clients keep reading the full report keys until the scan summary is ported. | diff --git a/docs/reference/matrix-updates/0.11.0-activation.tsv b/docs/reference/matrix-updates/0.11.0-activation.tsv new file mode 100644 index 000000000..418374adc --- /dev/null +++ b/docs/reference/matrix-updates/0.11.0-activation.tsv @@ -0,0 +1,2 @@ +inactivity:log-texts adapted BootUI 2.6.0 (BootUiShellGuardAutoConfiguration.java:66-76) logs fixed inactivity texts. sharpit logs the same texts and levels with BootUI replaced by sharpit, the bootui.* properties replaced by the SHARPIT_* variables and Spring Boot DevTools replaced by a reloading development server, because sharpit has no Spring properties and detects reload through the development server. +inactivity:warnings-count adapted BootUI logs neither the configuration warnings nor their number while it is inactive. While sharpit is inactive it logs one WARNING with the number of configuration warnings (omitted when there are none) instead of the warnings themselves, because the count keeps an invalid setting visible without printing its value. The count leaves out the invalid SHARPIT_ENABLED warning, which the fixed text already reports, so an invalid SHARPIT_ENABLED logs one record as in BootUI. diff --git a/docs/reference/matrix-updates/0.11.0-github.tsv b/docs/reference/matrix-updates/0.11.0-github.tsv new file mode 100644 index 000000000..08df1e6d4 --- /dev/null +++ b/docs/reference/matrix-updates/0.11.0-github.tsv @@ -0,0 +1,15 @@ +github.detector.unc-pointer adapted An unsafe gitdir pointer (UNC, backslash-rooted, /\, or NUL) stops the walk before any filesystem call on its target, so an enclosing repository cannot be selected. An unsafe commondir target is refused and only the worktree config is read. An empty gitdir pointer resolves to the .git file's own folder and stops there; its config is absent. A .git symlink or junction, a relative pointer through a symlinked directory, and a mapped network drive letter are not covered. +github.detector.percent-encoding matched decoded then validated as BootUI; invalid UTF-8 in config is decoded with replacement, as BootUI does. +github.token.control-chars adapted BootUI trims and accepts a token host containing a Unicode Cc character other than ASCII whitespace padding. sharpit refuses such characters in the remote host and in GH_HOST before matching, so a credential is never bound to a different host. +github.detector.uri-characters adapted BootUI's URI.create rejects \\, "<>^`{|}, a second @, and malformed percent escapes; Python urlsplit accepts them, so sharpit rejects them explicitly. Unbracketed hosts follow Java server-authority hostname grammar, with valid dotted IPv4 and one trailing dot; ports must contain digits only and have no TCP range limit. Bracketed IPv6 retains its existing handling. +op:github.refresh.invalid-json matched BootUI 2.6.0 decodes response bodies as UTF-8 with replacement and accepts number literals up to 1000 digits and property names up to 50,000 characters; blank, non-object/non-array, trailing tokens, NaN/Infinity, JSONDecodeError, number-limit violations, and RecursionError on 2xx yield GitHub returned invalid JSON for