diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml index 06d540b..da9f0f4 100644 --- a/.github/actions/build/action.yml +++ b/.github/actions/build/action.yml @@ -6,7 +6,7 @@ runs: - name: Execute Build Action id: action continue-on-error: true - uses: commercekit-tools/ccv2-build@923535d589bd8cebece4f3cbf479608f9535c4c3 + uses: commercekit-tools/ccv2-build@fc65ee281f39b98d2cecad36ff93d40cf055fbc2 with: token-endpoint: ${{ env.CCV2_TOKEN_ENDPOINT }} client-id: ${{ env.CCV2_CLIENT_ID }} diff --git a/.github/actions/cleanup/action.yml b/.github/actions/cleanup/action.yml index 6c4eec8..c370145 100644 --- a/.github/actions/cleanup/action.yml +++ b/.github/actions/cleanup/action.yml @@ -10,7 +10,7 @@ runs: - name: Execute cleanup dry-run id: action continue-on-error: true - uses: commercekit-tools/ccv2-build-cleanup@4ab51d33ded51a360e8223e686bb46918cf7863f + uses: commercekit-tools/ccv2-build-cleanup@8b1786b731be8d2d3fac137cd358d2ee5488bd58 with: token-endpoint: ${{ env.CCV2_TOKEN_ENDPOINT }} client-id: ${{ env.CCV2_CLIENT_ID }} diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml index 5ef63de..4256dfd 100644 --- a/.github/actions/deploy/action.yml +++ b/.github/actions/deploy/action.yml @@ -17,7 +17,7 @@ runs: id: action if: steps.inputs.outputs.enabled == 'true' continue-on-error: true - uses: commercekit-tools/ccv2-deploy@e2b3f4cb7e03bfbcbba22eaf84545829b5629557 + uses: commercekit-tools/ccv2-deploy@1af852b9a00e981da4ea13565bb18c7ce7fda27f with: token-endpoint: ${{ env.CCV2_TOKEN_ENDPOINT }} client-id: ${{ env.CCV2_CLIENT_ID }} diff --git a/.github/actions/notify/action.yml b/.github/actions/notify/action.yml index 7837340..829b356 100644 --- a/.github/actions/notify/action.yml +++ b/.github/actions/notify/action.yml @@ -23,7 +23,7 @@ runs: - name: Deliver test notification id: action if: steps.inputs.outputs.enabled == 'true' && inputs.provider != 'none' - uses: commercekit-tools/notify@8242af6a4aaafd7917c93f0db27f1794266efeee + uses: commercekit-tools/notify@abc752ead104a6e5153c5f166d04ee5e595e0ca6 with: provider: ${{ inputs.provider }} event-file: ${{ steps.inputs.outputs.event-file }} diff --git a/.github/workflows/build-approve-deploy.yml b/.github/workflows/build-approve-deploy.yml index ebc5ea8..b75bc78 100644 --- a/.github/workflows/build-approve-deploy.yml +++ b/.github/workflows/build-approve-deploy.yml @@ -48,7 +48,7 @@ jobs: steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 - name: Install verified CommerceKit CLI - uses: commercekit-tools/setup-commercekit@7f650f3162ab027bfd784cf879832f44d3248584 + uses: commercekit-tools/setup-commercekit@52a5a098d89f9ef2c42a234b4c3baa5d60a7a896 with: version: '0.1.0-preview.2' - name: Check the supported synthetic Commerce files diff --git a/README.md b/README.md index 28b3bbe..e80d28c 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,17 @@ See [workflow setup, dispatch and limits](docs/WORKFLOWS.md). In particular, merged Sandbox source does not prove that the hosted `/cleanup-fixture` endpoint is deployed. Live workflow results are recorded separately from offline tests. +## Consistent reporting validation + +The [local reporting harness](docs/REPORTING.md) validates all five actual bundled +Actions against exact published notification-contract 0.0.6. It verifies normal +registry manifests/locks, installed public package bytes, reviewed sources and +bundle hashes before using the local Sandbox and mocked provider fetches. Input +coverage, secret masking, status icons/tables and notification/summary parity are +checked without hosted dispatches, live provider sends or real SAP calls. +[Historical source-candidate evidence](docs/REPORTING-CANDIDATES.md) is archived +separately and does not substitute for registry-backed validation. + ## Development Use Node 24 and pnpm 12.6.0, then configure local GitHub Packages read access as @@ -62,7 +73,7 @@ pnpm quality Shared schema validation and CCv2 HTTP/authentication come from the existing `@commercekit-tools/notification-contract` and `@commercekit-tools/ccv2-client` -packages, pinned to `0.0.4` and `0.0.3` respectively. These package versions are separate from Action +packages, pinned to `0.0.6` and `0.0.3` respectively. These package versions are separate from Action versions. Action revisions are catalogued in `action-refs.json`. Producer pins live in the composite wrappers under `.github/actions/`; CLI setup is pinned in the build/approval workflow. diff --git a/action-inputs.json b/action-inputs.json new file mode 100644 index 0000000..089fc0a --- /dev/null +++ b/action-inputs.json @@ -0,0 +1,71 @@ +{ + "commercekit-tools/ccv2-build": { + "ref": "fc65ee281f39b98d2cecad36ff93d40cf055fbc2", + "inputs": [ + "token-endpoint", + "client-id", + "client-secret", + "resource", + "subscription-code", + "branch", + "build-name", + "application-code", + "api-base-url", + "poll-interval-seconds", + "timeout-minutes" + ] + }, + "commercekit-tools/ccv2-deploy": { + "ref": "1af852b9a00e981da4ea13565bb18c7ce7fda27f", + "inputs": [ + "operation", + "token-endpoint", + "client-id", + "client-secret", + "resource", + "subscription-code", + "deployment-code", + "build-code", + "environment-code", + "database-update-mode", + "strategy", + "validate-deployment-modes", + "green-decision", + "decision-reason", + "traffic-split-json", + "rollback-database", + "cancel-reason", + "wait-for-completion", + "api-base-url", + "poll-interval-seconds", + "timeout-minutes" + ] + }, + "commercekit-tools/notify": { + "ref": "abc752ead104a6e5153c5f166d04ee5e595e0ca6", + "inputs": ["provider", "event-json", "event-file", "webhook-url", "fail-on-notification-error"] + }, + "commercekit-tools/ccv2-build-cleanup": { + "ref": "8b1786b731be8d2d3fac137cd358d2ee5488bd58", + "inputs": [ + "token-endpoint", + "client-id", + "client-secret", + "resource", + "subscription-code", + "api-base-url", + "application-code", + "retention-days", + "keep-latest", + "dry-run", + "max-deletions", + "exclude-build-codes", + "timeout-minutes", + "continue-on-delete-error" + ] + }, + "commercekit-tools/setup-commercekit": { + "ref": "52a5a098d89f9ef2c42a234b4c3baa5d60a7a896", + "inputs": ["version"] + } +} diff --git a/action-refs.json b/action-refs.json index 9174717..be339de 100644 --- a/action-refs.json +++ b/action-refs.json @@ -1,9 +1,9 @@ { "actions/checkout": "3d3c42e5aac5ba805825da76410c181273ba90b1", "actions/setup-node": "949feb2413d6458794dcd2491c4babbbce0c15c1", - "commercekit-tools/ccv2-build": "923535d589bd8cebece4f3cbf479608f9535c4c3", - "commercekit-tools/ccv2-deploy": "e2b3f4cb7e03bfbcbba22eaf84545829b5629557", - "commercekit-tools/notify": "8242af6a4aaafd7917c93f0db27f1794266efeee", - "commercekit-tools/ccv2-build-cleanup": "4ab51d33ded51a360e8223e686bb46918cf7863f", - "commercekit-tools/setup-commercekit": "7f650f3162ab027bfd784cf879832f44d3248584" + "commercekit-tools/ccv2-build": "fc65ee281f39b98d2cecad36ff93d40cf055fbc2", + "commercekit-tools/ccv2-deploy": "1af852b9a00e981da4ea13565bb18c7ce7fda27f", + "commercekit-tools/notify": "abc752ead104a6e5153c5f166d04ee5e595e0ca6", + "commercekit-tools/ccv2-build-cleanup": "8b1786b731be8d2d3fac137cd358d2ee5488bd58", + "commercekit-tools/setup-commercekit": "52a5a098d89f9ef2c42a234b4c3baa5d60a7a896" } diff --git a/docs/REPORTING-CANDIDATES.md b/docs/REPORTING-CANDIDATES.md new file mode 100644 index 0000000..7dc4d57 --- /dev/null +++ b/docs/REPORTING-CANDIDATES.md @@ -0,0 +1,26 @@ +# Historical reporting source-candidate validation + +Notification-contract 0.0.6 was subsequently published through the authorized +package-only workflow. Current normal installation and reporting validation use +that exact registry version; see [REPORTING.md](REPORTING.md). The candidate-only +entry point, file:tarball checks and consumer overrides have been retired. + +The original candidate implementation and reproduction instructions are retained +at immutable harness commit +[`724e86661c4f6b4062721961633e190cde942395`](https://github.com/commercekit-tools/action-integration-tests/tree/724e86661c4f6b4062721961633e190cde942395) +([instructions](https://github.com/commercekit-tools/action-integration-tests/blob/724e86661c4f6b4062721961633e190cde942395/docs/REPORTING-CANDIDATES.md), +[script](https://github.com/commercekit-tools/action-integration-tests/blob/724e86661c4f6b4062721961633e190cde942395/scripts/validate-reporting-candidates.mjs)). +The retained [candidate evidence JSON](reporting-candidate-evidence.json) records +24 successful local Action result/summary records, exact source/tarball/bundle +hashes and four isolated runs removed with absence verified. + +That private harness copy deliberately used an unborn Git workspace and a +file:tarball manifest transform. Its dirty/unborn proof is historical and honest; +it is not described as a clean registry-installed build. All five producer +sources were clean reviewed commits. No candidate artifact was represented as +a published registry dependency, and no local dependency link was committed. + +This archived phase performed no hosted workflow dispatch, live provider send, +package publication, Action release, Git tag, deployment or real SAP operation. +The later 0.0.6 package publication was separately authorized and is documented +with its actual provenance in the current validation guide. diff --git a/docs/REPORTING.md b/docs/REPORTING.md new file mode 100644 index 0000000..903b874 --- /dev/null +++ b/docs/REPORTING.md @@ -0,0 +1,272 @@ +# Registry-installed reporting validation + +## Published dependency + +Normal harness installation now pins exact published +`@commercekit-tools/notification-contract@0.0.6` with ccv2-client 0.0.3 unchanged. +The authorized [package-only workflow 43678067818](https://github.com/commercekit-tools/action-kit/actions/runs/43678067818) +published 0.0.6 from action-kit main +`3fecce40414d709884fa48e48eca278f470b20b0` after exact-main CI, all three OS jobs +and CodeQL passed. [CI](https://github.com/commercekit-tools/action-kit/actions/runs/43677942127), +[CodeQL](https://github.com/commercekit-tools/action-kit/actions/runs/43677942074) +and processed main analysis `2169851728` provide the publication gate evidence. +No Git release tag or Action release was created. + +Registry metadata and the downloaded artifact were independently verified: + +- SHA256: `e4b79576328c2992a96fed087e9ba6e63970e8b54d6fca976a6652702a7a73a9`. +- Integrity: `sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==`. +- Registry shasum: `8030f643d1dd6d741caa2c3c0ba321ad82b30cca`. +- Normal `pnpm install --frozen-lockfile`: PASS, with the real GitHub Packages + 0.0.6 tarball resolution and no file: dependency or source alias. + +[Earlier candidate evidence](REPORTING-CANDIDATES.md) remains historical. It is +not used by the normal registry validator or ordinary CI. + +## What executes + +`pnpm test:reporting` is an explicit local-only integration command. It verifies +normal registry manifests/locks, public package exports/schema, installed package +bytes against an independently downloaded registry tarball, source commit/tree/ +dirty fingerprints, matching runtime sources and exact bundle hashes. The five +Actions execute as standalone bundled processes without their own node_modules. +The harness does not copy production Action, authentication, token, retry or +provider-rendering implementations. + +The existing scenario catalog, run controller and domain assertions are reused: + +- Three Build invocations: rolling success, build failure and a successful + prerequisite for the green/manual scenario. +- Two Deploy invocations: rolling success and action-required/manual decision. +- Cleanup's existing 105-build mixed fixture and repeat: dry-run, warning + issues, complete input/count/result parity and zero target API mutations. +- Setup invalid input: failure notification/summary and zero network requests. +- Notify: seven actual producer events through both real provider renderers + with mocked delivery, plus mocked delivery-warning/failure cases. + +Both providers must retain every producer input name, safe values, shared status +icons/labels, colors, errors/issues and size limits. Every Action summary must +include matching semantic status, result/input tables and masked confidential +values. Known-secret and JWT absence are asserted. + +The fixed public Sandbox origin maps only to a verified local HTTPS loopback +server in this command. Child fetch/native HTTP(S) requests to other destinations +are denied; provider responses are mocked before any network connection. Child +environments never inherit package/GitHub/Cloudflare credentials. Hosted +workflow origin/approval/confirmation guards remain separate and unchanged. + +## Run locally + +Use Node 24.21.0 and pnpm 12.6.0. Install normal frozen dependencies in this +repository and the five reviewed Action checkouts; build each normal committed +bundle and pass its repository's full validation. Install the existing reviewed +local Sandbox's dependencies. OpenSSL and a free local HTTPS port are required. + +Download the exact published tarball for byte verification, without executing +package lifecycle scripts: + +```sh +npm pack @commercekit-tools/notification-contract@0.0.6 --ignore-scripts \ + --pack-destination /private/tmp/reviewed-registry-package +``` + +Create a private JSON manifest with reviewed actual values; all five Action +entries are mandatory. Source and consumer paths may be identical normal +registry-installed repositories: + +```json +{ + "schemaVersion": 1, + "classification": "registry-installed", + "contract": { + "version": "0.0.6", + "sourcePath": "/private/tmp/reviewed-action-kit", + "sourceSha": "", + "sourceHash": "", + "tarball": "/private/tmp/reviewed-registry-package/commercekit-tools-notification-contract-0.0.6.tgz", + "registryTarball": "https://npm.pkg.github.com/download/@commercekit-tools/notification-contract/0.0.6/8030f643d1dd6d741caa2c3c0ba321ad82b30cca", + "sha256": "e4b79576328c2992a96fed087e9ba6e63970e8b54d6fca976a6652702a7a73a9", + "integrity": "sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==" + }, + "sandbox": { + "sourcePath": "/private/tmp/reviewed-local-sandbox", + "sourceSha": "", + "sourceHash": "" + }, + "actions": { + "setup-commercekit": { + "sourcePath": "/private/tmp/reviewed-normal-action", + "consumerPath": "/private/tmp/reviewed-normal-action", + "sourceSha": "", + "sourceHash": "", + "bundleSha256": "" + } + } +} +``` + +Repeat the Action entry for `ccv2-build`, `ccv2-deploy`, `ccv2-build-cleanup` and +`notify`. `sourceProvenance` in `scripts/reporting-support.mjs` calculates source +fingerprints. Freeze and review sources before preparing the manifest; changed +files require a fresh reviewed fingerprint. Hashes identify inputs, not approval. + +```sh +REPORTING_MANIFEST=/private/tmp/reviewed-reporting-manifest.json \ +REPORTING_LOCAL_ORIGIN=https://localhost:18987 \ +pnpm test:reporting +``` + +Only HTTPS localhost/127.0.0.1/::1 origins with explicit unprivileged ports and +root paths are accepted. Credentials, query and fragment are rejected. Generated +local TLS certificates are trusted explicitly; verification is never disabled. +An execution deadline reserves teardown time within five minutes; child/request/ +response bounds remain finite. SIGINT/SIGTERM cancel work, owned process groups +are stopped, all isolated runs are removed through finally cleanup with absence +verified, and temporary credential/output/payload files are deleted. + +Retained evidence contains safe statuses/counts and source, bundle, runner-code +and summary hashes. It never contains credentials, raw API responses or provider +payloads. Fixture/control operations are separate from Cleanup target mutations. + +## Current execution status + +- PASS: exact registry 0.0.6 frozen installation and downloaded artifact proof; + focused registry guard tests reject file links/ranges/foreign registries and + integrity drift. +- PASS: complete ordinary normal-registry `pnpm quality`, 76 offline tests and + zero skips; formatting, lint, unchanged workflow policy, public scan and full + dependency audit passed with no known vulnerabilities. +- PASS: early combined five normal registry bundles on clean reviewed branch + heads, 24 records in 56,513 ms; four isolated runs created/removed with absence + verified, Cleanup zero target mutations, Setup zero network calls and strict + provider mocks. [Safe early evidence](reporting-registry-branch-evidence.json) + records exact normal source/bundle/lock proofs. +- PASS: initial merged-main replay, 24 records in 55,872 ms, with the same + read-only/mocked boundaries and all source trees clean. The executed harness + was committed as `089b7fae37497ddb0cd2bf4dfc0e2b3d4fe3bba3`. + [Initial-main evidence](reporting-registry-initial-main-evidence.json) is + retained separately from the final security-follow-up replay. +- PASS: final security-follow-up main replay, **24 records in 55,745 ms**, + from clean committed harness `a4224df787c277b88deb1458eaa9162e6838967c` + against all five final main revisions below. + [Final safe evidence](reporting-registry-main-evidence.json) records exact + source/tree/bundle/registry/input-metadata/runner-code hashes. All sources + were clean, four runs were removed with absence verified, both Cleanup + passes had zero target mutations, Setup had zero network calls, and all + 16 provider calls were mock-only. +- NOT RUN: new hosted Sandbox/provider workflows, real SAP validation. +- BLOCKED: real SAP apply eligibility, operational review and separate owner + non-production/release approvals. Green tests do not authorize real deletion. + +Hosted workflow pins now use the five actual reviewed merged main commits +listed below. `action-inputs.json` records their public input names, extracted +from each exact Action metadata file and bound to the matching ref in offline +policy checks. Runtime assertions require every input, authentication masking, +validation flags and event/result parity. Cleanup additionally requires warning +severity with accurate protected/blocked counts and explicit safety issues. +No future/unmerged commit is presented as an adopted hosted Action. Package publication does not create an Action +release, Git tag, deployment or permission for SAP operations. + +## Normal-registry preflight correction + +The first normal opt-in attempt stopped before starting any local Worker or +Action process: pnpm 12 locks contain separate package-manager and application +YAML documents. The harness now parses the bounded document set and requires +exactly one application graph containing the pinned contract; duplicate, missing +or malformed graphs are rejected. A dedicated regression test covers both +normal pnpm 12 and single-document locks. The corrected normal run passed all +24 actual bundled cases. This was a test-tooling compatibility fix, not a +consumer failure or package-integrity drift. + +The early registry run used clean normal Action source heads and real published +0.0.6 dependencies/bundles. Its harness proof honestly records base commit +`b1dd29a167289b083688b2ad45ddb492bcc5190a` with the parser correction dirty at +execution time. The recorded runner-code hashes match the correction committed +after validation. The initial merged-main run then passed from a clean committed harness; its +runner-code hashes and input metadata hash independently match the executed +files. Final security-follow-up main validation is recorded separately. + +## Adopted immutable merged Action revisions + +| Action | Adopted main commit | +| ------- | ------------------------------------------ | +| Setup | `52a5a098d89f9ef2c42a234b4c3baa5d60a7a896` | +| Build | `fc65ee281f39b98d2cecad36ff93d40cf055fbc2` | +| Deploy | `1af852b9a00e981da4ea13565bb18c7ce7fda27f` | +| Cleanup | `8b1786b731be8d2d3fac137cd358d2ee5488bd58` | +| Notify | `abc752ead104a6e5153c5f166d04ee5e595e0ca6` | + +Each source was checked out separately at its exact main commit and installed +with normal frozen registry dependencies. No owner working tree was replaced, +no file:tarball dependency was used, and no hosted workflow was dispatched. The +initial all-five main replay is archived above; the final security-follow-up +main replay passed separately, with every source matching the adopted refs. + +## Post-merge security verification + +The initial merged Build/Deploy jobs were green, but processed main analyses +`2169885840` and `2169885904` contained two and three +`js/bad-code-sanitization` findings in test-generated JavaScript preloads. +Those findings blocked final adoption. Narrow test-only +[Build PR #10](https://github.com/commercekit-tools/ccv2-build/pull/10) and +[Deploy PR #11](https://github.com/commercekit-tools/ccv2-deploy/pull/11) +replaced interpolation with static preload files and child-environment data. +Both merged only after complete validation and processed zero-finding PR +analyses. Their production bundles retained the independently recorded hashes; +the final local replay verified those exact main sources and bundles again. + +Final main evidence was independently checked for all six repositories. Every +processed analysis listed below has zero results, no processing errors/warnings +and zero open main alerts. Build's two and Deploy's three initial findings are +fixed; a green CodeQL job alone is not used as proof of zero findings. + +| Repository | Main validation | CodeQL job | Processed main analysis | Open main alerts | +| ---------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------- | ---------------- | +| action-kit | [43677942127](https://github.com/commercekit-tools/action-kit/actions/runs/43677942127) | [43677942074](https://github.com/commercekit-tools/action-kit/actions/runs/43677942074) | `2169851728` | 0 | +| Notify | [43679092935](https://github.com/commercekit-tools/notify/actions/runs/43679092935) | [43679092926](https://github.com/commercekit-tools/notify/actions/runs/43679092926) | `2169885501` | 0 | +| Setup | [43679114996](https://github.com/commercekit-tools/setup-commercekit/actions/runs/43679114996) | [43679114994](https://github.com/commercekit-tools/setup-commercekit/actions/runs/43679114994) | `2169886190` | 0 | +| Cleanup | [43679344145](https://github.com/commercekit-tools/ccv2-build-cleanup/actions/runs/43679344145) | [43679344327](https://github.com/commercekit-tools/ccv2-build-cleanup/actions/runs/43679344327) | `2169892997` | 0 | +| Build | [43680545359](https://github.com/commercekit-tools/ccv2-build/actions/runs/43680545359) | [43680545418](https://github.com/commercekit-tools/ccv2-build/actions/runs/43680545418) | `2169929303` | 0 | +| Deploy | [43680764774](https://github.com/commercekit-tools/ccv2-deploy/actions/runs/43680764774) | [43680764683](https://github.com/commercekit-tools/ccv2-deploy/actions/runs/43680764683) | `2169935725` | 0 | + +Setup's six native-runner jobs plus quality passed. Its existing Main ruleset +`25021617` required one review and explicitly allowed OrganizationAdmin always +bypass. After verifying `anilkreddy` held that role and every check was green, +the authorized merge used that existing administrator exception. No approval +was fabricated and no ruleset was changed. Other implementation merges used +normal exact-head guards. Cleanup's strict main protection still requires +`validate` (app 15368) and `CodeQL` (app 57789), with administrator enforcement +enabled and force-push/deletion disabled. + +## Final executed commands and limits + +| Command/check | Outcome | +| ------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- | +| `pnpm install --frozen-lockfile` in this harness and five exact-main read-only checkouts | PASS, real registry 0.0.6; no local overrides | +| `pnpm quality` after final five pins | PASS, 76 tests, zero skips, format/lint/policy/public scan/audit | +| `actionlint .github/workflows/*.yml` | PASS | +| Exact public `action.yml` input-name comparison for all five adopted refs | PASS | +| `REPORTING_MANIFEST=... REPORTING_LOCAL_ORIGIN=https://localhost:18987 pnpm test:reporting` | PASS, 24 records in 55,745 ms | +| Source/runner/input metadata hash and lifecycle assertions against final safe evidence | PASS | + +An earlier restricted-network quality rerun could not resolve npm's advisory +endpoint. Its authorized network retry passed, and the complete final quality +command passed afterward; the failed attempt is not reported as a pass. A narrow +independent source review found no generated-code, privacy or network-guard +defect in this harness; it did not execute CodeQL or replace processed analysis +evidence. + +The final replay used the normal published dependency without candidate flags, +file links or rewritten package metadata. The five Action bundles ran as +standalone processes. Source and consumer paths matched the normal exact-main +checkouts; public package byte/SRI/schema/export proof ran before any target +operation. The clean executed harness commit and runtime/source hashes remain +in the evidence even though this later report-only commit adds the result file. + +No new hosted Sandbox workflow was dispatched. All provider delivery was +mocked; no real SAP, production cleanup, deployment, Action release or Git tag +was performed. Package 0.0.6 publication was separately authorized and completed +as recorded above. Remaining gates are production SAP eligibility evidence, +operational/non-production owner approval and any future Action release +approval. Sandbox passes do not prove SAP deletion guarantees or authorize +real deletion. diff --git a/docs/SCENARIOS.md b/docs/SCENARIOS.md index cbe4d45..0d536cd 100644 --- a/docs/SCENARIOS.md +++ b/docs/SCENARIOS.md @@ -108,7 +108,8 @@ eligibility. Expected result: `blocked`, `dryRun=true`, 105 scanned/skipped, 13 protected dispositions, zero eligible/planned/requested/failed/unknown/deferred. Every exact per-build reason set and the shared cleanup notification are checked; reason categories overlap. `blocked` in dry-run is a handled successful Action -execution with a shared failure-status notification, not a deletion. +execution with a shared warning-status notification and explicit safety issues, +not a deletion. A second invocation must preserve counts/decisions. Observed target API counters must contain only supported reads/authentication, and listing counters must prove diff --git a/docs/SETUP.md b/docs/SETUP.md index 9be6d7f..34e41b7 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -14,7 +14,7 @@ commits. This setup does not deploy the Sandbox or release any Action. workflows need no contents-write, release, or package-publish permission. 4. In each shared package's **Manage Actions access**, grant this repository **Read** access to `notification-contract` and `ccv2-client`. The contract is pinned - exactly to `0.0.4` and the client to `0.0.3`. A successful install with an owner's local credential does + exactly to `0.0.6` and the client to `0.0.3`. A successful install with an owner's local credential does not prove the repository's workflow token has package access. 5. Create/configure the environments below before the first live dispatch. diff --git a/docs/VALIDATION.md b/docs/VALIDATION.md index 24c3e96..8b99c2c 100644 --- a/docs/VALIDATION.md +++ b/docs/VALIDATION.md @@ -1,5 +1,43 @@ # Workflow validation — updated 2026-11-15 (UTC) +## Published 0.0.6 registry transition + +The authorized package-only [run 43678067818](https://github.com/commercekit-tools/action-kit/actions/runs/43678067818) +published notification-contract 0.0.6 from main +`3fecce40414d709884fa48e48eca278f470b20b0`. This harness now installs exact +registry 0.0.6 with client 0.0.3 unchanged. Frozen installation, independent +registry tarball SHA256/SRI/byte proof and the complete ordinary `pnpm quality` +passed: **76 offline tests, zero skips**, format/lint, unchanged workflow policy, +public scan and audit with no known vulnerabilities. + +The local reporting command now requires normal registry manifests/locks and +installed public package bytes; candidate-only overrides were retired. An early combined five normal registry bundle replay passed all 24 records on +clean reviewed branch heads. The first attempt exposed pnpm 12 multi-document +lock parsing before any target call; strict graph selection and a dedicated +regression test resolved it. Final reviewed merged Action pins passed a new +24-record replay in **55,745 ms** from clean committed harness +`a4224df787c277b88deb1458eaa9162e6838967c`; every source was clean and matched +the adopted immutable ref. Four disposable runs were removed with absence +verified, both Cleanup passes made zero target mutations, Setup invalid input +made zero network calls, and all 16 provider requests were mocked. See +[final safe evidence](reporting-registry-main-evidence.json) and +[current reporting evidence](REPORTING.md); prior +source-candidate evidence remains [historical](REPORTING-CANDIDATES.md). New +hosted dispatches and live provider/SAP validation have not run. + +The final Build/Deploy pins include narrow test-only CodeQL corrections. Their +initial green jobs had two/three processed findings; final exact-main analyses +now contain zero results and zero open alerts. All six repositories have green +main validation/CodeQL and clear processed analyses. The combined report also +records Setup's existing OrganizationAdmin merge exception, without suggesting +that review was fabricated or protection changed. + +## Historical 0.0.4 baseline and hosted workflow evidence + +The remaining sections record earlier published 0.0.4 Action pins and their +executed workflows. Their legacy failure-status cleanup event assertions do +not describe the new 0.0.6 warning vocabulary or establish a new hosted run. + This record distinguishes offline/local validation from owner-authorized hosted Sandbox execution. Both new manual workflows completed successfully after PR #1 merged. No provider send, real SAP operation, release, tag, package publication or diff --git a/docs/WORKFLOWS.md b/docs/WORKFLOWS.md index b8f81c1..90d8da1 100644 --- a/docs/WORKFLOWS.md +++ b/docs/WORKFLOWS.md @@ -91,7 +91,7 @@ continue-on-delete-error=false, and **dry-run=true**. There is no apply input or schedule. `sandbox-e2e` main-only protection remains in use. The expected production-shaped result is blocked because eligibility evidence is -unverified. Assertions require exact counts/reasons, valid contract 0.0.4 cleanup +unverified. Assertions require exact counts/reasons, valid contract 0.0.6 cleanup events, matching repeat-run decisions and zero target API mutations. They also check listing counters to establish multi-page discovery. Fixture/control-plane operations do not count as target DELETE requests. The run is removed in an diff --git a/docs/reporting-candidate-evidence.json b/docs/reporting-candidate-evidence.json new file mode 100644 index 0000000..f7ef30f --- /dev/null +++ b/docs/reporting-candidate-evidence.json @@ -0,0 +1,290 @@ +{ + "schemaVersion": 1, + "classification": "unpublished-source-candidate", + "outcome": "PASS", + "sources": { + "contract": { + "sourceSha": "475cc4db42f79310240496201f90d7047aa54330", + "gitTree": "9a42427d4aaf3521dd07be29cdf6425ec24cf8e0", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "59520de20d79d6258d80313ca98b8822872cd19726b5cd3a5748550998065cb6", + "runtimeHash": "928fc17ec18c9275afa219014c6558ec9e5f36b08f91c267fe7c365034af56be" + }, + "sandbox": { + "sourceSha": "ad7a4be86f60243f9005cea9feb63abbf9dbf01a", + "gitTree": "73f7db75196fa9e0c503e601a6bf8d4ed3777922", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "637f8e178e9374f827313eb6b9ef8fbd2830e5ee142f99875edcba48abbc7e06", + "runtimeHash": "f4608db903921e58fb32216e5eb8987f677c0bd6a8eb712388de568f62c26bc9" + }, + "setup-commercekit": { + "sourceSha": "5b8f44d20ecefa8196800f9c90ee5ecf79e48a5c", + "gitTree": "08009ed2efa2a4829f24de4b561ada4130ee0190", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "9149bfd646435bfec2429f063813b6f052f491980bf8bd29c2b08f209c3dd51a", + "runtimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c", + "bundleSha256": "ccec5024b018a009fada020bb6cebe292160b45cc2ee1224f6e4d957d9c81bae", + "consumerRuntimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c" + }, + "ccv2-build": { + "sourceSha": "5b74b36aa661c21835ab57190bf4950cd842fc5c", + "gitTree": "b31a28172a98b2d71f3c65435472c9d0ba92e4a4", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "a086df9b32919db171077904d40b4e8c178ef23a2b165f12278c752bc325d6b6", + "runtimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e", + "bundleSha256": "2f0f11dfe5318bafd8973cfc110714030b412f503f9303bf0a69101dbeeeb76a", + "consumerRuntimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e" + }, + "ccv2-deploy": { + "sourceSha": "56e037ca68d5adbc53438733020b65a8b4f65b2f", + "gitTree": "83e4599e106a6e4dea79c44d0538d9b099015347", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "1185e0b2f3a98d687d796ba3073898c1f7905f89b1f494470579a1eb5c003d9d", + "runtimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6", + "bundleSha256": "540d42a2072000d1ffa884c22a7eac933233a5a584c6831be85a1472d1e7744e", + "consumerRuntimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6" + }, + "ccv2-build-cleanup": { + "sourceSha": "4686db93bbf0accbf232a82874421920d4598b56", + "gitTree": "8f5a8f61091ea687efc55cc2bd4888e122a4faff", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "2c3fe7acfa7839ed5487c0e59e97f9ddc5379eb3ef596bc7413bc4acdb73bc3f", + "runtimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d", + "bundleSha256": "4aa35bc6852278754182751b7897364f9a3d1605f6f9967ea9d469a66b564b96", + "consumerRuntimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d" + }, + "notify": { + "sourceSha": "41e699d13bd183bd51551e45c386cf9e8f77d6dd", + "gitTree": "89d5e86dbaab9e1baedd42750c401b3b224d0fd4", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "837525bc85bfb2202df000e17a5f069250f9779cb8d1c09b2a8f5f5b6e35ff5a", + "runtimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee", + "bundleSha256": "e9142b35852702017cd44d067c3681ad1bb6e5c2b13ec6f4d666919539d4ac92", + "consumerRuntimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee" + } + }, + "harnessSource": { + "sourceSha": "unborn-private-workspace", + "gitTree": "unborn-private-workspace", + "dirty": true, + "dirtyFingerprint": "df9896fa3afcbdc67af0d78ede614c95272136ac5c945245a1fe43a68ec475d6", + "sourceHash": "65225fbea4f27de0fc05d418fefee00bb0ce2ef6886add133d234f7778c41d4e", + "runtimeHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "harnessCode": { + "validate-reporting-candidates.mjs": "3d72761981d65cb1421a5d6ba48a3c920646a4f9fcc980a83dd8362fdb071feb", + "candidate-support.mjs": "f7edfd04b07ac1e8bb9717506d4c5a026e0fe74ac2f436f3441cdccdef24aa27", + "candidate-fetch-preload.mjs": "bf2bf2a06a2682556fd8f2a7ca4769917716a52f166a79156d5730d8beb3745c", + "scenarios.mjs": "17242ee5ff979a641d27ea51f10e1ac4b206272f49d63c2149f7f361b097852b", + "runtime.mjs": "955bc6316b4bad8283af5ea970aa0a23bd22779077bedb5c70f2eaa1c9304ce6" + }, + "contract": { + "version": "0.0.6", + "sha256": "e4b79576328c2992a96fed087e9ba6e63970e8b54d6fca976a6652702a7a73a9", + "integrity": "sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==" + }, + "scenarios": [ + { + "action": "ccv2-build", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "18d3bab23d22e177aa3840e542fdf6a16d7c4ece9ff61cfb244f266bd4eea7bc" + }, + { + "action": "ccv2-deploy", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "c95930740776e4ab82b61edc80e00766e3d26764f9b3087d50cb05d2fc925e8e" + }, + { + "action": "ccv2-build", + "scenario": "build-failure", + "status": "failure", + "summarySha256": "dbafccfb07ba9167391eddf67491802d9788e8487af08690241fcaeea6f26e4d" + }, + { + "action": "ccv2-build", + "scenario": "green-manual", + "status": "success", + "summarySha256": "b466dd3553c9294fceb3fa5a279dbe9cc196c905b53ec3a56c3c36f6217e7f67" + }, + { + "action": "ccv2-deploy", + "scenario": "green-manual", + "status": "action-required", + "summarySha256": "9790948ea352dfb67a824187d6bd83da48132fce2bbbcdcd497bda6bb138798f" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "first", + "status": "warning", + "targetMutations": 0, + "summarySha256": "b98a8283447d5e8aa590d51d3f4e9350969f72632b9bf1b3ac8a7b3916e25418" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "repeat", + "status": "warning", + "targetMutations": 0, + "summarySha256": "68710647dee3d027005fbf1dbd14aa8235d80793854b0424610e27d6edc672e9" + }, + { + "action": "setup-commercekit", + "scenario": "invalid-input", + "status": "failure", + "networkCalls": 0, + "summarySha256": "ba840f18849cc1af5242677fbaa1964f723896bb768d33c6d6c5536b58b58a2e" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "6f436da45125caa1792b2ea2e9a6a4f4f8b72856ce6adf59406d418f377efd3c" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "408e102af7b11160bf54d81dfcc31816f36545f9cb87f239b6b1fe1168544f71" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "872caabea56321ba7df7fc933a5b5b338a758f1e9c7c026f314d839abb903e1a" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "0b419284de5d7f90a7606ef5eb28049159a0328d4e51689792701e863c890c11" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "e895948b5d6e4fe7c847b513f97e6d4a3952289924b99c925387d9c141832c97" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "857148678d7352d33de1022b5b5eaa056826a925ffee200440d0b82c3c3ff5bd" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "438e7fbf21bae11802454a07997061c34bb3472c5b19524e71b68736b11a43ce" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "408e102af7b11160bf54d81dfcc31816f36545f9cb87f239b6b1fe1168544f71" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "3499ace33695fc7159f5fe206ad99ecc20336d1e85d09addf7f471233950388b" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "5038fde726e22dda104f6f0b3ff0a41e2489db0366be73bda818113c9b9262b1" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "a061872ca8b70a1980e3cf5b1d3a0951046161819bcffe16e39fced0f97ce397" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "808a9198c58e28d2142e80ea881bcedba3777da4548dd3f3734b1b398f713652" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "d638dc5e2373659d01d2513da6cfec4debda66ccd0cda10c0d2994ed49c7c477" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "3c99cdfc67b54353943d4b03f88c379346270e91cbab3a61df7eeb804d62c2c2" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "warning", + "mockedRequests": 1, + "summarySha256": "d22cb4d63482132d3c98d826f21a967ea64e861b65dfa0f88592b3d0127bec89" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "failure", + "mockedRequests": 1, + "summarySha256": "62b056ad83828440be0923339bc5fe602709db3576d35db4591d6984d4d3f348" + } + ], + "localOnly": true, + "providerRequestsMocked": true, + "hostedDispatches": 0, + "realSapCalls": 0, + "validatedRunsCreated": 4, + "validatedRunsRemoved": 4, + "lastChild": { + "action": "notify", + "exitCode": 1, + "network": { + "attempted": 1, + "sandbox": 0, + "mockProvider": 1, + "blocked": 0 + }, + "summaryBytes": 783 + }, + "durationMs": 55708 +} diff --git a/docs/reporting-registry-branch-evidence.json b/docs/reporting-registry-branch-evidence.json new file mode 100644 index 0000000..5640708 --- /dev/null +++ b/docs/reporting-registry-branch-evidence.json @@ -0,0 +1,290 @@ +{ + "schemaVersion": 1, + "classification": "registry-installed", + "outcome": "PASS", + "sources": { + "contract": { + "sourceSha": "3fecce40414d709884fa48e48eca278f470b20b0", + "gitTree": "9a42427d4aaf3521dd07be29cdf6425ec24cf8e0", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "59520de20d79d6258d80313ca98b8822872cd19726b5cd3a5748550998065cb6", + "runtimeHash": "928fc17ec18c9275afa219014c6558ec9e5f36b08f91c267fe7c365034af56be" + }, + "sandbox": { + "sourceSha": "ad7a4be86f60243f9005cea9feb63abbf9dbf01a", + "gitTree": "73f7db75196fa9e0c503e601a6bf8d4ed3777922", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "637f8e178e9374f827313eb6b9ef8fbd2830e5ee142f99875edcba48abbc7e06", + "runtimeHash": "f4608db903921e58fb32216e5eb8987f677c0bd6a8eb712388de568f62c26bc9" + }, + "setup-commercekit": { + "sourceSha": "0adfaabc67d734e034209c59d80de22013d41402", + "gitTree": "40f5cae874e5a2d8f8e670338b6b11d454c92b41", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "e10bdbd42669a36310b2aa526cc29ace9d9c3fbf22f8939ec97885135b81da0a", + "runtimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c", + "bundleSha256": "ccec5024b018a009fada020bb6cebe292160b45cc2ee1224f6e4d957d9c81bae", + "consumerRuntimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c" + }, + "ccv2-build": { + "sourceSha": "aedd0f1a35dc4c8fc538812ab6a2c7cdc50eb47d", + "gitTree": "2dc2891f725f6fd0ff8ce602bece3ad4916d5d71", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "ba52486285d56fa6cd378c52217e225e000375cbc865ad49d7047916d03437b4", + "runtimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e", + "bundleSha256": "2f0f11dfe5318bafd8973cfc110714030b412f503f9303bf0a69101dbeeeb76a", + "consumerRuntimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e" + }, + "ccv2-deploy": { + "sourceSha": "71acea3d4ced7876ff89fe316d175b205d8ce5fa", + "gitTree": "73cb9bf1daeb27e9d6387d87ef194ef24d38a53e", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "fdce7ddd080c89004f6bad91b1565185d44f15e5cba15e1d5ce9fc0523174142", + "runtimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6", + "bundleSha256": "540d42a2072000d1ffa884c22a7eac933233a5a584c6831be85a1472d1e7744e", + "consumerRuntimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6" + }, + "ccv2-build-cleanup": { + "sourceSha": "82ef04cc9392cf08188873b43d1ceedcd8ed6d4c", + "gitTree": "052198eb318156c5fdfd5adb88b51b05bb8c31ff", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "c21a4d5ac9c2620d6e355d7c1e4e691432300255892acfe44e2afcf09a518d13", + "runtimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d", + "bundleSha256": "ab30073d8bb01ee4e120ba58f57737af2a9fd99b94bffb7cc52b83a80d004f9f", + "consumerRuntimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d" + }, + "notify": { + "sourceSha": "270f2cfe9adcde71cfd59dd3ff94bc7e58c66900", + "gitTree": "14e5a625cf5f13b62d1b49f0e74e309c8ce39611", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "415faea952b5091ba13f7a6368925aea52d12535ad09557ccce2834886c14eb1", + "runtimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee", + "bundleSha256": "e9142b35852702017cd44d067c3681ad1bb6e5c2b13ec6f4d666919539d4ac92", + "consumerRuntimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee" + } + }, + "harnessSource": { + "sourceSha": "b1dd29a167289b083688b2ad45ddb492bcc5190a", + "gitTree": "23615b3fac5eed568efc879910adb73b93fc2d71", + "dirty": true, + "dirtyFingerprint": "5def4259e5c0d4822d042f3f9a4c7a0b805d841b96d7f57174d5d9026d196481", + "sourceHash": "1748591105b3f7a1b19dbad94eb69a4be0c951d6c02fcdd9c6e044fbaab22bb5", + "runtimeHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "harnessCode": { + "validate-reporting.mjs": "3dd1eccc3a14ccf03ca439ba8fdc23ccd1ae0cd05dad834fab70ba1300617790", + "reporting-support.mjs": "51210fcdf63429c7a5359e05083cdcfb1f2cd9efcc4056f642ed008f1951477c", + "reporting-fetch-preload.mjs": "099358bc2778c976cf3026c051663b6a8eec231ecb27bb6974e875779c6d5807", + "scenarios.mjs": "85e9a4c28cedf5a1b165d39cb9ffe8d2fa3d77cabc2ff667f3b61c9eca5c23a3", + "runtime.mjs": "955bc6316b4bad8283af5ea970aa0a23bd22779077bedb5c70f2eaa1c9304ce6" + }, + "contract": { + "version": "0.0.6", + "sha256": "e4b79576328c2992a96fed087e9ba6e63970e8b54d6fca976a6652702a7a73a9", + "integrity": "sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==" + }, + "scenarios": [ + { + "action": "ccv2-build", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "0618fb3d72111f37876948f9eaa177ef48265e741a86c3c727ec1113a3360702" + }, + { + "action": "ccv2-deploy", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "25f999d1a30e2f77b7137ef995c7e4ee0891aa19c3c4d0713523caebeacefa5f" + }, + { + "action": "ccv2-build", + "scenario": "build-failure", + "status": "failure", + "summarySha256": "95af743c47dfd72859fe9d2b2c4e5c8148309273298b97fdc4a3744189c33101" + }, + { + "action": "ccv2-build", + "scenario": "green-manual", + "status": "success", + "summarySha256": "aedabcaef4b47bf18b4b2616a5ea51ed4eac8ccdef8a25130ad9f76ebc393a4a" + }, + { + "action": "ccv2-deploy", + "scenario": "green-manual", + "status": "action-required", + "summarySha256": "d65f371ad7698c711e2735a4f52674d70a2f8e97c28f1d3cc30f23da471f92a3" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "first", + "status": "warning", + "targetMutations": 0, + "summarySha256": "b4cf2ce7b7cfb8f17d26b6ecf8a6ecce7f4512049c8854cea1ff40294f2a5329" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "repeat", + "status": "warning", + "targetMutations": 0, + "summarySha256": "bbfe48518694d290840e2eefb07c3a1803be3819cd9e6eaef299a0cad8ae3afc" + }, + { + "action": "setup-commercekit", + "scenario": "invalid-input", + "status": "failure", + "networkCalls": 0, + "summarySha256": "942ad9e910257b258a54a025a321a985ff2ebb8717f23f442365034c9966128b" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "438e7fbf21bae11802454a07997061c34bb3472c5b19524e71b68736b11a43ce" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "408e102af7b11160bf54d81dfcc31816f36545f9cb87f239b6b1fe1168544f71" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "872caabea56321ba7df7fc933a5b5b338a758f1e9c7c026f314d839abb903e1a" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "86e82b6910f5586f858cff83d7771c43a2c7956760bd013aaaa4cb196a25f379" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "e516cdb3281964bb6884f47f9eb4f7a80b7ea7c4b8bf937fdea94962b217a153" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "438f1228e1a6fdc3055d7e5d6877c47c3e9d628ffb1bf2cb2e16e42b43f0c852" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "6f436da45125caa1792b2ea2e9a6a4f4f8b72856ce6adf59406d418f377efd3c" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "408e102af7b11160bf54d81dfcc31816f36545f9cb87f239b6b1fe1168544f71" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "9869bacef201bbf2fc220b79bd43b71f7198a310610d6420ee7d36c1c7d49860" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "24e542f1b162dba70d2993554e433437516784f0617984cd853bf73a2971eca0" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "683a5d8db692ac3077f19af6dfaf47be7322c7f596ac610f002d1b08f9692150" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "808a9198c58e28d2142e80ea881bcedba3777da4548dd3f3734b1b398f713652" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "d638dc5e2373659d01d2513da6cfec4debda66ccd0cda10c0d2994ed49c7c477" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "9ca38463d3c40c964e5a472fc1ef5bbe6d576632be193330ad9535645195ebeb" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "warning", + "mockedRequests": 1, + "summarySha256": "6854063ec712eecbc229530afd5afdbc1e3a51be5f43f4cac799a42d78866a9e" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "failure", + "mockedRequests": 1, + "summarySha256": "adc919aab2d963b8d01caeea7a3a0f3783dbf4a36b07ddecafa4509e10abf1eb" + } + ], + "localOnly": true, + "providerRequestsMocked": true, + "hostedDispatches": 0, + "realSapCalls": 0, + "validatedRunsCreated": 4, + "validatedRunsRemoved": 4, + "lastChild": { + "action": "notify", + "exitCode": 1, + "network": { + "attempted": 1, + "sandbox": 0, + "mockProvider": 1, + "blocked": 0 + }, + "summaryBytes": 783 + }, + "durationMs": 56513 +} diff --git a/docs/reporting-registry-initial-main-evidence.json b/docs/reporting-registry-initial-main-evidence.json new file mode 100644 index 0000000..dba9669 --- /dev/null +++ b/docs/reporting-registry-initial-main-evidence.json @@ -0,0 +1,292 @@ +{ + "schemaVersion": 1, + "classification": "registry-installed", + "outcome": "PASS", + "sources": { + "contract": { + "sourceSha": "3fecce40414d709884fa48e48eca278f470b20b0", + "gitTree": "9a42427d4aaf3521dd07be29cdf6425ec24cf8e0", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "59520de20d79d6258d80313ca98b8822872cd19726b5cd3a5748550998065cb6", + "runtimeHash": "928fc17ec18c9275afa219014c6558ec9e5f36b08f91c267fe7c365034af56be" + }, + "sandbox": { + "sourceSha": "ad7a4be86f60243f9005cea9feb63abbf9dbf01a", + "gitTree": "73f7db75196fa9e0c503e601a6bf8d4ed3777922", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "637f8e178e9374f827313eb6b9ef8fbd2830e5ee142f99875edcba48abbc7e06", + "runtimeHash": "f4608db903921e58fb32216e5eb8987f677c0bd6a8eb712388de568f62c26bc9" + }, + "ccv2-build": { + "sourceSha": "a4e4ede0ffba3f3fec6b16ea1c2324375d383940", + "gitTree": "2dc2891f725f6fd0ff8ce602bece3ad4916d5d71", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "ba52486285d56fa6cd378c52217e225e000375cbc865ad49d7047916d03437b4", + "runtimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e", + "bundleSha256": "2f0f11dfe5318bafd8973cfc110714030b412f503f9303bf0a69101dbeeeb76a", + "consumerRuntimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e" + }, + "ccv2-deploy": { + "sourceSha": "9486574b5abc7a9d85ec2809b03a02380dcf7ee2", + "gitTree": "73cb9bf1daeb27e9d6387d87ef194ef24d38a53e", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "fdce7ddd080c89004f6bad91b1565185d44f15e5cba15e1d5ce9fc0523174142", + "runtimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6", + "bundleSha256": "540d42a2072000d1ffa884c22a7eac933233a5a584c6831be85a1472d1e7744e", + "consumerRuntimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6" + }, + "notify": { + "sourceSha": "abc752ead104a6e5153c5f166d04ee5e595e0ca6", + "gitTree": "14e5a625cf5f13b62d1b49f0e74e309c8ce39611", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "415faea952b5091ba13f7a6368925aea52d12535ad09557ccce2834886c14eb1", + "runtimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee", + "bundleSha256": "e9142b35852702017cd44d067c3681ad1bb6e5c2b13ec6f4d666919539d4ac92", + "consumerRuntimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee" + }, + "ccv2-build-cleanup": { + "sourceSha": "8b1786b731be8d2d3fac137cd358d2ee5488bd58", + "gitTree": "06a25c1cca43e60fe18680e14804e6aa910b1e6f", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "769e211cb6d6fd1c2ad50f89fcd4638b55a1016ed2b867c7a300755e3fd5adce", + "runtimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d", + "bundleSha256": "ab30073d8bb01ee4e120ba58f57737af2a9fd99b94bffb7cc52b83a80d004f9f", + "consumerRuntimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d" + }, + "setup-commercekit": { + "sourceSha": "52a5a098d89f9ef2c42a234b4c3baa5d60a7a896", + "gitTree": "40f5cae874e5a2d8f8e670338b6b11d454c92b41", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "e10bdbd42669a36310b2aa526cc29ace9d9c3fbf22f8939ec97885135b81da0a", + "runtimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c", + "bundleSha256": "ccec5024b018a009fada020bb6cebe292160b45cc2ee1224f6e4d957d9c81bae", + "consumerRuntimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c" + } + }, + "harnessSource": { + "sourceSha": "089b7fae37497ddb0cd2bf4dfc0e2b3d4fe3bba3", + "gitTree": "11c1b488b288d2f5013eb87567a344ad7ba1db42", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "76745318115c93568447046eac3fd11b6509cfb0a452399375dea6285cc4506b", + "runtimeHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "harnessCode": { + "validate-reporting.mjs": "a55c6f280ebe4c7501b37564186b24f20abe0f96c63690982a74c24aea22dc53", + "reporting-support.mjs": "51210fcdf63429c7a5359e05083cdcfb1f2cd9efcc4056f642ed008f1951477c", + "reporting-fetch-preload.mjs": "099358bc2778c976cf3026c051663b6a8eec231ecb27bb6974e875779c6d5807", + "reporting-inputs.mjs": "24996746ea852928b6bbc388e249e7ee9a9af28dca6845139b5816b4bc4a6c3c", + "scenarios.mjs": "85e9a4c28cedf5a1b165d39cb9ffe8d2fa3d77cabc2ff667f3b61c9eca5c23a3", + "runtime.mjs": "a2d8ac4f4b51f4f0b02a7854c03abf7a2f87271174ebb302c8d84c172e7078b0" + }, + "adoptedActionMetadataSha256": "af04884dfa0f79cf148776d83137526af82c893472b24ca955fdbd67d1e286cf", + "contract": { + "version": "0.0.6", + "sha256": "e4b79576328c2992a96fed087e9ba6e63970e8b54d6fca976a6652702a7a73a9", + "integrity": "sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==" + }, + "scenarios": [ + { + "action": "ccv2-build", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "d929098060dc27447ef4daa62463208f27b6aa38b679a9142d7fee374d1ffe5c" + }, + { + "action": "ccv2-deploy", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "329e45394493580f9f8a8c164eff5286d643deb004ce7ae4a065803cb27e3569" + }, + { + "action": "ccv2-build", + "scenario": "build-failure", + "status": "failure", + "summarySha256": "7d6b8bf1a15a8e1d537ab684b4bb44ac515f0484241715637fb9fdae081bd75e" + }, + { + "action": "ccv2-build", + "scenario": "green-manual", + "status": "success", + "summarySha256": "71ad17bb5a544b21f3a2848eb871c6c78ab30e9fe935d78d42d580b13c0f10d7" + }, + { + "action": "ccv2-deploy", + "scenario": "green-manual", + "status": "action-required", + "summarySha256": "61286c479f5e33412b7e2636700859231114d3752b5e7f7e819858c7a5702a3b" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "first", + "status": "warning", + "targetMutations": 0, + "summarySha256": "b98a8283447d5e8aa590d51d3f4e9350969f72632b9bf1b3ac8a7b3916e25418" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "repeat", + "status": "warning", + "targetMutations": 0, + "summarySha256": "68710647dee3d027005fbf1dbd14aa8235d80793854b0424610e27d6edc672e9" + }, + { + "action": "setup-commercekit", + "scenario": "invalid-input", + "status": "failure", + "networkCalls": 0, + "summarySha256": "942ad9e910257b258a54a025a321a985ff2ebb8717f23f442365034c9966128b" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "6f436da45125caa1792b2ea2e9a6a4f4f8b72856ce6adf59406d418f377efd3c" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "3d5483cb18f1229feb2f32f641ad8ec43c513ab5467a8ad12e0b9a7c17fda37e" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "872caabea56321ba7df7fc933a5b5b338a758f1e9c7c026f314d839abb903e1a" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "325fe2447434238b5d4fa1df80a9c25cb2e85d2234476067cc7c207beda28a6f" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "e516cdb3281964bb6884f47f9eb4f7a80b7ea7c4b8bf937fdea94962b217a153" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "9c941cf7af6785743fc0b62aa3159e0106b1cf5998084651178a44288a36375f" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "438e7fbf21bae11802454a07997061c34bb3472c5b19524e71b68736b11a43ce" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "32130204a39a9a890c574af0b91ed87b8466eccb9eec008c5f55d1e2747e7e91" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "e063c25a1995fe3f259c4f4574dedbefcc7ae399eef76d1c3383151fb3c20044" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "5038fde726e22dda104f6f0b3ff0a41e2489db0366be73bda818113c9b9262b1" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "a061872ca8b70a1980e3cf5b1d3a0951046161819bcffe16e39fced0f97ce397" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "808a9198c58e28d2142e80ea881bcedba3777da4548dd3f3734b1b398f713652" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "a9d128e7e5a4f287f5b81c64daa1c224ab0ae9da32e0bc35645f1fa546387f02" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "a2cb9d4ff7d57cde55d002ee141931ba1cb1a3c1f68cc2bccd32037bb8240d61" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "warning", + "mockedRequests": 1, + "summarySha256": "d22cb4d63482132d3c98d826f21a967ea64e861b65dfa0f88592b3d0127bec89" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "failure", + "mockedRequests": 1, + "summarySha256": "62b056ad83828440be0923339bc5fe602709db3576d35db4591d6984d4d3f348" + } + ], + "localOnly": true, + "providerRequestsMocked": true, + "hostedDispatches": 0, + "realSapCalls": 0, + "validatedRunsCreated": 4, + "validatedRunsRemoved": 4, + "lastChild": { + "action": "notify", + "exitCode": 1, + "network": { + "attempted": 1, + "sandbox": 0, + "mockProvider": 1, + "blocked": 0 + }, + "summaryBytes": 783 + }, + "durationMs": 55872 +} diff --git a/docs/reporting-registry-main-evidence.json b/docs/reporting-registry-main-evidence.json new file mode 100644 index 0000000..fea7d06 --- /dev/null +++ b/docs/reporting-registry-main-evidence.json @@ -0,0 +1,292 @@ +{ + "schemaVersion": 1, + "classification": "registry-installed", + "outcome": "PASS", + "sources": { + "contract": { + "sourceSha": "3fecce40414d709884fa48e48eca278f470b20b0", + "gitTree": "9a42427d4aaf3521dd07be29cdf6425ec24cf8e0", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "59520de20d79d6258d80313ca98b8822872cd19726b5cd3a5748550998065cb6", + "runtimeHash": "928fc17ec18c9275afa219014c6558ec9e5f36b08f91c267fe7c365034af56be" + }, + "sandbox": { + "sourceSha": "ad7a4be86f60243f9005cea9feb63abbf9dbf01a", + "gitTree": "73f7db75196fa9e0c503e601a6bf8d4ed3777922", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "637f8e178e9374f827313eb6b9ef8fbd2830e5ee142f99875edcba48abbc7e06", + "runtimeHash": "f4608db903921e58fb32216e5eb8987f677c0bd6a8eb712388de568f62c26bc9" + }, + "ccv2-build": { + "sourceSha": "fc65ee281f39b98d2cecad36ff93d40cf055fbc2", + "gitTree": "667fd40f94e174945d24b183b2db5c46d899835d", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "2dba6957a02c5a0d150a5fd1ca642e3c4cdb9e6eee62f57924ae295e36e24ce1", + "runtimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e", + "bundleSha256": "2f0f11dfe5318bafd8973cfc110714030b412f503f9303bf0a69101dbeeeb76a", + "consumerRuntimeHash": "7bcac173ccdd28444cec3a051dfd44f6f16cefa82b9abc319a55bc1f7fc0764e" + }, + "ccv2-deploy": { + "sourceSha": "1af852b9a00e981da4ea13565bb18c7ce7fda27f", + "gitTree": "03c5d55a3daaa0146eedc86dd8a44e23cfa11887", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "f70e7790464280fb0dae2a618c648a216dae5ebf8849d0a6cc9366e7ce3a2d80", + "runtimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6", + "bundleSha256": "540d42a2072000d1ffa884c22a7eac933233a5a584c6831be85a1472d1e7744e", + "consumerRuntimeHash": "68ca8c38904594e451c156fd87d41c54fed98c4fb178b4de889bf103fb52d4f6" + }, + "notify": { + "sourceSha": "abc752ead104a6e5153c5f166d04ee5e595e0ca6", + "gitTree": "14e5a625cf5f13b62d1b49f0e74e309c8ce39611", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "415faea952b5091ba13f7a6368925aea52d12535ad09557ccce2834886c14eb1", + "runtimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee", + "bundleSha256": "e9142b35852702017cd44d067c3681ad1bb6e5c2b13ec6f4d666919539d4ac92", + "consumerRuntimeHash": "158fb9413630c52c842bff8b830c73dfd22c2f093fd45537522151be71ef9aee" + }, + "ccv2-build-cleanup": { + "sourceSha": "8b1786b731be8d2d3fac137cd358d2ee5488bd58", + "gitTree": "06a25c1cca43e60fe18680e14804e6aa910b1e6f", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "769e211cb6d6fd1c2ad50f89fcd4638b55a1016ed2b867c7a300755e3fd5adce", + "runtimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d", + "bundleSha256": "ab30073d8bb01ee4e120ba58f57737af2a9fd99b94bffb7cc52b83a80d004f9f", + "consumerRuntimeHash": "bdab709815b363e9d3f9583a162a9bba4861e28674c1874001097cc7afd7650d" + }, + "setup-commercekit": { + "sourceSha": "52a5a098d89f9ef2c42a234b4c3baa5d60a7a896", + "gitTree": "40f5cae874e5a2d8f8e670338b6b11d454c92b41", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "e10bdbd42669a36310b2aa526cc29ace9d9c3fbf22f8939ec97885135b81da0a", + "runtimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c", + "bundleSha256": "ccec5024b018a009fada020bb6cebe292160b45cc2ee1224f6e4d957d9c81bae", + "consumerRuntimeHash": "5289f978933c2d9040fdea0277155a07de992b254399eff798cda04dfd8ee19c" + } + }, + "harnessSource": { + "sourceSha": "a4224df787c277b88deb1458eaa9162e6838967c", + "gitTree": "cd0f18ea70b2c18e193259a0f578f3b42f267c2d", + "dirty": false, + "dirtyFingerprint": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", + "sourceHash": "d995bd88f14ea5f8d31f7600e318cbd10a593110f4d6d3e1b90ee4e67b426405", + "runtimeHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" + }, + "harnessCode": { + "validate-reporting.mjs": "a55c6f280ebe4c7501b37564186b24f20abe0f96c63690982a74c24aea22dc53", + "reporting-support.mjs": "51210fcdf63429c7a5359e05083cdcfb1f2cd9efcc4056f642ed008f1951477c", + "reporting-fetch-preload.mjs": "099358bc2778c976cf3026c051663b6a8eec231ecb27bb6974e875779c6d5807", + "reporting-inputs.mjs": "24996746ea852928b6bbc388e249e7ee9a9af28dca6845139b5816b4bc4a6c3c", + "scenarios.mjs": "85e9a4c28cedf5a1b165d39cb9ffe8d2fa3d77cabc2ff667f3b61c9eca5c23a3", + "runtime.mjs": "a2d8ac4f4b51f4f0b02a7854c03abf7a2f87271174ebb302c8d84c172e7078b0" + }, + "adoptedActionMetadataSha256": "764dce21a1e908ed9f47be4602841315b2346fa2c34d636f72913bd5d5d485f4", + "contract": { + "version": "0.0.6", + "sha256": "e4b79576328c2992a96fed087e9ba6e63970e8b54d6fca976a6652702a7a73a9", + "integrity": "sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==" + }, + "scenarios": [ + { + "action": "ccv2-build", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "6cfcabe0b6435d0f0f02ee67defb3f0e05080dce960ee0de262be77c9e8cec6d" + }, + { + "action": "ccv2-deploy", + "scenario": "rolling-success", + "status": "success", + "summarySha256": "8225109426d242a980cd4bdb7e7994b338eb34923161b01a76f26d167a8379f0" + }, + { + "action": "ccv2-build", + "scenario": "build-failure", + "status": "failure", + "summarySha256": "a9b23a20ed794f6289a957b83a5de7684adfcc02ae5d70d847341ab49b60324f" + }, + { + "action": "ccv2-build", + "scenario": "green-manual", + "status": "success", + "summarySha256": "63ae1c4d1f8f68d2de0ff2762647d44fe04ab598d53b1ad66d3ae2c1d2955eec" + }, + { + "action": "ccv2-deploy", + "scenario": "green-manual", + "status": "action-required", + "summarySha256": "964d1eac0a1fdd71832ee949de0591784d0ff27b1577a60553b48b3b6ec8e9cc" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "first", + "status": "warning", + "targetMutations": 0, + "summarySha256": "d8e41d6fc52866e02c10368009a68635b5f7f459261afefaad4e527030f9fc9a" + }, + { + "action": "ccv2-build-cleanup", + "scenario": "repeat", + "status": "warning", + "targetMutations": 0, + "summarySha256": "0c74ab5170fdd1b1e5c052ef4382555794c345132042a7c5beb11f0ac7db5518" + }, + { + "action": "setup-commercekit", + "scenario": "invalid-input", + "status": "failure", + "networkCalls": 0, + "summarySha256": "942ad9e910257b258a54a025a321a985ff2ebb8717f23f442365034c9966128b" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "438e7fbf21bae11802454a07997061c34bb3472c5b19524e71b68736b11a43ce" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "408e102af7b11160bf54d81dfcc31816f36545f9cb87f239b6b1fe1168544f71" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "c32544217069d0bf91e2354e703c6f4d500441572141b010bdadeafbb0e69e55" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "86e82b6910f5586f858cff83d7771c43a2c7956760bd013aaaa4cb196a25f379" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "8ac5bebfe1cabef7ec4e1571536dea592d40b961893038e0997d006b4b3b08a0" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "e00625db7177dc94f4412275ad211da08fa2132825840ef8318ba05c65fd3a22" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "438e7fbf21bae11802454a07997061c34bb3472c5b19524e71b68736b11a43ce" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "success", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "3d5483cb18f1229feb2f32f641ad8ec43c513ab5467a8ad12e0b9a7c17fda37e" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "37be6790115c737467b9c33c4a40d2f4632365eb722716d5c6524352716f1d97" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "action-required", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "5038fde726e22dda104f6f0b3ff0a41e2489db0366be73bda818113c9b9262b1" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "a061872ca8b70a1980e3cf5b1d3a0951046161819bcffe16e39fced0f97ce397" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "warning", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "ef86f256d91d46adec6e03bedfb7c86dba775fca950f779b1d8f105b4cdd6046" + }, + { + "action": "notify", + "provider": "slack", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "d638dc5e2373659d01d2513da6cfec4debda66ccd0cda10c0d2994ed49c7c477" + }, + { + "action": "notify", + "provider": "teams-workflow", + "sourceStatus": "failure", + "delivered": true, + "mockedRequests": 1, + "summarySha256": "9ca38463d3c40c964e5a472fc1ef5bbe6d576632be193330ad9535645195ebeb" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "warning", + "mockedRequests": 1, + "summarySha256": "d22cb4d63482132d3c98d826f21a967ea64e861b65dfa0f88592b3d0127bec89" + }, + { + "action": "notify", + "scenario": "delivery-error", + "status": "failure", + "mockedRequests": 1, + "summarySha256": "62b056ad83828440be0923339bc5fe602709db3576d35db4591d6984d4d3f348" + } + ], + "localOnly": true, + "providerRequestsMocked": true, + "hostedDispatches": 0, + "realSapCalls": 0, + "validatedRunsCreated": 4, + "validatedRunsRemoved": 4, + "lastChild": { + "action": "notify", + "exitCode": 1, + "network": { + "attempted": 1, + "sandbox": 0, + "mockProvider": 1, + "blocked": 0 + }, + "summaryBytes": 783 + }, + "durationMs": 55745 +} diff --git a/package.json b/package.json index 4568341..606afe0 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,13 @@ "policy": "node scripts/check-policy.mjs", "scan:public": "node scripts/scan-public.mjs", "audit": "pnpm audit --audit-level=high", - "quality": "pnpm format:check && pnpm lint && pnpm test && pnpm policy && pnpm scan:public && pnpm audit" + "quality": "pnpm format:check && pnpm lint && pnpm test && pnpm policy && pnpm scan:public && pnpm audit", + "test:reporting": "node scripts/validate-reporting.mjs" }, "dependencies": { "@actions/core": "3.0.1", "@commercekit-tools/ccv2-client": "0.0.3", - "@commercekit-tools/notification-contract": "0.0.4" + "@commercekit-tools/notification-contract": "0.0.6" }, "devDependencies": { "@eslint/js": "10.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index db3c5ca..9e14e64 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -176,8 +176,8 @@ importers: specifier: 0.0.3 version: 0.0.3 '@commercekit-tools/notification-contract': - specifier: 0.0.4 - version: 0.0.4 + specifier: 0.0.6 + version: 0.0.6 devDependencies: '@eslint/js': specifier: 10.0.1 @@ -219,8 +219,8 @@ packages: resolution: {integrity: sha512-AkGkMm0KPWsvq34/EHYIYQBgnNfS7eXby3O5z5Gpw6sLTGaoLQReA65UubYsEE+3KKg7dwLtRNknuZfhKDa4Wg==, tarball: https://npm.pkg.github.com/download/@commercekit-tools/ccv2-client/0.0.3/897df8bd5b1dce9a5f3b33ee6f98913b8f7c2ee8} engines: {node: '>=24.21.0'} - '@commercekit-tools/notification-contract@0.0.4': - resolution: {integrity: sha512-y1kTB/s049V0DGLoQZd4s+vlFscShG5wS5g2H4WH6t6rRSOuJrKiCy42dcNlx5wC7NAy6hQuYoTFOQVQ1+PVoA==, tarball: https://npm.pkg.github.com/download/@commercekit-tools/notification-contract/0.0.4/ea3bb209c62d42cc78865055de3efb193db46876} + '@commercekit-tools/notification-contract@0.0.6': + resolution: {integrity: sha512-n6F84900sDPBeYm5dnf8HLCM9B2DUVATEeF717dqKsSXTJtq1FIj/3hZ2UcNTtXe7v8R90HYF6HIom4auM8Kyw==, tarball: https://npm.pkg.github.com/download/@commercekit-tools/notification-contract/0.0.6/8030f643d1dd6d741caa2c3c0ba321ad82b30cca} engines: {node: '>=24.21.0'} '@eslint-community/eslint-utils@4.10.1': @@ -606,7 +606,7 @@ snapshots: '@commercekit-tools/ccv2-client@0.0.3': {} - '@commercekit-tools/notification-contract@0.0.4': + '@commercekit-tools/notification-contract@0.0.6': dependencies: ajv: 8.20.0 ajv-formats: 3.0.1(ajv@8.20.0) diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 73c7f72..adfe8a0 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,5 @@ minimumReleaseAgeExclude: - '@commercekit-tools/ccv2-client@0.0.3' - - '@commercekit-tools/notification-contract@0.0.4' + - '@commercekit-tools/notification-contract@0.0.6' overrides: minimatch: 11.0.1 diff --git a/scripts/check-policy.mjs b/scripts/check-policy.mjs index b19eb5e..4a98c33 100644 --- a/scripts/check-policy.mjs +++ b/scripts/check-policy.mjs @@ -21,6 +21,7 @@ export function readPolicyFiles() { ...readdirSync('.github/workflows').map((name) => `.github/workflows/${name}`), ...compositePaths, 'action-refs.json', + 'action-inputs.json', ]; return Object.fromEntries(paths.map((path) => [path, readFileSync(path, 'utf8')])); } @@ -31,6 +32,22 @@ export function validatePolicy(files) { const pins = JSON.parse(files['action-refs.json']); assert.equal(Object.keys(pins).length, 7, 'Unexpected Action dependency.'); for (const sha of Object.values(pins)) assert.match(sha, /^[a-f0-9]{40}$/); + const metadata = JSON.parse(files['action-inputs.json']); + assert.deepEqual( + Object.keys(metadata).sort(), + Object.keys(pins) + .filter((name) => name.startsWith('commercekit-tools/')) + .sort(), + ); + for (const [name, snapshot] of Object.entries(metadata)) { + assert.equal(snapshot.ref, pins[name], 'Input metadata must bind to the adopted Action ref.'); + assert( + Array.isArray(snapshot.inputs) && snapshot.inputs.length > 0 && snapshot.inputs.length <= 50, + ); + assert.equal(new Set(snapshot.inputs).size, snapshot.inputs.length); + assert(snapshot.inputs.every((input) => /^[a-z][a-z0-9-]{0,63}$/.test(input))); + } + const docs = Object.fromEntries( [...workflowPaths, ...compositePaths].map((path) => [path, parse(files[path])]), ); diff --git a/scripts/reporting-fetch-preload.mjs b/scripts/reporting-fetch-preload.mjs new file mode 100644 index 0000000..90c61e3 --- /dev/null +++ b/scripts/reporting-fetch-preload.mjs @@ -0,0 +1,72 @@ +/** Test-only process preload: deny external network; map only fixed Sandbox requests to loopback. */ +import assert from 'node:assert/strict'; +import http from 'node:http'; +import https from 'node:https'; +import { syncBuiltinESMExports } from 'node:module'; +import { readFileSync, writeFileSync } from 'node:fs'; +import { join } from 'node:path'; +import { assertLoopbackOrigin, localSandboxFetch } from './reporting-support.mjs'; + +const mode = process.env.COMMERCEKIT_REPORTING_MODE; +assert(['sandbox', 'provider-mock', 'deny'].includes(mode)); +const origin = assertLoopbackOrigin(process.env.COMMERCEKIT_REPORTING_LOCAL_ORIGIN); +const counts = { attempted: 0, sandbox: 0, mockProvider: 0, blocked: 0 }; +const save = () => + writeFileSync(join(process.cwd(), 'network.json'), JSON.stringify(counts), { mode: 0o600 }); +save(); +const blocked = () => { + counts.attempted++; + counts.blocked++; + save(); + throw new Error('External network denied by reporting harness.'); +}; +http.request = blocked; +http.get = blocked; +https.request = blocked; +https.get = blocked; +syncBuiltinESMExports(); +const localFetch = localSandboxFetch( + origin, + readFileSync(process.env.COMMERCEKIT_REPORTING_CA_FILE), +); +globalThis.fetch = async (url, options = {}) => { + counts.attempted++; + if (mode === 'provider-mock') { + const target = new URL(typeof url === 'string' || url instanceof URL ? url : url.url); + const slack = + target.origin === 'https://' + 'hooks.slack.com' && + target.pathname === '/services/reporting/reporting/reporting'; + const teams = target.href === 'https://provider.example.test/reporting'; + if ( + !(slack || teams) || + options.method !== 'POST' || + target.username + target.password + target.search + target.hash !== '' + ) { + counts.blocked++; + save(); + throw new Error('Provider destination denied by reporting harness.'); + } + counts.mockProvider++; + save(); + assert(typeof options.body === 'string' && Buffer.byteLength(options.body) <= 65536); + writeFileSync(join(process.cwd(), 'payload.json'), options.body, { mode: 0o600 }); + const status = Number(process.env.COMMERCEKIT_REPORTING_MOCK_STATUS); + assert([200, 400].includes(status)); + return new Response('', { status }); + } + if (mode === 'sandbox') { + try { + const response = await localFetch(url, options); + counts.sandbox++; + save(); + return response; + } catch { + counts.blocked++; + save(); + throw new Error('Local reporting request failed or was denied.'); + } + } + counts.blocked++; + save(); + throw new Error('Network denied for offline reporting.'); +}; diff --git a/scripts/reporting-inputs.mjs b/scripts/reporting-inputs.mjs new file mode 100644 index 0000000..fd8a696 --- /dev/null +++ b/scripts/reporting-inputs.mjs @@ -0,0 +1,40 @@ +import assert from 'node:assert/strict'; +import { readFileSync } from 'node:fs'; +import { + isConfidentialInputName, + redactJwtLikeTokens, +} from '@commercekit-tools/notification-contract'; + +/** Public input names extracted from the exact adopted Action metadata, not an event schema. */ +export const actionInputMetadata = Object.freeze( + Object.fromEntries( + Object.entries( + JSON.parse(readFileSync(new URL('../action-inputs.json', import.meta.url), 'utf8')), + ).map(([name, value]) => [ + name, + Object.freeze({ ref: value.ref, inputs: Object.freeze(value.inputs) }), + ]), + ), +); + +export function actionInputNames(name) { + const metadata = actionInputMetadata[`commercekit-tools/${name}`]; + assert(metadata, 'Unknown Action input metadata.'); + return metadata.inputs; +} + +/** Current hosted scenarios provide valid short inputs; producer and event must agree exactly. */ +export function assertReportedInputs(name, result, event) { + const expected = actionInputNames(name); + assert(result.inputs && event.data.inputs); + assert.deepEqual(Object.keys(result.inputs).sort(), [...expected].sort()); + assert.deepEqual(event.data.inputs, result.inputs); + assert.equal(result.inputsValidated, true); + assert.equal(result.inputsTruncated, false); + assert.equal(event.data.inputsValidated, result.inputsValidated); + assert.equal(event.data.inputsTruncated, result.inputsTruncated); + for (const input of expected) + if (isConfidentialInputName(input)) assert.equal(result.inputs[input], '[REDACTED]'); + const serialized = JSON.stringify(result.inputs); + assert.equal(redactJwtLikeTokens(serialized), serialized); +} diff --git a/scripts/reporting-support.mjs b/scripts/reporting-support.mjs new file mode 100644 index 0000000..3ac14b9 --- /dev/null +++ b/scripts/reporting-support.mjs @@ -0,0 +1,349 @@ +import assert from 'node:assert/strict'; +import { execFileSync, spawn } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { copyFile, lstat, mkdir, readFile, writeFile } from 'node:fs/promises'; +import https from 'node:https'; +import { isAbsolute, join, resolve } from 'node:path'; +import { parse, parseAllDocuments } from 'yaml'; + +export const reportingActionNames = Object.freeze([ + 'setup-commercekit', + 'ccv2-build', + 'ccv2-deploy', + 'ccv2-build-cleanup', + 'notify', +]); +export const sandboxOrigin = 'https://ccv2.sandbox.commercekit.tools'; +const originalHttpsRequest = https.request.bind(https); +const hex = /^[a-f0-9]{64}$/; +const gitSha = /^[a-f0-9]{40}$/; +export const sha256 = (bytes) => createHash('sha256').update(bytes).digest('hex'); + +export function assertLoopbackOrigin(value) { + const url = new URL(value); + assert.equal(url.protocol, 'https:'); + assert(['localhost', '127.0.0.1', '[::1]'].includes(url.hostname)); + assert.equal(url.username + url.password + url.search + url.hash, ''); + assert.equal(url.pathname, '/'); + assert(/^\d+$/.test(url.port) && Number(url.port) >= 1024 && Number(url.port) <= 65535); + return url.origin; +} + +export function assertReportingManifest(manifest) { + assert.equal(manifest?.schemaVersion, 1); + assert.equal(manifest?.classification, 'registry-installed'); + assert.equal(manifest.contract?.version, '0.0.6'); + assertRegistryTarball(manifest.contract?.registryTarball); + assert(hex.test(manifest.contract?.sha256 ?? '')); + assert(/^sha512-[A-Za-z0-9+/]+=*$/.test(manifest.contract?.integrity ?? '')); + assert.equal(Object.keys(manifest.actions ?? {}).length, reportingActionNames.length); + for (const name of reportingActionNames) { + const action = manifest.actions[name]; + assert(action && isAbsolute(action.sourcePath) && isAbsolute(action.consumerPath)); + assert(gitSha.test(action.sourceSha ?? '') && hex.test(action.sourceHash ?? '')); + assert(hex.test(action.bundleSha256 ?? '')); + } + for (const item of [manifest.contract, manifest.sandbox]) { + assert(item && isAbsolute(item.sourcePath)); + assert(gitSha.test(item.sourceSha ?? '') && hex.test(item.sourceHash ?? '')); + } + assert(isAbsolute(manifest.contract.tarball) && manifest.contract.tarball.endsWith('.tgz')); + return manifest; +} + +export function assertRegistryTarball(value) { + const url = new URL(value); + assert.equal(url.origin, 'https://npm.pkg.github.com'); + assert.equal(url.username + url.password + url.search + url.hash, ''); + assert( + /^\/download\/@commercekit-tools\/notification-contract\/0\.0\.6\/[a-f0-9]{40}$/.test( + url.pathname, + ), + ); + return url.href; +} + +/** pnpm 12 stores package-manager and application graphs as separate YAML documents. */ +export function parseRegistryLock(text) { + const documents = parseAllDocuments(text); + assert(documents.length >= 1 && documents.length <= 2); + assert(documents.every((document) => document.errors.length === 0)); + const graphs = documents.map((document) => document.toJS()); + assert(graphs.every((graph) => graph?.lockfileVersion === '9.0')); + const app = graphs.filter((graph) => + Object.hasOwn( + graph.importers?.['.']?.dependencies ?? {}, + '@commercekit-tools/notification-contract', + ), + ); + assert.equal(app.length, 1, 'Exactly one application dependency graph is required.'); + return app[0]; +} + +/** A frozen normal registry dependency must match the reviewed public artifact. */ +export function assertRegistryInstall(manifest, lock, artifact) { + assert.equal(manifest.private, true); + assert.equal(manifest.dependencies['@commercekit-tools/notification-contract'], '0.0.6'); + const direct = lock.importers?.['.']?.dependencies?.['@commercekit-tools/notification-contract']; + assert.deepEqual(direct, { specifier: '0.0.6', version: '0.0.6' }); + const resolution = lock.packages?.['@commercekit-tools/notification-contract@0.0.6']?.resolution; + assert.equal(resolution?.integrity, artifact.integrity); + assert.equal(assertRegistryTarball(resolution?.tarball), artifact.registryTarball); +} + +function git(cwd, args) { + return execFileSync('git', args, { + cwd, + encoding: 'utf8', + maxBuffer: 4 * 1024 * 1024, + stdio: ['ignore', 'pipe', 'pipe'], + }).trim(); +} +export async function sourceProvenance(directory, { allowUnborn = false } = {}) { + assert(isAbsolute(directory)); + const files = git(directory, ['ls-files', '--cached', '--others', '--exclude-standard', '-z']) + .split('\0') + .filter(Boolean) + .sort(); + assert(files.length > 0 && files.length <= 3000); + const digest = createHash('sha256'); + const runtime = createHash('sha256'); + let total = 0; + for (const file of new Set(files)) { + assert(!isAbsolute(file) && !file.split('/').includes('..')); + const path = join(directory, file); + const stat = await lstat(path); + assert(stat.isFile() && !stat.isSymbolicLink() && stat.size <= 4 * 1024 * 1024); + total += stat.size; + assert(total <= 32 * 1024 * 1024); + const bytes = await readFile(path); + const record = `${file}\0${sha256(bytes)}\n`; + digest.update(record); + if (/^(?:src\/|action\.yml$|tsconfig[^/]*\.json$)/.test(file)) runtime.update(record); + } + const status = git(directory, ['status', '--porcelain=v1']); + const revision = (args) => { + try { + return git(directory, args); + } catch { + assert(allowUnborn); + return 'unborn-private-workspace'; + } + }; + return { + sourceSha: revision(['rev-parse', 'HEAD']), + gitTree: revision(['rev-parse', 'HEAD^{tree}']), + dirty: status !== '', + dirtyFingerprint: sha256(status), + sourceHash: digest.digest('hex'), + runtimeHash: runtime.digest('hex'), + }; +} + +export function parseActionOutputs(text) { + assert(Buffer.byteLength(text) <= 1024 * 1024); + const outputs = {}; + const lines = text.split(/\r?\n/); + for (let index = 0; index < lines.length; index++) { + const line = lines[index]; + if (!line) continue; + const multiline = /^([a-z][a-z0-9-]*)<<(.+)$/.exec(line); + if (multiline) { + const body = []; + while (++index < lines.length && lines[index] !== multiline[2]) body.push(lines[index]); + assert(index < lines.length); + assert(!Object.hasOwn(outputs, multiline[1])); + outputs[multiline[1]] = body.join('\n'); + } else { + const match = /^([a-z][a-z0-9-]*)=(.*)$/.exec(line); + assert(match); + assert(!Object.hasOwn(outputs, match[1])); + outputs[match[1]] = match[2]; + } + } + return outputs; +} + +/** An explicit test transport: public Sandbox paths map only to this local HTTPS server. */ +export function localSandboxFetch(localOrigin, ca, signal) { + const base = assertLoopbackOrigin(localOrigin); + return async (input, init = {}) => { + const source = new URL(typeof input === 'string' || input instanceof URL ? input : input.url); + assert.equal( + source.origin, + sandboxOrigin, + 'Only the fixed Sandbox origin may use local transport.', + ); + assert( + source.pathname.startsWith('/sandbox/v1/') || + source.pathname.startsWith('/v2/') || + source.pathname === '/oauth2/token', + ); + assert.equal(source.username + source.password + source.hash, ''); + const target = new URL(source.pathname + source.search, base); + const signals = [ + AbortSignal.timeout(10000), + ...(signal ? [signal] : []), + ...(init.signal ? [init.signal] : []), + ]; + return await new Promise((resolveResponse, reject) => { + const req = originalHttpsRequest( + target, + { + method: init.method ?? 'GET', + ca, + rejectUnauthorized: true, + headers: Object.fromEntries(new Headers(init.headers).entries()), + signal: AbortSignal.any(signals), + }, + (response) => { + const chunks = []; + let size = 0; + response.on('data', (chunk) => { + size += chunk.length; + if (size > 1024 * 1024) req.destroy(new Error('Local response limit exceeded.')); + else chunks.push(chunk); + }); + response.on('error', reject); + response.on('end', () => { + const status = response.statusCode; + const headers = new Headers(); + for (const [name, value] of Object.entries(response.headers)) + if (value !== undefined) + headers.set(name, Array.isArray(value) ? value.join(', ') : value); + resolveResponse( + new Response([204, 205, 304].includes(status) ? null : Buffer.concat(chunks), { + status, + headers, + }), + ); + }); + }, + ); + req.on('error', reject); + if (init.body !== undefined) { + assert(typeof init.body === 'string' || Buffer.isBuffer(init.body)); + req.write(init.body); + } + req.end(); + }); + }; +} + +export function plainSummary(markdown) { + return markdown + .replace(/\\([\\`*_[\]{}()|!#~])/g, '$1') + .replaceAll('<', '<') + .replaceAll('>', '>') + .replaceAll('&', '&'); +} +export function assertSummary(markdown, status, style, names = [], secrets = []) { + assert(Buffer.byteLength(markdown) > 0 && Buffer.byteLength(markdown) <= 65536); + assert(markdown.startsWith(`## ${style.icon} `)); + assert(markdown.includes(style.label)); + assert(markdown.includes('### Result') && markdown.includes('| Detail | Value |')); + if (names.length) { + assert(markdown.includes('### Inputs') && markdown.includes('| Input | Value |')); + for (const name of names) assert(markdown.includes(name), 'Input name missing from summary.'); + } + for (const secret of secrets.filter(Boolean)) + assert(!markdown.includes(secret), 'Secret leaked in summary.'); + assert(typeof status === 'string'); +} + +export async function actionMetadata(directory) { + const document = parse(await readFile(join(directory, 'action.yml'), 'utf8')); + assert.equal(document.runs.using, 'node24'); + assert.equal(document.runs.main, 'dist/index.js'); + assert(document.inputs && Object.keys(document.inputs).length <= 50); + return document; +} +export function effectiveInputs(metadata, overrides) { + const values = Object.fromEntries( + Object.entries(metadata.inputs).map(([name, input]) => [name, String(input.default ?? '')]), + ); + for (const name of Object.keys(overrides)) assert(Object.hasOwn(values, name)); + return { ...values, ...overrides }; +} + +export async function runReportingBundle({ + action, + directory, + inputs, + mode, + localOrigin, + caFile, + preload, + signal, + mockStatus = 200, +}) { + await mkdir(directory, { mode: 0o700 }); + await copyFile(join(action.consumerPath, 'dist/index.js'), join(directory, 'index.mjs')); + for (const file of ['output', 'summary']) + await writeFile(join(directory, file), '', { mode: 0o600 }); + const env = { + PATH: process.env.PATH, + TZ: 'UTC', + RUNNER_TEMP: directory, + RUNNER_TOOL_CACHE: join(directory, 'tool-cache'), + GITHUB_OUTPUT: join(directory, 'output'), + GITHUB_STEP_SUMMARY: join(directory, 'summary'), + GITHUB_REPOSITORY: 'commercekit-tools/action-integration-tests', + GITHUB_REF: 'refs/heads/main', + GITHUB_RUN_ID: '123', + GITHUB_RUN_ATTEMPT: '1', + GITHUB_SERVER_URL: 'https://github.com', + COMMERCEKIT_REPORTING_MODE: mode, + COMMERCEKIT_REPORTING_LOCAL_ORIGIN: localOrigin, + COMMERCEKIT_REPORTING_CA_FILE: caFile, + COMMERCEKIT_REPORTING_MOCK_STATUS: String(mockStatus), + NODE_EXTRA_CA_CERTS: caFile, + }; + for (const [name, value] of Object.entries(inputs)) env[`INPUT_${name.toUpperCase()}`] = value; + const child = spawn(process.execPath, ['--import', preload, join(directory, 'index.mjs')], { + cwd: directory, + env, + stdio: ['ignore', 'pipe', 'pipe'], + signal, + }); + // Mask commands may contain generated credentials. Drain without retaining stdout/stderr. + child.stdout.resume(); + child.stderr.resume(); + const timer = setTimeout(() => child.kill('SIGKILL'), 60000); + let code; + try { + code = await new Promise((resolveExit, reject) => { + child.once('error', reject); + child.once('exit', resolveExit); + }); + } finally { + clearTimeout(timer); + if (child.exitCode === null) child.kill('SIGKILL'); + } + assert(Number.isInteger(code)); + assert((await lstat(join(directory, 'output'))).size <= 1024 * 1024); + assert((await lstat(join(directory, 'summary'))).size <= 65536); + const outputs = parseActionOutputs(await readFile(join(directory, 'output'), 'utf8')); + const summary = await readFile(join(directory, 'summary'), 'utf8'); + const network = JSON.parse(await readFile(join(directory, 'network.json'), 'utf8')); + assert.deepEqual(Object.keys(network).sort(), [ + 'attempted', + 'blocked', + 'mockProvider', + 'sandbox', + ]); + for (const count of Object.values(network)) + assert(Number.isSafeInteger(count) && count >= 0 && count <= 10000); + assert.equal(network.attempted, network.blocked + network.mockProvider + network.sandbox); + let payload; + if (mode === 'provider-mock' && network.mockProvider > 0) { + assert((await lstat(join(directory, 'payload.json'))).size <= 65536); + payload = JSON.parse(await readFile(join(directory, 'payload.json'), 'utf8')); + } + return { outputs, summary, network, code, ...(payload ? { payload } : {}) }; +} + +export function resolveReportingPath(value) { + assert(typeof value === 'string' && isAbsolute(value)); + return resolve(value); +} diff --git a/scripts/runtime.mjs b/scripts/runtime.mjs index 0e5af5c..a98762d 100644 --- a/scripts/runtime.mjs +++ b/scripts/runtime.mjs @@ -3,6 +3,7 @@ import { chmod, lstat, mkdir, readFile, rm, writeFile } from 'node:fs/promises'; import { isAbsolute, join } from 'node:path'; import { TechnicalUserTokenManager, createCcv2Client } from '@commercekit-tools/ccv2-client'; import { parseNotificationEventJson } from '@commercekit-tools/notification-contract'; +import { assertReportedInputs } from './reporting-inputs.mjs'; import { approvedFixtureBuildCode, createApprovedBuildFixture, @@ -212,6 +213,7 @@ export function assertActionRecord({ scenarioId, phase, outputs, outcome, run }) assert.equal(outputs['poll-count'], String(result.pollCount)); assert.equal(outputs['build-code'], result.buildCode ?? ''); const build = phase === 'build'; + assertReportedInputs(build ? 'ccv2-build' : 'ccv2-deploy', result, event); assert.equal(event.source.component, build ? 'ccv2-build' : 'ccv2-deploy'); assert.equal( event.eventType, @@ -381,7 +383,18 @@ export function assertCleanupRecord({ outputs, outcome, run, state }) { indexes.map(cleanupBuildCode), ); assert.equal(event.eventType, 'ccv2.build-cleanup.completed'); - assert.equal(event.status, 'failure'); + assert.equal(event.status, 'warning'); + assertReportedInputs('ccv2-build-cleanup', result, event); + assert.equal(event.data.protectedCount, result.counts.protected); + assert.equal( + event.data.blockedCount, + result.decisions.filter((decision) => decision.disposition === 'blocked').length, + ); + assert(Array.isArray(event.data.issues)); + assert.deepEqual( + event.data.issues.map((issue) => issue.code), + ['eligibility-unverified', 'protection-unverified'], + ); assert.equal(event.source.component, 'ccv2-build-cleanup'); assert.equal(event.occurredAt, result.runStartedAt); assert.equal(event.data.mode, 'dry-run'); diff --git a/scripts/scenarios.mjs b/scripts/scenarios.mjs index eb55b8c..ead4cd5 100644 --- a/scripts/scenarios.mjs +++ b/scripts/scenarios.mjs @@ -54,6 +54,13 @@ export const scenarioIds = Object.freeze(Object.keys(definitions)); export const providers = Object.freeze(['none', 'slack', 'teams-workflow']); export const phases = Object.freeze(['build', 'initial', 'followup', 'final']); export const cleanupScenarioId = 'cleanup-dry-run'; +/** Opt-in local reporting matrix; never added to the hosted suite plans. */ +export const reportingScenarioIds = Object.freeze([ + 'rolling-success', + 'build-failure', + 'green-manual', + cleanupScenarioId, +]); export const cleanupPolicy = Object.freeze({ retentionDays: 30, keepLatest: 10, maxDeletions: 20 }); export const cleanupBuildCode = (index) => `cleanup-${String(index).padStart(3, '0')}`; diff --git a/scripts/validate-reporting.mjs b/scripts/validate-reporting.mjs new file mode 100644 index 0000000..e855eab --- /dev/null +++ b/scripts/validate-reporting.mjs @@ -0,0 +1,788 @@ +/** Opt-in local registry-installed integration. Never dispatches a workflow or sends provider requests. */ +import assert from 'node:assert/strict'; +import { execFileSync, spawn } from 'node:child_process'; +import { createHash, generateKeyPairSync } from 'node:crypto'; +import { lstat, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; +import { tmpdir } from 'node:os'; +import { dirname, join, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import * as contract from '@commercekit-tools/notification-contract'; +import { createRequire } from 'node:module'; +const requirePublic = createRequire(import.meta.url); +const metadata = requirePublic('@commercekit-tools/notification-contract/package.json'); +const publicSchema = requirePublic('@commercekit-tools/notification-contract/schema'); +import { + actionMetadata, + assertReportingManifest, + assertRegistryInstall, + parseRegistryLock, + assertLoopbackOrigin, + assertSummary, + reportingActionNames, + effectiveInputs, + localSandboxFetch, + plainSummary, + resolveReportingPath, + runReportingBundle, + sandboxOrigin, + sha256, + sourceProvenance, +} from './reporting-support.mjs'; +import { + assertActionRecord, + assertCleanupRecord, + controlRequest, + nextDeployInputs, + runCommand, + subscription, +} from './runtime.mjs'; +import { getScenario, reportingScenarioIds } from './scenarios.mjs'; + +const root = resolve(fileURLToPath(new URL('..', import.meta.url))); +const maximumRuntimeMs = 270000; +const payloadText = (value) => + typeof value === 'string' + ? plainSummary(value) + : value && typeof value === 'object' + ? Object.values(value).map(payloadText).join(' ') + : ''; + +function testCore() { + const outputs = {}, + exported = {}, + masked = []; + return { + outputs, + exported, + masked, + setOutput: (name, value) => { + outputs[name] = value; + }, + exportVariable: (name, value) => { + exported[name] = value; + }, + setSecret: (value) => { + masked.push(value); + }, + info: () => {}, + summary: { addRaw: () => ({ write: async () => {} }) }, + }; +} +function scenarioEnvironment(directory, scenario) { + return { + STATE_DIRECTORY: directory, + SCENARIO: scenario, + PROVIDER: 'none', + CONFIRMATION: 'RUN-COMMERCEKIT-SANDBOX-TESTS', + GITHUB_EVENT_NAME: 'workflow_dispatch', + GITHUB_REPOSITORY: 'commercekit-tools/action-integration-tests', + GITHUB_REF: 'refs/heads/main', + GITHUB_RUN_ID: '123', + GITHUB_RUN_ATTEMPT: '1', + }; +} +function mutationCounts(state) { + return Object.fromEntries( + Object.entries(state.faultCounters).filter(([name]) => /^(?:create|delete|update)/.test(name)), + ); +} +function eventContext(event) { + return ( + event.data.inputContext ?? + (event.data.inputs + ? { + inputs: event.data.inputs, + inputsValidated: event.data.inputsValidated, + inputsTruncated: event.data.inputsTruncated, + } + : undefined) + ); +} +function assertProducerContext(event, markdown, definition, secrets) { + const context = eventContext(event); + assert( + context && + typeof context.inputsValidated === 'boolean' && + typeof context.inputsTruncated === 'boolean', + ); + assert.deepEqual(Object.keys(context.inputs).sort(), Object.keys(definition.inputs).sort()); + for (const name of Object.keys(definition.inputs)) + if (contract.isConfidentialInputName(name)) assert.equal(context.inputs[name], '[REDACTED]'); + const text = JSON.stringify(event); + assert.equal(contract.redactJwtLikeTokens(text), text); + assert.equal(contract.redactJwtLikeTokens(markdown), markdown); + for (const secret of secrets.filter(Boolean)) + assert(!text.includes(secret), 'Credential leaked in event.'); + assertSummary( + markdown, + event.status, + contract.getNotificationStyle(event.status), + Object.keys(definition.inputs), + secrets, + ); + if (event.data.error) { + assert(markdown.includes('### Issues')); + if (event.data.error.code) assert(plainSummary(markdown).includes(event.data.error.code)); + } + for (const issue of event.data.issues ?? []) { + assert(markdown.includes('### Issues')); + if (issue.code) assert(plainSummary(markdown).includes(issue.code)); + } + return context; +} + +async function verifyArtifacts(manifest) { + assertReportingManifest(manifest); + assert.equal(process.versions.node.split('.')[0], '24'); + assert.equal(metadata.version, '0.0.6'); + const own = JSON.parse(await readFile(join(root, 'package.json'), 'utf8')); + assertRegistryInstall( + own, + parseRegistryLock(await readFile(join(root, 'pnpm-lock.yaml'), 'utf8')), + manifest.contract, + ); + const tarballStat = await lstat(manifest.contract.tarball); + assert(tarballStat.isFile() && !tarballStat.isSymbolicLink() && tarballStat.size <= 1024 * 1024); + const bytes = await readFile(manifest.contract.tarball); + assert.equal(sha256(bytes), manifest.contract.sha256); + assert.equal( + `sha512-${createHash('sha512').update(bytes).digest('base64')}`, + manifest.contract.integrity, + ); + for (const name of [ + 'parseNotificationEventJson', + 'createBuildCleanupEvent', + 'createSetupEvent', + 'getNotificationStyle', + 'renderActionSummary', + 'captureActionInputs', + 'createActionInputContext', + 'isConfidentialInputName', + ]) + assert.equal(typeof contract[name], 'function', 'Required public contract export missing.'); + assert(publicSchema.properties.eventType.enum.includes('commercekit.setup.completed')); + const installed = dirname( + fileURLToPath(import.meta.resolve('@commercekit-tools/notification-contract/package.json')), + ); + const entries = execFileSync('tar', ['-tzf', manifest.contract.tarball], { + encoding: 'utf8', + maxBuffer: 65536, + }) + .trim() + .split('\n'); + assert(entries.length > 0 && entries.length <= 100); + for (const entry of entries) { + assert( + entry.startsWith('package/') && !entry.split('/').includes('..') && !entry.endsWith('/'), + ); + const packed = execFileSync('tar', ['-xOf', manifest.contract.tarball, entry], { + maxBuffer: 1024 * 1024, + }); + assert((await readFile(join(installed, entry.slice('package/'.length)))).equals(packed)); + } + const sources = {}; + for (const [name, item] of Object.entries({ + contract: manifest.contract, + sandbox: manifest.sandbox, + ...manifest.actions, + })) { + const proof = await sourceProvenance(item.sourcePath); + assert.equal(proof.sourceSha, item.sourceSha); + assert.equal(proof.sourceHash, item.sourceHash); + sources[name] = proof; + if (manifest.actions[name]) { + const consumerProof = await sourceProvenance(item.consumerPath, { allowUnborn: true }); + assert.equal( + consumerProof.runtimeHash, + proof.runtimeHash, + 'Reporting runtime source differs from reviewed source.', + ); + assert.equal( + sha256(await readFile(join(item.consumerPath, 'dist/index.js'))), + item.bundleSha256, + ); + sources[name].bundleSha256 = item.bundleSha256; + sources[name].consumerRuntimeHash = consumerProof.runtimeHash; + const consumer = JSON.parse(await readFile(join(item.consumerPath, 'package.json'), 'utf8')); + assertRegistryInstall( + consumer, + parseRegistryLock(await readFile(join(item.consumerPath, 'pnpm-lock.yaml'), 'utf8')), + manifest.contract, + ); + assert.deepEqual( + consumer.scripts, + JSON.parse(await readFile(join(item.sourcePath, 'package.json'), 'utf8')).scripts, + ); + } + } + return sources; +} + +async function stopLocalSandbox(child) { + const kill = (signal) => { + try { + if (process.platform !== 'win32' && child.pid) process.kill(-child.pid, signal); + else child.kill(signal); + } catch { + /* Owned local process group may already have exited. */ + } + }; + kill('SIGTERM'); + await Promise.race([ + new Promise((done) => child.once('exit', done)), + new Promise((done) => setTimeout(done, 2000)), + ]); + kill('SIGKILL'); +} + +async function startLocalSandbox(manifest, temporary, localOrigin, signal) { + const url = new URL(assertLoopbackOrigin(localOrigin)); + const cert = join(temporary, 'cert.pem'), + key = join(temporary, 'key.pem'); + execFileSync( + 'openssl', + [ + 'req', + '-x509', + '-newkey', + 'rsa:2048', + '-nodes', + '-keyout', + key, + '-out', + cert, + '-days', + '1', + '-subj', + '/CN=localhost', + '-addext', + 'subjectAltName=DNS:localhost,IP:127.0.0.1', + ], + { stdio: 'ignore' }, + ); + const pair = generateKeyPairSync('rsa', { modulusLength: 2048 }); + const vars = { + MOCK_JWT_ISSUER: sandboxOrigin, + MOCK_JWT_PRIVATE_KEY: pair.privateKey.export({ format: 'pem', type: 'pkcs8' }), + MOCK_JWT_PUBLIC_JWK: JSON.stringify(pair.publicKey.export({ format: 'jwk' })), + MOCK_JWT_KID: 'reporting-local-reporting', + RUN_TOKEN_SIGNING_KEY: 'synthetic-reporting-reporting-local-only-signing-key', + }; + const envFile = join(temporary, 'sandbox.env'); + await writeFile( + envFile, + Object.entries(vars) + .map( + ([name, value]) => + `${name}=${name === 'MOCK_JWT_PUBLIC_JWK' ? "'" + value + "'" : JSON.stringify(value)}`, + ) + .join('\n'), + { mode: 0o600 }, + ); + const app = join(manifest.sandbox.sourcePath, 'apps/ccv2'); + const child = spawn( + process.execPath, + [ + join(app, 'node_modules/wrangler/bin/wrangler.js'), + 'dev', + '--local', + '--ip', + '127.0.0.1', + '--port', + url.port, + '--inspector-port', + '0', + '--local-protocol', + 'https', + '--https-key-path', + key, + '--https-cert-path', + cert, + '--env-file', + envFile, + '--persist-to', + join(temporary, 'sandbox-state'), + '--show-interactive-dev-session=false', + ], + { + cwd: app, + env: { + PATH: process.env.PATH, + HOME: process.env.HOME, + WRANGLER_LOG_PATH: join(temporary, 'wrangler.log'), + WRANGLER_SEND_METRICS: 'false', + }, + stdio: ['ignore', 'pipe', 'pipe'], + detached: process.platform !== 'win32', + }, + ); + child.stdout.resume(); + child.stderr.resume(); + const fetcher = localSandboxFetch(localOrigin, await readFile(cert), signal); + try { + for (let attempt = 0; attempt < 120; attempt++) { + signal.throwIfAborted(); + assert(child.exitCode === null, 'Local worker exited during startup.'); + try { + if ((await fetcher(`${sandboxOrigin}/sandbox/v1/health`)).status === 200) + return { child, cert, fetcher }; + } catch { + /* bounded local startup */ + } + await new Promise((done) => setTimeout(done, 250)); + } + throw new Error('Local Sandbox did not become ready.'); + } catch (error) { + await stopLocalSandbox(child); + throw error; + } +} + +export async function validateReporting(manifest, localOrigin) { + assertLoopbackOrigin(localOrigin); // Validate before artifact reads, network, or subprocesses. + const sources = await verifyArtifacts(manifest); + const harnessSource = await sourceProvenance(root, { allowUnborn: true }); + const definitions = Object.fromEntries( + await Promise.all( + reportingActionNames.map(async (name) => [ + name, + await actionMetadata(manifest.actions[name].sourcePath), + ]), + ), + ); + const started = Date.now(); + const temporary = await mkdtemp(join(tmpdir(), 'commercekit-reporting-reporting-')); + const cancellation = new AbortController(); + const timer = setTimeout(() => cancellation.abort(), maximumRuntimeMs); + const cancel = () => cancellation.abort(); + process.once('SIGINT', cancel); + process.once('SIGTERM', cancel); + const evidence = { + schemaVersion: 1, + classification: 'registry-installed', + outcome: 'FAIL', + sources, + harnessSource, + harnessCode: Object.fromEntries( + await Promise.all( + [ + 'validate-reporting.mjs', + 'reporting-support.mjs', + 'reporting-fetch-preload.mjs', + 'reporting-inputs.mjs', + 'scenarios.mjs', + 'runtime.mjs', + ].map(async (file) => [file, sha256(await readFile(join(root, 'scripts', file)))]), + ), + ), + adoptedActionMetadataSha256: sha256(await readFile(join(root, 'action-inputs.json'))), + contract: { + version: metadata.version, + sha256: manifest.contract.sha256, + integrity: manifest.contract.integrity, + }, + scenarios: [], + localOnly: true, + providerRequestsMocked: true, + hostedDispatches: 0, + realSapCalls: 0, + validatedRunsCreated: 0, + validatedRunsRemoved: 0, + }; + let server, active; + let stage = 'startup'; + const preload = join(root, 'scripts/reporting-fetch-preload.mjs'); + const capturedEvents = []; + let sequence = 0; + const action = async (name, inputs, mode = 'sandbox', mockStatus = 200) => { + cancellation.signal.throwIfAborted(); + const observed = await runReportingBundle({ + action: manifest.actions[name], + directory: join(temporary, `action-${sequence++}`), + inputs: effectiveInputs(definitions[name], inputs), + mode, + localOrigin, + caFile: server.cert, + preload, + signal: cancellation.signal, + mockStatus, + }); + evidence.lastChild = { + action: name, + exitCode: observed.code, + network: observed.network, + summaryBytes: Buffer.byteLength(observed.summary), + }; + return observed; + }; + const cleanupActive = async () => { + if (!active) return; + const fetcher = localSandboxFetch( + localOrigin, + await readFile(server.cert), + AbortSignal.timeout(15000), + ); + await runCommand('cleanup', active.env, active.core, { fetcher }); + if (active.validated) evidence.validatedRunsRemoved++; + active = undefined; + }; + const readState = async (run) => + await controlRequest(`/sandbox/v1/runs/${run.runId}/state`, { + token: run.controlToken, + fetcher: server.fetcher, + }); + try { + server = await startLocalSandbox(manifest, temporary, localOrigin, cancellation.signal); + for (const scenarioId of reportingScenarioIds) { + stage = scenarioId; + const env = scenarioEnvironment(join(temporary, `run-${scenarioId}`), scenarioId); + const core = testCore(); + active = { env, core }; + try { + stage = `${scenarioId}:prepare`; + await runCommand('prepare', env, core, { fetcher: server.fetcher }); + const run = JSON.parse(await readFile(join(env.STATE_DIRECTORY, 'run.json'), 'utf8')); + active.validated = true; + evidence.validatedRunsCreated++; + const knownSecrets = [run.controlToken, ...Object.values(run.credentials)]; + const authentication = { + 'token-endpoint': run.credentials.tokenUrl, + 'client-id': run.credentials.clientId, + 'client-secret': run.credentials.clientSecret, + resource: run.credentials.resource, + 'subscription-code': subscription, + 'api-base-url': sandboxOrigin, + }; + const before = await readState(run); + if (scenarioId === 'cleanup-dry-run') { + const cleanupInputs = { + ...authentication, + 'application-code': 'commerce', + 'retention-days': '30', + 'keep-latest': '10', + 'max-deletions': '20', + 'exclude-build-codes': 'cleanup-006', + 'dry-run': 'true', + 'timeout-minutes': '2', + 'continue-on-delete-error': 'false', + }; + let first; + for (const attempt of ['first', 'repeat']) { + stage = `${scenarioId}:${attempt}:execute`; + const observed = await action('ccv2-build-cleanup', cleanupInputs); + stage = `${scenarioId}:${attempt}:assert`; + const state = await readState(run); + const record = assertCleanupRecord({ + outputs: observed.outputs, + outcome: observed.code === 0 ? 'success' : 'failure', + run, + state, + }); + assert.deepEqual(record.event.data.inputs, record.result.inputs); + assertProducerContext( + record.event, + observed.summary, + definitions['ccv2-build-cleanup'], + knownSecrets, + ); + assert.equal(record.event.data.protectedCount, record.result.counts.protected); + assert.equal( + record.event.data.blockedCount, + record.result.decisions.filter((decision) => decision.disposition === 'blocked') + .length, + ); + assert.deepEqual(mutationCounts(state), mutationCounts(before)); + assert.equal(observed.network.blocked, 0); + if (first) { + assert.deepEqual(record.result.counts, first.result.counts); + assert.deepEqual(record.result.decisions, first.result.decisions); + } else { + first = record; + capturedEvents.push({ + event: record.event, + names: Object.keys(definitions['ccv2-build-cleanup'].inputs), + secrets: knownSecrets, + }); + } + evidence.scenarios.push({ + action: 'ccv2-build-cleanup', + scenario: attempt, + status: record.event.status, + targetMutations: 0, + summarySha256: sha256(observed.summary), + }); + } + } else { + stage = `${scenarioId}:build-execute`; + const build = await action('ccv2-build', { + ...authentication, + branch: 'main', + 'build-name': core.outputs['build-name'], + 'application-code': 'commerce', + 'poll-interval-seconds': '10', + 'timeout-minutes': '1', + }); + stage = `${scenarioId}:build-assert`; + const record = assertActionRecord({ + scenarioId, + phase: 'build', + outputs: build.outputs, + outcome: build.code === 0 ? 'success' : 'failure', + run, + }); + assert.deepEqual(record.event.data.inputs, record.result.inputs); + assertProducerContext( + record.event, + build.summary, + definitions['ccv2-build'], + knownSecrets, + ); + assert.equal(build.network.blocked, 0); + capturedEvents.push({ + event: record.event, + names: Object.keys(definitions['ccv2-build'].inputs), + secrets: knownSecrets, + }); + evidence.scenarios.push({ + action: 'ccv2-build', + scenario: scenarioId, + status: record.event.status, + summarySha256: sha256(build.summary), + }); + const records = { build: record }; + if (getScenario(scenarioId).deploy) { + const planned = nextDeployInputs(scenarioId, 'initial', records); + delete planned.enabled; + stage = `${scenarioId}:deploy-execute`; + const deploy = await action('ccv2-deploy', { + ...authentication, + ...planned, + 'poll-interval-seconds': '10', + 'timeout-minutes': '1', + }); + stage = `${scenarioId}:deploy-assert`; + records.initial = assertActionRecord({ + scenarioId, + phase: 'initial', + outputs: deploy.outputs, + outcome: deploy.code === 0 ? 'success' : 'failure', + run, + }); + assert.deepEqual(records.initial.event.data.inputs, records.initial.result.inputs); + assertProducerContext( + records.initial.event, + deploy.summary, + definitions['ccv2-deploy'], + knownSecrets, + ); + assert.equal(deploy.network.blocked, 0); + capturedEvents.push({ + event: records.initial.event, + names: Object.keys(definitions['ccv2-deploy'].inputs), + secrets: knownSecrets, + }); + evidence.scenarios.push({ + action: 'ccv2-deploy', + scenario: scenarioId, + status: records.initial.event.status, + summarySha256: sha256(deploy.summary), + }); + } else assert.equal(nextDeployInputs(scenarioId, 'initial', records).enabled, 'false'); + stage = `${scenarioId}:mutation-counts`; + const after = await readState(run); + assert.equal(after.counts.builds, 1); + assert.equal(after.counts.deployments, getScenario(scenarioId).deploy ? 1 : 0); + assert.equal( + Object.entries(after.faultCounters) + .filter(([name]) => name.startsWith('createBuild:')) + .reduce((sum, [, count]) => sum + count, 0), + 1, + ); + assert.equal( + Object.entries(after.faultCounters) + .filter(([name]) => name.startsWith('createDeployment:')) + .reduce((sum, [, count]) => sum + count, 0), + getScenario(scenarioId).deploy ? 1 : 0, + ); + } + } finally { + await cleanupActive(); + } + } + stage = 'setup-invalid-input'; + const setup = await action( + 'setup-commercekit', + { version: 'invalid reporting version' }, + 'deny', + ); + assert.equal(setup.code, 1); + assert.equal(setup.network.attempted, 0); + const setupEvent = contract.parseNotificationEventJson(setup.outputs['notification-event']); + assert.equal(setupEvent.status, 'failure'); + assertProducerContext(setupEvent, setup.summary, definitions['setup-commercekit'], []); + capturedEvents.push({ + event: setupEvent, + names: Object.keys(definitions['setup-commercekit'].inputs), + secrets: [], + }); + evidence.scenarios.push({ + action: 'setup-commercekit', + scenario: 'invalid-input', + status: setupEvent.status, + networkCalls: 0, + summarySha256: sha256(setup.summary), + }); + for (const { event, names, secrets } of capturedEvents) + for (const provider of ['slack', 'teams-workflow']) { + stage = `notify-${provider}-${event.status}`; + const webhook = + provider === 'slack' + ? 'https://' + 'hooks.slack.com/services/reporting/reporting/reporting' + : 'https://provider.example.test/reporting'; + const delivery = await action( + 'notify', + { + provider, + 'event-json': JSON.stringify(event), + 'webhook-url': webhook, + 'fail-on-notification-error': 'true', + }, + 'provider-mock', + ); + assert.equal(delivery.code, 0); + assert.equal(delivery.outputs.delivered, 'true'); + assert.equal(delivery.outputs.status, event.status); + assert.equal(delivery.network.mockProvider, 1); + assert.equal(delivery.network.blocked, 0); + const payload = JSON.stringify(delivery.payload); + assert.equal(contract.redactJwtLikeTokens(payload), payload); + const style = contract.getNotificationStyle(event.status); + assert(payload.includes(style.icon) && payload.includes(style.label)); + for (const name of names) + assert(payload.includes(name), 'Producer input missing from provider payload.'); + assert(!payload.includes(webhook)); + for (const secret of secrets.filter(Boolean)) + assert(!payload.includes(secret), 'Credential leaked in provider payload.'); + for (const issue of [ + ...(event.data.error ? [event.data.error] : []), + ...(event.data.issues ?? []), + ]) { + const displayed = payloadText(delivery.payload); + if (issue.code) assert(displayed.includes(issue.code)); + assert(displayed.includes(issue.message.slice(0, 80))); + } + if (provider === 'teams-workflow') assert(Buffer.byteLength(payload) <= 27 * 1024); + else + assert( + delivery.payload.blocks.length + delivery.payload.attachments[0].blocks.length <= 50, + ); + assertSummary( + delivery.summary, + 'success', + contract.getNotificationStyle('success'), + Object.keys(definitions.notify.inputs), + [webhook], + ); + if (provider === 'slack') assert.equal(delivery.payload.attachments[0].color, style.accent); + else + assert.equal( + delivery.payload.attachments[0].content.body[0].style, + { + success: 'good', + warning: 'warning', + 'action-required': 'warning', + failure: 'attention', + 'internal-error': 'attention', + }[event.status], + ); + evidence.scenarios.push({ + action: 'notify', + provider, + sourceStatus: event.status, + delivered: true, + mockedRequests: 1, + summarySha256: sha256(delivery.summary), + }); + } + for (const failOn of ['false', 'true']) { + stage = `notify-delivery-${failOn === 'true' ? 'failure' : 'warning'}`; + const event = capturedEvents[0].event; + const delivery = await action( + 'notify', + { + provider: 'teams-workflow', + 'event-json': JSON.stringify(event), + 'webhook-url': 'https://provider.example.test/reporting', + 'fail-on-notification-error': failOn, + }, + 'provider-mock', + 400, + ); + assert.equal(delivery.code, failOn === 'true' ? 1 : 0); + assert.equal(delivery.outputs.delivered, 'false'); + assert.equal(delivery.network.mockProvider, 1); + const status = failOn === 'true' ? 'failure' : 'warning'; + assertSummary( + delivery.summary, + status, + contract.getNotificationStyle(status), + Object.keys(definitions.notify.inputs), + ); + assert(delivery.summary.includes('### Issues')); + evidence.scenarios.push({ + action: 'notify', + scenario: 'delivery-error', + status, + mockedRequests: 1, + summarySha256: sha256(delivery.summary), + }); + } + assert.equal(evidence.validatedRunsCreated, 4); + assert.equal(evidence.validatedRunsRemoved, 4); + evidence.outcome = 'PASS'; + } catch { + evidence.failureStage = stage; + } finally { + clearTimeout(timer); + process.removeListener('SIGINT', cancel); + process.removeListener('SIGTERM', cancel); + try { + await cleanupActive(); + } catch { + evidence.outcome = 'FAIL'; + evidence.cleanupFailed = true; + } + if (server?.child) await stopLocalSandbox(server.child); + await rm(temporary, { recursive: true, force: true }); + } + evidence.durationMs = Date.now() - started; + const reportDirectory = await mkdtemp(join(tmpdir(), 'commercekit-reporting-evidence-')); + const report = join(reportDirectory, 'validation.json'); + await writeFile(report, JSON.stringify(evidence, null, 2) + '\n', { mode: 0o600 }); + console.log( + `${evidence.outcome}: local registry-installed ecosystem validation. Evidence: ${report}`, + ); + assert.equal( + evidence.outcome, + 'PASS', + `Reporting validation failed at ${evidence.failureStage ?? 'cleanup'}.`, + ); + return evidence; +} + +if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) { + try { + const path = resolveReportingPath(process.env.REPORTING_MANIFEST); + assert((await lstat(path)).size <= 65536); + const manifest = JSON.parse(await readFile(path, 'utf8')); + await validateReporting( + manifest, + process.env.REPORTING_LOCAL_ORIGIN ?? 'https://localhost:18987', + ); + } catch { + console.error( + 'Registry reporting validation failed. No raw Action output, provider response or credentials are logged.', + ); + process.exitCode = 1; + } +} diff --git a/tests/approved-runtime.test.mjs b/tests/approved-runtime.test.mjs index 617b8c3..fcb92d4 100644 --- a/tests/approved-runtime.test.mjs +++ b/tests/approved-runtime.test.mjs @@ -8,6 +8,7 @@ import { createDeploymentEvent, parseNotificationEventJson, } from '@commercekit-tools/notification-contract'; +import { fixtureInputs } from './reporting-fixtures.mjs'; import { origin, runCommand, subscription } from '../scripts/runtime.mjs'; const sourceBuildCode = '20261114.7'; @@ -75,6 +76,7 @@ function buildOutputs(code = sourceBuildCode) { pollCount: 1, buildCode: code, buildStatus: 'SUCCESS', + ...fixtureInputs('ccv2-build', syntheticRun('f')), }; return { 'result-json': JSON.stringify(result), @@ -99,6 +101,7 @@ function deployOutputs(code = fixtureBuildCode) { originalDeploymentCode: '700007', deploymentStatus: 'DEPLOYED', actionRequired: false, + ...fixtureInputs('ccv2-deploy', syntheticRun('f')), }; return { 'result-json': JSON.stringify(result), diff --git a/tests/cleanup-runtime.test.mjs b/tests/cleanup-runtime.test.mjs index 183847e..b10b7c9 100644 --- a/tests/cleanup-runtime.test.mjs +++ b/tests/cleanup-runtime.test.mjs @@ -8,6 +8,7 @@ import { createBuildCleanupEvent, parseNotificationEventJson, } from '@commercekit-tools/notification-contract'; +import { fixtureInputs } from './reporting-fixtures.mjs'; import { cleanupScenarioId, getCleanupExpectations, @@ -137,15 +138,23 @@ function producerRecord() { disposition: protectedIndexes.has(index) ? 'protected' : 'blocked', })), truncation: { omittedDecisions: 0 }, + ...fixtureInputs('ccv2-build-cleanup', run), }; const event = createBuildCleanupEvent({ - status: 'failure', + status: 'warning', occurredAt: result.runStartedAt, env: { GITHUB_REPOSITORY: 'commercekit-tools/action-integration-tests', GITHUB_REF: 'refs/heads/main', }, data: { + ...fixtureInputs('ccv2-build-cleanup', run), + protectedCount: 13, + blockedCount: 92, + issues: [ + { code: 'eligibility-unverified', message: 'Eligibility evidence is unavailable.' }, + { code: 'protection-unverified', message: 'Protection evidence is incomplete.' }, + ], mode: 'dry-run', subscriptionCode: subscription, applicationCode: 'commerce', @@ -232,14 +241,14 @@ test('cleanup catalog is isolated, multipage, mixed and leaves existing suites u }); test('cleanup producer uses actual published shared factory/parser with accurate blocked dry-run counts', () => { - assert.equal(metadata.version, '0.0.4'); + assert.equal(metadata.version, '0.0.6'); const record = producerRecord(); const actual = assertCleanupRecord(record); assert.equal(actual.targetApiMutationCount, 0); assert.equal(actual.event.eventType, 'ccv2.build-cleanup.completed'); assert.equal(actual.result.counts.scanned, 105); assert.equal(actual.result.counts.skipped, 105); - assert.equal(parseNotificationEventJson(record.outputs['notification-event']).status, 'failure'); + assert.equal(parseNotificationEventJson(record.outputs['notification-event']).status, 'warning'); }); test('shared lifecycle seeds only isolated control plane, validates repeat output, masks secrets and cleans private state', async () => { @@ -524,3 +533,34 @@ test('cleanup control whitelist permits only the supported run-scoped fixture pa }), ); }); + +test('current blocked dry-run requires warning, complete input context and accurate protection issues/counts', () => { + for (const mutate of [ + (event) => { + event.status = 'failure'; + }, + (event) => { + event.data.protectedCount = 14; + }, + (event) => { + event.data.blockedCount = 91; + }, + (event) => { + delete event.data.issues; + }, + (event) => { + event.data.issues[0].code = 'unexpected'; + }, + (event) => { + delete event.data.inputs; + }, + (event) => { + event.data.inputsValidated = false; + }, + ]) { + const record = producerRecord(); + mutate(record.event); + record.outputs['notification-event'] = JSON.stringify(record.event); + assert.throws(() => assertCleanupRecord(record)); + } +}); diff --git a/tests/reporting-fixtures.mjs b/tests/reporting-fixtures.mjs new file mode 100644 index 0000000..d87f320 --- /dev/null +++ b/tests/reporting-fixtures.mjs @@ -0,0 +1,23 @@ +import { createActionInputContext } from '@commercekit-tools/notification-contract'; +import { actionInputNames } from '../scripts/reporting-inputs.mjs'; + +/** Fixture display context uses the actual shared display-context/redaction factory. */ +export function fixtureInputs(name, run, values = {}) { + const definitions = actionInputNames(name).map((input) => ({ name: input })); + const raw = Object.fromEntries(definitions.map(({ name: input }) => [input, ''])); + Object.assign( + raw, + { + 'token-endpoint': run.credentials.tokenUrl, + 'client-id': run.credentials.clientId, + 'client-secret': run.credentials.clientSecret, + resource: run.credentials.resource, + }, + values, + ); + return createActionInputContext(definitions, raw, { + validated: true, + effective: raw, + secrets: Object.values(run.credentials), + }); +} diff --git a/tests/reporting.test.mjs b/tests/reporting.test.mjs new file mode 100644 index 0000000..03ca1cf --- /dev/null +++ b/tests/reporting.test.mjs @@ -0,0 +1,380 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { execFileSync } from 'node:child_process'; +import { mkdtemp, readFile, rm, writeFile } from 'node:fs/promises'; +import { join } from 'node:path'; +import { tmpdir } from 'node:os'; +import { + assertReportingManifest, + assertRegistryInstall, + parseRegistryLock, + assertLoopbackOrigin, + assertSummary, + reportingActionNames, + effectiveInputs, + parseActionOutputs, + plainSummary, + sha256, + sourceProvenance, +} from '../scripts/reporting-support.mjs'; +import { validateReporting } from '../scripts/validate-reporting.mjs'; + +import { createBuildEvent } from '@commercekit-tools/notification-contract'; +import { assertReportedInputs, actionInputNames } from '../scripts/reporting-inputs.mjs'; +import { fixtureInputs } from './reporting-fixtures.mjs'; + +function manifest() { + const source = { + sourcePath: join(tmpdir(), 'source'), + sourceSha: 'a'.repeat(40), + sourceHash: 'b'.repeat(64), + }; + return { + schemaVersion: 1, + classification: 'registry-installed', + contract: { + ...source, + version: '0.0.6', + registryTarball: + 'https://npm.pkg.github.com/download/@commercekit-tools/notification-contract/0.0.6/' + + 'a'.repeat(40), + tarball: join(tmpdir(), 'contract.tgz'), + sha256: 'c'.repeat(64), + integrity: 'sha512-' + 'YQ==', + }, + sandbox: { ...source }, + actions: Object.fromEntries( + reportingActionNames.map((name) => [ + name, + { ...source, consumerPath: join(tmpdir(), name), bundleSha256: 'd'.repeat(64) }, + ]), + ), + }; +} +test('reporting local origins require explicit HTTPS loopback and bounded port', () => { + assert.equal(assertLoopbackOrigin('https://localhost:18987'), 'https://localhost:18987'); + assert.equal(assertLoopbackOrigin('https://127.0.0.1:18987/'), 'https://127.0.0.1:18987'); + assert.equal(assertLoopbackOrigin('https://[::1]:18987/'), 'https://[::1]:18987'); + for (const value of [ + 'http://localhost:18987', + 'https://portalapi.example:18987', + 'https://localhost', + 'https://localhost:443', + 'https://localhost:18987/path', + 'https://local:secret@localhost:18987', + 'https://localhost:18987?token=secret', + 'https://localhost:18987#x', + ]) + assert.throws(() => assertLoopbackOrigin(value)); +}); +test('invalid reporting origin fails before package checks or any network/subprocess work', async () => { + await assert.rejects(validateReporting({}, 'https://production.example')); +}); +test('reporting artifact manifest requires exact hashes and all five real consumers', () => { + assert.equal(assertReportingManifest(manifest()).classification, 'registry-installed'); + for (const mutate of [ + (value) => { + value.classification = 'registry-release'; + }, + (value) => { + delete value.actions.notify; + }, + (value) => { + value.actions.notify.sourceSha = 'main'; + }, + (value) => { + value.actions.notify.sourceHash = 'unknown'; + }, + (value) => { + value.actions.notify.bundleSha256 = 'latest'; + }, + (value) => { + value.actions.notify.sourcePath = './source'; + }, + (value) => { + value.contract.tarball = 'https://registry.example/package.tgz'; + }, + (value) => { + value.contract.sha256 = ''; + }, + (value) => { + value.contract.integrity = 'unverified'; + }, + ]) { + const value = manifest(); + mutate(value); + assert.throws(() => assertReportingManifest(value)); + } +}); +test('actual GitHub output parsing retains multiline event JSON and rejects ambiguous records', () => { + assert.deepEqual( + parseActionOutputs('count=0\nevent< parseActionOutputs(value)); +}); +test('metadata defaults are passed explicitly and unknown input names are rejected', () => { + const definition = { + inputs: { optional: {}, policy: { default: 'true' }, scope: { required: true } }, + }; + assert.deepEqual(effectiveInputs(definition, { scope: 'synthetic' }), { + optional: '', + policy: 'true', + scope: 'synthetic', + }); + assert.throws(() => effectiveInputs(definition, { invented: 'bad' })); +}); +test('summary assertions check status/table/input coverage and reject confidential text', () => { + const style = { icon: '⚠️', label: 'Completed with warnings' }; + const text = + '## ⚠️ Example — Completed with warnings\n### Result\n| Detail | Value |\n### Inputs\n| Input | Value |\n| client-secret | [REDACTED] |\n'; + assertSummary(text, 'warning', style, ['client-secret'], ['synthetic-secret']); + for (const value of [ + text.replace('⚠️', '✅'), + text.replace('### Result', ''), + text.replace('client-secret', 'unknown'), + text + 'synthetic-secret', + ]) + assert.throws(() => + assertSummary(value, 'warning', style, ['client-secret'], ['synthetic-secret']), + ); + assert.equal(plainSummary('\\[REDACTED\\] <tag> & safe'), '[REDACTED] & safe'); +}); +test('source evidence records committed identity, runtime digest and dirty fingerprint', async () => { + const directory = await mkdtemp(join(tmpdir(), 'reporting-provenance-test-')); + try { + execFileSync('git', ['init', '--quiet'], { cwd: directory }); + await writeFile(join(directory, 'action.yml'), 'runs: {using: node24}\n'); + const initial = await sourceProvenance(directory, { allowUnborn: true }); + assert.equal(initial.sourceSha, 'unborn-private-workspace'); + assert.equal(initial.dirty, true); + assert.match(initial.runtimeHash, /^[a-f0-9]{64}$/); + execFileSync('git', ['add', 'action.yml'], { cwd: directory }); + execFileSync( + 'git', + [ + '-c', + 'user.name=CommerceKit fixture', + '-c', + 'user.email=fixture@example.test', + 'commit', + '--quiet', + '-m', + 'synthetic fixture', + ], + { cwd: directory }, + ); + const committed = await sourceProvenance(directory); + assert.equal(committed.dirty, false); + assert.match(committed.sourceSha, /^[a-f0-9]{40}$/); + assert.equal(committed.runtimeHash, initial.runtimeHash); + await writeFile(join(directory, 'action.yml'), 'runs: {using: node24}\n# changed\n'); + const changed = await sourceProvenance(directory); + assert.equal(changed.sourceSha, committed.sourceSha); + assert.notEqual(changed.sourceHash, committed.sourceHash); + assert.notEqual(changed.dirtyFingerprint, committed.dirtyFingerprint); + assert.equal(sha256(await readFile(join(directory, 'action.yml'))).length, 64); + } finally { + await rm(directory, { recursive: true, force: true }); + } +}); + +test('the actual child preload blocks external fetch and native HTTPS without network', async () => { + const directory = await mkdtemp(join(tmpdir(), 'reporting-preload-test-')); + try { + const certificate = join(directory, 'unused-ca.pem'); + await writeFile(certificate, 'unused synthetic certificate; no connection is made'); + execFileSync( + process.execPath, + [ + '--import', + new URL('../scripts/reporting-fetch-preload.mjs', import.meta.url).pathname, + '--input-type=module', + '-e', + ` + import https from 'node:https'; + await fetch('https://production.example/private').catch(() => {}); + try { https.get('https://provider.example/private'); } catch {} + `, + ], + { + cwd: directory, + stdio: 'pipe', + timeout: 5000, + env: { + COMMERCEKIT_REPORTING_MODE: 'deny', + COMMERCEKIT_REPORTING_LOCAL_ORIGIN: 'https://localhost:18987', + COMMERCEKIT_REPORTING_CA_FILE: certificate, + }, + }, + ); + assert.deepEqual(JSON.parse(await readFile(join(directory, 'network.json'), 'utf8')), { + attempted: 2, + sandbox: 0, + mockProvider: 0, + blocked: 2, + }); + } finally { + await rm(directory, { recursive: true, force: true }); + } +}); + +test('reporting child cancellation terminates a process even if it ignores SIGTERM', async () => { + const directory = await mkdtemp(join(tmpdir(), 'reporting-cancellation-test-')); + try { + const { mkdir } = await import('node:fs/promises'); + const { runReportingBundle } = await import('../scripts/reporting-support.mjs'); + const source = join(directory, 'consumer'); + await mkdir(join(source, 'dist'), { recursive: true }); + await writeFile( + join(source, 'dist/index.js'), + "process.on('SIGTERM', () => {}); setInterval(() => {}, 1000); await new Promise(() => {});\n", + ); + const certificate = join(directory, 'unused-ca.pem'); + await writeFile(certificate, 'unused synthetic certificate; no connection is made'); + const controller = new AbortController(); + const timer = setTimeout(() => controller.abort(), 100); + const started = Date.now(); + try { + await assert.rejects( + runReportingBundle({ + action: { consumerPath: source }, + directory: join(directory, 'child'), + inputs: {}, + mode: 'deny', + localOrigin: 'https://localhost:18987', + caFile: certificate, + preload: new URL('../scripts/reporting-fetch-preload.mjs', import.meta.url).pathname, + signal: controller.signal, + }), + ); + assert(Date.now() - started < 3000); + } finally { + clearTimeout(timer); + } + } finally { + await rm(directory, { recursive: true, force: true }); + } +}); + +test('registry installation proof rejects local links, ranges, integrity drift and foreign registry hosts', () => { + const artifact = manifest().contract; + const pkg = { + private: true, + dependencies: { '@commercekit-tools/notification-contract': '0.0.6' }, + }; + const lock = { + importers: { + '.': { + dependencies: { + '@commercekit-tools/notification-contract': { specifier: '0.0.6', version: '0.0.6' }, + }, + }, + }, + packages: { + '@commercekit-tools/notification-contract@0.0.6': { + resolution: { integrity: artifact.integrity, tarball: artifact.registryTarball }, + }, + }, + }; + assertRegistryInstall(pkg, lock, artifact); + for (const dependency of ['^0.0.6', 'preview', 'file:/private/tmp/package.tgz']) + assert.throws(() => + assertRegistryInstall( + { ...pkg, dependencies: { '@commercekit-tools/notification-contract': dependency } }, + lock, + artifact, + ), + ); + for (const mutate of [ + (value) => { + value.importers['.'].dependencies['@commercekit-tools/notification-contract'].version = + '0.0.4'; + }, + (value) => { + value.packages['@commercekit-tools/notification-contract@0.0.6'].resolution.integrity = + 'sha512-wrong'; + }, + (value) => { + value.packages['@commercekit-tools/notification-contract@0.0.6'].resolution.tarball = + 'https://registry.example/private.tgz'; + }, + ]) { + const changed = structuredClone(lock); + mutate(changed); + assert.throws(() => assertRegistryInstall(pkg, changed, artifact)); + } +}); + +test('normal registry proof selects the pnpm 12 application graph and rejects ambiguous lock documents', () => { + const application = + "lockfileVersion: '9.0'\nimporters:\n .:\n dependencies:\n '@commercekit-tools/notification-contract':\n specifier: 0.0.6\n version: 0.0.6\n"; + const manager = + "lockfileVersion: '9.0'\nimporters:\n .:\n packageManagerDependencies:\n pnpm:\n version: 12.6.0\n"; + const selected = parseRegistryLock('---\n' + manager + '---\n' + application); + assert.equal( + selected.importers['.'].dependencies['@commercekit-tools/notification-contract'].version, + '0.0.6', + ); + assert.deepEqual(parseRegistryLock(application), selected); + for (const text of [ + manager, + '---\n' + application + '---\n' + application, + 'lockfileVersion: [invalid', + application.replace('9.0', '8.0'), + ]) + assert.throws(() => parseRegistryLock(text)); +}); + +test('adopted producer inputs require complete metadata, validation parity and confidential masking', () => { + const run = { + credentials: { + tokenUrl: 'https://sandbox.example.test/oauth2/token', + clientId: 'synthetic-client', + clientSecret: 'synthetic-secret', + resource: 'synthetic-resource', + }, + }; + const context = fixtureInputs('ccv2-build', run); + const result = { ...context }; + const event = createBuildEvent({ status: 'success', data: result }); + assertReportedInputs('ccv2-build', result, event); + assert.throws(() => actionInputNames('unknown')); + for (const mutate of [ + (value, notification) => { + delete value.inputs['client-secret']; + delete notification.data.inputs['client-secret']; + }, + (value, notification) => { + value.inputs['client-secret'] = notification.data.inputs['client-secret'] = + 'unmasked-fixture'; + }, + (value, notification) => { + value.inputsValidated = notification.data.inputsValidated = false; + }, + (value, notification) => { + value.inputsTruncated = notification.data.inputsTruncated = true; + }, + (_value, notification) => { + notification.data.inputs['application-code'] = 'different-app'; + }, + (_value, notification) => { + notification.data.inputsValidated = false; + }, + (value, notification) => { + value.inputs.branch = notification.data.inputs.branch = + 'eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJzeW50aGV0aWMifQ.c3ludGhldGljLXNpZ25hdHVyZQ'; + }, + ]) { + const modified = structuredClone(result); + const notification = structuredClone(event); + mutate(modified, notification); + assert.throws(() => assertReportedInputs('ccv2-build', modified, notification)); + } +}); diff --git a/tests/runtime.test.mjs b/tests/runtime.test.mjs index 6a628ae..de3f704 100644 --- a/tests/runtime.test.mjs +++ b/tests/runtime.test.mjs @@ -4,6 +4,7 @@ import { chmod, lstat, mkdtemp, readFile, rm, symlink, writeFile } from 'node:fs import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { createBuildEvent, createDeploymentEvent } from '@commercekit-tools/notification-contract'; +import { fixtureInputs } from './reporting-fixtures.mjs'; import { getScenario, makePlan, scenarioIds } from '../scripts/scenarios.mjs'; import { assertActionRecord, @@ -119,6 +120,7 @@ function actionOutputs(id, phase) { if (id === 'deploy-create-error') result.error = { code: 'CREATE_DEPLOYMENT_AMBIGUOUS', message: 'Synthetic create error.' }; } + Object.assign(result, fixtureInputs(build ? 'ccv2-build' : 'ccv2-deploy', run)); const event = build ? createBuildEvent({ status: outcome, data: result }) : createDeploymentEvent({ diff --git a/tests/workflow-policy.test.mjs b/tests/workflow-policy.test.mjs index 6b1920e..ec1eb86 100644 --- a/tests/workflow-policy.test.mjs +++ b/tests/workflow-policy.test.mjs @@ -156,3 +156,26 @@ test('approved deploy requires ordered checks, a protected environment and publi validatePolicy(mutation('.github/workflows/build-approve-deploy.yml', change)), ); }); + +test('public input-name metadata is bound to adopted immutable Action refs', () => { + for (const mutate of [ + (value) => { + value['commercekit-tools/ccv2-build'].ref = 'a'.repeat(40); + }, + (value) => { + value['commercekit-tools/ccv2-build'].inputs.push('client-secret'); + }, + (value) => { + value['commercekit-tools/ccv2-build'].inputs.push('invalid input'); + }, + (value) => { + delete value['commercekit-tools/ccv2-build']; + }, + ]) { + const files = readPolicyFiles(); + const metadata = JSON.parse(files['action-inputs.json']); + mutate(metadata); + files['action-inputs.json'] = JSON.stringify(metadata); + assert.throws(() => validatePolicy(files)); + } +});