@empire-builder-kit/nx 1.0.0-rc.46 → 1.0.0-rc.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -169
- package/executors.json +24 -79
- package/generators.json +18 -18
- package/package.json +13 -71
- package/src/aws/identity.d.ts +1 -1
- package/src/aws-authority/boundary-transforms.d.ts +9 -0
- package/src/aws-authority/boundary-transforms.js +78 -0
- package/src/aws-authority/contracts.d.ts +116 -0
- package/src/aws-authority/contracts.js +40 -0
- package/src/aws-authority/deployment-guardrails.d.ts +4 -0
- package/src/aws-authority/deployment-guardrails.js +543 -0
- package/src/aws-authority/deployment-policy-groups.d.ts +3 -0
- package/src/aws-authority/deployment-policy-groups.js +299 -0
- package/src/aws-authority/deployment-resources.d.ts +64 -0
- package/src/aws-authority/deployment-resources.js +265 -0
- package/src/aws-authority/deployment-services.d.ts +3 -0
- package/src/aws-authority/deployment-services.js +717 -0
- package/src/aws-authority/development-authority.d.ts +11 -0
- package/src/aws-authority/development-authority.js +160 -0
- package/src/aws-authority/guardrail-actions.d.ts +87 -0
- package/src/aws-authority/guardrail-actions.js +463 -0
- package/src/aws-authority/policy-document.d.ts +15 -0
- package/src/aws-authority/policy-document.js +264 -0
- package/src/aws-authority/runtime-boundary.d.ts +7 -0
- package/src/aws-authority/runtime-boundary.js +211 -0
- package/src/aws-authority/service-actions.d.ts +96 -0
- package/src/aws-authority/service-actions.js +512 -0
- package/src/aws-authority/stage-authority.d.ts +6 -244
- package/src/aws-authority/stage-authority.js +114 -3419
- package/src/aws-authority/stage-identity.d.ts +6 -0
- package/src/aws-authority/stage-identity.js +134 -0
- package/src/cli/bootstrap.d.ts +0 -20
- package/src/cli/bootstrap.js +2 -153
- package/src/cli/dev-command.d.ts +2 -4
- package/src/cli/dev-command.js +1 -19
- package/src/cli/main.d.ts +0 -4
- package/src/cli/main.js +22 -80
- package/src/cli/output.d.ts +2 -4
- package/src/cli/output.js +2 -8
- package/src/executors/deployment-plan/deployment-plan.d.ts +0 -2
- package/src/executors/deployment-plan/deployment-plan.js +5 -67
- package/src/executors/dev-doctor/dev-doctor.d.ts +25 -3
- package/src/executors/dev-doctor/dev-doctor.js +137 -50
- package/src/executors/dev-setup/dev-setup.d.ts +18 -1
- package/src/executors/dev-setup/dev-setup.js +320 -196
- package/src/executors/foundation-preflight/foundation-preflight.js +9 -1
- package/src/executors/foundation-remove-preflight/foundation-remove-preflight.js +2 -2
- package/src/executors/local-deploy/deployed-smoke.d.ts +12 -0
- package/src/executors/local-deploy/deployed-smoke.js +115 -0
- package/src/executors/local-deploy/deployment-authority.d.ts +24 -0
- package/src/executors/local-deploy/deployment-authority.js +81 -0
- package/src/executors/local-deploy/deployment-child.d.ts +18 -0
- package/src/executors/local-deploy/deployment-child.js +77 -0
- package/src/executors/local-deploy/deployment-contracts.d.ts +96 -0
- package/src/executors/local-deploy/deployment-contracts.js +3 -0
- package/src/executors/local-deploy/deployment-projects.d.ts +4 -0
- package/src/executors/local-deploy/deployment-projects.js +16 -0
- package/src/executors/local-deploy/deployment-receipt.d.ts +4 -0
- package/src/executors/local-deploy/deployment-receipt.js +55 -0
- package/src/executors/local-deploy/deployment-scope.d.ts +17 -0
- package/src/executors/local-deploy/deployment-scope.js +239 -0
- package/src/executors/local-deploy/deployment-source.d.ts +13 -0
- package/src/executors/local-deploy/deployment-source.js +86 -0
- package/src/executors/local-deploy/local-deploy.d.ts +5 -106
- package/src/executors/local-deploy/local-deploy.js +56 -855
- package/src/executors/sst-lifecycle/governed-child-process.d.ts +27 -0
- package/src/executors/sst-lifecycle/governed-child-process.js +277 -0
- package/src/executors/sst-lifecycle/governed-native-operation.js +4 -10
- package/src/executors/sst-lifecycle/run-sst-command.d.ts +4 -85
- package/src/executors/sst-lifecycle/run-sst-command.js +28 -788
- package/src/executors/sst-lifecycle/sst-contracts.d.ts +44 -0
- package/src/executors/sst-lifecycle/sst-contracts.js +3 -0
- package/src/executors/sst-lifecycle/sst-invocation.d.ts +17 -0
- package/src/executors/sst-lifecycle/sst-invocation.js +502 -0
- package/src/executors/sst-lifecycle/task-unlock.js +3 -3
- package/src/foundation/discovery.d.ts +1 -5
- package/src/foundation/discovery.js +0 -2
- package/src/foundation/identity-domain-parent-ready.d.ts +91 -0
- package/src/foundation/identity-domain-parent-ready.js +333 -0
- package/src/foundation/identity-domain.d.ts +94 -0
- package/src/foundation/identity-domain.js +115 -0
- package/src/foundation/index.d.ts +2 -2
- package/src/foundation/index.js +7 -9
- package/src/foundation/local-private-smoke-access.d.ts +6 -15
- package/src/foundation/local-private-smoke-access.js +8 -192
- package/src/foundation/observability.d.ts +16 -26
- package/src/foundation/observability.js +34 -135
- package/src/foundation/preflight.js +16 -14
- package/src/foundation/private-smoke-access.d.ts +7 -14
- package/src/foundation/private-smoke-access.js +4 -126
- package/src/foundation/root-site-workspace.d.ts +35 -0
- package/src/foundation/root-site-workspace.js +80 -0
- package/src/foundation/root-site.d.ts +82 -0
- package/src/foundation/root-site.js +276 -0
- package/src/generators/formatting.js +5 -4
- package/src/generators/framework-prerequisites.d.ts +2 -0
- package/src/generators/framework-prerequisites.js +34 -0
- package/src/generators/function/function.d.ts +20 -1
- package/src/generators/function/function.js +143 -90
- package/src/generators/function/schema.d.ts +1 -0
- package/src/generators/function/schema.json +8 -2
- package/src/generators/function-access/function-access.d.ts +8 -0
- package/src/generators/function-access/function-access.js +73 -0
- package/src/generators/function-access/schema.d.ts +6 -0
- package/src/generators/function-access/schema.json +25 -0
- package/src/generators/observability-policy.js +1 -2
- package/src/{supply-chain → generators}/pnpm-toolchain-authority.d.ts +3 -3
- package/src/{supply-chain → generators}/pnpm-toolchain-authority.js +12 -12
- package/src/generators/post-generation-install.d.ts +2 -9
- package/src/generators/post-generation-install.js +12 -140
- package/src/generators/preset/dependency-overrides.d.ts +14 -20
- package/src/generators/preset/dependency-overrides.js +13 -57
- package/src/generators/preset/generator.js +0 -3
- package/src/generators/preset/workspace-files-foundation-infra.d.ts +6 -0
- package/src/generators/preset/workspace-files-foundation-infra.js +586 -0
- package/src/generators/preset/workspace-files-foundation-readme.d.ts +5 -0
- package/src/generators/preset/workspace-files-foundation-readme.js +90 -0
- package/src/generators/preset/workspace-files-foundation.d.ts +3 -0
- package/src/generators/preset/workspace-files-foundation.js +170 -0
- package/src/generators/preset/workspace-files-ownership.d.ts +9 -0
- package/src/generators/preset/workspace-files-ownership.js +124 -0
- package/src/generators/preset/workspace-files-root-config.d.ts +32 -0
- package/src/generators/preset/workspace-files-root-config.js +356 -0
- package/src/generators/preset/workspace-files-root-docs.d.ts +5 -0
- package/src/generators/preset/workspace-files-root-docs.js +109 -0
- package/src/generators/preset/workspace-files-shared.d.ts +18 -0
- package/src/generators/preset/workspace-files-shared.js +7 -0
- package/src/generators/preset/workspace-files-workflows.d.ts +39 -0
- package/src/generators/preset/workspace-files-workflows.js +306 -0
- package/src/generators/preset/workspace-files-workspace-health.d.ts +6 -0
- package/src/generators/preset/workspace-files-workspace-health.js +148 -0
- package/src/generators/preset/workspace-files.d.ts +10 -24
- package/src/generators/preset/workspace-files.js +48 -10511
- package/src/generators/site/built-in-site-documentation-files.d.ts +3 -0
- package/src/generators/site/built-in-site-documentation-files.js +51 -0
- package/src/generators/site/built-in-site-files.d.ts +11 -0
- package/src/generators/site/built-in-site-files.js +41 -0
- package/src/generators/site/built-in-site-infrastructure-files.d.ts +3 -0
- package/src/generators/site/built-in-site-infrastructure-files.js +115 -0
- package/src/generators/site/built-in-site-plan.d.ts +23 -0
- package/src/generators/site/built-in-site-plan.js +67 -0
- package/src/generators/site/built-in-site-project-files.d.ts +11 -0
- package/src/generators/site/built-in-site-project-files.js +212 -0
- package/src/generators/site/built-in-site-script-files.d.ts +4 -0
- package/src/generators/site/built-in-site-script-files.js +102 -0
- package/src/generators/site/built-in-site-shared.d.ts +69 -0
- package/src/generators/site/built-in-site-shared.js +314 -0
- package/src/generators/site/built-in-site-sst-config-files.d.ts +3 -0
- package/src/generators/site/built-in-site-sst-config-files.js +107 -0
- package/src/generators/site/built-in-site-web-files.d.ts +3 -0
- package/src/generators/site/built-in-site-web-files.js +78 -0
- package/src/generators/site/schema.d.ts +9 -0
- package/src/generators/site/schema.json +26 -0
- package/src/generators/site/site.d.ts +5 -0
- package/src/generators/site/site.js +153 -0
- package/src/generators/slice/built-in-plan-api-files.d.ts +1 -2
- package/src/generators/slice/built-in-plan-api-files.js +30 -890
- package/src/generators/slice/built-in-plan-database-lifecycle-files.js +57 -1851
- package/src/generators/slice/built-in-plan-infrastructure-files.d.ts +5 -2
- package/src/generators/slice/built-in-plan-infrastructure-files.js +80 -3358
- package/src/generators/slice/built-in-plan-key-value-files.d.ts +3 -2
- package/src/generators/slice/built-in-plan-key-value-files.js +3 -21
- package/src/generators/slice/built-in-plan-project-files.d.ts +5 -3
- package/src/generators/slice/built-in-plan-project-files.js +79 -897
- package/src/generators/slice/built-in-plan-shared.d.ts +4 -19
- package/src/generators/slice/built-in-plan-shared.js +5 -58
- package/src/generators/slice/built-in-plan-sst-config.d.ts +49 -0
- package/src/generators/slice/built-in-plan-sst-config.js +160 -0
- package/src/generators/slice/built-in-plan-web-files.d.ts +1 -1
- package/src/generators/slice/built-in-plan-web-files.js +14 -475
- package/src/generators/slice/built-in-plan.d.ts +2 -3
- package/src/generators/slice/built-in-plan.js +79 -277
- package/src/{developer-agent/preview-changes.d.ts → generators/slice/generation-tree.d.ts} +1 -5
- package/src/generators/slice/generation-tree.js +161 -0
- package/src/generators/slice/persistence-contract.js +2 -2
- package/src/generators/slice/schema.json +12 -4
- package/src/generators/slice/slice-config.d.ts +7 -0
- package/src/generators/slice/slice-config.js +125 -0
- package/src/generators/slice/slice.js +52 -257
- package/src/generators/slice/sql-bootstrap.d.ts +1 -0
- package/src/generators/slice/sql-bootstrap.js +505 -0
- package/src/generators/slice/sql-client.d.ts +1 -0
- package/src/generators/slice/sql-client.js +107 -0
- package/src/generators/slice/sql-infrastructure.d.ts +1 -0
- package/src/generators/slice/sql-infrastructure.js +225 -0
- package/src/generators/slice/sql-logging.d.ts +1 -0
- package/src/generators/slice/sql-logging.js +266 -0
- package/src/generators/slice/sql-migration.d.ts +2 -0
- package/src/generators/slice/sql-migration.js +202 -0
- package/src/generators/slice/standard-slice-contract.d.ts +25 -0
- package/src/generators/slice/standard-slice-contract.js +64 -0
- package/src/generators/sql/schema.json +1 -1
- package/src/generators/sql/sql.d.ts +1 -1
- package/src/generators/sql/sql.js +13 -7
- package/src/generators/upgrade/framework-package-upgrade.d.ts +35 -0
- package/src/generators/upgrade/framework-package-upgrade.js +55 -0
- package/src/generators/upgrade/framework-packages.d.ts +25 -0
- package/src/generators/upgrade/framework-packages.js +138 -0
- package/src/generators/upgrade/function-authentication-notice.d.ts +21 -0
- package/src/generators/upgrade/function-authentication-notice.js +54 -0
- package/src/generators/upgrade/schema.d.ts +0 -3
- package/src/generators/upgrade/schema.json +7 -17
- package/src/generators/upgrade/slice-compositions.d.ts +20 -0
- package/src/generators/upgrade/slice-compositions.js +100 -0
- package/src/generators/upgrade/slice-upgrade-guidance.d.ts +19 -0
- package/src/generators/upgrade/slice-upgrade-guidance.js +50 -0
- package/src/generators/upgrade/slice-upgrade.d.ts +4 -0
- package/src/generators/upgrade/slice-upgrade.js +231 -0
- package/src/generators/upgrade/upgrade-plan.d.ts +49 -0
- package/src/generators/upgrade/upgrade-plan.js +242 -0
- package/src/generators/upgrade/upgrade-preflight.d.ts +20 -0
- package/src/generators/upgrade/upgrade-preflight.js +64 -0
- package/src/generators/upgrade/upgrade.d.ts +8 -87
- package/src/generators/upgrade/upgrade.js +27 -1909
- package/src/generators/workload/schema.json +2 -2
- package/src/generators/workload/workload.d.ts +11 -11
- package/src/generators/workload/workload.js +167 -1200
- package/src/index.d.ts +0 -5
- package/src/index.js +0 -5
- package/src/local-dev/browser-verification.d.ts +0 -7
- package/src/local-dev/browser-verification.js +0 -136
- package/src/local-dev/contracts.d.ts +6 -0
- package/src/local-dev/contracts.js +17 -9
- package/src/local-dev/environment-checks.d.ts +126 -0
- package/src/local-dev/environment-checks.js +81 -0
- package/src/local-dev/environment-inspector.d.ts +3 -124
- package/src/local-dev/environment-inspector.js +9 -148
- package/src/local-dev/fleet-process.d.ts +9 -2
- package/src/local-dev/fleet-process.js +27 -7
- package/src/local-dev/gateway-daemon.d.ts +1 -1
- package/src/local-dev/gateway-daemon.js +6 -4
- package/src/local-dev/portless.d.ts +5 -0
- package/src/local-dev/portless.js +5 -0
- package/src/local-dev/private-state.d.ts +1 -0
- package/src/local-dev/private-state.js +19 -23
- package/src/local-dev/process-group.d.ts +10 -0
- package/src/local-dev/process-group.js +33 -0
- package/src/local-dev/process-identity.js +4 -2
- package/src/local-dev/slice-runner-child.d.ts +37 -0
- package/src/local-dev/slice-runner-child.js +127 -0
- package/src/local-dev/slice-runner-recovery.d.ts +32 -0
- package/src/local-dev/slice-runner-recovery.js +216 -0
- package/src/local-dev/slice-runner-state.d.ts +82 -0
- package/src/local-dev/slice-runner-state.js +265 -0
- package/src/local-dev/slice-runner.d.ts +4 -117
- package/src/local-dev/slice-runner.js +59 -594
- package/src/local-dev/tls.js +39 -99
- package/src/local-dev/trust-store.d.ts +42 -0
- package/src/local-dev/trust-store.js +87 -0
- package/src/ownership/composition.d.ts +7 -0
- package/src/ownership/composition.js +64 -56
- package/src/ownership/index.d.ts +2 -0
- package/src/ownership/index.js +7 -0
- package/src/ownership/pnpm-workspace.d.ts +77 -0
- package/src/ownership/pnpm-workspace.js +225 -0
- package/src/ownership/record.d.ts +19 -0
- package/src/ownership/record.js +26 -2
- package/src/ownership/site-record.d.ts +26 -0
- package/src/ownership/site-record.js +120 -0
- package/src/repository-policy/capacity-migration.d.ts +1 -1
- package/src/repository-policy/capacity-migration.js +1 -1
- package/src/repository-policy/deployment-plan.d.ts +3 -0
- package/src/repository-policy/deployment-plan.js +33 -4
- package/src/repository-policy/foundation-router.d.ts +17 -0
- package/src/repository-policy/foundation-router.js +44 -0
- package/src/repository-policy/index.d.ts +3 -0
- package/src/repository-policy/index.js +3 -0
- package/src/repository-policy/policy-accounts.d.ts +22 -0
- package/src/repository-policy/policy-accounts.js +134 -0
- package/src/repository-policy/policy-files.d.ts +8 -0
- package/src/repository-policy/policy-files.js +201 -0
- package/src/repository-policy/policy-internal.d.ts +2 -0
- package/src/repository-policy/policy-internal.js +11 -0
- package/src/repository-policy/policy-model.d.ts +95 -0
- package/src/repository-policy/policy-model.js +42 -0
- package/src/repository-policy/policy-validation.d.ts +4 -0
- package/src/repository-policy/policy-validation.js +308 -0
- package/src/repository-policy/policy.d.ts +6 -109
- package/src/repository-policy/policy.js +52 -626
- package/src/repository-policy/public-dns.d.ts +69 -0
- package/src/repository-policy/public-dns.js +265 -0
- package/src/{generators/repository-policy → repository-policy}/tree-policy.d.ts +1 -1
- package/src/{generators/repository-policy → repository-policy}/tree-policy.js +5 -5
- package/src/schemas/generated-ownership-v2.json +6 -0
- package/src/schemas/repository-policy-v1.json +106 -3
- package/src/secrets/index.d.ts +0 -5
- package/src/secrets/index.js +0 -5
- package/src/slice-infra/index.d.ts +57 -0
- package/src/slice-infra/index.js +117 -0
- package/src/slice-scripts/build.d.ts +27 -0
- package/src/slice-scripts/build.js +120 -0
- package/src/slice-scripts/database.d.ts +87 -0
- package/src/slice-scripts/database.js +328 -0
- package/src/slice-scripts/index.d.ts +11 -0
- package/src/slice-scripts/index.js +23 -0
- package/src/slice-scripts/root-site-routes.d.ts +11 -0
- package/src/slice-scripts/root-site-routes.js +83 -0
- package/src/slice-scripts/sql-migration-engine.mjs +180 -0
- package/src/workload-roles/effective-policy.d.ts +0 -37
- package/src/workload-roles/effective-policy.js +1 -174
- package/src/workload-roles/standard-slice.d.ts +2 -19
- package/src/workload-roles/standard-slice.js +3 -129
- package/src/workspace-deployment/ownership.d.ts +15 -0
- package/src/workspace-deployment/ownership.js +19 -3
- package/src/api-contract/baseline-update.d.ts +0 -82
- package/src/api-contract/baseline-update.js +0 -225
- package/src/api-contract/compatibility.d.ts +0 -30
- package/src/api-contract/compatibility.js +0 -643
- package/src/api-contract/contract-graph.d.ts +0 -35
- package/src/api-contract/contract-graph.js +0 -141
- package/src/api-contract/evidence.d.ts +0 -23
- package/src/api-contract/evidence.js +0 -87
- package/src/api-contract/index.d.ts +0 -6
- package/src/api-contract/index.js +0 -10
- package/src/api-contract/model.d.ts +0 -144
- package/src/api-contract/model.js +0 -993
- package/src/api-contract/rollout.d.ts +0 -32
- package/src/api-contract/rollout.js +0 -88
- package/src/authorization/compatibility.d.ts +0 -62
- package/src/authorization/compatibility.js +0 -175
- package/src/authorization/index.d.ts +0 -1
- package/src/authorization/index.js +0 -5
- package/src/blueprints/execution.d.ts +0 -55
- package/src/blueprints/execution.js +0 -329
- package/src/blueprints/external-sandbox.d.ts +0 -53
- package/src/blueprints/external-sandbox.js +0 -1194
- package/src/blueprints/index.d.ts +0 -5
- package/src/blueprints/index.js +0 -9
- package/src/blueprints/inputs.d.ts +0 -43
- package/src/blueprints/inputs.js +0 -103
- package/src/blueprints/manifest.d.ts +0 -281
- package/src/blueprints/manifest.js +0 -424
- package/src/blueprints/resolver.d.ts +0 -37
- package/src/blueprints/resolver.js +0 -387
- package/src/blueprints/transitions.d.ts +0 -20
- package/src/blueprints/transitions.js +0 -61
- package/src/cli/agent-command.d.ts +0 -30
- package/src/cli/agent-command.js +0 -204
- package/src/cli/agent-runtime.d.ts +0 -25
- package/src/cli/agent-runtime.js +0 -498
- package/src/cli/blueprint-authority.d.ts +0 -9
- package/src/cli/blueprint-authority.js +0 -43
- package/src/cli/blueprint-command.d.ts +0 -24
- package/src/cli/blueprint-command.js +0 -63
- package/src/data-lifecycle/index.d.ts +0 -3
- package/src/data-lifecycle/index.js +0 -7
- package/src/data-lifecycle/model.d.ts +0 -172
- package/src/data-lifecycle/model.js +0 -95
- package/src/data-lifecycle/sensitive-artifacts.d.ts +0 -28
- package/src/data-lifecycle/sensitive-artifacts.js +0 -146
- package/src/data-lifecycle/validation.d.ts +0 -32
- package/src/data-lifecycle/validation.js +0 -837
- package/src/database-retirement/contract.d.ts +0 -68
- package/src/database-retirement/contract.js +0 -166
- package/src/database-retirement/index.d.ts +0 -1
- package/src/database-retirement/index.js +0 -5
- package/src/developer-agent/context.d.ts +0 -57
- package/src/developer-agent/context.js +0 -662
- package/src/developer-agent/generator-planning.d.ts +0 -34
- package/src/developer-agent/generator-planning.js +0 -666
- package/src/developer-agent/generator-preview.d.ts +0 -8
- package/src/developer-agent/generator-preview.js +0 -650
- package/src/developer-agent/git-inspection.d.ts +0 -112
- package/src/developer-agent/git-inspection.js +0 -887
- package/src/developer-agent/handoff.d.ts +0 -43
- package/src/developer-agent/handoff.js +0 -713
- package/src/developer-agent/index.d.ts +0 -10
- package/src/developer-agent/index.js +0 -14
- package/src/developer-agent/model.d.ts +0 -493
- package/src/developer-agent/model.js +0 -143
- package/src/developer-agent/operation-registry.d.ts +0 -60
- package/src/developer-agent/operation-registry.js +0 -1550
- package/src/developer-agent/ordering.d.ts +0 -9
- package/src/developer-agent/ordering.js +0 -15
- package/src/developer-agent/planning.d.ts +0 -25
- package/src/developer-agent/planning.js +0 -478
- package/src/developer-agent/preview-changes.js +0 -215
- package/src/developer-agent/preview-source.d.ts +0 -2
- package/src/developer-agent/preview-source.js +0 -19
- package/src/developer-agent/validation.d.ts +0 -30
- package/src/developer-agent/validation.js +0 -2725
- package/src/developer-agent/workspace-inspection.d.ts +0 -20
- package/src/developer-agent/workspace-inspection.js +0 -1189
- package/src/developer-agent/workspace-path.d.ts +0 -6
- package/src/developer-agent/workspace-path.js +0 -22
- package/src/executors/blueprint-trust/blueprint-trust.d.ts +0 -29
- package/src/executors/blueprint-trust/blueprint-trust.js +0 -121
- package/src/executors/blueprint-trust/schema.json +0 -27
- package/src/executors/blueprint-verification/blueprint-verification.d.ts +0 -13
- package/src/executors/blueprint-verification/blueprint-verification.js +0 -110
- package/src/executors/blueprint-verification/schema.json +0 -44
- package/src/executors/developer-context/developer-context.d.ts +0 -38
- package/src/executors/developer-context/developer-context.js +0 -78
- package/src/executors/developer-context/schema.json +0 -87
- package/src/executors/foundation-profile-preflight/foundation-profile-preflight.d.ts +0 -19
- package/src/executors/foundation-profile-preflight/foundation-profile-preflight.js +0 -105
- package/src/executors/foundation-profile-preflight/schema.json +0 -32
- package/src/executors/github-bootstrap/github-bootstrap.d.ts +0 -13
- package/src/executors/github-bootstrap/github-bootstrap.js +0 -62
- package/src/executors/github-bootstrap/schema.json +0 -50
- package/src/executors/infrastructure-plan/infrastructure-plan.d.ts +0 -37
- package/src/executors/infrastructure-plan/infrastructure-plan.js +0 -268
- package/src/executors/infrastructure-plan/schema.json +0 -38
- package/src/executors/router-waf-rehearsal/router-waf-rehearsal.d.ts +0 -42
- package/src/executors/router-waf-rehearsal/router-waf-rehearsal.js +0 -1229
- package/src/executors/router-waf-rehearsal/schema.json +0 -29
- package/src/executors/secret-guardrails/schema.json +0 -6
- package/src/executors/secret-guardrails/secret-guardrails.d.ts +0 -3
- package/src/executors/secret-guardrails/secret-guardrails.js +0 -44
- package/src/executors/secret-initialize/schema.json +0 -42
- package/src/executors/secret-initialize/secret-initialize.d.ts +0 -34
- package/src/executors/secret-initialize/secret-initialize.js +0 -297
- package/src/executors/secret-metadata/schema.json +0 -36
- package/src/executors/secret-metadata/secret-metadata.d.ts +0 -46
- package/src/executors/secret-metadata/secret-metadata.js +0 -230
- package/src/executors/sst-lifecycle/generated-secret-retirement.d.ts +0 -53
- package/src/executors/sst-lifecycle/generated-secret-retirement.js +0 -192
- package/src/executors/sst-lifecycle/logging-preflight.d.ts +0 -22
- package/src/executors/sst-lifecycle/logging-preflight.js +0 -206
- package/src/executors/sst-lifecycle/secret-preflight.d.ts +0 -27
- package/src/executors/sst-lifecycle/secret-preflight.js +0 -125
- package/src/executors/work-markers/schema.json +0 -14
- package/src/executors/work-markers/work-markers.d.ts +0 -6
- package/src/executors/work-markers/work-markers.js +0 -20
- package/src/foundation/cost-estimate.d.ts +0 -175
- package/src/foundation/cost-estimate.js +0 -706
- package/src/foundation/private-smoke-admission.d.ts +0 -45
- package/src/foundation/private-smoke-admission.js +0 -180
- package/src/foundation/private-smoke-control-plane.d.ts +0 -18
- package/src/foundation/private-smoke-control-plane.js +0 -184
- package/src/foundation/router-waf-rate-rehearsal.d.ts +0 -97
- package/src/foundation/router-waf-rate-rehearsal.js +0 -210
- package/src/foundation/router-waf.d.ts +0 -149
- package/src/foundation/router-waf.js +0 -809
- package/src/frontend-security/index.d.ts +0 -1
- package/src/frontend-security/index.js +0 -5
- package/src/frontend-security/security-headers.d.ts +0 -50
- package/src/frontend-security/security-headers.js +0 -418
- package/src/generators/blueprint/blueprint.d.ts +0 -5
- package/src/generators/blueprint/blueprint.js +0 -102
- package/src/generators/blueprint/files.d.ts +0 -6
- package/src/generators/blueprint/files.js +0 -217
- package/src/generators/blueprint/schema.d.ts +0 -4
- package/src/generators/blueprint/schema.json +0 -18
- package/src/generators/feature-registry.d.ts +0 -13
- package/src/generators/feature-registry.js +0 -73
- package/src/generators/observability-infrastructure.d.ts +0 -2
- package/src/generators/observability-infrastructure.js +0 -31
- package/src/generators/preset/workspace-files-adopter-skills.d.ts +0 -7
- package/src/generators/preset/workspace-files-adopter-skills.js +0 -345
- package/src/generators/preset/workspace-files-agent-development.d.ts +0 -9
- package/src/generators/preset/workspace-files-agent-development.js +0 -42
- package/src/generators/preset/workspace-files-ci-acceptance.d.ts +0 -1
- package/src/generators/preset/workspace-files-ci-acceptance.js +0 -791
- package/src/generators/preset/workspace-files-ci-install.d.ts +0 -2
- package/src/generators/preset/workspace-files-ci-install.js +0 -196
- package/src/generators/preset/workspace-files-developer-agent.d.ts +0 -16
- package/src/generators/preset/workspace-files-developer-agent.js +0 -638
- package/src/generators/preset/workspace-files-ecr-inspector.d.ts +0 -18
- package/src/generators/preset/workspace-files-ecr-inspector.js +0 -298
- package/src/generators/preset/workspace-files-foundation-workload-roles.d.ts +0 -6
- package/src/generators/preset/workspace-files-foundation-workload-roles.js +0 -409
- package/src/generators/preset/workspace-files-performance-cost.d.ts +0 -66
- package/src/generators/preset/workspace-files-performance-cost.js +0 -866
- package/src/generators/preset/workspace-files-performance-load.d.ts +0 -73
- package/src/generators/preset/workspace-files-performance-load.js +0 -815
- package/src/generators/preset/workspace-files-shared-operation-claims.d.ts +0 -10
- package/src/generators/preset/workspace-files-shared-operation-claims.js +0 -59
- package/src/generators/preset/workspace-files-stage-authority.d.ts +0 -6
- package/src/generators/preset/workspace-files-stage-authority.js +0 -529
- package/src/generators/preset/workspace-files-thin-deploy.d.ts +0 -65
- package/src/generators/preset/workspace-files-thin-deploy.js +0 -2520
- package/src/generators/preset/workspace-files-thin-docs.d.ts +0 -7
- package/src/generators/preset/workspace-files-thin-docs.js +0 -358
- package/src/generators/preset/workspace-files-thin-release.d.ts +0 -14
- package/src/generators/preset/workspace-files-thin-release.js +0 -26
- package/src/generators/preset/workspace-files-workload-role-baseline.d.ts +0 -9
- package/src/generators/preset/workspace-files-workload-role-baseline.js +0 -1314
- package/src/generators/repository-policy/repository-policy.d.ts +0 -4
- package/src/generators/repository-policy/repository-policy.js +0 -293
- package/src/generators/repository-policy/schema.d.ts +0 -28
- package/src/generators/repository-policy/schema.json +0 -122
- package/src/generators/slice/built-in-plan-alarm-identity.d.ts +0 -173
- package/src/generators/slice/built-in-plan-alarm-identity.js +0 -202
- package/src/generators/slice/built-in-plan-api-contract-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-api-contract-files.js +0 -2830
- package/src/generators/slice/built-in-plan-async-work-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-async-work-files.js +0 -6100
- package/src/generators/slice/built-in-plan-authorization-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-authorization-files.js +0 -2082
- package/src/generators/slice/built-in-plan-authorization-infrastructure-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-authorization-infrastructure-files.js +0 -1301
- package/src/generators/slice/built-in-plan-authorization-storage.d.ts +0 -3
- package/src/generators/slice/built-in-plan-authorization-storage.js +0 -119
- package/src/generators/slice/built-in-plan-background-work-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-background-work-files.js +0 -99
- package/src/generators/slice/built-in-plan-data-deletion-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-deletion-files.js +0 -273
- package/src/generators/slice/built-in-plan-data-export-infrastructure-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-export-infrastructure-files.js +0 -223
- package/src/generators/slice/built-in-plan-data-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-files.js +0 -513
- package/src/generators/slice/built-in-plan-data-lifecycle-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-lifecycle-files.js +0 -775
- package/src/generators/slice/built-in-plan-data-lifecycle-runtime-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-lifecycle-runtime-files.js +0 -863
- package/src/generators/slice/built-in-plan-data-retention-job-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-retention-job-files.js +0 -169
- package/src/generators/slice/built-in-plan-data-retention-launcher-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-retention-launcher-files.js +0 -186
- package/src/generators/slice/built-in-plan-data-rights-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-data-rights-files.js +0 -152
- package/src/generators/slice/built-in-plan-database-retirement-rehearsal-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-database-retirement-rehearsal-files.js +0 -508
- package/src/generators/slice/built-in-plan-event-contract-literal.d.ts +0 -6
- package/src/generators/slice/built-in-plan-event-contract-literal.js +0 -52
- package/src/generators/slice/built-in-plan-foundation-files.d.ts +0 -3
- package/src/generators/slice/built-in-plan-foundation-files.js +0 -205
- package/src/generators/slice/built-in-plan-frontend-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-frontend-files.js +0 -2244
- package/src/generators/slice/built-in-plan-infrastructure-safety-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-infrastructure-safety-files.js +0 -373
- package/src/generators/slice/built-in-plan-key-value-cleanup.d.ts +0 -4
- package/src/generators/slice/built-in-plan-key-value-cleanup.js +0 -100
- package/src/generators/slice/built-in-plan-key-value-consumer.d.ts +0 -4
- package/src/generators/slice/built-in-plan-key-value-consumer.js +0 -151
- package/src/generators/slice/built-in-plan-key-value-deletion.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-deletion.js +0 -377
- package/src/generators/slice/built-in-plan-key-value-delivery.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-delivery.js +0 -137
- package/src/generators/slice/built-in-plan-key-value-export.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-export.js +0 -595
- package/src/generators/slice/built-in-plan-key-value-holds.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-holds.js +0 -189
- package/src/generators/slice/built-in-plan-key-value-infrastructure.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-infrastructure.js +0 -102
- package/src/generators/slice/built-in-plan-key-value-performance.d.ts +0 -5
- package/src/generators/slice/built-in-plan-key-value-performance.js +0 -530
- package/src/generators/slice/built-in-plan-key-value-provider.d.ts +0 -4
- package/src/generators/slice/built-in-plan-key-value-provider.js +0 -366
- package/src/generators/slice/built-in-plan-key-value-records.d.ts +0 -3
- package/src/generators/slice/built-in-plan-key-value-records.js +0 -232
- package/src/generators/slice/built-in-plan-key-value-retention-infrastructure.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-retention-infrastructure.js +0 -103
- package/src/generators/slice/built-in-plan-key-value-retention-job-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-retention-job-files.js +0 -160
- package/src/generators/slice/built-in-plan-key-value-retention-maintenance.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-retention-maintenance.js +0 -329
- package/src/generators/slice/built-in-plan-key-value-retention-worker.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-retention-worker.js +0 -477
- package/src/generators/slice/built-in-plan-key-value-retention.d.ts +0 -2
- package/src/generators/slice/built-in-plan-key-value-retention.js +0 -184
- package/src/generators/slice/built-in-plan-metadata-files.d.ts +0 -3
- package/src/generators/slice/built-in-plan-metadata-files.js +0 -384
- package/src/generators/slice/built-in-plan-native-runtime-authority-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-native-runtime-authority-files.js +0 -324
- package/src/generators/slice/built-in-plan-operations-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-operations-files.js +0 -1218
- package/src/generators/slice/built-in-plan-performance-files.d.ts +0 -4
- package/src/generators/slice/built-in-plan-performance-files.js +0 -2439
- package/src/generators/slice/built-in-plan-release-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-release-files.js +0 -6585
- package/src/generators/slice/built-in-plan-reliability-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-reliability-files.js +0 -4724
- package/src/generators/slice/built-in-plan-secret-runtime-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-secret-runtime-files.js +0 -1015
- package/src/generators/slice/built-in-plan-sql-events.d.ts +0 -2
- package/src/generators/slice/built-in-plan-sql-events.js +0 -276
- package/src/generators/slice/built-in-plan-testing-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-testing-files.js +0 -2575
- package/src/generators/slice/built-in-plan-testing-persistence-event-files.d.ts +0 -7
- package/src/generators/slice/built-in-plan-testing-persistence-event-files.js +0 -487
- package/src/generators/slice/built-in-plan-testing-persistence-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-testing-persistence-files.js +0 -180
- package/src/generators/slice/built-in-plan-thin-release-files.d.ts +0 -11
- package/src/generators/slice/built-in-plan-thin-release-files.js +0 -162
- package/src/generators/slice/built-in-plan-verification-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-verification-files.js +0 -431
- package/src/generators/slice/built-in-plan-workload-role-files.d.ts +0 -2
- package/src/generators/slice/built-in-plan-workload-role-files.js +0 -2220
- package/src/generators/slice/data-policy-review-seed.d.ts +0 -2
- package/src/generators/slice/data-policy-review-seed.js +0 -22
- package/src/generators/slice/deployed-smoke-readiness.d.ts +0 -2
- package/src/generators/slice/deployed-smoke-readiness.js +0 -214
- package/src/generators/slice/local-source-identity.d.ts +0 -2
- package/src/generators/slice/local-source-identity.js +0 -31
- package/src/generators/upgrade/sql-seeded-reconciliation.d.ts +0 -2
- package/src/generators/upgrade/sql-seeded-reconciliation.js +0 -170
- package/src/generators/workload/performance-registration.d.ts +0 -33
- package/src/generators/workload/performance-registration.js +0 -224
- package/src/generators/workload/reliability-registration.d.ts +0 -16
- package/src/generators/workload/reliability-registration.js +0 -150
- package/src/generators/workload/service-performance-files.d.ts +0 -5
- package/src/generators/workload/service-performance-files.js +0 -1883
- package/src/git-policy/action-pins.d.ts +0 -43
- package/src/git-policy/action-pins.js +0 -50
- package/src/git-policy/github-bootstrap.d.ts +0 -94
- package/src/git-policy/github-bootstrap.js +0 -1248
- package/src/git-policy/index.d.ts +0 -3
- package/src/git-policy/index.js +0 -7
- package/src/git-policy/routing.d.ts +0 -21
- package/src/git-policy/routing.js +0 -138
- package/src/infrastructure-change/convergence.d.ts +0 -13
- package/src/infrastructure-change/convergence.js +0 -85
- package/src/infrastructure-change/drift.d.ts +0 -13
- package/src/infrastructure-change/drift.js +0 -112
- package/src/infrastructure-change/index.d.ts +0 -7
- package/src/infrastructure-change/index.js +0 -11
- package/src/infrastructure-change/local-capability.d.ts +0 -73
- package/src/infrastructure-change/local-capability.js +0 -114
- package/src/infrastructure-change/model.d.ts +0 -274
- package/src/infrastructure-change/model.js +0 -29
- package/src/infrastructure-change/normalize.d.ts +0 -16
- package/src/infrastructure-change/normalize.js +0 -285
- package/src/infrastructure-change/plan.d.ts +0 -67
- package/src/infrastructure-change/plan.js +0 -671
- package/src/infrastructure-change/risk.d.ts +0 -9
- package/src/infrastructure-change/risk.js +0 -349
- package/src/infrastructure-change/summary.d.ts +0 -20
- package/src/infrastructure-change/summary.js +0 -130
- package/src/performance/cost-collection.d.ts +0 -225
- package/src/performance/cost-collection.js +0 -827
- package/src/performance/cost-controls.d.ts +0 -135
- package/src/performance/cost-controls.js +0 -347
- package/src/performance/evidence.d.ts +0 -140
- package/src/performance/evidence.js +0 -601
- package/src/performance/index.d.ts +0 -10
- package/src/performance/index.js +0 -14
- package/src/performance/load-safety.d.ts +0 -84
- package/src/performance/load-safety.js +0 -348
- package/src/performance/model.d.ts +0 -129
- package/src/performance/model.js +0 -451
- package/src/performance/pr-artifact-budget.d.ts +0 -42
- package/src/performance/pr-artifact-budget.js +0 -151
- package/src/performance/runner.d.ts +0 -75
- package/src/performance/runner.js +0 -227
- package/src/performance/scenario-endpoint.d.ts +0 -1
- package/src/performance/scenario-endpoint.js +0 -5
- package/src/performance/scenario.d.ts +0 -215
- package/src/performance/scenario.js +0 -744
- package/src/performance/unit-cost.d.ts +0 -105
- package/src/performance/unit-cost.js +0 -364
- package/src/release/index.d.ts +0 -2
- package/src/release/index.js +0 -6
- package/src/release/lifecycle.d.ts +0 -132
- package/src/release/lifecycle.js +0 -411
- package/src/release/manifest.d.ts +0 -148
- package/src/release/manifest.js +0 -503
- package/src/release/rollout.d.ts +0 -170
- package/src/release/rollout.js +0 -578
- package/src/release/source-authority.d.ts +0 -19
- package/src/release/source-authority.js +0 -212
- package/src/schemas/aggregate-count-evidence-v1.json +0 -135
- package/src/schemas/api-contract-baseline-v1.json +0 -674
- package/src/schemas/api-contract-compatibility-report-v1.json +0 -126
- package/src/schemas/aws-billing-actual-evidence-v1.json +0 -407
- package/src/schemas/blueprint-input-schema-v1.json +0 -23
- package/src/schemas/blueprint-v1.json +0 -188
- package/src/schemas/data-lifecycle-policy-v1.json +0 -517
- package/src/schemas/performance-policy-v1.json +0 -335
- package/src/schemas/testing-evidence-quarantine-v1.json +0 -168
- package/src/schemas/testing-evidence-result-v1.json +0 -319
- package/src/secrets/aws-control-plane.d.ts +0 -29
- package/src/secrets/aws-control-plane.js +0 -322
- package/src/secrets/generated-aws-control-plane.d.ts +0 -33
- package/src/secrets/generated-aws-control-plane.js +0 -322
- package/src/secrets/guardrails.d.ts +0 -26
- package/src/secrets/guardrails.js +0 -328
- package/src/secrets/metadata.d.ts +0 -48
- package/src/secrets/metadata.js +0 -199
- package/src/secrets/operator.d.ts +0 -190
- package/src/secrets/operator.js +0 -701
- package/src/secrets/verification.d.ts +0 -18
- package/src/secrets/verification.js +0 -152
- package/src/supply-chain/action-pins.d.ts +0 -26
- package/src/supply-chain/action-pins.js +0 -262
- package/src/supply-chain/blueprint-trust-git.d.ts +0 -130
- package/src/supply-chain/blueprint-trust-git.js +0 -1642
- package/src/supply-chain/blueprint-trust-process.d.ts +0 -4
- package/src/supply-chain/blueprint-trust-process.js +0 -88
- package/src/supply-chain/blueprint-trust.d.ts +0 -354
- package/src/supply-chain/blueprint-trust.js +0 -1558
- package/src/supply-chain/blueprint-verification-authority.d.ts +0 -62
- package/src/supply-chain/blueprint-verification-authority.js +0 -661
- package/src/supply-chain/blueprint-verification-execution.d.ts +0 -68
- package/src/supply-chain/blueprint-verification-execution.js +0 -639
- package/src/supply-chain/build-output-bounds.d.ts +0 -2
- package/src/supply-chain/build-output-bounds.js +0 -12
- package/src/supply-chain/build-output.d.ts +0 -41
- package/src/supply-chain/build-output.js +0 -551
- package/src/supply-chain/common.d.ts +0 -21
- package/src/supply-chain/common.js +0 -107
- package/src/supply-chain/container-artifact-contract.d.ts +0 -23
- package/src/supply-chain/container-artifact-contract.js +0 -208
- package/src/supply-chain/container-release.d.ts +0 -119
- package/src/supply-chain/container-release.js +0 -496
- package/src/supply-chain/ecr-applicability.d.ts +0 -19
- package/src/supply-chain/ecr-applicability.js +0 -103
- package/src/supply-chain/ecr-scanning.d.ts +0 -85
- package/src/supply-chain/ecr-scanning.js +0 -325
- package/src/supply-chain/ecs-deployed-image.d.ts +0 -87
- package/src/supply-chain/ecs-deployed-image.js +0 -302
- package/src/supply-chain/errors.d.ts +0 -6
- package/src/supply-chain/errors.js +0 -15
- package/src/supply-chain/generated-blueprint-trust-command.d.ts +0 -4
- package/src/supply-chain/generated-blueprint-trust-command.js +0 -1379
- package/src/supply-chain/generated-command.d.ts +0 -1
- package/src/supply-chain/generated-command.js +0 -775
- package/src/supply-chain/generated-container-release-command.d.ts +0 -16
- package/src/supply-chain/generated-container-release-command.js +0 -3248
- package/src/supply-chain/generated-ecr-collector-command.d.ts +0 -20
- package/src/supply-chain/generated-ecr-collector-command.js +0 -1445
- package/src/supply-chain/generated-files.d.ts +0 -13
- package/src/supply-chain/generated-files.js +0 -421
- package/src/supply-chain/generated-scanner-command.d.ts +0 -1
- package/src/supply-chain/generated-scanner-command.js +0 -778
- package/src/supply-chain/index.d.ts +0 -28
- package/src/supply-chain/index.js +0 -36
- package/src/supply-chain/inventory.d.ts +0 -96
- package/src/supply-chain/inventory.js +0 -828
- package/src/supply-chain/license-expression.d.ts +0 -7
- package/src/supply-chain/license-expression.js +0 -128
- package/src/supply-chain/policy.d.ts +0 -105
- package/src/supply-chain/policy.js +0 -304
- package/src/supply-chain/publication.d.ts +0 -48
- package/src/supply-chain/publication.js +0 -85
- package/src/supply-chain/sbom.d.ts +0 -228
- package/src/supply-chain/sbom.js +0 -913
- package/src/supply-chain/scanner.d.ts +0 -77
- package/src/supply-chain/scanner.js +0 -514
- package/src/supply-chain/vendored-source.d.ts +0 -95
- package/src/supply-chain/vendored-source.js +0 -315
- package/src/testing-evidence/fixture-scope.d.ts +0 -53
- package/src/testing-evidence/fixture-scope.js +0 -142
- package/src/testing-evidence/index.d.ts +0 -5
- package/src/testing-evidence/index.js +0 -9
- package/src/testing-evidence/quarantine.d.ts +0 -48
- package/src/testing-evidence/quarantine.js +0 -253
- package/src/testing-evidence/result.d.ts +0 -109
- package/src/testing-evidence/result.js +0 -585
- package/src/testing-evidence/runner-adapter.d.ts +0 -51
- package/src/testing-evidence/runner-adapter.js +0 -288
- package/src/testing-evidence/sensitive-artifacts.d.ts +0 -13
- package/src/testing-evidence/sensitive-artifacts.js +0 -93
- package/src/work-markers/index.d.ts +0 -1
- package/src/work-markers/index.js +0 -5
- package/src/work-markers/work-markers.d.ts +0 -39
- package/src/work-markers/work-markers.js +0 -360
- package/src/workload-roles/account-baseline.d.ts +0 -143
- package/src/workload-roles/account-baseline.js +0 -980
- package/src/workload-roles/authority.d.ts +0 -40
- package/src/workload-roles/authority.js +0 -202
- package/src/workload-roles/aws-adapter.d.ts +0 -99
- package/src/workload-roles/aws-adapter.js +0 -416
- package/src/workload-roles/aws-internal-handler.d.ts +0 -27
- package/src/workload-roles/aws-internal-handler.js +0 -58
- package/src/workload-roles/aws-s3-state.d.ts +0 -52
- package/src/workload-roles/aws-s3-state.js +0 -191
- package/src/workload-roles/aws-sdk-control-plane.d.ts +0 -12
- package/src/workload-roles/aws-sdk-control-plane.js +0 -291
- package/src/workload-roles/boundary.d.ts +0 -34
- package/src/workload-roles/boundary.js +0 -137
- package/src/workload-roles/convergence.d.ts +0 -66
- package/src/workload-roles/convergence.js +0 -186
- package/src/workload-roles/handler.d.ts +0 -43
- package/src/workload-roles/handler.js +0 -158
- package/src/workload-roles/history.d.ts +0 -47
- package/src/workload-roles/history.js +0 -324
- package/src/workload-roles/injection.d.ts +0 -119
- package/src/workload-roles/injection.js +0 -495
- package/src/workload-roles/manifest.d.ts +0 -54
- package/src/workload-roles/manifest.js +0 -343
- package/src/workload-roles/provisioner.d.ts +0 -70
- package/src/workload-roles/provisioner.js +0 -239
- package/src/workload-roles/registration.d.ts +0 -102
- package/src/workload-roles/registration.js +0 -462
- package/src/workload-roles/stage-boundary.d.ts +0 -31
- package/src/workload-roles/stage-boundary.js +0 -208
- /package/src/executors/{foundation-profile-preflight → local-deploy}/production-database-safeguard.d.ts +0 -0
- /package/src/executors/{foundation-profile-preflight → local-deploy}/production-database-safeguard.js +0 -0
|
@@ -1,3248 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CRANE_RELEASES = exports.CRANE_VERSION = void 0;
|
|
4
|
-
exports.renderContainerReleaseCommand = renderContainerReleaseCommand;
|
|
5
|
-
const generated_ecr_collector_command_js_1 = require("./generated-ecr-collector-command.js");
|
|
6
|
-
const safe_reference_1 = require("@empire-builder-kit/runtime/safe-reference");
|
|
7
|
-
exports.CRANE_VERSION = '0.21.7';
|
|
8
|
-
const WINDOWS_HARDEN_PRIVATE_ACL = String.raw `
|
|
9
|
-
$ErrorActionPreference = 'Stop'
|
|
10
|
-
$path = $env:EBK_PRIVATE_PATH
|
|
11
|
-
$kind = $env:EBK_PRIVATE_KIND
|
|
12
|
-
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
|
13
|
-
if ($kind -eq 'directory') {
|
|
14
|
-
$info = [System.IO.DirectoryInfo]::new($path)
|
|
15
|
-
} else {
|
|
16
|
-
$info = [System.IO.FileInfo]::new($path)
|
|
17
|
-
}
|
|
18
|
-
$acl = $info.GetAccessControl()
|
|
19
|
-
$acl.SetAccessRuleProtection($true, $false)
|
|
20
|
-
foreach ($rule in @($acl.Access)) {
|
|
21
|
-
[void]$acl.RemoveAccessRuleSpecific($rule)
|
|
22
|
-
}
|
|
23
|
-
$rights = [System.Security.AccessControl.FileSystemRights]::FullControl
|
|
24
|
-
$type = [System.Security.AccessControl.AccessControlType]::Allow
|
|
25
|
-
if ($kind -eq 'directory') {
|
|
26
|
-
$inheritance = [System.Security.AccessControl.InheritanceFlags]'ContainerInherit,ObjectInherit'
|
|
27
|
-
$propagation = [System.Security.AccessControl.PropagationFlags]::None
|
|
28
|
-
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
|
|
29
|
-
$identity.User, $rights, $inheritance, $propagation, $type
|
|
30
|
-
)
|
|
31
|
-
} else {
|
|
32
|
-
$rule = [System.Security.AccessControl.FileSystemAccessRule]::new(
|
|
33
|
-
$identity.User, $rights, $type
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
$acl.AddAccessRule($rule)
|
|
37
|
-
$info.SetAccessControl($acl)
|
|
38
|
-
`;
|
|
39
|
-
const WINDOWS_ASSERT_PRIVATE_ACL = String.raw `
|
|
40
|
-
$ErrorActionPreference = 'Stop'
|
|
41
|
-
$path = $env:EBK_PRIVATE_PATH
|
|
42
|
-
$kind = $env:EBK_PRIVATE_KIND
|
|
43
|
-
$identity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
|
|
44
|
-
if ($kind -eq 'directory') {
|
|
45
|
-
$info = [System.IO.DirectoryInfo]::new($path)
|
|
46
|
-
} else {
|
|
47
|
-
$info = [System.IO.FileInfo]::new($path)
|
|
48
|
-
}
|
|
49
|
-
$acl = $info.GetAccessControl()
|
|
50
|
-
if (-not $acl.AreAccessRulesProtected) {
|
|
51
|
-
throw 'ACL inheritance is enabled.'
|
|
52
|
-
}
|
|
53
|
-
$allowRules = @($acl.Access | Where-Object {
|
|
54
|
-
$_.AccessControlType -eq [System.Security.AccessControl.AccessControlType]::Allow
|
|
55
|
-
})
|
|
56
|
-
$unsafeRules = @($allowRules | Where-Object {
|
|
57
|
-
$_.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value -ne $identity.User.Value
|
|
58
|
-
})
|
|
59
|
-
$selfRules = @($allowRules | Where-Object {
|
|
60
|
-
$_.IdentityReference.Translate([System.Security.Principal.SecurityIdentifier]).Value -eq $identity.User.Value
|
|
61
|
-
})
|
|
62
|
-
if ($unsafeRules.Count -ne 0 -or $selfRules.Count -eq 0) {
|
|
63
|
-
throw 'ACL grants access beyond the current user or omits the current user.'
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
exports.CRANE_RELEASES = Object.freeze({
|
|
67
|
-
'darwin-arm64': {
|
|
68
|
-
archiveFormat: 'tar-gzip',
|
|
69
|
-
sha256: '1858c55dcd6053fe869bcb0c4ec20666383ddce445ad0f7e15e1e506b1f7fe52',
|
|
70
|
-
source: 'https://github.com/google/go-containerregistry/releases/download/v0.21.7/go-containerregistry_Darwin_arm64.tar.gz',
|
|
71
|
-
},
|
|
72
|
-
'darwin-x64': {
|
|
73
|
-
archiveFormat: 'tar-gzip',
|
|
74
|
-
sha256: '63a7dd15168d4dcac37933c7f6745438f2943d5898a1cf7896ad3341d8519bf2',
|
|
75
|
-
source: 'https://github.com/google/go-containerregistry/releases/download/v0.21.7/go-containerregistry_Darwin_x86_64.tar.gz',
|
|
76
|
-
},
|
|
77
|
-
'linux-arm64': {
|
|
78
|
-
archiveFormat: 'tar-gzip',
|
|
79
|
-
sha256: 'b6ee979d9411dfb05ce35ab9e156fe5de7def11a230764a7856ffa2eb971fa88',
|
|
80
|
-
source: 'https://github.com/google/go-containerregistry/releases/download/v0.21.7/go-containerregistry_Linux_arm64.tar.gz',
|
|
81
|
-
},
|
|
82
|
-
'linux-x64': {
|
|
83
|
-
archiveFormat: 'tar-gzip',
|
|
84
|
-
sha256: '1a57bc98207fa1c0d04bf760699099e26f8383499bfd55b99c1b919a928a7230',
|
|
85
|
-
source: 'https://github.com/google/go-containerregistry/releases/download/v0.21.7/go-containerregistry_Linux_x86_64.tar.gz',
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
function validatedReleases(releases) {
|
|
89
|
-
if (Object.keys(releases).length === 0 ||
|
|
90
|
-
Object.entries(releases).some(([platform, release]) => !/^(?:darwin|linux)-(?:arm64|x64)$/.test(platform) ||
|
|
91
|
-
!['binary', 'tar-gzip'].includes(release.archiveFormat) ||
|
|
92
|
-
!/^[a-f0-9]{64}$/.test(release.sha256) ||
|
|
93
|
-
!/^https:\/\/github\.com\/anchore\/syft\/releases\/download\/v\d+\.\d+\.\d+\/[A-Za-z0-9._-]+$/.test(release.source))) {
|
|
94
|
-
throw new Error('Container-release Syft assets must be exact official integrity-bound releases.');
|
|
95
|
-
}
|
|
96
|
-
return releases;
|
|
97
|
-
}
|
|
98
|
-
function validatedCraneReleases(releases) {
|
|
99
|
-
if (Object.keys(releases).length === 0 ||
|
|
100
|
-
Object.entries(releases).some(([platform, release]) => !/^(?:darwin|linux)-(?:arm64|x64)$/.test(platform) ||
|
|
101
|
-
release.archiveFormat !== 'tar-gzip' ||
|
|
102
|
-
!/^[a-f0-9]{64}$/.test(release.sha256) ||
|
|
103
|
-
!/^https:\/\/github\.com\/google\/go-containerregistry\/releases\/download\/v\d+\.\d+\.\d+\/go-containerregistry_(?:Darwin|Linux)_(?:arm64|x86_64)\.tar\.gz$/.test(release.source))) {
|
|
104
|
-
throw new Error('Container-release Crane assets must be exact official integrity-bound releases.');
|
|
105
|
-
}
|
|
106
|
-
return releases;
|
|
107
|
-
}
|
|
108
|
-
/** Render the protected native-platform OCI build and assembly command. */
|
|
109
|
-
function renderContainerReleaseCommand(options = {}) {
|
|
110
|
-
const moduleSpecifier = options.moduleSpecifier ?? '@empire-builder-kit/nx/supply-chain';
|
|
111
|
-
const releases = validatedReleases(options.releases ?? generated_ecr_collector_command_js_1.SYFT_COLLECTOR_RELEASES);
|
|
112
|
-
const syftVersion = options.syftVersion ?? generated_ecr_collector_command_js_1.SYFT_VERSION;
|
|
113
|
-
const craneReleases = validatedCraneReleases(options.craneReleases ?? exports.CRANE_RELEASES);
|
|
114
|
-
const craneVersion = options.craneVersion ?? exports.CRANE_VERSION;
|
|
115
|
-
if (!/^(?:@empire-builder-kit\/nx\/supply-chain|file:\/\/\/[^'"\n]+)$/.test(moduleSpecifier) ||
|
|
116
|
-
!/^\d+\.\d+\.\d+$/.test(syftVersion) ||
|
|
117
|
-
!/^\d+\.\d+\.\d+$/.test(craneVersion)) {
|
|
118
|
-
throw new Error('The generated container release configuration is invalid.');
|
|
119
|
-
}
|
|
120
|
-
return `import { createHash, randomBytes } from 'node:crypto';
|
|
121
|
-
import { execFileSync, spawn, spawnSync } from 'node:child_process';
|
|
122
|
-
import {
|
|
123
|
-
chmodSync,
|
|
124
|
-
copyFileSync,
|
|
125
|
-
existsSync,
|
|
126
|
-
lstatSync,
|
|
127
|
-
mkdirSync,
|
|
128
|
-
mkdtempSync,
|
|
129
|
-
readFileSync,
|
|
130
|
-
realpathSync,
|
|
131
|
-
readdirSync,
|
|
132
|
-
renameSync,
|
|
133
|
-
rmSync,
|
|
134
|
-
unlinkSync,
|
|
135
|
-
writeFileSync,
|
|
136
|
-
} from 'node:fs';
|
|
137
|
-
import { basename, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
138
|
-
import { platform as hostOperatingSystem, tmpdir } from 'node:os';
|
|
139
|
-
import {
|
|
140
|
-
CONTAINER_NATIVE_LIFECYCLE_PROOFS,
|
|
141
|
-
CONTAINER_RELEASE_PLATFORMS,
|
|
142
|
-
containerReleaseRepositoryName,
|
|
143
|
-
createContainerNativeRunProof,
|
|
144
|
-
createContainerPlatformEvidence,
|
|
145
|
-
createContainerReleaseBinding,
|
|
146
|
-
hasSensitiveSupplyChainShape,
|
|
147
|
-
resolveContainerReleaseArtifact,
|
|
148
|
-
supplyChainDigest,
|
|
149
|
-
validateContainerArtifactIdentity,
|
|
150
|
-
validateContainerReleaseBinding,
|
|
151
|
-
validateContainerNativeRunProof,
|
|
152
|
-
validateContainerPlatformEvidence,
|
|
153
|
-
validateReviewedReleaseCheckout,
|
|
154
|
-
} from '${moduleSpecifier}';
|
|
155
|
-
|
|
156
|
-
const SYFT_VERSION = ${JSON.stringify(syftVersion)};
|
|
157
|
-
const SYFT_RELEASES = Object.freeze(${JSON.stringify(releases)});
|
|
158
|
-
const CRANE_VERSION = ${JSON.stringify(craneVersion)};
|
|
159
|
-
const CRANE_RELEASES = Object.freeze(${JSON.stringify(craneReleases)});
|
|
160
|
-
const WINDOWS_HARDEN_PRIVATE_ACL = ${JSON.stringify(WINDOWS_HARDEN_PRIVATE_ACL)};
|
|
161
|
-
const WINDOWS_ASSERT_PRIVATE_ACL = ${JSON.stringify(WINDOWS_ASSERT_PRIVATE_ACL)};
|
|
162
|
-
const SHA256 = /^[a-f0-9]{64}$/;
|
|
163
|
-
const IMAGE_DIGEST = /^sha256:[a-f0-9]{64}$/;
|
|
164
|
-
const COMMIT = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/;
|
|
165
|
-
const REFERENCE = new RegExp(${JSON.stringify((0, safe_reference_1.safeReferencePatternSource)())});
|
|
166
|
-
const PACKAGE_NAME =
|
|
167
|
-
/^(?:@[A-Za-z0-9][A-Za-z0-9._-]*[/])?[A-Za-z0-9][A-Za-z0-9._-]*$/;
|
|
168
|
-
const AWS_REGION_NAME =
|
|
169
|
-
/^(?=.{9,32}$)[a-z]{2}(?:-gov)?-[a-z]+(?:-[a-z]+)*-\\d$/;
|
|
170
|
-
const MAX_TOOL_BYTES = 100 * 1024 * 1024;
|
|
171
|
-
const MAX_OUTPUT_BYTES = 64 * 1024 * 1024;
|
|
172
|
-
// Optional absolute cache roots supplied by the workflow (runner-local, restored
|
|
173
|
-
// by the managed cache step). Absent or relative values disable the caches.
|
|
174
|
-
const optionalCacheRoot = (name) => {
|
|
175
|
-
const value = process.env[name]?.trim() ?? '';
|
|
176
|
-
return value !== '' && isAbsolute(value) && !value.includes('..') ? value : '';
|
|
177
|
-
};
|
|
178
|
-
const buildxLayerCache = (repositoryName, architecture) => {
|
|
179
|
-
const root = optionalCacheRoot('EBK_BUILDX_CACHE_DIR');
|
|
180
|
-
if (root === '') return { arguments: [], commit: () => {} };
|
|
181
|
-
const scope = repositoryName.replaceAll('/', '-') + '-' + architecture;
|
|
182
|
-
const current = join(root, scope);
|
|
183
|
-
const next = join(root, scope + '.next');
|
|
184
|
-
mkdirSync(root, { mode: 0o700, recursive: true });
|
|
185
|
-
rmSync(next, { force: true, recursive: true });
|
|
186
|
-
return {
|
|
187
|
-
arguments: [
|
|
188
|
-
...(existsSync(current)
|
|
189
|
-
? ['--cache-from', 'type=local,src=' + current]
|
|
190
|
-
: []),
|
|
191
|
-
'--cache-to',
|
|
192
|
-
'type=local,dest=' + next + ',mode=max',
|
|
193
|
-
],
|
|
194
|
-
commit: () => {
|
|
195
|
-
if (!existsSync(next)) return;
|
|
196
|
-
rmSync(current, { force: true, recursive: true });
|
|
197
|
-
renameSync(next, current);
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
};
|
|
201
|
-
const cachedReleaseToolArchive = (name, sha256) => {
|
|
202
|
-
const root = optionalCacheRoot('EBK_RELEASE_TOOL_CACHE_DIR');
|
|
203
|
-
return root === '' ? '' : join(root, name + '-' + sha256);
|
|
204
|
-
};
|
|
205
|
-
const mode = process.argv[2];
|
|
206
|
-
const requestedPlatform = process.argv[3];
|
|
207
|
-
if (
|
|
208
|
-
!['platform', 'assemble', 'promote'].includes(mode) ||
|
|
209
|
-
(mode === 'platform' &&
|
|
210
|
-
!CONTAINER_RELEASE_PLATFORMS.includes(requestedPlatform)) ||
|
|
211
|
-
(['assemble', 'promote'].includes(mode) && requestedPlatform !== undefined)
|
|
212
|
-
) {
|
|
213
|
-
throw new Error(
|
|
214
|
-
'Usage: container-release.mjs <platform linux/amd64|platform linux/arm64|assemble|promote>',
|
|
215
|
-
);
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const digestBytes = (value) =>
|
|
219
|
-
createHash('sha256').update(value).digest('hex');
|
|
220
|
-
const repositoryRoot = realpathSync(
|
|
221
|
-
execFileSync('git', ['rev-parse', '--show-toplevel'], {
|
|
222
|
-
encoding: 'utf8',
|
|
223
|
-
}).trim(),
|
|
224
|
-
);
|
|
225
|
-
const sliceRoot = realpathSync(process.cwd());
|
|
226
|
-
const slice = basename(sliceRoot);
|
|
227
|
-
if (
|
|
228
|
-
relative(repositoryRoot, sliceRoot).split(sep).join('/') !==
|
|
229
|
-
'packages/' + slice
|
|
230
|
-
) {
|
|
231
|
-
throw new Error('Container release must run from one exact Product Slice root.');
|
|
232
|
-
}
|
|
233
|
-
const deploymentSourceCommit = process.env.EBK_SOURCE_COMMIT?.trim() ?? '';
|
|
234
|
-
const sourceCommit =
|
|
235
|
-
process.env.EBK_RELEASE_SOURCE_COMMIT?.trim() ?? deploymentSourceCommit;
|
|
236
|
-
const stage = process.env.EBK_STAGE?.trim() ?? '';
|
|
237
|
-
const accountId = process.env.AWS_EXPECTED_ACCOUNT_ID?.trim() ?? '';
|
|
238
|
-
const region = process.env.AWS_REGION?.trim() ?? '';
|
|
239
|
-
const packageRegistryInput =
|
|
240
|
-
process.env.EBK_CONTAINER_PACKAGE_REGISTRY?.trim() ?? '';
|
|
241
|
-
const localFederated =
|
|
242
|
-
process.env.GITHUB_ACTIONS !== 'true' &&
|
|
243
|
-
process.env.EBK_LOCAL_DEPLOYMENT_MODE === 'federated';
|
|
244
|
-
const localRunId = process.env.EBK_LOCAL_CONTAINER_RUN_ID?.trim() ?? '';
|
|
245
|
-
const policy = JSON.parse(
|
|
246
|
-
readFileSync(join(repositoryRoot, 'ebk.repository-policy.json'), 'utf8'),
|
|
247
|
-
);
|
|
248
|
-
const selectedDeploymentProfile =
|
|
249
|
-
process.env.EBK_DEPLOYMENT_PROFILE?.trim() ?? '';
|
|
250
|
-
const activeStages = {
|
|
251
|
-
starter: ['development', 'production'],
|
|
252
|
-
'production-isolated': ['development', 'staging', 'production'],
|
|
253
|
-
'fully-isolated': ['development', 'staging', 'production'],
|
|
254
|
-
}[policy.deploymentProfile];
|
|
255
|
-
const locallyAdmittedStages = {
|
|
256
|
-
starter: ['development', 'production'],
|
|
257
|
-
'production-isolated': ['development', 'staging'],
|
|
258
|
-
'fully-isolated': ['development'],
|
|
259
|
-
}[policy.deploymentProfile];
|
|
260
|
-
if (
|
|
261
|
-
selectedDeploymentProfile !== policy.deploymentProfile ||
|
|
262
|
-
!activeStages ||
|
|
263
|
-
!activeStages.includes(stage) ||
|
|
264
|
-
policy.deploymentAccounts?.[stage] !== accountId ||
|
|
265
|
-
policy.deploymentRegion !== region
|
|
266
|
-
) {
|
|
267
|
-
throw new Error(
|
|
268
|
-
'Container release requires the exact committed profile, active stage, account, and Region.',
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
if (
|
|
272
|
-
localFederated &&
|
|
273
|
-
(!locallyAdmittedStages || !locallyAdmittedStages.includes(stage))
|
|
274
|
-
) {
|
|
275
|
-
throw new Error(
|
|
276
|
-
'Local container release requires one of the committed profile locally admitted stages.',
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
const runId = localFederated
|
|
280
|
-
? localRunId
|
|
281
|
-
: process.env.GITHUB_RUN_ID?.trim() ?? '';
|
|
282
|
-
const runAttempt = localFederated
|
|
283
|
-
? '1'
|
|
284
|
-
: process.env.GITHUB_RUN_ATTEMPT?.trim() ?? '';
|
|
285
|
-
const workflow = localFederated
|
|
286
|
-
? 'local-federated/' + stage + '/' + accountId + '/' + region
|
|
287
|
-
: process.env.GITHUB_WORKFLOW_REF?.trim() ?? '';
|
|
288
|
-
if (
|
|
289
|
-
!COMMIT.test(deploymentSourceCommit) ||
|
|
290
|
-
!COMMIT.test(sourceCommit) ||
|
|
291
|
-
!['development', 'staging', 'production'].includes(stage) ||
|
|
292
|
-
!/^\\d{12}$/.test(accountId) ||
|
|
293
|
-
!AWS_REGION_NAME.test(region) ||
|
|
294
|
-
(!localFederated && process.env.GITHUB_ACTIONS !== 'true') ||
|
|
295
|
-
!/^[1-9]\\d*$/.test(runId) ||
|
|
296
|
-
!/^[1-9]\\d*$/.test(runAttempt) ||
|
|
297
|
-
!REFERENCE.test(workflow)
|
|
298
|
-
) {
|
|
299
|
-
throw new Error(
|
|
300
|
-
'Container release requires one exact GitHub or local-federated source, run, account, Region, and stage.',
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
const packageRegistry = (() => {
|
|
304
|
-
if (packageRegistryInput === '') return undefined;
|
|
305
|
-
if (packageRegistryInput.length > 2_048) {
|
|
306
|
-
throw new Error('Container package registry authority is invalid.');
|
|
307
|
-
}
|
|
308
|
-
let parsed;
|
|
309
|
-
try {
|
|
310
|
-
parsed = new URL(packageRegistryInput);
|
|
311
|
-
} catch {
|
|
312
|
-
throw new Error('Container package registry authority is invalid.');
|
|
313
|
-
}
|
|
314
|
-
const normalized = parsed.href;
|
|
315
|
-
const canonicalInput =
|
|
316
|
-
packageRegistryInput === normalized ||
|
|
317
|
-
packageRegistryInput + '/' === normalized;
|
|
318
|
-
const localPlaintext =
|
|
319
|
-
parsed.protocol === 'http:' &&
|
|
320
|
-
['127.0.0.1', 'localhost', 'host.docker.internal', '[::1]'].includes(
|
|
321
|
-
parsed.hostname,
|
|
322
|
-
);
|
|
323
|
-
if (
|
|
324
|
-
!canonicalInput ||
|
|
325
|
-
(parsed.protocol !== 'https:' && !localPlaintext) ||
|
|
326
|
-
parsed.username !== '' ||
|
|
327
|
-
parsed.password !== '' ||
|
|
328
|
-
parsed.search !== '' ||
|
|
329
|
-
parsed.hash !== ''
|
|
330
|
-
) {
|
|
331
|
-
throw new Error('Container package registry authority is invalid.');
|
|
332
|
-
}
|
|
333
|
-
return normalized.endsWith('/') ? normalized.slice(0, -1) : normalized;
|
|
334
|
-
})();
|
|
335
|
-
const requireReviewedCheckout = () => {
|
|
336
|
-
validateReviewedReleaseCheckout({
|
|
337
|
-
deploymentSourceCommit,
|
|
338
|
-
releaseSourceCommit: sourceCommit,
|
|
339
|
-
repositoryRoot,
|
|
340
|
-
});
|
|
341
|
-
const checkoutStatus = execFileSync(
|
|
342
|
-
'git',
|
|
343
|
-
['status', '--porcelain=v1', '--untracked-files=all'],
|
|
344
|
-
{ encoding: 'utf8' },
|
|
345
|
-
);
|
|
346
|
-
if (checkoutStatus.length !== 0) {
|
|
347
|
-
throw new Error(
|
|
348
|
-
'Container release requires an entirely clean reviewed checkout.',
|
|
349
|
-
);
|
|
350
|
-
}
|
|
351
|
-
};
|
|
352
|
-
requireReviewedCheckout();
|
|
353
|
-
const safePath = (candidate, label, options = {}) => {
|
|
354
|
-
if (
|
|
355
|
-
typeof candidate !== 'string' ||
|
|
356
|
-
candidate === '' ||
|
|
357
|
-
candidate !== candidate.trim() ||
|
|
358
|
-
isAbsolute(candidate)
|
|
359
|
-
) {
|
|
360
|
-
throw new Error(label + ' must be one relative repository path.');
|
|
361
|
-
}
|
|
362
|
-
const absolute = resolve(options.base ?? repositoryRoot, candidate);
|
|
363
|
-
const fromRoot = relative(repositoryRoot, absolute);
|
|
364
|
-
if (
|
|
365
|
-
fromRoot === '..' ||
|
|
366
|
-
fromRoot.startsWith('..' + sep) ||
|
|
367
|
-
isAbsolute(fromRoot)
|
|
368
|
-
) {
|
|
369
|
-
throw new Error(label + ' escapes the repository.');
|
|
370
|
-
}
|
|
371
|
-
let walked = repositoryRoot;
|
|
372
|
-
for (const segment of fromRoot.split(sep).filter(Boolean)) {
|
|
373
|
-
walked = join(walked, segment);
|
|
374
|
-
if (!existsSync(walked)) {
|
|
375
|
-
if (options.output) return absolute;
|
|
376
|
-
throw new Error(label + ' is absent.');
|
|
377
|
-
}
|
|
378
|
-
if (lstatSync(walked).isSymbolicLink()) {
|
|
379
|
-
throw new Error(label + ' may not traverse symbolic links.');
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
if (!options.output && realpathSync(absolute) !== absolute) {
|
|
383
|
-
throw new Error(label + ' aliases another path.');
|
|
384
|
-
}
|
|
385
|
-
return absolute;
|
|
386
|
-
};
|
|
387
|
-
const digestCandidatePaths = (paths, label) => {
|
|
388
|
-
if (!Array.isArray(paths) || paths.length === 0) {
|
|
389
|
-
throw new Error(label + ' must name at least one candidate path.');
|
|
390
|
-
}
|
|
391
|
-
const files = [];
|
|
392
|
-
const seen = new Set();
|
|
393
|
-
const visit = (absolute) => {
|
|
394
|
-
const metadata = lstatSync(absolute);
|
|
395
|
-
if (metadata.isSymbolicLink()) {
|
|
396
|
-
throw new Error(label + ' may not traverse symbolic links.');
|
|
397
|
-
}
|
|
398
|
-
if (metadata.isDirectory()) {
|
|
399
|
-
for (const child of readdirSync(absolute).sort()) {
|
|
400
|
-
visit(
|
|
401
|
-
safePath(
|
|
402
|
-
relative(repositoryRoot, join(absolute, child)),
|
|
403
|
-
label,
|
|
404
|
-
),
|
|
405
|
-
);
|
|
406
|
-
}
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (!metadata.isFile()) {
|
|
410
|
-
throw new Error(label + ' may contain only regular files.');
|
|
411
|
-
}
|
|
412
|
-
const normalized = relative(repositoryRoot, absolute)
|
|
413
|
-
.split(sep)
|
|
414
|
-
.join('/');
|
|
415
|
-
if (seen.has(normalized)) {
|
|
416
|
-
throw new Error(label + ' contains overlapping candidate paths.');
|
|
417
|
-
}
|
|
418
|
-
seen.add(normalized);
|
|
419
|
-
files.push([normalized, absolute]);
|
|
420
|
-
};
|
|
421
|
-
for (const candidate of [...paths].sort()) {
|
|
422
|
-
visit(safePath(candidate, label));
|
|
423
|
-
}
|
|
424
|
-
const hash = createHash('sha256');
|
|
425
|
-
for (const [path, absolute] of files.sort(([left], [right]) =>
|
|
426
|
-
left < right ? -1 : left > right ? 1 : 0,
|
|
427
|
-
)) {
|
|
428
|
-
const content = readFileSync(absolute);
|
|
429
|
-
hash.update(path, 'utf8');
|
|
430
|
-
hash.update('\\0');
|
|
431
|
-
hash.update(String(content.byteLength), 'utf8');
|
|
432
|
-
hash.update('\\0');
|
|
433
|
-
hash.update(content);
|
|
434
|
-
hash.update('\\0');
|
|
435
|
-
}
|
|
436
|
-
return hash.digest('hex');
|
|
437
|
-
};
|
|
438
|
-
const readJson = (path, label) => {
|
|
439
|
-
const metadata = lstatSync(path);
|
|
440
|
-
if (
|
|
441
|
-
!metadata.isFile() ||
|
|
442
|
-
metadata.isSymbolicLink() ||
|
|
443
|
-
metadata.size <= 0 ||
|
|
444
|
-
metadata.size > MAX_OUTPUT_BYTES
|
|
445
|
-
) {
|
|
446
|
-
throw new Error(label + ' must be one bounded regular file.');
|
|
447
|
-
}
|
|
448
|
-
try {
|
|
449
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
450
|
-
} catch {
|
|
451
|
-
throw new Error(label + ' is not valid JSON.');
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
const immutableWrite = (path, value) => {
|
|
455
|
-
const serialized =
|
|
456
|
-
typeof value === 'string' ? value : JSON.stringify(value, null, 2) + '\\n';
|
|
457
|
-
mkdirSync(resolve(path, '..'), { recursive: true, mode: 0o700 });
|
|
458
|
-
try {
|
|
459
|
-
writeFileSync(path, serialized, {
|
|
460
|
-
encoding: 'utf8',
|
|
461
|
-
flag: 'wx',
|
|
462
|
-
mode: 0o600,
|
|
463
|
-
});
|
|
464
|
-
} catch (error) {
|
|
465
|
-
if (readFileSync(path, 'utf8') !== serialized) throw error;
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
const execute = (command, args, label, options = {}) => {
|
|
469
|
-
try {
|
|
470
|
-
return execFileSync(command, args, {
|
|
471
|
-
cwd: options.cwd ?? repositoryRoot,
|
|
472
|
-
encoding: options.encoding ?? 'utf8',
|
|
473
|
-
env: { ...process.env, ...(options.env ?? {}) },
|
|
474
|
-
input: options.input,
|
|
475
|
-
maxBuffer: options.maximumBytes ?? MAX_OUTPUT_BYTES,
|
|
476
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
477
|
-
});
|
|
478
|
-
} catch (error) {
|
|
479
|
-
if (options.failureDiagnostics === 'bounded-closure') {
|
|
480
|
-
const diagnosticStream = (value) => {
|
|
481
|
-
const raw = value === undefined || value === null ? '' : String(value);
|
|
482
|
-
if (raw.length === 0) return '[empty]';
|
|
483
|
-
if (hasSensitiveSupplyChainShape(raw)) {
|
|
484
|
-
return '[redacted-sensitive-output]';
|
|
485
|
-
}
|
|
486
|
-
const bytes = Buffer.from(raw, 'utf8');
|
|
487
|
-
const truncated = bytes.byteLength > 1_024;
|
|
488
|
-
const tail = truncated
|
|
489
|
-
? bytes.subarray(bytes.byteLength - 1_024).toString('utf8')
|
|
490
|
-
: raw;
|
|
491
|
-
return JSON.stringify((truncated ? '[truncated]\\n' : '') + tail);
|
|
492
|
-
};
|
|
493
|
-
const status = Number.isSafeInteger(error?.status)
|
|
494
|
-
? String(error.status)
|
|
495
|
-
: 'unavailable';
|
|
496
|
-
const signal =
|
|
497
|
-
typeof error?.signal === 'string' && /^[A-Z0-9]+$/.test(error.signal)
|
|
498
|
-
? error.signal
|
|
499
|
-
: 'none';
|
|
500
|
-
throw new Error(
|
|
501
|
-
label +
|
|
502
|
-
' failed without complete evidence: ' +
|
|
503
|
-
'status=' +
|
|
504
|
-
status +
|
|
505
|
-
'; signal=' +
|
|
506
|
-
signal +
|
|
507
|
-
'; stdout=' +
|
|
508
|
-
diagnosticStream(error?.stdout) +
|
|
509
|
-
'; stderr=' +
|
|
510
|
-
diagnosticStream(error?.stderr),
|
|
511
|
-
);
|
|
512
|
-
}
|
|
513
|
-
throw new Error(
|
|
514
|
-
label + ' failed without complete evidence: ' +
|
|
515
|
-
String(error?.stderr ?? error?.message ?? error).slice(0, 2_000),
|
|
516
|
-
);
|
|
517
|
-
}
|
|
518
|
-
};
|
|
519
|
-
let releaseBuilder;
|
|
520
|
-
let releaseBuildChild;
|
|
521
|
-
let releaseBuildStopPromise;
|
|
522
|
-
let releaseBuilderSignal;
|
|
523
|
-
const releaseBuilderSignalHandlers = new Map();
|
|
524
|
-
const releaseToolTemporaryDirectories = new Set();
|
|
525
|
-
const yieldToReleaseSignals = () =>
|
|
526
|
-
new Promise((resolve) => setImmediate(resolve));
|
|
527
|
-
const stopExactReleaseBuildChild = async (signal = 'SIGTERM') => {
|
|
528
|
-
if (releaseBuildStopPromise) return releaseBuildStopPromise;
|
|
529
|
-
const observed = releaseBuildChild;
|
|
530
|
-
if (!observed) return;
|
|
531
|
-
releaseBuildStopPromise = (async () => {
|
|
532
|
-
const child = observed.child;
|
|
533
|
-
if (hostOperatingSystem() === 'win32') {
|
|
534
|
-
const taskkill = join(process.env.SystemRoot ?? '', 'System32', 'taskkill.exe');
|
|
535
|
-
if (!isAbsolute(taskkill) || !existsSync(taskkill) || realpathSync(taskkill) !== taskkill) {
|
|
536
|
-
throw new Error('Exact Windows Buildx cleanup requires canonical SystemRoot.');
|
|
537
|
-
}
|
|
538
|
-
const stopped = spawnSync(
|
|
539
|
-
taskkill,
|
|
540
|
-
['/PID', String(child.pid), '/T', '/F'],
|
|
541
|
-
{
|
|
542
|
-
cwd: repositoryRoot,
|
|
543
|
-
encoding: 'utf8',
|
|
544
|
-
env: process.env,
|
|
545
|
-
maxBuffer: 1024 * 1024,
|
|
546
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
547
|
-
windowsHide: true,
|
|
548
|
-
},
|
|
549
|
-
);
|
|
550
|
-
if (
|
|
551
|
-
child.exitCode === null &&
|
|
552
|
-
(stopped.error || stopped.signal || stopped.status !== 0)
|
|
553
|
-
) {
|
|
554
|
-
throw new Error('Exact Windows Buildx process-tree cleanup failed.');
|
|
555
|
-
}
|
|
556
|
-
} else if (child.pid) {
|
|
557
|
-
try {
|
|
558
|
-
process.kill(-child.pid, signal);
|
|
559
|
-
} catch (error) {
|
|
560
|
-
if (error?.code !== 'ESRCH') throw error;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
if (child.exitCode === null) {
|
|
564
|
-
const closed = await Promise.race([
|
|
565
|
-
observed.close.then(() => true),
|
|
566
|
-
new Promise((resolve) => setTimeout(() => resolve(false), 5_000)),
|
|
567
|
-
]);
|
|
568
|
-
if (!closed && hostOperatingSystem() !== 'win32' && child.pid) {
|
|
569
|
-
try {
|
|
570
|
-
process.kill(-child.pid, 'SIGKILL');
|
|
571
|
-
} catch (error) {
|
|
572
|
-
if (error?.code !== 'ESRCH') throw error;
|
|
573
|
-
}
|
|
574
|
-
const killed = await Promise.race([
|
|
575
|
-
observed.close.then(() => true),
|
|
576
|
-
new Promise((resolve) => setTimeout(() => resolve(false), 5_000)),
|
|
577
|
-
]);
|
|
578
|
-
if (!killed) {
|
|
579
|
-
throw new Error('Exact Buildx process group did not terminate.');
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
})().finally(() => {
|
|
584
|
-
if (releaseBuildChild === observed) releaseBuildChild = undefined;
|
|
585
|
-
releaseBuildStopPromise = undefined;
|
|
586
|
-
});
|
|
587
|
-
return releaseBuildStopPromise;
|
|
588
|
-
};
|
|
589
|
-
const executeObservedBuildx = async (args, label) => {
|
|
590
|
-
if (releaseBuildChild) {
|
|
591
|
-
throw new Error('Only one invocation-owned Buildx child may run at a time.');
|
|
592
|
-
}
|
|
593
|
-
const child = spawn('docker', args, {
|
|
594
|
-
cwd: repositoryRoot,
|
|
595
|
-
detached: hostOperatingSystem() !== 'win32',
|
|
596
|
-
env: process.env,
|
|
597
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
598
|
-
windowsHide: true,
|
|
599
|
-
});
|
|
600
|
-
const stdout = [];
|
|
601
|
-
const stderr = [];
|
|
602
|
-
let outputBytes = 0;
|
|
603
|
-
const retain = (chunks, stream, chunk) => {
|
|
604
|
-
outputBytes += chunk.byteLength;
|
|
605
|
-
if (outputBytes > MAX_OUTPUT_BYTES) {
|
|
606
|
-
void stopExactReleaseBuildChild('SIGTERM');
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
chunks.push(chunk);
|
|
610
|
-
stream.write(chunk);
|
|
611
|
-
};
|
|
612
|
-
child.stdout.on('data', (chunk) => retain(stdout, process.stdout, chunk));
|
|
613
|
-
child.stderr.on('data', (chunk) => retain(stderr, process.stderr, chunk));
|
|
614
|
-
const close = new Promise((resolve) => {
|
|
615
|
-
child.once('error', (error) => resolve({ error }));
|
|
616
|
-
child.once('close', (status, signal) => resolve({ signal, status }));
|
|
617
|
-
});
|
|
618
|
-
releaseBuildChild = { child, close };
|
|
619
|
-
const result = await close;
|
|
620
|
-
await stopExactReleaseBuildChild();
|
|
621
|
-
if (
|
|
622
|
-
outputBytes > MAX_OUTPUT_BYTES ||
|
|
623
|
-
result.error ||
|
|
624
|
-
result.signal ||
|
|
625
|
-
result.status !== 0
|
|
626
|
-
) {
|
|
627
|
-
throw new Error(
|
|
628
|
-
label + ' failed without complete evidence: ' +
|
|
629
|
-
Buffer.concat(stderr).toString('utf8').slice(-2_000),
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
return Buffer.concat(stdout).toString('utf8');
|
|
633
|
-
};
|
|
634
|
-
const runWindowsPrivateAcl = (script, path, kind) => {
|
|
635
|
-
const systemRoot = process.env.SystemRoot;
|
|
636
|
-
if (!systemRoot || !isAbsolute(systemRoot)) {
|
|
637
|
-
throw new Error('Windows private-path hardening requires an absolute SystemRoot.');
|
|
638
|
-
}
|
|
639
|
-
const powershell = join(
|
|
640
|
-
systemRoot,
|
|
641
|
-
'System32',
|
|
642
|
-
'WindowsPowerShell',
|
|
643
|
-
'v1.0',
|
|
644
|
-
'powershell.exe',
|
|
645
|
-
);
|
|
646
|
-
const result = spawnSync(
|
|
647
|
-
powershell,
|
|
648
|
-
[
|
|
649
|
-
'-NoLogo',
|
|
650
|
-
'-NoProfile',
|
|
651
|
-
'-NonInteractive',
|
|
652
|
-
'-EncodedCommand',
|
|
653
|
-
Buffer.from(script, 'utf16le').toString('base64'),
|
|
654
|
-
],
|
|
655
|
-
{
|
|
656
|
-
cwd: repositoryRoot,
|
|
657
|
-
encoding: 'utf8',
|
|
658
|
-
env: {
|
|
659
|
-
...process.env,
|
|
660
|
-
EBK_PRIVATE_KIND: kind,
|
|
661
|
-
EBK_PRIVATE_PATH: path,
|
|
662
|
-
},
|
|
663
|
-
maxBuffer: 1024 * 1024,
|
|
664
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
665
|
-
timeout: 15_000,
|
|
666
|
-
windowsHide: true,
|
|
667
|
-
},
|
|
668
|
-
);
|
|
669
|
-
if (result.error || result.signal || result.status !== 0) {
|
|
670
|
-
throw new Error(
|
|
671
|
-
'Windows private-path ACL operation failed closed: ' +
|
|
672
|
-
String(result.stderr || result.error?.message || result.signal || result.status)
|
|
673
|
-
.slice(-2_000),
|
|
674
|
-
);
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
const assertPrivateReleaseBuilderPathIdentity = (path, kind) => {
|
|
678
|
-
const metadata = lstatSync(path);
|
|
679
|
-
if (
|
|
680
|
-
metadata.isSymbolicLink() ||
|
|
681
|
-
(kind === 'directory' ? !metadata.isDirectory() : !metadata.isFile()) ||
|
|
682
|
-
realpathSync(path) !== path
|
|
683
|
-
) {
|
|
684
|
-
throw new Error(
|
|
685
|
-
'Container-release builder ownership path failed canonical type validation.',
|
|
686
|
-
);
|
|
687
|
-
}
|
|
688
|
-
return metadata;
|
|
689
|
-
};
|
|
690
|
-
const assertPrivateReleaseBuilderPath = (path, kind) => {
|
|
691
|
-
const metadata = assertPrivateReleaseBuilderPathIdentity(path, kind);
|
|
692
|
-
if (hostOperatingSystem() === 'win32') {
|
|
693
|
-
runWindowsPrivateAcl(WINDOWS_ASSERT_PRIVATE_ACL, path, kind);
|
|
694
|
-
return metadata;
|
|
695
|
-
}
|
|
696
|
-
const expectedMode = kind === 'directory' ? 0o700 : 0o600;
|
|
697
|
-
if (
|
|
698
|
-
(metadata.mode & 0o777) !== expectedMode ||
|
|
699
|
-
(typeof process.getuid === 'function' && metadata.uid !== process.getuid())
|
|
700
|
-
) {
|
|
701
|
-
throw new Error(
|
|
702
|
-
'Container-release builder ownership path is not current-user private.',
|
|
703
|
-
);
|
|
704
|
-
}
|
|
705
|
-
return metadata;
|
|
706
|
-
};
|
|
707
|
-
const hardenPrivateReleaseBuilderPath = (path, kind) => {
|
|
708
|
-
assertPrivateReleaseBuilderPathIdentity(path, kind);
|
|
709
|
-
if (hostOperatingSystem() === 'win32') {
|
|
710
|
-
runWindowsPrivateAcl(WINDOWS_HARDEN_PRIVATE_ACL, path, kind);
|
|
711
|
-
} else {
|
|
712
|
-
chmodSync(path, kind === 'directory' ? 0o700 : 0o600);
|
|
713
|
-
}
|
|
714
|
-
return assertPrivateReleaseBuilderPath(path, kind);
|
|
715
|
-
};
|
|
716
|
-
const assertCanonicalAncestorsBeforeCreate = (requested) => {
|
|
717
|
-
const requestedRelative = relative(repositoryRoot, requested);
|
|
718
|
-
if (
|
|
719
|
-
requestedRelative === '' ||
|
|
720
|
-
requestedRelative === '..' ||
|
|
721
|
-
requestedRelative.startsWith('..' + sep) ||
|
|
722
|
-
isAbsolute(requestedRelative)
|
|
723
|
-
) {
|
|
724
|
-
throw new Error('Container-release builder ownership path escapes its repository.');
|
|
725
|
-
}
|
|
726
|
-
let cursor = repositoryRoot;
|
|
727
|
-
for (const segment of requestedRelative.split(sep)) {
|
|
728
|
-
cursor = join(cursor, segment);
|
|
729
|
-
if (!existsSync(cursor)) break;
|
|
730
|
-
const metadata = lstatSync(cursor);
|
|
731
|
-
if (metadata.isSymbolicLink() || realpathSync(cursor) !== cursor) {
|
|
732
|
-
throw new Error(
|
|
733
|
-
'Container-release builder ownership path has a symbolic or noncanonical ancestor.',
|
|
734
|
-
);
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
};
|
|
738
|
-
const releaseBuilderLeaseRoot = () => {
|
|
739
|
-
const requested = resolve(
|
|
740
|
-
repositoryRoot,
|
|
741
|
-
'.ebk/cache/container-release-builders',
|
|
742
|
-
);
|
|
743
|
-
assertCanonicalAncestorsBeforeCreate(requested);
|
|
744
|
-
mkdirSync(requested, { mode: 0o700, recursive: true });
|
|
745
|
-
hardenPrivateReleaseBuilderPath(requested, 'directory');
|
|
746
|
-
const canonical = realpathSync(requested);
|
|
747
|
-
if (canonical !== requested) {
|
|
748
|
-
throw new Error(
|
|
749
|
-
'Container-release builder leases require one repository-private owned directory.',
|
|
750
|
-
);
|
|
751
|
-
}
|
|
752
|
-
return canonical;
|
|
753
|
-
};
|
|
754
|
-
const readReleaseBuilderLease = (leasePath, expectedName) => {
|
|
755
|
-
const metadata = assertPrivateReleaseBuilderPath(leasePath, 'file');
|
|
756
|
-
if (
|
|
757
|
-
metadata.nlink !== 1 ||
|
|
758
|
-
metadata.size < 2 ||
|
|
759
|
-
metadata.size > 16 * 1024
|
|
760
|
-
) {
|
|
761
|
-
throw new Error('Container-release builder lease is not one private file.');
|
|
762
|
-
}
|
|
763
|
-
let lease;
|
|
764
|
-
try {
|
|
765
|
-
lease = JSON.parse(readFileSync(leasePath, 'utf8'));
|
|
766
|
-
} catch {
|
|
767
|
-
throw new Error('Container-release builder lease is invalid JSON.');
|
|
768
|
-
}
|
|
769
|
-
const keys = Object.keys(lease ?? {}).sort();
|
|
770
|
-
if (
|
|
771
|
-
JSON.stringify(keys) !==
|
|
772
|
-
JSON.stringify([
|
|
773
|
-
'builder',
|
|
774
|
-
'cleanup',
|
|
775
|
-
'createdAt',
|
|
776
|
-
'driver',
|
|
777
|
-
'kind',
|
|
778
|
-
'ownerPid',
|
|
779
|
-
'schemaVersion',
|
|
780
|
-
]) ||
|
|
781
|
-
lease.kind !== 'ebk-container-release-builder-lease' ||
|
|
782
|
-
lease.schemaVersion !== 1 ||
|
|
783
|
-
lease.builder !== expectedName ||
|
|
784
|
-
!/^ebk-release-[a-f0-9]{32}$/.test(lease.builder) ||
|
|
785
|
-
lease.driver !== 'docker-container' ||
|
|
786
|
-
JSON.stringify(lease.cleanup) !==
|
|
787
|
-
JSON.stringify(['docker', 'buildx', 'rm', lease.builder]) ||
|
|
788
|
-
!Number.isSafeInteger(lease.ownerPid) ||
|
|
789
|
-
lease.ownerPid <= 0 ||
|
|
790
|
-
!Number.isFinite(Date.parse(lease.createdAt)) ||
|
|
791
|
-
new Date(lease.createdAt).toISOString() !== lease.createdAt
|
|
792
|
-
) {
|
|
793
|
-
throw new Error('Container-release builder lease has an invalid identity.');
|
|
794
|
-
}
|
|
795
|
-
return lease;
|
|
796
|
-
};
|
|
797
|
-
const removeReleaseBuilderSignalHandlers = () => {
|
|
798
|
-
for (const [signal, handler] of releaseBuilderSignalHandlers) {
|
|
799
|
-
process.removeListener(signal, handler);
|
|
800
|
-
}
|
|
801
|
-
releaseBuilderSignalHandlers.clear();
|
|
802
|
-
};
|
|
803
|
-
const ensureReleaseBuilderSignalHandlers = () => {
|
|
804
|
-
if (releaseBuilderSignalHandlers.size > 0) return;
|
|
805
|
-
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
806
|
-
const handler = () => void handleReleaseBuilderSignal(signal);
|
|
807
|
-
releaseBuilderSignalHandlers.set(signal, handler);
|
|
808
|
-
process.on(signal, handler);
|
|
809
|
-
}
|
|
810
|
-
};
|
|
811
|
-
const removeReleaseBuilderSignalHandlersWhenIdle = () => {
|
|
812
|
-
if (!releaseBuilder && releaseToolTemporaryDirectories.size === 0) {
|
|
813
|
-
removeReleaseBuilderSignalHandlers();
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
const createReleaseToolTemporaryDirectory = (prefix) => {
|
|
817
|
-
const created = mkdtempSync(join(tmpdir(), prefix));
|
|
818
|
-
const metadata = lstatSync(created);
|
|
819
|
-
if (
|
|
820
|
-
!metadata.isDirectory() ||
|
|
821
|
-
metadata.isSymbolicLink() ||
|
|
822
|
-
!isAbsolute(created)
|
|
823
|
-
) {
|
|
824
|
-
throw new Error('Container-release tool temporary directory is not exact.');
|
|
825
|
-
}
|
|
826
|
-
const temporary = realpathSync(created);
|
|
827
|
-
const canonicalMetadata = lstatSync(temporary);
|
|
828
|
-
if (
|
|
829
|
-
!isAbsolute(temporary) ||
|
|
830
|
-
!canonicalMetadata.isDirectory() ||
|
|
831
|
-
canonicalMetadata.isSymbolicLink() ||
|
|
832
|
-
canonicalMetadata.dev !== metadata.dev ||
|
|
833
|
-
canonicalMetadata.ino !== metadata.ino
|
|
834
|
-
) {
|
|
835
|
-
throw new Error('Container-release tool temporary directory is not canonical.');
|
|
836
|
-
}
|
|
837
|
-
releaseToolTemporaryDirectories.add(temporary);
|
|
838
|
-
ensureReleaseBuilderSignalHandlers();
|
|
839
|
-
return temporary;
|
|
840
|
-
};
|
|
841
|
-
const removeExactReleaseToolTemporaryDirectory = (temporary) => {
|
|
842
|
-
if (!releaseToolTemporaryDirectories.has(temporary)) {
|
|
843
|
-
throw new Error('Container-release tool temporary directory is not owned.');
|
|
844
|
-
}
|
|
845
|
-
const metadata = lstatSync(temporary);
|
|
846
|
-
if (
|
|
847
|
-
!metadata.isDirectory() ||
|
|
848
|
-
metadata.isSymbolicLink() ||
|
|
849
|
-
!isAbsolute(temporary) ||
|
|
850
|
-
realpathSync(temporary) !== temporary
|
|
851
|
-
) {
|
|
852
|
-
throw new Error(
|
|
853
|
-
'Container-release tool temporary directory changed identity before cleanup.',
|
|
854
|
-
);
|
|
855
|
-
}
|
|
856
|
-
rmSync(temporary, { force: true, recursive: true });
|
|
857
|
-
if (existsSync(temporary)) {
|
|
858
|
-
throw new Error('Container-release tool temporary directory cleanup failed.');
|
|
859
|
-
}
|
|
860
|
-
releaseToolTemporaryDirectories.delete(temporary);
|
|
861
|
-
removeReleaseBuilderSignalHandlersWhenIdle();
|
|
862
|
-
};
|
|
863
|
-
const removeAllReleaseToolTemporaryDirectories = () => {
|
|
864
|
-
const cleanupErrors = [];
|
|
865
|
-
for (const temporary of [...releaseToolTemporaryDirectories]) {
|
|
866
|
-
try {
|
|
867
|
-
removeExactReleaseToolTemporaryDirectory(temporary);
|
|
868
|
-
} catch (error) {
|
|
869
|
-
cleanupErrors.push(error);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
if (cleanupErrors.length > 0) {
|
|
873
|
-
throw new AggregateError(
|
|
874
|
-
cleanupErrors,
|
|
875
|
-
'Exact container-release tool temporary cleanup failed.',
|
|
876
|
-
);
|
|
877
|
-
}
|
|
878
|
-
};
|
|
879
|
-
const releaseBuilderCleanupDiagnostic = (builder) =>
|
|
880
|
-
'docker buildx rm ' + builder.name +
|
|
881
|
-
' (ownership lease: ' + builder.leasePath + ')';
|
|
882
|
-
const listExactReleaseBuilderNames = ({ signal } = {}) => {
|
|
883
|
-
const inventory = spawnSync(
|
|
884
|
-
'docker',
|
|
885
|
-
['buildx', 'ls', '--format', '{{json .Name}}'],
|
|
886
|
-
{
|
|
887
|
-
cwd: repositoryRoot,
|
|
888
|
-
encoding: 'utf8',
|
|
889
|
-
env: process.env,
|
|
890
|
-
maxBuffer: 1024 * 1024,
|
|
891
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
892
|
-
timeout: signal ? 5_000 : undefined,
|
|
893
|
-
},
|
|
894
|
-
);
|
|
895
|
-
if (inventory.error || inventory.signal || inventory.status !== 0) {
|
|
896
|
-
throw new Error(
|
|
897
|
-
'Invocation-owned Buildx inventory failed while proving exact cleanup: ' +
|
|
898
|
-
String(
|
|
899
|
-
inventory.stderr ||
|
|
900
|
-
inventory.error?.message ||
|
|
901
|
-
inventory.signal ||
|
|
902
|
-
inventory.status,
|
|
903
|
-
).slice(-2_000),
|
|
904
|
-
);
|
|
905
|
-
}
|
|
906
|
-
const lines = inventory.stdout.trim() === ''
|
|
907
|
-
? []
|
|
908
|
-
: inventory.stdout.trim().split(/\\r?\\n/u);
|
|
909
|
-
if (lines.length > 256) {
|
|
910
|
-
throw new Error('Invocation-owned Buildx inventory is unbounded.');
|
|
911
|
-
}
|
|
912
|
-
const names = new Set();
|
|
913
|
-
for (const line of lines) {
|
|
914
|
-
let name;
|
|
915
|
-
try {
|
|
916
|
-
name = JSON.parse(line);
|
|
917
|
-
} catch {
|
|
918
|
-
throw new Error('Invocation-owned Buildx inventory is not exact JSON.');
|
|
919
|
-
}
|
|
920
|
-
if (
|
|
921
|
-
typeof name !== 'string' ||
|
|
922
|
-
name.length === 0 ||
|
|
923
|
-
name.length > 256 ||
|
|
924
|
-
names.has(name)
|
|
925
|
-
) {
|
|
926
|
-
throw new Error('Invocation-owned Buildx inventory has an invalid identity.');
|
|
927
|
-
}
|
|
928
|
-
names.add(name);
|
|
929
|
-
}
|
|
930
|
-
return names;
|
|
931
|
-
};
|
|
932
|
-
const removeExactReleaseBuilder = (builder, { signal } = {}) => {
|
|
933
|
-
readReleaseBuilderLease(builder.leasePath, builder.name);
|
|
934
|
-
const cleanup = spawnSync(
|
|
935
|
-
'docker',
|
|
936
|
-
['buildx', 'rm', builder.name],
|
|
937
|
-
{
|
|
938
|
-
cwd: repositoryRoot,
|
|
939
|
-
encoding: 'utf8',
|
|
940
|
-
env: process.env,
|
|
941
|
-
maxBuffer: 1024 * 1024,
|
|
942
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
943
|
-
timeout: signal ? 5_000 : undefined,
|
|
944
|
-
},
|
|
945
|
-
);
|
|
946
|
-
if (cleanup.error || cleanup.signal || cleanup.status !== 0) {
|
|
947
|
-
let builderNames;
|
|
948
|
-
try {
|
|
949
|
-
builderNames = listExactReleaseBuilderNames({ signal });
|
|
950
|
-
} catch (inventoryError) {
|
|
951
|
-
const error = new AggregateError(
|
|
952
|
-
[
|
|
953
|
-
cleanup.error ?? new Error(String(cleanup.stderr || cleanup.status)),
|
|
954
|
-
inventoryError,
|
|
955
|
-
],
|
|
956
|
-
'Invocation-owned Buildx cleanup and exact absence proof both failed; ' +
|
|
957
|
-
'retain ' + releaseBuilderCleanupDiagnostic(builder) + '.',
|
|
958
|
-
);
|
|
959
|
-
if (signal) {
|
|
960
|
-
process.stderr.write(error.message + '\\n');
|
|
961
|
-
return false;
|
|
962
|
-
}
|
|
963
|
-
throw error;
|
|
964
|
-
}
|
|
965
|
-
if (!builderNames.has(builder.name)) {
|
|
966
|
-
unlinkSync(builder.leasePath);
|
|
967
|
-
process.stderr.write(
|
|
968
|
-
'ebk-release-builder-already-absent ' +
|
|
969
|
-
JSON.stringify({ builder: builder.name, leasePath: builder.leasePath }) +
|
|
970
|
-
'\\n',
|
|
971
|
-
);
|
|
972
|
-
return true;
|
|
973
|
-
}
|
|
974
|
-
const diagnostic = [cleanup.stdout, cleanup.stderr]
|
|
975
|
-
.filter(Boolean)
|
|
976
|
-
.join('\\n')
|
|
977
|
-
.slice(-2_000);
|
|
978
|
-
const error = new Error(
|
|
979
|
-
'Invocation-owned Buildx cleanup failed; use only the exact retained ' +
|
|
980
|
-
'hard-kill cleanup command ' + releaseBuilderCleanupDiagnostic(builder) +
|
|
981
|
-
(diagnostic ? ': ' + diagnostic : ''),
|
|
982
|
-
);
|
|
983
|
-
if (signal) {
|
|
984
|
-
process.stderr.write(error.message + '\\n');
|
|
985
|
-
return false;
|
|
986
|
-
}
|
|
987
|
-
throw error;
|
|
988
|
-
}
|
|
989
|
-
unlinkSync(builder.leasePath);
|
|
990
|
-
return true;
|
|
991
|
-
};
|
|
992
|
-
const recoverReleaseBuilders = () => {
|
|
993
|
-
const leaseRoot = releaseBuilderLeaseRoot();
|
|
994
|
-
const entries = readdirSync(leaseRoot, { withFileTypes: true }).sort(
|
|
995
|
-
(left, right) =>
|
|
996
|
-
left.name < right.name ? -1 : left.name > right.name ? 1 : 0,
|
|
997
|
-
);
|
|
998
|
-
if (entries.length > 64) {
|
|
999
|
-
throw new Error('Container-release builder lease inventory is unbounded.');
|
|
1000
|
-
}
|
|
1001
|
-
for (const entry of entries) {
|
|
1002
|
-
const matched = /^(ebk-release-[a-f0-9]{32})\\.json$/.exec(entry.name);
|
|
1003
|
-
if (!entry.isFile() || !matched) {
|
|
1004
|
-
throw new Error(
|
|
1005
|
-
'Container-release builder lease directory contains an unexpected entry.',
|
|
1006
|
-
);
|
|
1007
|
-
}
|
|
1008
|
-
const leasePath = join(leaseRoot, entry.name);
|
|
1009
|
-
const lease = readReleaseBuilderLease(leasePath, matched[1]);
|
|
1010
|
-
const builderNames = listExactReleaseBuilderNames();
|
|
1011
|
-
if (builderNames.has(lease.builder)) {
|
|
1012
|
-
throw new Error(
|
|
1013
|
-
'A retained invocation-owned Buildx builder still exists; inspect it and use only the exact cleanup command ' +
|
|
1014
|
-
releaseBuilderCleanupDiagnostic({ leasePath, name: lease.builder }) + '.',
|
|
1015
|
-
);
|
|
1016
|
-
}
|
|
1017
|
-
unlinkSync(leasePath);
|
|
1018
|
-
process.stderr.write(
|
|
1019
|
-
'ebk-release-builder-recovered ' +
|
|
1020
|
-
JSON.stringify({ builder: lease.builder, leasePath }) +
|
|
1021
|
-
'\\n',
|
|
1022
|
-
);
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
const cleanupReleaseBuilder = ({ signal } = {}) => {
|
|
1026
|
-
const builder = releaseBuilder;
|
|
1027
|
-
if (!builder) {
|
|
1028
|
-
removeReleaseBuilderSignalHandlersWhenIdle();
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
releaseBuilder = undefined;
|
|
1032
|
-
const removed = removeExactReleaseBuilder(builder, { signal });
|
|
1033
|
-
removeReleaseBuilderSignalHandlersWhenIdle();
|
|
1034
|
-
return removed;
|
|
1035
|
-
};
|
|
1036
|
-
const handleReleaseBuilderSignal = async (signal) => {
|
|
1037
|
-
if (releaseBuilderSignal) return;
|
|
1038
|
-
releaseBuilderSignal = signal;
|
|
1039
|
-
removeReleaseBuilderSignalHandlers();
|
|
1040
|
-
const cleanupErrors = [];
|
|
1041
|
-
let childStopped = false;
|
|
1042
|
-
try {
|
|
1043
|
-
await stopExactReleaseBuildChild(signal);
|
|
1044
|
-
childStopped = true;
|
|
1045
|
-
} catch (error) {
|
|
1046
|
-
cleanupErrors.push(error);
|
|
1047
|
-
}
|
|
1048
|
-
if (childStopped) {
|
|
1049
|
-
try {
|
|
1050
|
-
cleanupReleaseBuilder({ signal });
|
|
1051
|
-
} catch (error) {
|
|
1052
|
-
cleanupErrors.push(error);
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
try {
|
|
1056
|
-
removeAllReleaseToolTemporaryDirectories();
|
|
1057
|
-
} catch (error) {
|
|
1058
|
-
cleanupErrors.push(error);
|
|
1059
|
-
}
|
|
1060
|
-
if (cleanupErrors.length > 0) {
|
|
1061
|
-
process.stderr.write(
|
|
1062
|
-
'Invocation-owned Buildx signal cleanup failed closed; the exact ' +
|
|
1063
|
-
'ownership lease was retained: ' +
|
|
1064
|
-
cleanupErrors
|
|
1065
|
-
.map((error) => String(error?.message ?? error))
|
|
1066
|
-
.join('; ')
|
|
1067
|
-
.slice(-2_000) + '\\n',
|
|
1068
|
-
);
|
|
1069
|
-
}
|
|
1070
|
-
try {
|
|
1071
|
-
removeReleaseBuilderSignalHandlers();
|
|
1072
|
-
} finally {
|
|
1073
|
-
process.kill(process.pid, signal);
|
|
1074
|
-
}
|
|
1075
|
-
};
|
|
1076
|
-
const ensureReleaseBuilder = () => {
|
|
1077
|
-
if (releaseBuilder) return releaseBuilder;
|
|
1078
|
-
const name = 'ebk-release-' + randomBytes(16).toString('hex');
|
|
1079
|
-
const leaseRoot = releaseBuilderLeaseRoot();
|
|
1080
|
-
const leasePath = join(leaseRoot, name + '.json');
|
|
1081
|
-
const builder = {
|
|
1082
|
-
leasePath,
|
|
1083
|
-
leaseRoot,
|
|
1084
|
-
name,
|
|
1085
|
-
};
|
|
1086
|
-
writeFileSync(
|
|
1087
|
-
leasePath,
|
|
1088
|
-
JSON.stringify({
|
|
1089
|
-
builder: name,
|
|
1090
|
-
cleanup: ['docker', 'buildx', 'rm', name],
|
|
1091
|
-
createdAt: new Date().toISOString(),
|
|
1092
|
-
driver: 'docker-container',
|
|
1093
|
-
kind: 'ebk-container-release-builder-lease',
|
|
1094
|
-
ownerPid: process.pid,
|
|
1095
|
-
schemaVersion: 1,
|
|
1096
|
-
}) + '\\n',
|
|
1097
|
-
{ encoding: 'utf8', flag: 'wx', mode: 0o600 },
|
|
1098
|
-
);
|
|
1099
|
-
hardenPrivateReleaseBuilderPath(leasePath, 'file');
|
|
1100
|
-
releaseBuilder = builder;
|
|
1101
|
-
ensureReleaseBuilderSignalHandlers();
|
|
1102
|
-
process.stderr.write(
|
|
1103
|
-
'ebk-release-builder-ownership ' +
|
|
1104
|
-
JSON.stringify({
|
|
1105
|
-
builder: name,
|
|
1106
|
-
hardKillCleanup: ['docker', 'buildx', 'rm', name],
|
|
1107
|
-
leasePath,
|
|
1108
|
-
}) +
|
|
1109
|
-
'\\n',
|
|
1110
|
-
);
|
|
1111
|
-
try {
|
|
1112
|
-
execute(
|
|
1113
|
-
'docker',
|
|
1114
|
-
['buildx', 'create', '--name', name, '--driver', 'docker-container'],
|
|
1115
|
-
'Invocation-owned native Buildx builder creation',
|
|
1116
|
-
);
|
|
1117
|
-
} catch (error) {
|
|
1118
|
-
try {
|
|
1119
|
-
cleanupReleaseBuilder();
|
|
1120
|
-
} catch (cleanupError) {
|
|
1121
|
-
throw new AggregateError(
|
|
1122
|
-
[error, cleanupError],
|
|
1123
|
-
'Invocation-owned Buildx creation and cleanup both failed.',
|
|
1124
|
-
);
|
|
1125
|
-
}
|
|
1126
|
-
throw error;
|
|
1127
|
-
}
|
|
1128
|
-
return builder;
|
|
1129
|
-
};
|
|
1130
|
-
const awsJson = (args, label) => {
|
|
1131
|
-
const raw = execute('aws', args, label);
|
|
1132
|
-
try {
|
|
1133
|
-
return JSON.parse(raw);
|
|
1134
|
-
} catch {
|
|
1135
|
-
throw new Error(label + ' returned invalid JSON.');
|
|
1136
|
-
}
|
|
1137
|
-
};
|
|
1138
|
-
const describeRepository = (repositoryName) => {
|
|
1139
|
-
const result = spawnSync(
|
|
1140
|
-
'aws',
|
|
1141
|
-
[
|
|
1142
|
-
'ecr',
|
|
1143
|
-
'describe-repositories',
|
|
1144
|
-
'--repository-names',
|
|
1145
|
-
repositoryName,
|
|
1146
|
-
'--region',
|
|
1147
|
-
region,
|
|
1148
|
-
'--output',
|
|
1149
|
-
'json',
|
|
1150
|
-
],
|
|
1151
|
-
{
|
|
1152
|
-
cwd: repositoryRoot,
|
|
1153
|
-
encoding: 'utf8',
|
|
1154
|
-
env: process.env,
|
|
1155
|
-
maxBuffer: MAX_OUTPUT_BYTES,
|
|
1156
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
1157
|
-
},
|
|
1158
|
-
);
|
|
1159
|
-
if (result.status === 0) {
|
|
1160
|
-
try {
|
|
1161
|
-
return JSON.parse(result.stdout);
|
|
1162
|
-
} catch {
|
|
1163
|
-
throw new Error('ECR repository lookup returned invalid JSON.');
|
|
1164
|
-
}
|
|
1165
|
-
}
|
|
1166
|
-
const error = String(result.stderr ?? '').trimStart();
|
|
1167
|
-
const notFound =
|
|
1168
|
-
'An error occurred (RepositoryNotFoundException) when calling the DescribeRepositories operation:';
|
|
1169
|
-
if (
|
|
1170
|
-
!error.startsWith(notFound) &&
|
|
1171
|
-
!error.startsWith('aws: [ERROR]: ' + notFound)
|
|
1172
|
-
) {
|
|
1173
|
-
throw new Error('ECR repository lookup failed outside the create-if-absent path.');
|
|
1174
|
-
}
|
|
1175
|
-
return undefined;
|
|
1176
|
-
};
|
|
1177
|
-
const caller = awsJson(
|
|
1178
|
-
['sts', 'get-caller-identity', '--output', 'json'],
|
|
1179
|
-
'AWS caller identity',
|
|
1180
|
-
);
|
|
1181
|
-
if (caller?.Account !== accountId) {
|
|
1182
|
-
throw new Error('Container release AWS caller differs from the target account.');
|
|
1183
|
-
}
|
|
1184
|
-
execute(
|
|
1185
|
-
process.execPath,
|
|
1186
|
-
[
|
|
1187
|
-
safePath(
|
|
1188
|
-
'tools/stage-authority-render.mjs',
|
|
1189
|
-
'Workspace ownership doctor',
|
|
1190
|
-
),
|
|
1191
|
-
'--stage=' + stage,
|
|
1192
|
-
'--ownership-doctor=true',
|
|
1193
|
-
],
|
|
1194
|
-
'Workspace stage ownership',
|
|
1195
|
-
);
|
|
1196
|
-
const controls = readJson(
|
|
1197
|
-
safePath('operations/release.json', 'Release controls', { base: sliceRoot }),
|
|
1198
|
-
'Release controls',
|
|
1199
|
-
);
|
|
1200
|
-
const candidateBundle = safePath(
|
|
1201
|
-
'.ebk/evidence/release-candidate/packages/' + slice +
|
|
1202
|
-
'/release-artifacts.json',
|
|
1203
|
-
'Release artifact evidence',
|
|
1204
|
-
);
|
|
1205
|
-
const artifactEvidence = readJson(candidateBundle, 'Release artifact evidence');
|
|
1206
|
-
if (
|
|
1207
|
-
controls?.schemaVersion !== 1 ||
|
|
1208
|
-
!Array.isArray(controls.artifactInventory) ||
|
|
1209
|
-
controls.artifactInventory.length === 0 ||
|
|
1210
|
-
artifactEvidence?.kind !== 'ebk-release-artifact-evidence' ||
|
|
1211
|
-
artifactEvidence.schemaVersion !== 1 ||
|
|
1212
|
-
artifactEvidence.sourceCommit !== sourceCommit ||
|
|
1213
|
-
!Array.isArray(artifactEvidence.artifacts) ||
|
|
1214
|
-
artifactEvidence.inventoryDigest !==
|
|
1215
|
-
digestBytes(Buffer.from(JSON.stringify(controls.artifactInventory), 'utf8'))
|
|
1216
|
-
) {
|
|
1217
|
-
throw new Error('Container release controls and candidate evidence are stale.');
|
|
1218
|
-
}
|
|
1219
|
-
const capturedByName = new Map(
|
|
1220
|
-
artifactEvidence.artifacts.map((artifact) => [artifact?.name, artifact]),
|
|
1221
|
-
);
|
|
1222
|
-
const declaredContainers = controls.artifactInventory
|
|
1223
|
-
.filter(
|
|
1224
|
-
(artifact) =>
|
|
1225
|
-
artifact?.finalArtifact?.support === 'supported' &&
|
|
1226
|
-
artifact.finalArtifact.family === 'oci-image' &&
|
|
1227
|
-
artifact.finalArtifact.imageConsumption === 'digest-qualified',
|
|
1228
|
-
)
|
|
1229
|
-
.sort((left, right) =>
|
|
1230
|
-
String(left.id) < String(right.id)
|
|
1231
|
-
? -1
|
|
1232
|
-
: String(left.id) > String(right.id)
|
|
1233
|
-
? 1
|
|
1234
|
-
: 0,
|
|
1235
|
-
);
|
|
1236
|
-
if (declaredContainers.length === 0) {
|
|
1237
|
-
throw new Error('Release controls contain no digest-qualified OCI artifacts.');
|
|
1238
|
-
}
|
|
1239
|
-
const releaseContainerInputs = declaredContainers.map((declared, index) => {
|
|
1240
|
-
const identity = validateContainerArtifactIdentity(
|
|
1241
|
-
declared,
|
|
1242
|
-
slice,
|
|
1243
|
-
'artifactInventory[' + String(index) + ']',
|
|
1244
|
-
);
|
|
1245
|
-
const captured = capturedByName.get(declared.name);
|
|
1246
|
-
const candidateArtifactDigest =
|
|
1247
|
-
captured?.classification === 'stage-neutral'
|
|
1248
|
-
? captured.digest
|
|
1249
|
-
: captured?.candidateDigest;
|
|
1250
|
-
const candidate = declared.candidate;
|
|
1251
|
-
// Promotion copies reviewed staging images without rebuilding, so the build
|
|
1252
|
-
// material is never present in that job; the candidate evidence restored
|
|
1253
|
-
// from the exact release artifact already binds the material digest
|
|
1254
|
-
// (EBK-INT-2026-076).
|
|
1255
|
-
const materialDigest =
|
|
1256
|
-
mode === 'promote'
|
|
1257
|
-
? candidateArtifactDigest
|
|
1258
|
-
: digestCandidatePaths(
|
|
1259
|
-
candidate.materialPaths,
|
|
1260
|
-
'OCI artifact candidate material',
|
|
1261
|
-
);
|
|
1262
|
-
const buildRecipeDigest = digestCandidatePaths(
|
|
1263
|
-
candidate.recipePaths,
|
|
1264
|
-
'OCI artifact candidate recipe',
|
|
1265
|
-
);
|
|
1266
|
-
const sourceInputsDigest = digestCandidatePaths(
|
|
1267
|
-
candidate.sourceInputPaths,
|
|
1268
|
-
'OCI artifact source inputs',
|
|
1269
|
-
);
|
|
1270
|
-
const container = declared.finalArtifact.container;
|
|
1271
|
-
if (
|
|
1272
|
-
!declared ||
|
|
1273
|
-
!REFERENCE.test(declared.id ?? '') ||
|
|
1274
|
-
!REFERENCE.test(declared.name ?? '') ||
|
|
1275
|
-
!['job', 'service'].includes(declared.workload) ||
|
|
1276
|
-
!captured ||
|
|
1277
|
-
!SHA256.test(candidateArtifactDigest ?? '') ||
|
|
1278
|
-
!container ||
|
|
1279
|
-
Object.keys(container).sort().join('\\0') !==
|
|
1280
|
-
[
|
|
1281
|
-
'context',
|
|
1282
|
-
'dockerfile',
|
|
1283
|
-
'nativeLifecycleProof',
|
|
1284
|
-
'proofEntrypoints',
|
|
1285
|
-
'proofImports',
|
|
1286
|
-
'role',
|
|
1287
|
-
].join('\\0') ||
|
|
1288
|
-
typeof container.context !== 'string' ||
|
|
1289
|
-
typeof container.dockerfile !== 'string' ||
|
|
1290
|
-
!['job', 'migration', 'retirement', 'service'].includes(container.role) ||
|
|
1291
|
-
!CONTAINER_NATIVE_LIFECYCLE_PROOFS.includes(
|
|
1292
|
-
container.nativeLifecycleProof,
|
|
1293
|
-
) ||
|
|
1294
|
-
!(
|
|
1295
|
-
(container.nativeLifecycleProof === 'service-default-health' &&
|
|
1296
|
-
container.role === 'service') ||
|
|
1297
|
-
(container.nativeLifecycleProof === 'job-default-success' &&
|
|
1298
|
-
container.role === 'job' &&
|
|
1299
|
-
!container.proofEntrypoints?.includes(
|
|
1300
|
-
'dist/jobs/data-retention/src/run.js',
|
|
1301
|
-
)) ||
|
|
1302
|
-
(container.nativeLifecycleProof === 'retention-default-refusal' &&
|
|
1303
|
-
container.role === 'job' &&
|
|
1304
|
-
container.proofEntrypoints?.includes(
|
|
1305
|
-
'dist/jobs/data-retention/src/run.js',
|
|
1306
|
-
)) ||
|
|
1307
|
-
(container.nativeLifecycleProof === 'migration-explicit-refusal' &&
|
|
1308
|
-
container.role === 'migration' &&
|
|
1309
|
-
container.proofEntrypoints?.includes('jobs/migrate-database.mjs')) ||
|
|
1310
|
-
(container.nativeLifecycleProof === 'retirement-explicit-refusal' &&
|
|
1311
|
-
container.role === 'retirement' &&
|
|
1312
|
-
container.proofEntrypoints?.includes('jobs/retire-database.mjs'))
|
|
1313
|
-
) ||
|
|
1314
|
-
!Array.isArray(container.proofEntrypoints) ||
|
|
1315
|
-
container.proofEntrypoints.length === 0 ||
|
|
1316
|
-
container.proofEntrypoints.length > 16 ||
|
|
1317
|
-
container.proofEntrypoints.some(
|
|
1318
|
-
(entrypoint) =>
|
|
1319
|
-
typeof entrypoint !== 'string' ||
|
|
1320
|
-
!/^(?!\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[A-Za-z0-9._/-]{1,256}$/.test(
|
|
1321
|
-
entrypoint,
|
|
1322
|
-
),
|
|
1323
|
-
) ||
|
|
1324
|
-
!Array.isArray(container.proofImports) ||
|
|
1325
|
-
container.proofImports.length === 0 ||
|
|
1326
|
-
container.proofImports.length > 32 ||
|
|
1327
|
-
container.proofImports.some(
|
|
1328
|
-
(specifier) =>
|
|
1329
|
-
typeof specifier !== 'string' ||
|
|
1330
|
-
!/^(?:@[a-z0-9._-]+\\/[a-z0-9._/-]+|[a-z0-9][a-z0-9._/-]*)$/.test(
|
|
1331
|
-
specifier,
|
|
1332
|
-
),
|
|
1333
|
-
)
|
|
1334
|
-
) {
|
|
1335
|
-
throw new Error(
|
|
1336
|
-
'OCI artifact ' + index + ' does not match the exact container contract.',
|
|
1337
|
-
);
|
|
1338
|
-
}
|
|
1339
|
-
if (
|
|
1340
|
-
candidateArtifactDigest !== materialDigest ||
|
|
1341
|
-
captured.buildRecipeDigest !== buildRecipeDigest ||
|
|
1342
|
-
captured.sourceInputsDigest !== sourceInputsDigest ||
|
|
1343
|
-
captured.workload !== declared.workload ||
|
|
1344
|
-
JSON.stringify(captured.stages) !==
|
|
1345
|
-
JSON.stringify(['production', 'staging'])
|
|
1346
|
-
) {
|
|
1347
|
-
throw new Error(
|
|
1348
|
-
'OCI artifact candidate evidence does not bind its exact material, recipe, source, and workload authority.',
|
|
1349
|
-
);
|
|
1350
|
-
}
|
|
1351
|
-
const context = safePath(container.context, 'Container context');
|
|
1352
|
-
const dockerfile = safePath(container.dockerfile, 'Container Dockerfile');
|
|
1353
|
-
if (!lstatSync(context).isDirectory() || !lstatSync(dockerfile).isFile()) {
|
|
1354
|
-
throw new Error('Container context or Dockerfile has the wrong file type.');
|
|
1355
|
-
}
|
|
1356
|
-
const packageManifestPath = safePath(
|
|
1357
|
-
identity.packageManifest,
|
|
1358
|
-
'Container package manifest',
|
|
1359
|
-
);
|
|
1360
|
-
const packageManifest = readJson(
|
|
1361
|
-
packageManifestPath,
|
|
1362
|
-
'Container package manifest',
|
|
1363
|
-
);
|
|
1364
|
-
if (
|
|
1365
|
-
!PACKAGE_NAME.test(packageManifest?.name ?? '') ||
|
|
1366
|
-
typeof packageManifest?.version !== 'string' ||
|
|
1367
|
-
!/^\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?$/.test(packageManifest.version)
|
|
1368
|
-
) {
|
|
1369
|
-
throw new Error('Container package manifest has no exact package identity.');
|
|
1370
|
-
}
|
|
1371
|
-
return {
|
|
1372
|
-
buildRecipeDigest,
|
|
1373
|
-
candidateArtifactDigest,
|
|
1374
|
-
context,
|
|
1375
|
-
declared,
|
|
1376
|
-
dockerfile,
|
|
1377
|
-
materialDigest,
|
|
1378
|
-
packageManifestPath,
|
|
1379
|
-
packageName: packageManifest.name,
|
|
1380
|
-
nativeLifecycleProof: container.nativeLifecycleProof,
|
|
1381
|
-
proofEntrypoints: [...new Set(container.proofEntrypoints)].sort(),
|
|
1382
|
-
proofImports: [...new Set(container.proofImports)].sort(),
|
|
1383
|
-
sourceInputsDigest,
|
|
1384
|
-
};
|
|
1385
|
-
});
|
|
1386
|
-
if (
|
|
1387
|
-
capturedByName.size !== artifactEvidence.artifacts.length ||
|
|
1388
|
-
releaseContainerInputs.some(
|
|
1389
|
-
({ declared }) =>
|
|
1390
|
-
artifactEvidence.artifacts.filter(({ name }) => name === declared.name)
|
|
1391
|
-
.length !== 1,
|
|
1392
|
-
)
|
|
1393
|
-
) {
|
|
1394
|
-
throw new Error('Container release candidate artifact identities are ambiguous.');
|
|
1395
|
-
}
|
|
1396
|
-
const requireCandidateAuthority = (input) => {
|
|
1397
|
-
if (
|
|
1398
|
-
digestCandidatePaths(
|
|
1399
|
-
input.declared.candidate.materialPaths,
|
|
1400
|
-
'OCI artifact candidate material',
|
|
1401
|
-
) !== input.materialDigest ||
|
|
1402
|
-
digestCandidatePaths(
|
|
1403
|
-
input.declared.candidate.recipePaths,
|
|
1404
|
-
'OCI artifact candidate recipe',
|
|
1405
|
-
) !== input.buildRecipeDigest ||
|
|
1406
|
-
digestCandidatePaths(
|
|
1407
|
-
input.declared.candidate.sourceInputPaths,
|
|
1408
|
-
'OCI artifact source inputs',
|
|
1409
|
-
) !== input.sourceInputsDigest
|
|
1410
|
-
) {
|
|
1411
|
-
throw new Error(
|
|
1412
|
-
'Container release source or candidate bytes changed after authority validation.',
|
|
1413
|
-
);
|
|
1414
|
-
}
|
|
1415
|
-
};
|
|
1416
|
-
const retirementArtifactId = slice + '.job.database-retirement';
|
|
1417
|
-
const containerInputs =
|
|
1418
|
-
stage === 'development'
|
|
1419
|
-
? releaseContainerInputs.filter(
|
|
1420
|
-
({ declared }) => declared.id === retirementArtifactId,
|
|
1421
|
-
)
|
|
1422
|
-
: releaseContainerInputs;
|
|
1423
|
-
if (
|
|
1424
|
-
stage === 'development' &&
|
|
1425
|
-
(mode === 'promote' ||
|
|
1426
|
-
containerInputs.length !== 1 ||
|
|
1427
|
-
containerInputs[0]?.declared.finalArtifact.container.role !== 'retirement' ||
|
|
1428
|
-
containerInputs[0]?.nativeLifecycleProof !== 'retirement-explicit-refusal')
|
|
1429
|
-
) {
|
|
1430
|
-
throw new Error(
|
|
1431
|
-
'Development container release is reserved for one exact database-retirement rehearsal artifact.',
|
|
1432
|
-
);
|
|
1433
|
-
}
|
|
1434
|
-
const registrySuffix = region.startsWith('cn-') ? '.com.cn' : '.com';
|
|
1435
|
-
const registry =
|
|
1436
|
-
accountId + '.dkr.ecr.' + region + '.amazonaws' + registrySuffix;
|
|
1437
|
-
const repositoryForStage = (artifactId, targetStage) =>
|
|
1438
|
-
containerReleaseRepositoryName({ artifactId, slice, stage: targetStage });
|
|
1439
|
-
const repositoryFor = (artifactId) => repositoryForStage(artifactId, stage);
|
|
1440
|
-
const ensureRepository = (repositoryName) => {
|
|
1441
|
-
let response = describeRepository(repositoryName);
|
|
1442
|
-
if (!response) {
|
|
1443
|
-
try {
|
|
1444
|
-
const created = awsJson(
|
|
1445
|
-
[
|
|
1446
|
-
'ecr',
|
|
1447
|
-
'create-repository',
|
|
1448
|
-
'--repository-name',
|
|
1449
|
-
repositoryName,
|
|
1450
|
-
'--image-tag-mutability',
|
|
1451
|
-
'IMMUTABLE',
|
|
1452
|
-
'--encryption-configuration',
|
|
1453
|
-
'encryptionType=AES256',
|
|
1454
|
-
'--image-scanning-configuration',
|
|
1455
|
-
'scanOnPush=true',
|
|
1456
|
-
'--region',
|
|
1457
|
-
region,
|
|
1458
|
-
'--output',
|
|
1459
|
-
'json',
|
|
1460
|
-
],
|
|
1461
|
-
'ECR repository creation',
|
|
1462
|
-
);
|
|
1463
|
-
response = { repositories: [created.repository] };
|
|
1464
|
-
} catch (error) {
|
|
1465
|
-
if (!String(error).includes('RepositoryAlreadyExistsException')) {
|
|
1466
|
-
throw error;
|
|
1467
|
-
}
|
|
1468
|
-
response = describeRepository(repositoryName);
|
|
1469
|
-
if (!response) {
|
|
1470
|
-
throw new Error('Raced ECR repository creation did not converge.');
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
}
|
|
1474
|
-
const repositories = response?.repositories;
|
|
1475
|
-
if (
|
|
1476
|
-
!Array.isArray(repositories) ||
|
|
1477
|
-
repositories.length !== 1 ||
|
|
1478
|
-
repositories[0]?.registryId !== accountId ||
|
|
1479
|
-
repositories[0]?.repositoryName !== repositoryName ||
|
|
1480
|
-
repositories[0]?.imageTagMutability !== 'IMMUTABLE' ||
|
|
1481
|
-
repositories[0]?.imageScanningConfiguration?.scanOnPush !== true ||
|
|
1482
|
-
repositories[0]?.encryptionConfiguration?.encryptionType !== 'AES256'
|
|
1483
|
-
) {
|
|
1484
|
-
throw new Error('ECR repository does not match the protected immutable contract.');
|
|
1485
|
-
}
|
|
1486
|
-
};
|
|
1487
|
-
const login = () => {
|
|
1488
|
-
const password = execute(
|
|
1489
|
-
'aws',
|
|
1490
|
-
['ecr', 'get-login-password', '--region', region],
|
|
1491
|
-
'ECR login token',
|
|
1492
|
-
);
|
|
1493
|
-
const result = spawnSync(
|
|
1494
|
-
'docker',
|
|
1495
|
-
['login', '--username', 'AWS', '--password-stdin', registry],
|
|
1496
|
-
{
|
|
1497
|
-
cwd: repositoryRoot,
|
|
1498
|
-
encoding: 'utf8',
|
|
1499
|
-
env: process.env,
|
|
1500
|
-
input: password,
|
|
1501
|
-
maxBuffer: 2 * 1024 * 1024,
|
|
1502
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1503
|
-
},
|
|
1504
|
-
);
|
|
1505
|
-
if (result.status !== 0) {
|
|
1506
|
-
throw new Error('Docker ECR login failed without exposing its credential.');
|
|
1507
|
-
}
|
|
1508
|
-
};
|
|
1509
|
-
const exactImageByTag = (repositoryName, tag) => {
|
|
1510
|
-
const response = awsJson(
|
|
1511
|
-
[
|
|
1512
|
-
'ecr',
|
|
1513
|
-
'describe-images',
|
|
1514
|
-
'--registry-id',
|
|
1515
|
-
accountId,
|
|
1516
|
-
'--repository-name',
|
|
1517
|
-
repositoryName,
|
|
1518
|
-
'--image-ids',
|
|
1519
|
-
'imageTag=' + tag,
|
|
1520
|
-
'--region',
|
|
1521
|
-
region,
|
|
1522
|
-
'--output',
|
|
1523
|
-
'json',
|
|
1524
|
-
],
|
|
1525
|
-
'Exact ECR image lookup',
|
|
1526
|
-
);
|
|
1527
|
-
if (
|
|
1528
|
-
!Array.isArray(response?.imageDetails) ||
|
|
1529
|
-
response.imageDetails.length !== 1 ||
|
|
1530
|
-
response.imageDetails[0]?.registryId !== accountId ||
|
|
1531
|
-
response.imageDetails[0]?.repositoryName !== repositoryName ||
|
|
1532
|
-
!IMAGE_DIGEST.test(response.imageDetails[0]?.imageDigest ?? '')
|
|
1533
|
-
) {
|
|
1534
|
-
throw new Error('Exact ECR image tag is absent or ambiguous.');
|
|
1535
|
-
}
|
|
1536
|
-
return response.imageDetails[0].imageDigest;
|
|
1537
|
-
};
|
|
1538
|
-
const exactImageByDigest = (repositoryName, imageDigest) => {
|
|
1539
|
-
const response = awsJson(
|
|
1540
|
-
[
|
|
1541
|
-
'ecr',
|
|
1542
|
-
'describe-images',
|
|
1543
|
-
'--registry-id',
|
|
1544
|
-
accountId,
|
|
1545
|
-
'--repository-name',
|
|
1546
|
-
repositoryName,
|
|
1547
|
-
'--image-ids',
|
|
1548
|
-
'imageDigest=' + imageDigest,
|
|
1549
|
-
'--region',
|
|
1550
|
-
region,
|
|
1551
|
-
'--output',
|
|
1552
|
-
'json',
|
|
1553
|
-
],
|
|
1554
|
-
'Exact ECR image digest lookup',
|
|
1555
|
-
);
|
|
1556
|
-
return (
|
|
1557
|
-
Array.isArray(response?.imageDetails) &&
|
|
1558
|
-
response.imageDetails.length === 1 &&
|
|
1559
|
-
response.imageDetails[0]?.registryId === accountId &&
|
|
1560
|
-
response.imageDetails[0]?.repositoryName === repositoryName &&
|
|
1561
|
-
response.imageDetails[0]?.imageDigest === imageDigest
|
|
1562
|
-
);
|
|
1563
|
-
};
|
|
1564
|
-
// An unchanged artifact (same candidate material, recipe, Dockerfile, platform,
|
|
1565
|
-
// and production closure) may reuse the image and SBOM retained by the newest
|
|
1566
|
-
// successful deployment on this branch instead of rebuilding. Declining reuse
|
|
1567
|
-
// is always safe: the full native build runs. The native run proof is always
|
|
1568
|
-
// re-executed against the reused image.
|
|
1569
|
-
const reusableBaselinePlatformRecord = (input, requestedPlatform, architecture, repositoryName, expectedClosure) => {
|
|
1570
|
-
const root = optionalCacheRoot('EBK_CONTAINER_BASELINE_ROOT');
|
|
1571
|
-
if (root === '' || process.env.EBK_OCI_REBUILD?.trim() === 'all') return undefined;
|
|
1572
|
-
const safeArtifact = input.declared.name.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
1573
|
-
const recordPath = join(
|
|
1574
|
-
root,
|
|
1575
|
-
'container-release',
|
|
1576
|
-
'partials',
|
|
1577
|
-
stage,
|
|
1578
|
-
slice,
|
|
1579
|
-
architecture,
|
|
1580
|
-
safeArtifact + '.platform.json',
|
|
1581
|
-
);
|
|
1582
|
-
const decline = (reason) => {
|
|
1583
|
-
process.stderr.write(
|
|
1584
|
-
'ebk-container-release-reuse ' +
|
|
1585
|
-
JSON.stringify({ artifact: input.declared.id, platform: requestedPlatform, reason, reused: false }) +
|
|
1586
|
-
'\\n',
|
|
1587
|
-
);
|
|
1588
|
-
return undefined;
|
|
1589
|
-
};
|
|
1590
|
-
if (!existsSync(recordPath) || lstatSync(recordPath).isSymbolicLink()) {
|
|
1591
|
-
return decline('no baseline platform record');
|
|
1592
|
-
}
|
|
1593
|
-
let record;
|
|
1594
|
-
try {
|
|
1595
|
-
record = validateContainerPlatformEvidence(JSON.parse(readFileSync(recordPath, 'utf8')));
|
|
1596
|
-
} catch (error) {
|
|
1597
|
-
return decline('baseline platform record is invalid: ' + String(error?.message ?? error));
|
|
1598
|
-
}
|
|
1599
|
-
if (
|
|
1600
|
-
record.accountId !== accountId ||
|
|
1601
|
-
record.region !== region ||
|
|
1602
|
-
record.stage !== stage ||
|
|
1603
|
-
record.slice !== slice ||
|
|
1604
|
-
record.artifactId !== input.declared.id ||
|
|
1605
|
-
record.artifactName !== input.declared.name ||
|
|
1606
|
-
record.platform !== requestedPlatform ||
|
|
1607
|
-
record.repositoryName !== repositoryName ||
|
|
1608
|
-
record.candidateArtifactDigest !== input.candidateArtifactDigest ||
|
|
1609
|
-
record.dockerfileDigest !== digestBytes(readFileSync(input.dockerfile)) ||
|
|
1610
|
-
record.productionClosureDigest !== expectedClosure.digest ||
|
|
1611
|
-
!IMAGE_DIGEST.test(record.imageDigest) ||
|
|
1612
|
-
record.imageReference !== registry + '/' + repositoryName + '@' + record.imageDigest
|
|
1613
|
-
) {
|
|
1614
|
-
return decline('artifact inputs changed since the baseline');
|
|
1615
|
-
}
|
|
1616
|
-
const evidencePrefix = '.ebk/evidence/';
|
|
1617
|
-
const sbomPath = join(
|
|
1618
|
-
root,
|
|
1619
|
-
record.sbom.path.startsWith(evidencePrefix)
|
|
1620
|
-
? record.sbom.path.slice(evidencePrefix.length)
|
|
1621
|
-
: record.sbom.path,
|
|
1622
|
-
);
|
|
1623
|
-
if (!existsSync(sbomPath) || lstatSync(sbomPath).isSymbolicLink()) {
|
|
1624
|
-
return decline('baseline SBOM is absent');
|
|
1625
|
-
}
|
|
1626
|
-
const sbomBytes = readFileSync(sbomPath);
|
|
1627
|
-
if (digestBytes(sbomBytes) !== record.sbom.sha256) {
|
|
1628
|
-
return decline('baseline SBOM bytes differ from the retained record');
|
|
1629
|
-
}
|
|
1630
|
-
if (!exactImageByDigest(repositoryName, record.imageDigest)) {
|
|
1631
|
-
return decline('baseline image is no longer in the registry');
|
|
1632
|
-
}
|
|
1633
|
-
process.stderr.write(
|
|
1634
|
-
'ebk-container-release-reuse ' +
|
|
1635
|
-
JSON.stringify({
|
|
1636
|
-
artifact: input.declared.id,
|
|
1637
|
-
baselineCommit: record.sourceCommit,
|
|
1638
|
-
imageDigest: record.imageDigest,
|
|
1639
|
-
platform: requestedPlatform,
|
|
1640
|
-
reused: true,
|
|
1641
|
-
}) +
|
|
1642
|
-
'\\n',
|
|
1643
|
-
);
|
|
1644
|
-
return { imageDigest: record.imageDigest, sbomBytes };
|
|
1645
|
-
};
|
|
1646
|
-
const acquireSyft = async () => {
|
|
1647
|
-
const platformKey = process.platform + '-' + process.arch;
|
|
1648
|
-
const release = SYFT_RELEASES[platformKey];
|
|
1649
|
-
if (!release) {
|
|
1650
|
-
throw new Error('No reviewed Syft release exists for ' + platformKey + '.');
|
|
1651
|
-
}
|
|
1652
|
-
const temporary = createReleaseToolTemporaryDirectory('ebk-container-syft-');
|
|
1653
|
-
try {
|
|
1654
|
-
const supplied = process.env.EBK_SYFT_ARCHIVE_PATH?.trim();
|
|
1655
|
-
const archive = supplied
|
|
1656
|
-
? safePath(relative(repositoryRoot, resolve(repositoryRoot, supplied)), 'Supplied Syft archive')
|
|
1657
|
-
: join(temporary, 'syft-archive');
|
|
1658
|
-
const cachedArchive = supplied ? '' : cachedReleaseToolArchive('syft', release.sha256);
|
|
1659
|
-
if (!supplied && cachedArchive && existsSync(cachedArchive)) {
|
|
1660
|
-
// Reuse the archive verified by an earlier invocation on this runner; the
|
|
1661
|
-
// digest check below still runs against the copied bytes.
|
|
1662
|
-
copyFileSync(cachedArchive, archive);
|
|
1663
|
-
} else if (!supplied) {
|
|
1664
|
-
const response = await fetch(release.source, {
|
|
1665
|
-
redirect: 'follow',
|
|
1666
|
-
signal: AbortSignal.timeout(120_000),
|
|
1667
|
-
});
|
|
1668
|
-
if (
|
|
1669
|
-
!response.ok ||
|
|
1670
|
-
Number(response.headers.get('content-length') ?? 0) > MAX_TOOL_BYTES
|
|
1671
|
-
) {
|
|
1672
|
-
throw new Error('Pinned Syft archive download failed or was oversized.');
|
|
1673
|
-
}
|
|
1674
|
-
const bytes = Buffer.from(await response.arrayBuffer());
|
|
1675
|
-
if (bytes.byteLength === 0 || bytes.byteLength > MAX_TOOL_BYTES) {
|
|
1676
|
-
throw new Error('Pinned Syft archive is empty or oversized.');
|
|
1677
|
-
}
|
|
1678
|
-
writeFileSync(archive, bytes, { mode: 0o600 });
|
|
1679
|
-
}
|
|
1680
|
-
const bytes = readFileSync(archive);
|
|
1681
|
-
if (
|
|
1682
|
-
bytes.byteLength === 0 ||
|
|
1683
|
-
bytes.byteLength > MAX_TOOL_BYTES ||
|
|
1684
|
-
digestBytes(bytes) !== release.sha256
|
|
1685
|
-
) {
|
|
1686
|
-
throw new Error('Pinned Syft archive integrity does not match policy.');
|
|
1687
|
-
}
|
|
1688
|
-
if (cachedArchive && !existsSync(cachedArchive)) {
|
|
1689
|
-
mkdirSync(optionalCacheRoot('EBK_RELEASE_TOOL_CACHE_DIR'), { mode: 0o700, recursive: true });
|
|
1690
|
-
writeFileSync(cachedArchive, bytes, { mode: 0o600 });
|
|
1691
|
-
}
|
|
1692
|
-
const path = join(temporary, 'syft');
|
|
1693
|
-
if (release.archiveFormat === 'binary') {
|
|
1694
|
-
writeFileSync(path, bytes, { mode: 0o700 });
|
|
1695
|
-
} else {
|
|
1696
|
-
execute('tar', ['-xzf', archive, '-C', temporary, 'syft'], 'Syft extraction');
|
|
1697
|
-
chmodSync(path, 0o700);
|
|
1698
|
-
}
|
|
1699
|
-
const version = String(execute(path, ['version'], 'Syft version'));
|
|
1700
|
-
await yieldToReleaseSignals();
|
|
1701
|
-
if (
|
|
1702
|
-
!new RegExp('(?:Version|version):?\\\\s*' + SYFT_VERSION.replaceAll('.', '\\\\.')).test(
|
|
1703
|
-
version,
|
|
1704
|
-
)
|
|
1705
|
-
) {
|
|
1706
|
-
throw new Error('Syft runtime version differs from reviewed policy.');
|
|
1707
|
-
}
|
|
1708
|
-
return { path, temporary };
|
|
1709
|
-
} catch (error) {
|
|
1710
|
-
try {
|
|
1711
|
-
removeExactReleaseToolTemporaryDirectory(temporary);
|
|
1712
|
-
} catch (cleanupError) {
|
|
1713
|
-
throw new AggregateError(
|
|
1714
|
-
[error, cleanupError],
|
|
1715
|
-
'Syft acquisition and exact temporary cleanup both failed.',
|
|
1716
|
-
);
|
|
1717
|
-
}
|
|
1718
|
-
throw error;
|
|
1719
|
-
}
|
|
1720
|
-
};
|
|
1721
|
-
const acquireCrane = async () => {
|
|
1722
|
-
const platformKey = process.platform + '-' + process.arch;
|
|
1723
|
-
const release = CRANE_RELEASES[platformKey];
|
|
1724
|
-
if (!release) {
|
|
1725
|
-
throw new Error('No reviewed Crane release exists for ' + platformKey + '.');
|
|
1726
|
-
}
|
|
1727
|
-
const temporary = createReleaseToolTemporaryDirectory('ebk-container-crane-');
|
|
1728
|
-
try {
|
|
1729
|
-
const supplied = process.env.EBK_CRANE_ARCHIVE_PATH?.trim();
|
|
1730
|
-
const archive = supplied
|
|
1731
|
-
? safePath(
|
|
1732
|
-
relative(repositoryRoot, resolve(repositoryRoot, supplied)),
|
|
1733
|
-
'Supplied Crane archive',
|
|
1734
|
-
)
|
|
1735
|
-
: join(temporary, 'crane-archive.tar.gz');
|
|
1736
|
-
const cachedArchive = supplied ? '' : cachedReleaseToolArchive('crane', release.sha256);
|
|
1737
|
-
if (!supplied && cachedArchive && existsSync(cachedArchive)) {
|
|
1738
|
-
copyFileSync(cachedArchive, archive);
|
|
1739
|
-
} else if (!supplied) {
|
|
1740
|
-
const response = await fetch(release.source, {
|
|
1741
|
-
redirect: 'follow',
|
|
1742
|
-
signal: AbortSignal.timeout(120_000),
|
|
1743
|
-
});
|
|
1744
|
-
if (
|
|
1745
|
-
!response.ok ||
|
|
1746
|
-
Number(response.headers.get('content-length') ?? 0) > MAX_TOOL_BYTES
|
|
1747
|
-
) {
|
|
1748
|
-
throw new Error('Pinned Crane archive download failed or was oversized.');
|
|
1749
|
-
}
|
|
1750
|
-
const bytes = Buffer.from(await response.arrayBuffer());
|
|
1751
|
-
if (bytes.byteLength === 0 || bytes.byteLength > MAX_TOOL_BYTES) {
|
|
1752
|
-
throw new Error('Pinned Crane archive is empty or oversized.');
|
|
1753
|
-
}
|
|
1754
|
-
writeFileSync(archive, bytes, { mode: 0o600 });
|
|
1755
|
-
}
|
|
1756
|
-
const bytes = readFileSync(archive);
|
|
1757
|
-
if (
|
|
1758
|
-
bytes.byteLength === 0 ||
|
|
1759
|
-
bytes.byteLength > MAX_TOOL_BYTES ||
|
|
1760
|
-
digestBytes(bytes) !== release.sha256
|
|
1761
|
-
) {
|
|
1762
|
-
throw new Error('Pinned Crane archive integrity does not match policy.');
|
|
1763
|
-
}
|
|
1764
|
-
if (cachedArchive && !existsSync(cachedArchive)) {
|
|
1765
|
-
mkdirSync(optionalCacheRoot('EBK_RELEASE_TOOL_CACHE_DIR'), { mode: 0o700, recursive: true });
|
|
1766
|
-
writeFileSync(cachedArchive, bytes, { mode: 0o600 });
|
|
1767
|
-
}
|
|
1768
|
-
execute('tar', ['-xzf', archive, '-C', temporary, 'crane'], 'Crane extraction');
|
|
1769
|
-
const path = join(temporary, 'crane');
|
|
1770
|
-
chmodSync(path, 0o700);
|
|
1771
|
-
const version = String(execute(path, ['version'], 'Crane version')).trim();
|
|
1772
|
-
await yieldToReleaseSignals();
|
|
1773
|
-
if (
|
|
1774
|
-
!new RegExp('(?:^|\\s|v)' + CRANE_VERSION.replaceAll('.', '\\.') + '(?:$|\\s)').test(
|
|
1775
|
-
version,
|
|
1776
|
-
)
|
|
1777
|
-
) {
|
|
1778
|
-
throw new Error('Crane runtime version differs from reviewed policy.');
|
|
1779
|
-
}
|
|
1780
|
-
return { path, temporary };
|
|
1781
|
-
} catch (error) {
|
|
1782
|
-
try {
|
|
1783
|
-
removeExactReleaseToolTemporaryDirectory(temporary);
|
|
1784
|
-
} catch (cleanupError) {
|
|
1785
|
-
throw new AggregateError(
|
|
1786
|
-
[error, cleanupError],
|
|
1787
|
-
'Crane acquisition and exact temporary cleanup both failed.',
|
|
1788
|
-
);
|
|
1789
|
-
}
|
|
1790
|
-
throw error;
|
|
1791
|
-
}
|
|
1792
|
-
};
|
|
1793
|
-
const parseCycloneDx = (value, label) => {
|
|
1794
|
-
if (
|
|
1795
|
-
value?.bomFormat !== 'CycloneDX' ||
|
|
1796
|
-
value.specVersion !== '1.7' ||
|
|
1797
|
-
value.version !== 1 ||
|
|
1798
|
-
!/^urn:uuid:[a-fA-F0-9-]{36}$/.test(value.serialNumber ?? '') ||
|
|
1799
|
-
!Array.isArray(value.components) ||
|
|
1800
|
-
value.components.length === 0 ||
|
|
1801
|
-
!Array.isArray(value.dependencies) ||
|
|
1802
|
-
!value.metadata ||
|
|
1803
|
-
typeof value.metadata !== 'object'
|
|
1804
|
-
) {
|
|
1805
|
-
throw new Error(label + ' is not complete CycloneDX 1.7.');
|
|
1806
|
-
}
|
|
1807
|
-
return value;
|
|
1808
|
-
};
|
|
1809
|
-
const isVersionlessSyftFileComponent = (component) =>
|
|
1810
|
-
component?.type === 'file' &&
|
|
1811
|
-
component.version === undefined &&
|
|
1812
|
-
component.purl === undefined &&
|
|
1813
|
-
typeof component.name === 'string' &&
|
|
1814
|
-
component.name.startsWith('/') &&
|
|
1815
|
-
component.name.length <= 4_096 &&
|
|
1816
|
-
Array.isArray(component.hashes) &&
|
|
1817
|
-
component.hashes.length === 2 &&
|
|
1818
|
-
component.hashes[0]?.alg === 'SHA-1' &&
|
|
1819
|
-
/^[a-f0-9]{40}$/.test(component.hashes[0]?.content ?? '') &&
|
|
1820
|
-
component.hashes[1]?.alg === 'SHA-256' &&
|
|
1821
|
-
/^[a-f0-9]{64}$/.test(component.hashes[1]?.content ?? '');
|
|
1822
|
-
const componentSetFor = (sbom) =>
|
|
1823
|
-
sbom.components
|
|
1824
|
-
.map((component) => ({
|
|
1825
|
-
name: component?.name,
|
|
1826
|
-
purl: component?.purl ?? '',
|
|
1827
|
-
type: component?.type,
|
|
1828
|
-
version: component?.version ?? '',
|
|
1829
|
-
}))
|
|
1830
|
-
.sort((left, right) =>
|
|
1831
|
-
JSON.stringify(left) < JSON.stringify(right)
|
|
1832
|
-
? -1
|
|
1833
|
-
: JSON.stringify(left) > JSON.stringify(right)
|
|
1834
|
-
? 1
|
|
1835
|
-
: 0,
|
|
1836
|
-
);
|
|
1837
|
-
const npmClosureFor = (syftDocument, options = {}) => {
|
|
1838
|
-
if (!Array.isArray(syftDocument?.artifacts)) {
|
|
1839
|
-
throw new Error('Syft npm closure inventory is malformed.');
|
|
1840
|
-
}
|
|
1841
|
-
const packages = syftDocument.artifacts.flatMap((artifact) => {
|
|
1842
|
-
if (artifact?.type !== 'npm') return [];
|
|
1843
|
-
const locations = Array.isArray(artifact.locations)
|
|
1844
|
-
? artifact.locations.map(({ path }) => {
|
|
1845
|
-
const value = String(path ?? '');
|
|
1846
|
-
return value.startsWith('./')
|
|
1847
|
-
? value.slice(2)
|
|
1848
|
-
: value.startsWith('/')
|
|
1849
|
-
? value.slice(1)
|
|
1850
|
-
: value;
|
|
1851
|
-
})
|
|
1852
|
-
: [];
|
|
1853
|
-
if (
|
|
1854
|
-
options.applicationOnly &&
|
|
1855
|
-
!locations.some(
|
|
1856
|
-
(path) =>
|
|
1857
|
-
path === 'app/package.json' ||
|
|
1858
|
-
path.startsWith('app/node_modules/'),
|
|
1859
|
-
)
|
|
1860
|
-
) {
|
|
1861
|
-
return [];
|
|
1862
|
-
}
|
|
1863
|
-
if (
|
|
1864
|
-
!PACKAGE_NAME.test(artifact.name ?? '') ||
|
|
1865
|
-
typeof artifact.version !== 'string' ||
|
|
1866
|
-
artifact.version.length === 0 ||
|
|
1867
|
-
artifact.version.length > 128
|
|
1868
|
-
) {
|
|
1869
|
-
throw new Error('Syft npm closure contains an invalid package identity.');
|
|
1870
|
-
}
|
|
1871
|
-
return [{ name: artifact.name, version: artifact.version }];
|
|
1872
|
-
});
|
|
1873
|
-
const unique = [
|
|
1874
|
-
...new Map(
|
|
1875
|
-
packages.map((entry) => [entry.name + '@' + entry.version, entry]),
|
|
1876
|
-
).values(),
|
|
1877
|
-
].sort(
|
|
1878
|
-
(left, right) =>
|
|
1879
|
-
(left.name < right.name ? -1 : left.name > right.name ? 1 : 0) ||
|
|
1880
|
-
(left.version < right.version
|
|
1881
|
-
? -1
|
|
1882
|
-
: left.version > right.version
|
|
1883
|
-
? 1
|
|
1884
|
-
: 0),
|
|
1885
|
-
);
|
|
1886
|
-
if (unique.length === 0) {
|
|
1887
|
-
throw new Error('Syft npm closure inventory is empty.');
|
|
1888
|
-
}
|
|
1889
|
-
return unique;
|
|
1890
|
-
};
|
|
1891
|
-
const deriveExpectedProductionClosure = async (syft, input) => {
|
|
1892
|
-
const temporary = createReleaseToolTemporaryDirectory('ebk-container-closure-');
|
|
1893
|
-
const deployed = join(temporary, 'deployed');
|
|
1894
|
-
try {
|
|
1895
|
-
execute(
|
|
1896
|
-
'pnpm',
|
|
1897
|
-
[
|
|
1898
|
-
'--config.store-dir=' +
|
|
1899
|
-
safePath('.ebk/cache/pnpm-store', 'Workspace pnpm store'),
|
|
1900
|
-
'--config.inject-workspace-packages=true',
|
|
1901
|
-
'--filter',
|
|
1902
|
-
input.packageName,
|
|
1903
|
-
'--trust-lockfile',
|
|
1904
|
-
'deploy',
|
|
1905
|
-
'--prod',
|
|
1906
|
-
'--offline',
|
|
1907
|
-
'--frozen-lockfile',
|
|
1908
|
-
deployed,
|
|
1909
|
-
],
|
|
1910
|
-
'Independent production closure deployment',
|
|
1911
|
-
{
|
|
1912
|
-
env: { COREPACK_ENABLE_DOWNLOAD_PROMPT: '0' },
|
|
1913
|
-
failureDiagnostics: 'bounded-closure',
|
|
1914
|
-
},
|
|
1915
|
-
);
|
|
1916
|
-
await yieldToReleaseSignals();
|
|
1917
|
-
const raw = String(
|
|
1918
|
-
execute(
|
|
1919
|
-
syft.path,
|
|
1920
|
-
['scan', 'dir:' + deployed, '--output', 'syft-json'],
|
|
1921
|
-
'Independent production closure inventory',
|
|
1922
|
-
{
|
|
1923
|
-
env: { SYFT_CHECK_FOR_APP_UPDATE: 'false' },
|
|
1924
|
-
failureDiagnostics: 'bounded-closure',
|
|
1925
|
-
},
|
|
1926
|
-
),
|
|
1927
|
-
);
|
|
1928
|
-
await yieldToReleaseSignals();
|
|
1929
|
-
let inventory;
|
|
1930
|
-
try {
|
|
1931
|
-
inventory = JSON.parse(raw);
|
|
1932
|
-
} catch {
|
|
1933
|
-
throw new Error('Independent production closure inventory is invalid JSON.');
|
|
1934
|
-
}
|
|
1935
|
-
const sourceManifest = readJson(
|
|
1936
|
-
input.packageManifestPath,
|
|
1937
|
-
'Container package manifest',
|
|
1938
|
-
);
|
|
1939
|
-
const deployedManifest = readJson(
|
|
1940
|
-
join(deployed, 'package.json'),
|
|
1941
|
-
'Deployed container package manifest',
|
|
1942
|
-
);
|
|
1943
|
-
if (
|
|
1944
|
-
sourceManifest.name !== input.packageName ||
|
|
1945
|
-
typeof sourceManifest.version !== 'string' ||
|
|
1946
|
-
sourceManifest.version.length === 0 ||
|
|
1947
|
-
sourceManifest.version.length > 128 ||
|
|
1948
|
-
deployedManifest.name !== sourceManifest.name ||
|
|
1949
|
-
deployedManifest.version !== sourceManifest.version
|
|
1950
|
-
) {
|
|
1951
|
-
throw new Error(
|
|
1952
|
-
'Independent production closure changed the workload package identity.',
|
|
1953
|
-
);
|
|
1954
|
-
}
|
|
1955
|
-
const packages = npmClosureFor(inventory);
|
|
1956
|
-
if (
|
|
1957
|
-
packages.some(
|
|
1958
|
-
({ name, version }) =>
|
|
1959
|
-
name === sourceManifest.name && version !== sourceManifest.version,
|
|
1960
|
-
)
|
|
1961
|
-
) {
|
|
1962
|
-
throw new Error(
|
|
1963
|
-
'Independent production closure contains a conflicting workload package identity.',
|
|
1964
|
-
);
|
|
1965
|
-
}
|
|
1966
|
-
if (!packages.some(({ name }) => name === sourceManifest.name)) {
|
|
1967
|
-
packages.push({
|
|
1968
|
-
name: sourceManifest.name,
|
|
1969
|
-
version: sourceManifest.version,
|
|
1970
|
-
});
|
|
1971
|
-
packages.sort(
|
|
1972
|
-
(left, right) =>
|
|
1973
|
-
(left.name < right.name ? -1 : left.name > right.name ? 1 : 0) ||
|
|
1974
|
-
(left.version < right.version
|
|
1975
|
-
? -1
|
|
1976
|
-
: left.version > right.version
|
|
1977
|
-
? 1
|
|
1978
|
-
: 0),
|
|
1979
|
-
);
|
|
1980
|
-
}
|
|
1981
|
-
return { digest: supplyChainDigest(packages), packages };
|
|
1982
|
-
} finally {
|
|
1983
|
-
removeExactReleaseToolTemporaryDirectory(temporary);
|
|
1984
|
-
}
|
|
1985
|
-
};
|
|
1986
|
-
const validateRetainedSbom = (entry, label) => {
|
|
1987
|
-
const path = safePath(entry.sbom.path, label, { base: repositoryRoot });
|
|
1988
|
-
const bytes = readFileSync(path);
|
|
1989
|
-
if (digestBytes(bytes) !== entry.sbom.sha256) {
|
|
1990
|
-
throw new Error(label + ' bytes differ from retained evidence.');
|
|
1991
|
-
}
|
|
1992
|
-
let sbom;
|
|
1993
|
-
try {
|
|
1994
|
-
sbom = parseCycloneDx(JSON.parse(bytes.toString('utf8')), label);
|
|
1995
|
-
} catch (error) {
|
|
1996
|
-
if (error instanceof SyntaxError) {
|
|
1997
|
-
throw new Error(label + ' is invalid JSON.');
|
|
1998
|
-
}
|
|
1999
|
-
throw error;
|
|
2000
|
-
}
|
|
2001
|
-
if (
|
|
2002
|
-
sbom.serialNumber.toLowerCase() !== entry.sbom.serialNumber ||
|
|
2003
|
-
supplyChainDigest(componentSetFor(sbom)) !== entry.sbom.componentSetDigest
|
|
2004
|
-
) {
|
|
2005
|
-
throw new Error(label + ' component identity differs from retained evidence.');
|
|
2006
|
-
}
|
|
2007
|
-
return sbom;
|
|
2008
|
-
};
|
|
2009
|
-
const validateRetainedRunProof = (entry, input, label) => {
|
|
2010
|
-
const path = safePath(entry.runProof.path, label, { base: repositoryRoot });
|
|
2011
|
-
const bytes = readFileSync(path);
|
|
2012
|
-
if (digestBytes(bytes) !== entry.runProof.sha256) {
|
|
2013
|
-
throw new Error(label + ' bytes differ from retained evidence.');
|
|
2014
|
-
}
|
|
2015
|
-
const proof = validateContainerNativeRunProof(readJson(path, label));
|
|
2016
|
-
if (
|
|
2017
|
-
proof.materialDigest !== entry.runProof.materialDigest ||
|
|
2018
|
-
proof.accountId !== entry.accountId ||
|
|
2019
|
-
proof.artifactId !== entry.artifactId ||
|
|
2020
|
-
proof.artifactName !== entry.artifactName ||
|
|
2021
|
-
proof.candidateArtifactDigest !== entry.candidateArtifactDigest ||
|
|
2022
|
-
proof.imageDigest !== entry.imageDigest ||
|
|
2023
|
-
proof.platform !== entry.platform ||
|
|
2024
|
-
proof.region !== entry.region ||
|
|
2025
|
-
proof.repositoryName !== entry.repositoryName ||
|
|
2026
|
-
proof.slice !== entry.slice ||
|
|
2027
|
-
proof.sourceCommit !== entry.sourceCommit ||
|
|
2028
|
-
proof.stage !== entry.stage ||
|
|
2029
|
-
proof.nativeLifecycleProof !== input.nativeLifecycleProof ||
|
|
2030
|
-
proof.role !== input.declared.finalArtifact.container.role ||
|
|
2031
|
-
JSON.stringify(proof.entrypoints) !==
|
|
2032
|
-
JSON.stringify(input.proofEntrypoints) ||
|
|
2033
|
-
JSON.stringify(proof.imports) !== JSON.stringify(input.proofImports)
|
|
2034
|
-
) {
|
|
2035
|
-
throw new Error(label + ' is stale, cross-paired, or incomplete.');
|
|
2036
|
-
}
|
|
2037
|
-
return proof;
|
|
2038
|
-
};
|
|
2039
|
-
const runNativeLifecycle = async (input, imageReference, platform) => {
|
|
2040
|
-
const architecture = platform.split('/')[1];
|
|
2041
|
-
const structuralProgram =
|
|
2042
|
-
'const {spawnSync}=await import("node:child_process");' +
|
|
2043
|
-
'const imports=' + JSON.stringify(input.proofImports) + ';' +
|
|
2044
|
-
'for(const value of imports)await import(value);' +
|
|
2045
|
-
'const entrypoints=' + JSON.stringify(input.proofEntrypoints) + ';' +
|
|
2046
|
-
'for(const value of entrypoints){const checked=spawnSync(' +
|
|
2047
|
-
'process.execPath,["--check",value],{encoding:"utf8"});' +
|
|
2048
|
-
'if(checked.status!==0)throw new Error("entrypoint check failed");}' +
|
|
2049
|
-
'process.stdout.write(JSON.stringify({architecture:process.arch,entrypoints,imports}));';
|
|
2050
|
-
const structuralRaw = String(
|
|
2051
|
-
execute(
|
|
2052
|
-
'docker',
|
|
2053
|
-
[
|
|
2054
|
-
'run',
|
|
2055
|
-
'--rm',
|
|
2056
|
-
'--platform',
|
|
2057
|
-
platform,
|
|
2058
|
-
'--entrypoint',
|
|
2059
|
-
'node',
|
|
2060
|
-
imageReference,
|
|
2061
|
-
'--input-type=module',
|
|
2062
|
-
'--eval',
|
|
2063
|
-
structuralProgram,
|
|
2064
|
-
],
|
|
2065
|
-
'Native container structural proof',
|
|
2066
|
-
),
|
|
2067
|
-
);
|
|
2068
|
-
let structural;
|
|
2069
|
-
try {
|
|
2070
|
-
structural = JSON.parse(structuralRaw);
|
|
2071
|
-
} catch {
|
|
2072
|
-
throw new Error('Native container structural proof returned invalid JSON.');
|
|
2073
|
-
}
|
|
2074
|
-
const structuralArchitecture =
|
|
2075
|
-
structural?.architecture === 'x64'
|
|
2076
|
-
? 'amd64'
|
|
2077
|
-
: structural?.architecture;
|
|
2078
|
-
if (
|
|
2079
|
-
structuralArchitecture !== architecture ||
|
|
2080
|
-
JSON.stringify(structural.entrypoints) !==
|
|
2081
|
-
JSON.stringify(input.proofEntrypoints) ||
|
|
2082
|
-
JSON.stringify(structural.imports) !== JSON.stringify(input.proofImports)
|
|
2083
|
-
) {
|
|
2084
|
-
throw new Error('Native container structural proof is incomplete.');
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
if (input.nativeLifecycleProof === 'service-default-health') {
|
|
2088
|
-
const containerId = String(
|
|
2089
|
-
execute(
|
|
2090
|
-
'docker',
|
|
2091
|
-
[
|
|
2092
|
-
'run',
|
|
2093
|
-
'--detach',
|
|
2094
|
-
'--rm',
|
|
2095
|
-
'--platform',
|
|
2096
|
-
platform,
|
|
2097
|
-
'--env',
|
|
2098
|
-
'EBK_STAGE=development',
|
|
2099
|
-
'--publish',
|
|
2100
|
-
'127.0.0.1::3000',
|
|
2101
|
-
imageReference,
|
|
2102
|
-
],
|
|
2103
|
-
'Native service default lifecycle start',
|
|
2104
|
-
),
|
|
2105
|
-
).trim();
|
|
2106
|
-
if (!/^[a-f0-9]{12,64}$/.test(containerId)) {
|
|
2107
|
-
throw new Error('Native service did not return one exact container identity.');
|
|
2108
|
-
}
|
|
2109
|
-
try {
|
|
2110
|
-
let port;
|
|
2111
|
-
let health;
|
|
2112
|
-
for (let attempt = 0; attempt < 40; attempt += 1) {
|
|
2113
|
-
const mapping = spawnSync(
|
|
2114
|
-
'docker',
|
|
2115
|
-
['port', containerId, '3000/tcp'],
|
|
2116
|
-
{
|
|
2117
|
-
cwd: repositoryRoot,
|
|
2118
|
-
encoding: 'utf8',
|
|
2119
|
-
env: process.env,
|
|
2120
|
-
maxBuffer: 1024 * 1024,
|
|
2121
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
2122
|
-
},
|
|
2123
|
-
);
|
|
2124
|
-
const matched = String(mapping.stdout ?? '').trim().match(/:(\\d+)$/);
|
|
2125
|
-
if (mapping.status === 0 && matched) port = matched[1];
|
|
2126
|
-
if (port) {
|
|
2127
|
-
try {
|
|
2128
|
-
const response = await fetch('http://127.0.0.1:' + port + '/health', {
|
|
2129
|
-
signal: AbortSignal.timeout(1_000),
|
|
2130
|
-
});
|
|
2131
|
-
const body = await response.json();
|
|
2132
|
-
if (response.status === 200 && body?.status === 'ok') {
|
|
2133
|
-
health = { body, status: response.status };
|
|
2134
|
-
break;
|
|
2135
|
-
}
|
|
2136
|
-
} catch {
|
|
2137
|
-
// The real service process is still inside its bounded startup window.
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
await new Promise((resolveDelay) => setTimeout(resolveDelay, 250));
|
|
2141
|
-
}
|
|
2142
|
-
if (!port || health?.status !== 200) {
|
|
2143
|
-
throw new Error('Native service default lifecycle did not become healthy.');
|
|
2144
|
-
}
|
|
2145
|
-
const missing = await fetch(
|
|
2146
|
-
'http://127.0.0.1:' + port + '/__ebk_missing_health_proof',
|
|
2147
|
-
{ signal: AbortSignal.timeout(1_000) },
|
|
2148
|
-
);
|
|
2149
|
-
if (missing.status !== 404) {
|
|
2150
|
-
throw new Error('Native service default lifecycle routed an unknown path.');
|
|
2151
|
-
}
|
|
2152
|
-
return {
|
|
2153
|
-
architecture,
|
|
2154
|
-
entrypoints: input.proofEntrypoints,
|
|
2155
|
-
imports: input.proofImports,
|
|
2156
|
-
nativeLifecycleProof: input.nativeLifecycleProof,
|
|
2157
|
-
role: 'service',
|
|
2158
|
-
status: 'passed',
|
|
2159
|
-
};
|
|
2160
|
-
} finally {
|
|
2161
|
-
execute(
|
|
2162
|
-
'docker',
|
|
2163
|
-
['stop', '--time', '5', containerId],
|
|
2164
|
-
'Native service proof cleanup',
|
|
2165
|
-
);
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
|
|
2169
|
-
const databaseName =
|
|
2170
|
-
['development', slice, 'retirement_rehearsal']
|
|
2171
|
-
.join('_')
|
|
2172
|
-
.replaceAll('-', '_');
|
|
2173
|
-
const lifecycleArguments = ['run', '--rm', '--platform', platform];
|
|
2174
|
-
let expectedRefusal;
|
|
2175
|
-
if (input.nativeLifecycleProof === 'retirement-explicit-refusal') {
|
|
2176
|
-
const secretPrefix =
|
|
2177
|
-
'arn:aws:secretsmanager:' + region + ':' + accountId +
|
|
2178
|
-
':secret:ebk/development/' + slice +
|
|
2179
|
-
'/database/retirement_rehearsal/';
|
|
2180
|
-
for (const [name, value] of Object.entries({
|
|
2181
|
-
EBK_CANDIDATE_IDENTITY: input.candidateArtifactDigest,
|
|
2182
|
-
EBK_DATABASE_HOST: 'retirement-proof.invalid',
|
|
2183
|
-
EBK_DATABASE_IDENTIFIER: 'retirement_rehearsal',
|
|
2184
|
-
EBK_DATABASE_LIFECYCLE_CORRELATION_ID: 'native-lifecycle-proof',
|
|
2185
|
-
EBK_DATABASE_MIGRATOR_ROLE: databaseName + '_migrator',
|
|
2186
|
-
EBK_DATABASE_NAME: databaseName,
|
|
2187
|
-
EBK_DATABASE_PORT: '5432',
|
|
2188
|
-
EBK_DATABASE_READONLY_ROLE: databaseName + '_readonly',
|
|
2189
|
-
EBK_DATABASE_READWRITE_ROLE: databaseName + '_readwrite',
|
|
2190
|
-
EBK_EXECUTION_DATABASE_IDENTIFIER: 'retirement_rehearsal',
|
|
2191
|
-
EBK_EXECUTION_SLICE: slice,
|
|
2192
|
-
EBK_EXECUTION_STAGE: 'development',
|
|
2193
|
-
EBK_MASTER_SECRET_ARN: secretPrefix + 'master-proof',
|
|
2194
|
-
EBK_READONLY_SECRET_ARN: secretPrefix + 'readonly-proof',
|
|
2195
|
-
EBK_READWRITE_SECRET_ARN: secretPrefix + 'readwrite-proof',
|
|
2196
|
-
EBK_REGISTRATION_DIGEST: input.candidateArtifactDigest,
|
|
2197
|
-
EBK_SLICE: slice,
|
|
2198
|
-
EBK_STAGE: 'development',
|
|
2199
|
-
})) {
|
|
2200
|
-
lifecycleArguments.push('--env', name + '=' + value);
|
|
2201
|
-
}
|
|
2202
|
-
lifecycleArguments.push(
|
|
2203
|
-
'--entrypoint',
|
|
2204
|
-
'node',
|
|
2205
|
-
imageReference,
|
|
2206
|
-
'jobs/retire-database.mjs',
|
|
2207
|
-
);
|
|
2208
|
-
expectedRefusal = 'EBK_RETIREMENT_ID is required.';
|
|
2209
|
-
} else if (input.nativeLifecycleProof === 'migration-explicit-refusal') {
|
|
2210
|
-
lifecycleArguments.push(
|
|
2211
|
-
'--entrypoint',
|
|
2212
|
-
'node',
|
|
2213
|
-
imageReference,
|
|
2214
|
-
'jobs/migrate-database.mjs',
|
|
2215
|
-
);
|
|
2216
|
-
expectedRefusal = 'EBK_MIGRATION_ID is required.';
|
|
2217
|
-
} else {
|
|
2218
|
-
lifecycleArguments.push(imageReference);
|
|
2219
|
-
if (input.nativeLifecycleProof === 'retention-default-refusal') {
|
|
2220
|
-
expectedRefusal = 'EBK_RETENTION_MODE is required.';
|
|
2221
|
-
}
|
|
2222
|
-
}
|
|
2223
|
-
const lifecycle = spawnSync(
|
|
2224
|
-
'docker',
|
|
2225
|
-
lifecycleArguments,
|
|
2226
|
-
{
|
|
2227
|
-
cwd: repositoryRoot,
|
|
2228
|
-
encoding: 'utf8',
|
|
2229
|
-
env: process.env,
|
|
2230
|
-
maxBuffer: MAX_OUTPUT_BYTES,
|
|
2231
|
-
stdio: ['ignore', 'pipe', 'pipe'],
|
|
2232
|
-
timeout: 30_000,
|
|
2233
|
-
},
|
|
2234
|
-
);
|
|
2235
|
-
if (lifecycle.error || lifecycle.signal || lifecycle.status === null) {
|
|
2236
|
-
throw new Error(
|
|
2237
|
-
'Native container lifecycle proof did not complete normally.',
|
|
2238
|
-
);
|
|
2239
|
-
}
|
|
2240
|
-
const lifecycleOutput =
|
|
2241
|
-
String(lifecycle.stderr ?? '') + String(lifecycle.stdout ?? '');
|
|
2242
|
-
if (expectedRefusal) {
|
|
2243
|
-
if (lifecycle.status === 0 || !lifecycleOutput.includes(expectedRefusal)) {
|
|
2244
|
-
throw new Error(
|
|
2245
|
-
'Protected lifecycle command failed outside its exact missing-authority guard.',
|
|
2246
|
-
);
|
|
2247
|
-
}
|
|
2248
|
-
} else if (
|
|
2249
|
-
input.nativeLifecycleProof !== 'job-default-success' ||
|
|
2250
|
-
lifecycle.status !== 0
|
|
2251
|
-
) {
|
|
2252
|
-
throw new Error(
|
|
2253
|
-
'Native Job default command did not complete successfully.',
|
|
2254
|
-
);
|
|
2255
|
-
}
|
|
2256
|
-
return {
|
|
2257
|
-
architecture,
|
|
2258
|
-
entrypoints: input.proofEntrypoints,
|
|
2259
|
-
imports: input.proofImports,
|
|
2260
|
-
nativeLifecycleProof: input.nativeLifecycleProof,
|
|
2261
|
-
role: input.declared.finalArtifact.container.role,
|
|
2262
|
-
status: 'passed',
|
|
2263
|
-
};
|
|
2264
|
-
};
|
|
2265
|
-
|
|
2266
|
-
let developmentSourceArtifact;
|
|
2267
|
-
if (stage === 'development') {
|
|
2268
|
-
const expectedSourceAccountId =
|
|
2269
|
-
process.env.EBK_STAGING_PROMOTION_EXPECTED_ACCOUNT_ID?.trim() ?? '';
|
|
2270
|
-
const expectedSourceRegion =
|
|
2271
|
-
process.env.EBK_STAGING_PROMOTION_REGION?.trim() ?? '';
|
|
2272
|
-
const deploymentProfile = process.env.EBK_DEPLOYMENT_PROFILE?.trim() ?? '';
|
|
2273
|
-
if (
|
|
2274
|
-
deploymentProfile !== 'starter' &&
|
|
2275
|
-
deploymentProfile !== 'production-isolated' &&
|
|
2276
|
-
deploymentProfile !== 'fully-isolated'
|
|
2277
|
-
) {
|
|
2278
|
-
throw new Error('Container promotion requires one exact deployment profile.');
|
|
2279
|
-
}
|
|
2280
|
-
const sameAccountPromotion = deploymentProfile === 'starter';
|
|
2281
|
-
if (
|
|
2282
|
-
!/^\\d{12}$/.test(expectedSourceAccountId) ||
|
|
2283
|
-
!AWS_REGION_NAME.test(expectedSourceRegion) ||
|
|
2284
|
-
(sameAccountPromotion
|
|
2285
|
-
? expectedSourceAccountId !== accountId || expectedSourceRegion !== region
|
|
2286
|
-
: expectedSourceAccountId === accountId)
|
|
2287
|
-
) {
|
|
2288
|
-
throw new Error(
|
|
2289
|
-
sameAccountPromotion
|
|
2290
|
-
? 'Starter promotion requires the exact shared account and Region.'
|
|
2291
|
-
: 'Isolated promotion requires one independent staging account and exact Region.',
|
|
2292
|
-
);
|
|
2293
|
-
}
|
|
2294
|
-
const sourceBindingPath = safePath(
|
|
2295
|
-
process.env.EBK_CONTAINER_PROMOTION_SOURCE_BINDING_PATH?.trim() ?? '',
|
|
2296
|
-
'Development retirement source binding',
|
|
2297
|
-
);
|
|
2298
|
-
const sourceSidecarPath = safePath(
|
|
2299
|
-
process.env.EBK_CONTAINER_PROMOTION_SOURCE_SIDECAR_PATH?.trim() ?? '',
|
|
2300
|
-
'Development retirement release-bound container sidecar',
|
|
2301
|
-
);
|
|
2302
|
-
const sourceBinding = validateContainerReleaseBinding(
|
|
2303
|
-
readJson(sourceBindingPath, 'Development retirement source binding'),
|
|
2304
|
-
);
|
|
2305
|
-
const sourceSidecar = validateContainerReleaseBinding(
|
|
2306
|
-
readJson(
|
|
2307
|
-
sourceSidecarPath,
|
|
2308
|
-
'Development retirement release-bound container sidecar',
|
|
2309
|
-
),
|
|
2310
|
-
);
|
|
2311
|
-
const sourceCandidateDigests = Object.fromEntries(
|
|
2312
|
-
releaseContainerInputs.map(({ candidateArtifactDigest, declared }) => [
|
|
2313
|
-
declared.id,
|
|
2314
|
-
candidateArtifactDigest,
|
|
2315
|
-
]),
|
|
2316
|
-
);
|
|
2317
|
-
if (
|
|
2318
|
-
sourceBindingPath === sourceSidecarPath ||
|
|
2319
|
-
JSON.stringify(sourceBinding) !== JSON.stringify(sourceSidecar) ||
|
|
2320
|
-
sourceBinding.stage !== 'staging' ||
|
|
2321
|
-
sourceBinding.accountId !== expectedSourceAccountId ||
|
|
2322
|
-
sourceBinding.region !== expectedSourceRegion ||
|
|
2323
|
-
sourceBinding.slice !== slice ||
|
|
2324
|
-
sourceBinding.sourceCommit !== sourceCommit ||
|
|
2325
|
-
sourceBinding.artifacts.length !== releaseContainerInputs.length ||
|
|
2326
|
-
sourceBinding.artifacts.some(
|
|
2327
|
-
({ artifactId, candidateArtifactDigest }) =>
|
|
2328
|
-
sourceCandidateDigests[artifactId] !== candidateArtifactDigest,
|
|
2329
|
-
)
|
|
2330
|
-
) {
|
|
2331
|
-
throw new Error(
|
|
2332
|
-
'Development retirement source is not the exact sealed staging binding.',
|
|
2333
|
-
);
|
|
2334
|
-
}
|
|
2335
|
-
const retirementInput = containerInputs[0];
|
|
2336
|
-
developmentSourceArtifact = resolveContainerReleaseArtifact(sourceBinding, {
|
|
2337
|
-
artifactId: retirementInput.declared.id,
|
|
2338
|
-
candidateArtifactDigest: retirementInput.candidateArtifactDigest,
|
|
2339
|
-
});
|
|
2340
|
-
const dockerfileDigest = digestBytes(readFileSync(retirementInput.dockerfile));
|
|
2341
|
-
const sourceRepositoryName = repositoryForStage(
|
|
2342
|
-
retirementInput.declared.id,
|
|
2343
|
-
'staging',
|
|
2344
|
-
);
|
|
2345
|
-
if (
|
|
2346
|
-
developmentSourceArtifact.artifactName !== retirementInput.declared.name ||
|
|
2347
|
-
developmentSourceArtifact.dockerfileDigest !== dockerfileDigest ||
|
|
2348
|
-
developmentSourceArtifact.repositoryName !== sourceRepositoryName ||
|
|
2349
|
-
developmentSourceArtifact.platforms.some(
|
|
2350
|
-
(platform) =>
|
|
2351
|
-
platform.accountId !== expectedSourceAccountId ||
|
|
2352
|
-
platform.region !== expectedSourceRegion ||
|
|
2353
|
-
platform.slice !== slice ||
|
|
2354
|
-
platform.sourceCommit !== sourceCommit ||
|
|
2355
|
-
platform.stage !== 'staging' ||
|
|
2356
|
-
platform.dockerfileDigest !== dockerfileDigest ||
|
|
2357
|
-
platform.repositoryName !== sourceRepositoryName,
|
|
2358
|
-
)
|
|
2359
|
-
) {
|
|
2360
|
-
throw new Error(
|
|
2361
|
-
'Development retirement source artifact is stale or cross-paired.',
|
|
2362
|
-
);
|
|
2363
|
-
}
|
|
2364
|
-
for (const platform of developmentSourceArtifact.platforms) {
|
|
2365
|
-
validateRetainedSbom(
|
|
2366
|
-
platform,
|
|
2367
|
-
'Development retirement source platform SBOM',
|
|
2368
|
-
);
|
|
2369
|
-
validateRetainedRunProof(
|
|
2370
|
-
platform,
|
|
2371
|
-
retirementInput,
|
|
2372
|
-
'Development retirement source native run proof',
|
|
2373
|
-
);
|
|
2374
|
-
}
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
if (mode === 'promote') {
|
|
2378
|
-
if (stage !== 'production') {
|
|
2379
|
-
throw new Error('Exact OCI promotion targets production only.');
|
|
2380
|
-
}
|
|
2381
|
-
const expectedSourceAccountId =
|
|
2382
|
-
process.env.EBK_STAGING_PROMOTION_EXPECTED_ACCOUNT_ID?.trim() ?? '';
|
|
2383
|
-
const expectedSourceRegion =
|
|
2384
|
-
process.env.EBK_STAGING_PROMOTION_REGION?.trim() ?? '';
|
|
2385
|
-
const deploymentProfile = process.env.EBK_DEPLOYMENT_PROFILE?.trim() ?? '';
|
|
2386
|
-
if (
|
|
2387
|
-
deploymentProfile !== 'starter' &&
|
|
2388
|
-
deploymentProfile !== 'production-isolated' &&
|
|
2389
|
-
deploymentProfile !== 'fully-isolated'
|
|
2390
|
-
) {
|
|
2391
|
-
throw new Error('OCI promotion requires one exact deployment profile.');
|
|
2392
|
-
}
|
|
2393
|
-
const sameAccountPromotion = deploymentProfile === 'starter';
|
|
2394
|
-
if (
|
|
2395
|
-
!/^\\d{12}$/.test(expectedSourceAccountId) ||
|
|
2396
|
-
!AWS_REGION_NAME.test(expectedSourceRegion) ||
|
|
2397
|
-
(sameAccountPromotion
|
|
2398
|
-
? expectedSourceAccountId !== accountId || expectedSourceRegion !== region
|
|
2399
|
-
: expectedSourceAccountId === accountId)
|
|
2400
|
-
) {
|
|
2401
|
-
throw new Error(
|
|
2402
|
-
sameAccountPromotion
|
|
2403
|
-
? 'Starter OCI promotion requires the exact shared account and Region.'
|
|
2404
|
-
: 'Isolated OCI promotion requires one bounded independent staging account and exact Region.',
|
|
2405
|
-
);
|
|
2406
|
-
}
|
|
2407
|
-
const sourceBindingInput =
|
|
2408
|
-
process.env.EBK_CONTAINER_PROMOTION_SOURCE_BINDING_PATH?.trim() ?? '';
|
|
2409
|
-
const sourceBindingPath = safePath(
|
|
2410
|
-
sourceBindingInput,
|
|
2411
|
-
'Promotion source binding',
|
|
2412
|
-
);
|
|
2413
|
-
const sourceBinding = validateContainerReleaseBinding(
|
|
2414
|
-
readJson(sourceBindingPath, 'Promotion source binding'),
|
|
2415
|
-
);
|
|
2416
|
-
const sourceSidecarPath = safePath(
|
|
2417
|
-
process.env.EBK_CONTAINER_PROMOTION_SOURCE_SIDECAR_PATH?.trim() ?? '',
|
|
2418
|
-
'Promotion release-bound container sidecar',
|
|
2419
|
-
);
|
|
2420
|
-
const sourceSidecar = validateContainerReleaseBinding(
|
|
2421
|
-
readJson(sourceSidecarPath, 'Promotion release-bound container sidecar'),
|
|
2422
|
-
);
|
|
2423
|
-
if (
|
|
2424
|
-
sourceSidecarPath === sourceBindingPath ||
|
|
2425
|
-
JSON.stringify(sourceSidecar) !== JSON.stringify(sourceBinding)
|
|
2426
|
-
) {
|
|
2427
|
-
throw new Error(
|
|
2428
|
-
'Promotion source binding differs from the verified staging release sidecar.',
|
|
2429
|
-
);
|
|
2430
|
-
}
|
|
2431
|
-
const candidateDigests = Object.fromEntries(
|
|
2432
|
-
containerInputs.map(({ candidateArtifactDigest, declared }) => [
|
|
2433
|
-
declared.id,
|
|
2434
|
-
candidateArtifactDigest,
|
|
2435
|
-
]),
|
|
2436
|
-
);
|
|
2437
|
-
if (
|
|
2438
|
-
sourceBinding.stage !== 'staging' ||
|
|
2439
|
-
sourceBinding.accountId !== expectedSourceAccountId ||
|
|
2440
|
-
sourceBinding.region !== expectedSourceRegion ||
|
|
2441
|
-
sourceBinding.slice !== slice ||
|
|
2442
|
-
sourceBinding.sourceCommit !== sourceCommit ||
|
|
2443
|
-
sourceBinding.artifacts.length !== containerInputs.length ||
|
|
2444
|
-
sourceBinding.artifacts.some(
|
|
2445
|
-
({ artifactId, candidateArtifactDigest }) =>
|
|
2446
|
-
candidateDigests[artifactId] !== candidateArtifactDigest,
|
|
2447
|
-
)
|
|
2448
|
-
) {
|
|
2449
|
-
throw new Error('Promotion source is not the exact reviewed staging binding.');
|
|
2450
|
-
}
|
|
2451
|
-
const preparedSources = containerInputs.map((input) => {
|
|
2452
|
-
const sourceArtifact = resolveContainerReleaseArtifact(sourceBinding, {
|
|
2453
|
-
artifactId: input.declared.id,
|
|
2454
|
-
candidateArtifactDigest: input.candidateArtifactDigest,
|
|
2455
|
-
});
|
|
2456
|
-
const dockerfileDigest = digestBytes(readFileSync(input.dockerfile));
|
|
2457
|
-
const sourceRepositoryName = repositoryForStage(
|
|
2458
|
-
input.declared.id,
|
|
2459
|
-
'staging',
|
|
2460
|
-
);
|
|
2461
|
-
if (
|
|
2462
|
-
sourceArtifact.artifactName !== input.declared.name ||
|
|
2463
|
-
sourceArtifact.dockerfileDigest !== dockerfileDigest ||
|
|
2464
|
-
sourceArtifact.repositoryName !== sourceRepositoryName ||
|
|
2465
|
-
sourceArtifact.platforms.some(
|
|
2466
|
-
(platform) =>
|
|
2467
|
-
platform.accountId !== expectedSourceAccountId ||
|
|
2468
|
-
platform.region !== expectedSourceRegion ||
|
|
2469
|
-
platform.slice !== slice ||
|
|
2470
|
-
platform.sourceCommit !== sourceCommit ||
|
|
2471
|
-
platform.stage !== 'staging' ||
|
|
2472
|
-
platform.dockerfileDigest !== dockerfileDigest ||
|
|
2473
|
-
platform.repositoryName !== sourceRepositoryName,
|
|
2474
|
-
)
|
|
2475
|
-
) {
|
|
2476
|
-
throw new Error(
|
|
2477
|
-
'Promotion source artifact is stale or belongs to another build authority.',
|
|
2478
|
-
);
|
|
2479
|
-
}
|
|
2480
|
-
for (const platform of sourceArtifact.platforms) {
|
|
2481
|
-
validateRetainedSbom(platform, 'Promotion source platform SBOM');
|
|
2482
|
-
validateRetainedRunProof(
|
|
2483
|
-
platform,
|
|
2484
|
-
input,
|
|
2485
|
-
'Promotion source native run proof',
|
|
2486
|
-
);
|
|
2487
|
-
}
|
|
2488
|
-
return { input, sourceArtifact };
|
|
2489
|
-
});
|
|
2490
|
-
const crane = await acquireCrane();
|
|
2491
|
-
try {
|
|
2492
|
-
login();
|
|
2493
|
-
const artifacts = [];
|
|
2494
|
-
for (const { input, sourceArtifact } of preparedSources) {
|
|
2495
|
-
const repositoryName = repositoryFor(input.declared.id);
|
|
2496
|
-
ensureRepository(repositoryName);
|
|
2497
|
-
const tag =
|
|
2498
|
-
'promotion-' + sourceCommit + '-' + runId + '-' + runAttempt + '-index';
|
|
2499
|
-
const taggedReference = registry + '/' + repositoryName + ':' + tag;
|
|
2500
|
-
execute(
|
|
2501
|
-
crane.path,
|
|
2502
|
-
[
|
|
2503
|
-
'copy',
|
|
2504
|
-
sourceArtifact.imageReference,
|
|
2505
|
-
taggedReference,
|
|
2506
|
-
],
|
|
2507
|
-
'Recursive exact staging OCI index promotion',
|
|
2508
|
-
);
|
|
2509
|
-
const imageDigest = exactImageByTag(repositoryName, tag);
|
|
2510
|
-
if (imageDigest !== sourceArtifact.imageDigest) {
|
|
2511
|
-
throw new Error('Production OCI index digest differs from reviewed staging.');
|
|
2512
|
-
}
|
|
2513
|
-
const imageReference = registry + '/' + repositoryName + '@' + imageDigest;
|
|
2514
|
-
const rawIndex = String(
|
|
2515
|
-
execute(
|
|
2516
|
-
'docker',
|
|
2517
|
-
['buildx', 'imagetools', 'inspect', '--raw', imageReference],
|
|
2518
|
-
'Promoted OCI index inspection',
|
|
2519
|
-
),
|
|
2520
|
-
);
|
|
2521
|
-
let index;
|
|
2522
|
-
try {
|
|
2523
|
-
index = JSON.parse(rawIndex);
|
|
2524
|
-
} catch {
|
|
2525
|
-
throw new Error('Promoted OCI index inspection returned invalid JSON.');
|
|
2526
|
-
}
|
|
2527
|
-
const rawDescriptors = Array.isArray(index?.manifests)
|
|
2528
|
-
? index.manifests
|
|
2529
|
-
: [];
|
|
2530
|
-
const descriptors = rawDescriptors
|
|
2531
|
-
.map((descriptor) => ({
|
|
2532
|
-
digest: descriptor?.digest,
|
|
2533
|
-
platform:
|
|
2534
|
-
String(descriptor?.platform?.os) + '/' +
|
|
2535
|
-
String(descriptor?.platform?.architecture),
|
|
2536
|
-
}))
|
|
2537
|
-
.sort((left, right) =>
|
|
2538
|
-
left.platform < right.platform
|
|
2539
|
-
? -1
|
|
2540
|
-
: left.platform > right.platform
|
|
2541
|
-
? 1
|
|
2542
|
-
: 0,
|
|
2543
|
-
);
|
|
2544
|
-
const sourcePlatforms = [...sourceArtifact.platforms].sort((left, right) =>
|
|
2545
|
-
left.platform < right.platform
|
|
2546
|
-
? -1
|
|
2547
|
-
: left.platform > right.platform
|
|
2548
|
-
? 1
|
|
2549
|
-
: 0,
|
|
2550
|
-
);
|
|
2551
|
-
if (
|
|
2552
|
-
![
|
|
2553
|
-
'application/vnd.oci.image.index.v1+json',
|
|
2554
|
-
'application/vnd.docker.distribution.manifest.list.v2+json',
|
|
2555
|
-
].includes(index?.mediaType) ||
|
|
2556
|
-
rawDescriptors.length !== CONTAINER_RELEASE_PLATFORMS.length ||
|
|
2557
|
-
descriptors.some(
|
|
2558
|
-
({ digest, platform }) =>
|
|
2559
|
-
!IMAGE_DIGEST.test(digest) ||
|
|
2560
|
-
!CONTAINER_RELEASE_PLATFORMS.includes(platform),
|
|
2561
|
-
) ||
|
|
2562
|
-
descriptors.some(
|
|
2563
|
-
(descriptor, index) =>
|
|
2564
|
-
descriptor.platform !== sourcePlatforms[index]?.platform ||
|
|
2565
|
-
descriptor.digest !== sourcePlatforms[index]?.imageDigest,
|
|
2566
|
-
)
|
|
2567
|
-
) {
|
|
2568
|
-
throw new Error('Production OCI child manifests differ from staging.');
|
|
2569
|
-
}
|
|
2570
|
-
for (const descriptor of descriptors) {
|
|
2571
|
-
const response = awsJson(
|
|
2572
|
-
[
|
|
2573
|
-
'ecr',
|
|
2574
|
-
'batch-get-image',
|
|
2575
|
-
'--repository-name',
|
|
2576
|
-
repositoryName,
|
|
2577
|
-
'--image-ids',
|
|
2578
|
-
'imageDigest=' + descriptor.digest,
|
|
2579
|
-
'--accepted-media-types',
|
|
2580
|
-
'application/vnd.oci.image.manifest.v1+json',
|
|
2581
|
-
'application/vnd.docker.distribution.manifest.v2+json',
|
|
2582
|
-
'--region',
|
|
2583
|
-
region,
|
|
2584
|
-
'--output',
|
|
2585
|
-
'json',
|
|
2586
|
-
],
|
|
2587
|
-
'Promoted OCI child manifest lookup',
|
|
2588
|
-
);
|
|
2589
|
-
const image = response?.images?.[0];
|
|
2590
|
-
if (
|
|
2591
|
-
!Array.isArray(response?.images) ||
|
|
2592
|
-
response.images.length !== 1 ||
|
|
2593
|
-
!Array.isArray(response?.failures) ||
|
|
2594
|
-
response.failures.length !== 0 ||
|
|
2595
|
-
image?.imageId?.imageDigest !== descriptor.digest ||
|
|
2596
|
-
typeof image?.imageManifest !== 'string' ||
|
|
2597
|
-
image.imageManifest.length === 0 ||
|
|
2598
|
-
Buffer.byteLength(image.imageManifest, 'utf8') > MAX_OUTPUT_BYTES ||
|
|
2599
|
-
![
|
|
2600
|
-
'application/vnd.oci.image.manifest.v1+json',
|
|
2601
|
-
'application/vnd.docker.distribution.manifest.v2+json',
|
|
2602
|
-
].includes(image.imageManifestMediaType)
|
|
2603
|
-
) {
|
|
2604
|
-
throw new Error(
|
|
2605
|
-
'Promoted OCI child manifest is absent from the target repository.',
|
|
2606
|
-
);
|
|
2607
|
-
}
|
|
2608
|
-
}
|
|
2609
|
-
const platforms = sourcePlatforms.map((platform) =>
|
|
2610
|
-
createContainerPlatformEvidence({
|
|
2611
|
-
accountId,
|
|
2612
|
-
artifactId: platform.artifactId,
|
|
2613
|
-
artifactName: platform.artifactName,
|
|
2614
|
-
candidateArtifactDigest: platform.candidateArtifactDigest,
|
|
2615
|
-
dockerfileDigest: platform.dockerfileDigest,
|
|
2616
|
-
imageDigest: platform.imageDigest,
|
|
2617
|
-
imageReference:
|
|
2618
|
-
registry + '/' + repositoryName + '@' + platform.imageDigest,
|
|
2619
|
-
platform: platform.platform,
|
|
2620
|
-
productionClosureDigest: platform.productionClosureDigest,
|
|
2621
|
-
region,
|
|
2622
|
-
repositoryName,
|
|
2623
|
-
runProof: platform.runProof,
|
|
2624
|
-
sbom: platform.sbom,
|
|
2625
|
-
slice,
|
|
2626
|
-
sourceCommit,
|
|
2627
|
-
stage: 'production',
|
|
2628
|
-
}),
|
|
2629
|
-
);
|
|
2630
|
-
artifacts.push({
|
|
2631
|
-
...sourceArtifact,
|
|
2632
|
-
imageReference,
|
|
2633
|
-
platforms,
|
|
2634
|
-
repositoryName,
|
|
2635
|
-
sbomParityDigest: supplyChainDigest(
|
|
2636
|
-
platforms.map((entry) => ({
|
|
2637
|
-
componentSetDigest: entry.sbom.componentSetDigest,
|
|
2638
|
-
platform: entry.platform,
|
|
2639
|
-
productionClosureDigest: entry.productionClosureDigest,
|
|
2640
|
-
runProof: entry.runProof,
|
|
2641
|
-
})),
|
|
2642
|
-
),
|
|
2643
|
-
});
|
|
2644
|
-
}
|
|
2645
|
-
const binding = createContainerReleaseBinding({
|
|
2646
|
-
accountId,
|
|
2647
|
-
artifacts,
|
|
2648
|
-
builtAt: new Date().toISOString(),
|
|
2649
|
-
provenance: { runAttempt, runId, workflow },
|
|
2650
|
-
region,
|
|
2651
|
-
slice,
|
|
2652
|
-
sourceCommit,
|
|
2653
|
-
stage: 'production',
|
|
2654
|
-
});
|
|
2655
|
-
const output = resolve(
|
|
2656
|
-
repositoryRoot,
|
|
2657
|
-
'.ebk/evidence/container-release/production/packages',
|
|
2658
|
-
slice,
|
|
2659
|
-
'binding.json',
|
|
2660
|
-
);
|
|
2661
|
-
await yieldToReleaseSignals();
|
|
2662
|
-
immutableWrite(output, binding);
|
|
2663
|
-
process.stdout.write(
|
|
2664
|
-
JSON.stringify({
|
|
2665
|
-
artifactCount: artifacts.length,
|
|
2666
|
-
bindingDigest: binding.materialDigest,
|
|
2667
|
-
evidencePath: output,
|
|
2668
|
-
promotedFrom: sourceBinding.materialDigest,
|
|
2669
|
-
schemaVersion: 1,
|
|
2670
|
-
stage,
|
|
2671
|
-
}) + '\\n',
|
|
2672
|
-
);
|
|
2673
|
-
} finally {
|
|
2674
|
-
removeExactReleaseToolTemporaryDirectory(crane.temporary);
|
|
2675
|
-
}
|
|
2676
|
-
process.exit(0);
|
|
2677
|
-
}
|
|
2678
|
-
|
|
2679
|
-
if (mode === 'platform') {
|
|
2680
|
-
let syft;
|
|
2681
|
-
let crane;
|
|
2682
|
-
let platformError;
|
|
2683
|
-
try {
|
|
2684
|
-
syft = await acquireSyft();
|
|
2685
|
-
crane =
|
|
2686
|
-
stage === 'development' || optionalCacheRoot('EBK_CONTAINER_BASELINE_ROOT') !== ''
|
|
2687
|
-
? await acquireCrane()
|
|
2688
|
-
: undefined;
|
|
2689
|
-
recoverReleaseBuilders();
|
|
2690
|
-
// Artifacts that share a package, recipe, and Dockerfile (the migration and
|
|
2691
|
-
// retirement jobs) resolve one identical production closure.
|
|
2692
|
-
const expectedClosures = new Map();
|
|
2693
|
-
const closuresByRecipe = new Map();
|
|
2694
|
-
for (const input of containerInputs) {
|
|
2695
|
-
const recipeKey =
|
|
2696
|
-
input.packageName +
|
|
2697
|
-
':' +
|
|
2698
|
-
input.buildRecipeDigest +
|
|
2699
|
-
':' +
|
|
2700
|
-
digestBytes(readFileSync(input.dockerfile));
|
|
2701
|
-
if (!closuresByRecipe.has(recipeKey)) {
|
|
2702
|
-
closuresByRecipe.set(
|
|
2703
|
-
recipeKey,
|
|
2704
|
-
await deriveExpectedProductionClosure(syft, input),
|
|
2705
|
-
);
|
|
2706
|
-
}
|
|
2707
|
-
expectedClosures.set(input.declared.id, closuresByRecipe.get(recipeKey));
|
|
2708
|
-
}
|
|
2709
|
-
requireReviewedCheckout();
|
|
2710
|
-
for (const input of containerInputs) requireCandidateAuthority(input);
|
|
2711
|
-
login();
|
|
2712
|
-
const architecture = requestedPlatform.split('/')[1];
|
|
2713
|
-
const outputRoot = resolve(
|
|
2714
|
-
repositoryRoot,
|
|
2715
|
-
'.ebk/evidence/container-release/partials',
|
|
2716
|
-
stage,
|
|
2717
|
-
slice,
|
|
2718
|
-
architecture,
|
|
2719
|
-
);
|
|
2720
|
-
for (const input of containerInputs) {
|
|
2721
|
-
const expectedClosure = expectedClosures.get(input.declared.id);
|
|
2722
|
-
if (!expectedClosure) {
|
|
2723
|
-
throw new Error('Independent production closure is absent.');
|
|
2724
|
-
}
|
|
2725
|
-
const repositoryName = repositoryFor(input.declared.id);
|
|
2726
|
-
ensureRepository(repositoryName);
|
|
2727
|
-
const tag =
|
|
2728
|
-
'candidate-' + sourceCommit + '-' + runId + '-' + runAttempt + '-' +
|
|
2729
|
-
architecture;
|
|
2730
|
-
const taggedReference = registry + '/' + repositoryName + ':' + tag;
|
|
2731
|
-
requireReviewedCheckout();
|
|
2732
|
-
requireCandidateAuthority(input);
|
|
2733
|
-
const developmentSourcePlatform =
|
|
2734
|
-
stage === 'development'
|
|
2735
|
-
? developmentSourceArtifact?.platforms.find(
|
|
2736
|
-
({ platform }) => platform === requestedPlatform,
|
|
2737
|
-
)
|
|
2738
|
-
: undefined;
|
|
2739
|
-
const reusable =
|
|
2740
|
-
stage === 'development'
|
|
2741
|
-
? undefined
|
|
2742
|
-
: reusableBaselinePlatformRecord(
|
|
2743
|
-
input,
|
|
2744
|
-
requestedPlatform,
|
|
2745
|
-
architecture,
|
|
2746
|
-
repositoryName,
|
|
2747
|
-
expectedClosure,
|
|
2748
|
-
);
|
|
2749
|
-
if (reusable) {
|
|
2750
|
-
if (!crane) throw new Error('Unchanged artifact reuse requires the reviewed crane.');
|
|
2751
|
-
execute(
|
|
2752
|
-
crane.path,
|
|
2753
|
-
['copy', registry + '/' + repositoryName + '@' + reusable.imageDigest, taggedReference],
|
|
2754
|
-
'Unchanged artifact re-tag without rebuilding',
|
|
2755
|
-
);
|
|
2756
|
-
} else if (stage === 'development') {
|
|
2757
|
-
if (!crane || !developmentSourcePlatform) {
|
|
2758
|
-
throw new Error(
|
|
2759
|
-
'Development retirement source platform is absent.',
|
|
2760
|
-
);
|
|
2761
|
-
}
|
|
2762
|
-
execute(
|
|
2763
|
-
crane.path,
|
|
2764
|
-
['copy', developmentSourcePlatform.imageReference, taggedReference],
|
|
2765
|
-
'Exact staging retirement child promotion',
|
|
2766
|
-
);
|
|
2767
|
-
} else {
|
|
2768
|
-
// One BuildKit builder serves every artifact of this invocation so
|
|
2769
|
-
// shared layers (pnpm fetch, filtered install) are reused across the
|
|
2770
|
-
// Slice's images; the platform-mode finally block removes it.
|
|
2771
|
-
const platformBuilder = ensureReleaseBuilder();
|
|
2772
|
-
const layerCache = buildxLayerCache(repositoryName, architecture);
|
|
2773
|
-
await executeObservedBuildx([
|
|
2774
|
-
'buildx',
|
|
2775
|
-
'build',
|
|
2776
|
-
'--builder',
|
|
2777
|
-
platformBuilder.name,
|
|
2778
|
-
...(packageRegistry
|
|
2779
|
-
? [
|
|
2780
|
-
'--build-arg',
|
|
2781
|
-
'NPM_CONFIG_REGISTRY=' + packageRegistry,
|
|
2782
|
-
]
|
|
2783
|
-
: []),
|
|
2784
|
-
...layerCache.arguments,
|
|
2785
|
-
'--file',
|
|
2786
|
-
relative(repositoryRoot, input.dockerfile),
|
|
2787
|
-
'--label',
|
|
2788
|
-
'org.opencontainers.image.revision=' + sourceCommit,
|
|
2789
|
-
'--label',
|
|
2790
|
-
'dev.empire-builder-kit.candidate-digest=' +
|
|
2791
|
-
input.candidateArtifactDigest,
|
|
2792
|
-
'--platform',
|
|
2793
|
-
requestedPlatform,
|
|
2794
|
-
'--provenance=false',
|
|
2795
|
-
'--push',
|
|
2796
|
-
'--sbom=false',
|
|
2797
|
-
'--tag',
|
|
2798
|
-
taggedReference,
|
|
2799
|
-
relative(repositoryRoot, input.context) || '.',
|
|
2800
|
-
], 'Native container build and push');
|
|
2801
|
-
layerCache.commit();
|
|
2802
|
-
}
|
|
2803
|
-
const imageDigest = exactImageByTag(repositoryName, tag);
|
|
2804
|
-
const imageReference = registry + '/' + repositoryName + '@' + imageDigest;
|
|
2805
|
-
if (reusable && reusable.imageDigest !== imageDigest) {
|
|
2806
|
-
throw new Error('Unchanged artifact re-tag differs from the baseline image.');
|
|
2807
|
-
}
|
|
2808
|
-
if (
|
|
2809
|
-
stage === 'development' &&
|
|
2810
|
-
developmentSourcePlatform?.imageDigest !== imageDigest
|
|
2811
|
-
) {
|
|
2812
|
-
throw new Error(
|
|
2813
|
-
'Development retirement child promotion differs from exact staging.',
|
|
2814
|
-
);
|
|
2815
|
-
}
|
|
2816
|
-
const runtimeManifestRaw = String(
|
|
2817
|
-
execute(
|
|
2818
|
-
'docker',
|
|
2819
|
-
['buildx', 'imagetools', 'inspect', '--raw', imageReference],
|
|
2820
|
-
'Native runtime manifest inspection',
|
|
2821
|
-
),
|
|
2822
|
-
);
|
|
2823
|
-
let runtimeManifest;
|
|
2824
|
-
try {
|
|
2825
|
-
runtimeManifest = JSON.parse(runtimeManifestRaw);
|
|
2826
|
-
} catch {
|
|
2827
|
-
throw new Error('Native runtime manifest inspection returned invalid JSON.');
|
|
2828
|
-
}
|
|
2829
|
-
if (
|
|
2830
|
-
![
|
|
2831
|
-
'application/vnd.oci.image.manifest.v1+json',
|
|
2832
|
-
'application/vnd.docker.distribution.manifest.v2+json',
|
|
2833
|
-
].includes(runtimeManifest?.mediaType) ||
|
|
2834
|
-
Array.isArray(runtimeManifest?.manifests)
|
|
2835
|
-
) {
|
|
2836
|
-
throw new Error(
|
|
2837
|
-
'Native build must publish one plain runtime manifest; the integrity-bound Syft SBOM is retained separately.',
|
|
2838
|
-
);
|
|
2839
|
-
}
|
|
2840
|
-
const runProof = await runNativeLifecycle(
|
|
2841
|
-
input,
|
|
2842
|
-
imageReference,
|
|
2843
|
-
requestedPlatform,
|
|
2844
|
-
);
|
|
2845
|
-
if (
|
|
2846
|
-
runProof.architecture !== architecture ||
|
|
2847
|
-
runProof.status !== 'passed' ||
|
|
2848
|
-
runProof.nativeLifecycleProof !== input.nativeLifecycleProof ||
|
|
2849
|
-
JSON.stringify(runProof.entrypoints) !==
|
|
2850
|
-
JSON.stringify(input.proofEntrypoints) ||
|
|
2851
|
-
JSON.stringify(runProof.imports) !== JSON.stringify(input.proofImports) ||
|
|
2852
|
-
runProof.role !== input.declared.finalArtifact.container.role
|
|
2853
|
-
) {
|
|
2854
|
-
throw new Error('Native production container run proof is incomplete.');
|
|
2855
|
-
}
|
|
2856
|
-
const safeArtifact = input.declared.name.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
2857
|
-
const nativeRunProof = createContainerNativeRunProof({
|
|
2858
|
-
accountId,
|
|
2859
|
-
artifactId: input.declared.id,
|
|
2860
|
-
artifactName: input.declared.name,
|
|
2861
|
-
candidateArtifactDigest: input.candidateArtifactDigest,
|
|
2862
|
-
entrypoints: runProof.entrypoints,
|
|
2863
|
-
imageDigest,
|
|
2864
|
-
imports: runProof.imports,
|
|
2865
|
-
nativeLifecycleProof: runProof.nativeLifecycleProof,
|
|
2866
|
-
platform: requestedPlatform,
|
|
2867
|
-
region,
|
|
2868
|
-
repositoryName,
|
|
2869
|
-
role: runProof.role,
|
|
2870
|
-
slice,
|
|
2871
|
-
sourceCommit,
|
|
2872
|
-
stage,
|
|
2873
|
-
status: runProof.status,
|
|
2874
|
-
});
|
|
2875
|
-
const serializedRunProof = JSON.stringify(nativeRunProof, null, 2) + '\\n';
|
|
2876
|
-
const relativeRunProofPath =
|
|
2877
|
-
'.ebk/evidence/container-release/partials/' + stage + '/' +
|
|
2878
|
-
slice + '/' + architecture + '/' + safeArtifact + '.run-proof.json';
|
|
2879
|
-
immutableWrite(
|
|
2880
|
-
resolve(repositoryRoot, relativeRunProofPath),
|
|
2881
|
-
serializedRunProof,
|
|
2882
|
-
);
|
|
2883
|
-
if (!reusable) {
|
|
2884
|
-
const closureRaw = String(
|
|
2885
|
-
execute(
|
|
2886
|
-
syft.path,
|
|
2887
|
-
['scan', 'registry:' + imageReference, '--output', 'syft-json'],
|
|
2888
|
-
'Exact application npm closure inventory',
|
|
2889
|
-
{ env: { SYFT_CHECK_FOR_APP_UPDATE: 'false' } },
|
|
2890
|
-
),
|
|
2891
|
-
);
|
|
2892
|
-
let closureInventory;
|
|
2893
|
-
try {
|
|
2894
|
-
closureInventory = JSON.parse(closureRaw);
|
|
2895
|
-
} catch {
|
|
2896
|
-
throw new Error('Exact application npm closure inventory is invalid JSON.');
|
|
2897
|
-
}
|
|
2898
|
-
const observedClosure = npmClosureFor(closureInventory, {
|
|
2899
|
-
applicationOnly: true,
|
|
2900
|
-
});
|
|
2901
|
-
if (
|
|
2902
|
-
JSON.stringify(observedClosure) !==
|
|
2903
|
-
JSON.stringify(expectedClosure.packages)
|
|
2904
|
-
) {
|
|
2905
|
-
throw new Error(
|
|
2906
|
-
'Container application npm closure differs from the independently deployed production closure.',
|
|
2907
|
-
);
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
const rawSbom = reusable
|
|
2911
|
-
? reusable.sbomBytes.toString('utf8')
|
|
2912
|
-
: String(
|
|
2913
|
-
execute(
|
|
2914
|
-
syft.path,
|
|
2915
|
-
['scan', 'registry:' + imageReference, '--output', 'cyclonedx-json'],
|
|
2916
|
-
'Exact platform OCI SBOM',
|
|
2917
|
-
{ env: { SYFT_CHECK_FOR_APP_UPDATE: 'false' } },
|
|
2918
|
-
),
|
|
2919
|
-
);
|
|
2920
|
-
let sbom;
|
|
2921
|
-
try {
|
|
2922
|
-
sbom = parseCycloneDx(
|
|
2923
|
-
JSON.parse(rawSbom),
|
|
2924
|
-
'Syft platform SBOM',
|
|
2925
|
-
);
|
|
2926
|
-
} catch {
|
|
2927
|
-
throw new Error('Syft returned invalid platform CycloneDX JSON.');
|
|
2928
|
-
}
|
|
2929
|
-
const componentSet = componentSetFor(sbom);
|
|
2930
|
-
if (
|
|
2931
|
-
sbom.components.some(
|
|
2932
|
-
(component) =>
|
|
2933
|
-
typeof component?.name !== 'string' ||
|
|
2934
|
-
component.name.length === 0 ||
|
|
2935
|
-
typeof component.type !== 'string' ||
|
|
2936
|
-
component.type.length === 0 ||
|
|
2937
|
-
!(
|
|
2938
|
-
(typeof component.version === 'string' &&
|
|
2939
|
-
component.version.length > 0) ||
|
|
2940
|
-
isVersionlessSyftFileComponent(component)
|
|
2941
|
-
),
|
|
2942
|
-
)
|
|
2943
|
-
) {
|
|
2944
|
-
throw new Error('Platform SBOM contains an invalid component identity.');
|
|
2945
|
-
}
|
|
2946
|
-
const serializedSbom = JSON.stringify(sbom, null, 2) + '\\n';
|
|
2947
|
-
const relativeSbomPath =
|
|
2948
|
-
'.ebk/evidence/container-release/partials/' + stage + '/' +
|
|
2949
|
-
slice + '/' + architecture + '/' + safeArtifact + '.cdx.json';
|
|
2950
|
-
immutableWrite(resolve(repositoryRoot, relativeSbomPath), serializedSbom);
|
|
2951
|
-
const evidence = createContainerPlatformEvidence({
|
|
2952
|
-
accountId,
|
|
2953
|
-
artifactId: input.declared.id,
|
|
2954
|
-
artifactName: input.declared.name,
|
|
2955
|
-
candidateArtifactDigest: input.candidateArtifactDigest,
|
|
2956
|
-
dockerfileDigest: digestBytes(readFileSync(input.dockerfile)),
|
|
2957
|
-
imageDigest,
|
|
2958
|
-
imageReference,
|
|
2959
|
-
platform: requestedPlatform,
|
|
2960
|
-
productionClosureDigest: expectedClosure.digest,
|
|
2961
|
-
region,
|
|
2962
|
-
repositoryName,
|
|
2963
|
-
runProof: {
|
|
2964
|
-
materialDigest: nativeRunProof.materialDigest,
|
|
2965
|
-
path: relativeRunProofPath,
|
|
2966
|
-
sha256: digestBytes(Buffer.from(serializedRunProof, 'utf8')),
|
|
2967
|
-
},
|
|
2968
|
-
sbom: {
|
|
2969
|
-
componentSetDigest: supplyChainDigest(componentSet),
|
|
2970
|
-
path: relativeSbomPath,
|
|
2971
|
-
serialNumber: sbom.serialNumber.toLowerCase(),
|
|
2972
|
-
sha256: digestBytes(Buffer.from(serializedSbom, 'utf8')),
|
|
2973
|
-
},
|
|
2974
|
-
slice,
|
|
2975
|
-
sourceCommit,
|
|
2976
|
-
stage,
|
|
2977
|
-
});
|
|
2978
|
-
immutableWrite(
|
|
2979
|
-
join(outputRoot, safeArtifact + '.platform.json'),
|
|
2980
|
-
evidence,
|
|
2981
|
-
);
|
|
2982
|
-
}
|
|
2983
|
-
await yieldToReleaseSignals();
|
|
2984
|
-
process.stdout.write(
|
|
2985
|
-
JSON.stringify({
|
|
2986
|
-
artifactCount: containerInputs.length,
|
|
2987
|
-
platform: requestedPlatform,
|
|
2988
|
-
schemaVersion: 1,
|
|
2989
|
-
stage,
|
|
2990
|
-
}) + '\\n',
|
|
2991
|
-
);
|
|
2992
|
-
} catch (error) {
|
|
2993
|
-
platformError = error;
|
|
2994
|
-
} finally {
|
|
2995
|
-
const cleanupErrors = [];
|
|
2996
|
-
for (const cleanup of [
|
|
2997
|
-
() => cleanupReleaseBuilder(),
|
|
2998
|
-
...(syft
|
|
2999
|
-
? [() => removeExactReleaseToolTemporaryDirectory(syft.temporary)]
|
|
3000
|
-
: []),
|
|
3001
|
-
...(crane
|
|
3002
|
-
? [() => removeExactReleaseToolTemporaryDirectory(crane.temporary)]
|
|
3003
|
-
: []),
|
|
3004
|
-
]) {
|
|
3005
|
-
try {
|
|
3006
|
-
cleanup();
|
|
3007
|
-
} catch (error) {
|
|
3008
|
-
cleanupErrors.push(error);
|
|
3009
|
-
}
|
|
3010
|
-
}
|
|
3011
|
-
if (cleanupErrors.length > 0) {
|
|
3012
|
-
throw new AggregateError(
|
|
3013
|
-
[...(platformError ? [platformError] : []), ...cleanupErrors],
|
|
3014
|
-
'Container platform release and independent owned-resource cleanup failed.',
|
|
3015
|
-
);
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
if (platformError) throw platformError;
|
|
3019
|
-
process.exit(0);
|
|
3020
|
-
}
|
|
3021
|
-
|
|
3022
|
-
const partialRoot = resolve(
|
|
3023
|
-
repositoryRoot,
|
|
3024
|
-
'.ebk/evidence/container-release/partials',
|
|
3025
|
-
stage,
|
|
3026
|
-
slice,
|
|
3027
|
-
);
|
|
3028
|
-
if (!existsSync(partialRoot) || !lstatSync(partialRoot).isDirectory()) {
|
|
3029
|
-
throw new Error('Container platform evidence directory is absent.');
|
|
3030
|
-
}
|
|
3031
|
-
const partialPaths = [];
|
|
3032
|
-
const visit = (directory) => {
|
|
3033
|
-
for (const entry of readdirSync(directory).sort()) {
|
|
3034
|
-
const path = join(directory, entry);
|
|
3035
|
-
const metadata = lstatSync(path);
|
|
3036
|
-
if (metadata.isSymbolicLink()) {
|
|
3037
|
-
throw new Error('Container platform evidence may not contain symlinks.');
|
|
3038
|
-
}
|
|
3039
|
-
if (metadata.isDirectory()) visit(path);
|
|
3040
|
-
else if (metadata.isFile() && entry.endsWith('.platform.json')) {
|
|
3041
|
-
partialPaths.push(path);
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
};
|
|
3045
|
-
visit(partialRoot);
|
|
3046
|
-
if (
|
|
3047
|
-
partialPaths.length !==
|
|
3048
|
-
containerInputs.length * CONTAINER_RELEASE_PLATFORMS.length
|
|
3049
|
-
) {
|
|
3050
|
-
throw new Error('Container platform evidence is incomplete or excessive.');
|
|
3051
|
-
}
|
|
3052
|
-
const partials = partialPaths.map((path) =>
|
|
3053
|
-
validateContainerPlatformEvidence(readJson(path, 'Container platform evidence')),
|
|
3054
|
-
);
|
|
3055
|
-
const preparedArtifacts = containerInputs.map((input) => {
|
|
3056
|
-
const evidence = partials
|
|
3057
|
-
.filter(({ artifactId }) => artifactId === input.declared.id)
|
|
3058
|
-
.sort((left, right) =>
|
|
3059
|
-
left.platform < right.platform
|
|
3060
|
-
? -1
|
|
3061
|
-
: left.platform > right.platform
|
|
3062
|
-
? 1
|
|
3063
|
-
: 0,
|
|
3064
|
-
);
|
|
3065
|
-
const repositoryName = repositoryFor(input.declared.id);
|
|
3066
|
-
const dockerfileDigest = digestBytes(readFileSync(input.dockerfile));
|
|
3067
|
-
const expectedPlatforms = [...CONTAINER_RELEASE_PLATFORMS].sort();
|
|
3068
|
-
if (
|
|
3069
|
-
evidence.length !== CONTAINER_RELEASE_PLATFORMS.length ||
|
|
3070
|
-
evidence.some(
|
|
3071
|
-
(entry, index) =>
|
|
3072
|
-
entry.accountId !== accountId ||
|
|
3073
|
-
entry.region !== region ||
|
|
3074
|
-
entry.slice !== slice ||
|
|
3075
|
-
entry.sourceCommit !== sourceCommit ||
|
|
3076
|
-
entry.stage !== stage ||
|
|
3077
|
-
entry.artifactId !== input.declared.id ||
|
|
3078
|
-
entry.artifactName !== input.declared.name ||
|
|
3079
|
-
entry.candidateArtifactDigest !== input.candidateArtifactDigest ||
|
|
3080
|
-
entry.dockerfileDigest !== dockerfileDigest ||
|
|
3081
|
-
entry.repositoryName !== repositoryName ||
|
|
3082
|
-
entry.platform !== expectedPlatforms[index] ||
|
|
3083
|
-
entry.productionClosureDigest !== evidence[0]?.productionClosureDigest,
|
|
3084
|
-
)
|
|
3085
|
-
) {
|
|
3086
|
-
throw new Error(
|
|
3087
|
-
'Container platform evidence is stale, cross-paired, or incomplete.',
|
|
3088
|
-
);
|
|
3089
|
-
}
|
|
3090
|
-
for (const entry of evidence) {
|
|
3091
|
-
validateRetainedSbom(entry, 'Container platform SBOM');
|
|
3092
|
-
validateRetainedRunProof(entry, input, 'Container native run proof');
|
|
3093
|
-
}
|
|
3094
|
-
return { dockerfileDigest, evidence, input, repositoryName };
|
|
3095
|
-
});
|
|
3096
|
-
const assemblyCrane = stage === 'development' ? await acquireCrane() : undefined;
|
|
3097
|
-
try {
|
|
3098
|
-
login();
|
|
3099
|
-
const artifacts = [];
|
|
3100
|
-
for (const prepared of preparedArtifacts) {
|
|
3101
|
-
const { dockerfileDigest, evidence, input, repositoryName } = prepared;
|
|
3102
|
-
ensureRepository(repositoryName);
|
|
3103
|
-
const tag =
|
|
3104
|
-
'candidate-' + sourceCommit + '-' + runId + '-' + runAttempt + '-index';
|
|
3105
|
-
const taggedReference = registry + '/' + repositoryName + ':' + tag;
|
|
3106
|
-
if (assemblyCrane) {
|
|
3107
|
-
if (!developmentSourceArtifact) {
|
|
3108
|
-
throw new Error('Development retirement source index is absent.');
|
|
3109
|
-
}
|
|
3110
|
-
execute(
|
|
3111
|
-
assemblyCrane.path,
|
|
3112
|
-
['copy', developmentSourceArtifact.imageReference, taggedReference],
|
|
3113
|
-
'Exact staging retirement OCI index promotion',
|
|
3114
|
-
);
|
|
3115
|
-
} else {
|
|
3116
|
-
execute(
|
|
3117
|
-
'docker',
|
|
3118
|
-
[
|
|
3119
|
-
'buildx',
|
|
3120
|
-
'imagetools',
|
|
3121
|
-
'create',
|
|
3122
|
-
'--tag',
|
|
3123
|
-
taggedReference,
|
|
3124
|
-
...evidence.map(({ imageReference }) => imageReference),
|
|
3125
|
-
],
|
|
3126
|
-
'Dual-architecture OCI index assembly',
|
|
3127
|
-
);
|
|
3128
|
-
}
|
|
3129
|
-
const imageDigest = exactImageByTag(repositoryName, tag);
|
|
3130
|
-
const imageReference = registry + '/' + repositoryName + '@' + imageDigest;
|
|
3131
|
-
if (
|
|
3132
|
-
stage === 'development' &&
|
|
3133
|
-
developmentSourceArtifact?.imageDigest !== imageDigest
|
|
3134
|
-
) {
|
|
3135
|
-
throw new Error(
|
|
3136
|
-
'Development retirement OCI index differs from exact staging.',
|
|
3137
|
-
);
|
|
3138
|
-
}
|
|
3139
|
-
const rawIndex = String(
|
|
3140
|
-
execute(
|
|
3141
|
-
'docker',
|
|
3142
|
-
['buildx', 'imagetools', 'inspect', '--raw', imageReference],
|
|
3143
|
-
'Dual-architecture OCI index inspection',
|
|
3144
|
-
),
|
|
3145
|
-
);
|
|
3146
|
-
let index;
|
|
3147
|
-
try {
|
|
3148
|
-
index = JSON.parse(rawIndex);
|
|
3149
|
-
} catch {
|
|
3150
|
-
throw new Error('OCI index inspection returned invalid JSON.');
|
|
3151
|
-
}
|
|
3152
|
-
const rawDescriptors = Array.isArray(index?.manifests)
|
|
3153
|
-
? index.manifests
|
|
3154
|
-
: [];
|
|
3155
|
-
const descriptors = rawDescriptors
|
|
3156
|
-
.map((descriptor) => ({
|
|
3157
|
-
digest: descriptor?.digest,
|
|
3158
|
-
platform:
|
|
3159
|
-
String(descriptor?.platform?.os) + '/' +
|
|
3160
|
-
String(descriptor?.platform?.architecture),
|
|
3161
|
-
}))
|
|
3162
|
-
.sort((left, right) =>
|
|
3163
|
-
left.platform < right.platform
|
|
3164
|
-
? -1
|
|
3165
|
-
: left.platform > right.platform
|
|
3166
|
-
? 1
|
|
3167
|
-
: 0,
|
|
3168
|
-
);
|
|
3169
|
-
if (
|
|
3170
|
-
![
|
|
3171
|
-
'application/vnd.oci.image.index.v1+json',
|
|
3172
|
-
'application/vnd.docker.distribution.manifest.list.v2+json',
|
|
3173
|
-
].includes(index?.mediaType) ||
|
|
3174
|
-
rawDescriptors.length !== CONTAINER_RELEASE_PLATFORMS.length ||
|
|
3175
|
-
descriptors.some(
|
|
3176
|
-
({ digest, platform }) =>
|
|
3177
|
-
!IMAGE_DIGEST.test(digest) ||
|
|
3178
|
-
!CONTAINER_RELEASE_PLATFORMS.includes(platform),
|
|
3179
|
-
) ||
|
|
3180
|
-
descriptors.some(
|
|
3181
|
-
(descriptor, index) =>
|
|
3182
|
-
descriptor.platform !== evidence[index]?.platform ||
|
|
3183
|
-
descriptor.digest !== evidence[index]?.imageDigest,
|
|
3184
|
-
)
|
|
3185
|
-
) {
|
|
3186
|
-
throw new Error('OCI index does not contain exactly the two proven platform images.');
|
|
3187
|
-
}
|
|
3188
|
-
artifacts.push({
|
|
3189
|
-
artifactId: input.declared.id,
|
|
3190
|
-
artifactName: input.declared.name,
|
|
3191
|
-
candidateArtifactDigest: input.candidateArtifactDigest,
|
|
3192
|
-
dockerfileDigest,
|
|
3193
|
-
imageDigest,
|
|
3194
|
-
imageReference,
|
|
3195
|
-
platforms: evidence,
|
|
3196
|
-
repositoryName,
|
|
3197
|
-
sbomParityDigest: supplyChainDigest(
|
|
3198
|
-
evidence.map((entry) => ({
|
|
3199
|
-
componentSetDigest: entry.sbom.componentSetDigest,
|
|
3200
|
-
platform: entry.platform,
|
|
3201
|
-
productionClosureDigest: entry.productionClosureDigest,
|
|
3202
|
-
runProof: entry.runProof,
|
|
3203
|
-
})),
|
|
3204
|
-
),
|
|
3205
|
-
});
|
|
3206
|
-
}
|
|
3207
|
-
const builtAtInput = process.env.EBK_CONTAINER_BUILT_AT?.trim();
|
|
3208
|
-
const builtAt = builtAtInput ?? new Date().toISOString();
|
|
3209
|
-
if (!Number.isFinite(Date.parse(builtAt)) || new Date(builtAt).toISOString() !== builtAt) {
|
|
3210
|
-
throw new Error('EBK_CONTAINER_BUILT_AT must be canonical ISO-8601 when set.');
|
|
3211
|
-
}
|
|
3212
|
-
const binding = createContainerReleaseBinding({
|
|
3213
|
-
accountId,
|
|
3214
|
-
artifacts,
|
|
3215
|
-
builtAt,
|
|
3216
|
-
provenance: { runAttempt, runId, workflow },
|
|
3217
|
-
region,
|
|
3218
|
-
slice,
|
|
3219
|
-
sourceCommit,
|
|
3220
|
-
stage,
|
|
3221
|
-
});
|
|
3222
|
-
const output = resolve(
|
|
3223
|
-
repositoryRoot,
|
|
3224
|
-
'.ebk/evidence/container-release',
|
|
3225
|
-
stage,
|
|
3226
|
-
'packages',
|
|
3227
|
-
slice,
|
|
3228
|
-
'binding.json',
|
|
3229
|
-
);
|
|
3230
|
-
await yieldToReleaseSignals();
|
|
3231
|
-
immutableWrite(output, binding);
|
|
3232
|
-
process.stdout.write(
|
|
3233
|
-
JSON.stringify({
|
|
3234
|
-
artifactCount: artifacts.length,
|
|
3235
|
-
bindingDigest: binding.materialDigest,
|
|
3236
|
-
evidencePath: output,
|
|
3237
|
-
schemaVersion: 1,
|
|
3238
|
-
stage,
|
|
3239
|
-
}) + '\\n',
|
|
3240
|
-
);
|
|
3241
|
-
} finally {
|
|
3242
|
-
if (assemblyCrane) {
|
|
3243
|
-
removeExactReleaseToolTemporaryDirectory(assemblyCrane.temporary);
|
|
3244
|
-
}
|
|
3245
|
-
}
|
|
3246
|
-
`;
|
|
3247
|
-
}
|
|
3248
|
-
//# sourceMappingURL=generated-container-release-command.js.map
|