@capybara-hq/kernel 0.1.0-rc.145 → 0.1.0-rc.146
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/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/provenance.d.ts +69 -0
- package/dist/catalog/provenance.js +108 -0
- package/dist/ctx/create-ctx.d.ts +16 -0
- package/dist/ctx/create-ctx.js +269 -34
- package/dist/extensions/execution-realm.d.ts +96 -0
- package/dist/extensions/execution-realm.js +141 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/grant-epoch.d.ts +4 -2
- package/dist/extensions/grant-epoch.js +4 -2
- package/dist/extensions/host.d.ts +25 -2
- package/dist/extensions/host.js +120 -8
- package/dist/extensions/instance.d.ts +2 -0
- package/dist/extensions/instance.js +1 -0
- package/dist/extensions/isolated/admission.d.ts +6 -0
- package/dist/extensions/isolated/admission.js +17 -0
- package/dist/extensions/ledger.d.ts +5 -0
- package/dist/extensions/ledger.js +16 -0
- package/dist/extensions/permission-view.d.ts +2 -2
- package/dist/extensions/registry.d.ts +6 -0
- package/dist/extensions/registry.js +8 -0
- package/dist/extensions/review-hash.d.ts +114 -0
- package/dist/extensions/review-hash.js +145 -0
- package/dist/extensions/revision-grants.d.ts +10 -0
- package/dist/extensions/revocation-leases.d.ts +273 -0
- package/dist/extensions/revocation-leases.js +533 -0
- package/dist/extensions/revocation.d.ts +78 -0
- package/dist/extensions/revocation.js +202 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +6 -2
- package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
- package/dist/lifecycle/kernel-lifecycle.js +24 -18
- package/dist/overrides.d.ts +5 -1
- package/dist/overrides.js +2 -0
- package/dist/packages/official-publisher.d.ts +39 -0
- package/dist/packages/official-publisher.js +125 -47
- package/package.json +2 -2
|
@@ -33,27 +33,6 @@ const statementSchema = z.object({
|
|
|
33
33
|
.length(1),
|
|
34
34
|
predicate: z.unknown(),
|
|
35
35
|
});
|
|
36
|
-
const buildSchema = z.object({
|
|
37
|
-
buildDefinition: z.object({
|
|
38
|
-
buildType: z.literal(BUILD_TYPE),
|
|
39
|
-
externalParameters: z.object({
|
|
40
|
-
workflow: z.object({
|
|
41
|
-
repository: z.literal(REPOSITORY),
|
|
42
|
-
path: z.literal(WORKFLOW),
|
|
43
|
-
ref: z.literal(MAIN_REF),
|
|
44
|
-
}),
|
|
45
|
-
}),
|
|
46
|
-
internalParameters: z.object({
|
|
47
|
-
github: z.object({
|
|
48
|
-
repository_id: z.literal(REPOSITORY_ID),
|
|
49
|
-
repository_owner_id: z.literal(OWNER_ID),
|
|
50
|
-
}),
|
|
51
|
-
}),
|
|
52
|
-
resolvedDependencies: z
|
|
53
|
-
.array(z.object({ digest: z.object({ gitCommit: z.string().regex(/^[0-9a-f]{40}$/) }) }))
|
|
54
|
-
.min(1),
|
|
55
|
-
}),
|
|
56
|
-
});
|
|
57
36
|
const publishSchema = z.object({
|
|
58
37
|
name: z.string(),
|
|
59
38
|
version: z.string(),
|
|
@@ -82,7 +61,7 @@ function checkEnvelope(raw, type, revision) {
|
|
|
82
61
|
}
|
|
83
62
|
return { entity, predicate: statement.predicate };
|
|
84
63
|
}
|
|
85
|
-
function
|
|
64
|
+
function readBuildCertificate(entity) {
|
|
86
65
|
if (entity.key.$case !== "certificate") {
|
|
87
66
|
throw new Error("The build attestation has no signing certificate");
|
|
88
67
|
}
|
|
@@ -90,23 +69,67 @@ function verifyBuildSigner(entity) {
|
|
|
90
69
|
const signer = verifier.verify(entity, { extensions: { issuer: GITHUB_ISSUER } });
|
|
91
70
|
// Fulcio extensions sign these GitHub OIDC claims independently of the predicate.
|
|
92
71
|
const claim = (oid) => cert.extension(`1.3.6.1.4.1.57264.1.${oid}`)?.valueObj.subs[0]?.value.toString("utf8");
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
claim(15) !== REPOSITORY_ID ||
|
|
100
|
-
claim(17) !== OWNER_ID) {
|
|
101
|
-
throw new Error("The signing certificate does not match the official repository identity");
|
|
102
|
-
}
|
|
72
|
+
const identity = signer.identity?.subjectAlternativeName;
|
|
73
|
+
const buildSigner = claim(9);
|
|
74
|
+
const repository = claim(12);
|
|
75
|
+
const ref = claim(14);
|
|
76
|
+
const repositoryId = claim(15);
|
|
77
|
+
const ownerId = claim(17);
|
|
103
78
|
const commit = claim(13);
|
|
104
|
-
if (!
|
|
105
|
-
|
|
106
|
-
|
|
79
|
+
if (!identity ||
|
|
80
|
+
!buildSigner ||
|
|
81
|
+
!repository ||
|
|
82
|
+
!ref ||
|
|
83
|
+
!repositoryId ||
|
|
84
|
+
!ownerId ||
|
|
85
|
+
!commit ||
|
|
86
|
+
identity !== buildSigner) {
|
|
87
|
+
throw new Error("The signing certificate does not carry a complete GitHub Actions identity");
|
|
88
|
+
}
|
|
89
|
+
// A reusable workflow signs with its own file (the SAN and build signer name the called
|
|
90
|
+
// workflow, possibly in another repository at another ref), not the source repository's
|
|
91
|
+
// workflow. Such a signer is refused: the identity reviewers approve and continuity compares is
|
|
92
|
+
// `<repository>/<workflow>`, and a called workflow outside the repository would let whoever owns
|
|
93
|
+
// it publish under that repository's name, so the workflow must live in the source repository at
|
|
94
|
+
// the built ref.
|
|
95
|
+
const prefix = `${repository}/`;
|
|
96
|
+
const suffix = `@${ref}`;
|
|
97
|
+
if (!buildSigner.startsWith(prefix) || !buildSigner.endsWith(suffix)) {
|
|
98
|
+
throw new Error("The signing certificate's workflow is not in its source repository and ref");
|
|
99
|
+
}
|
|
100
|
+
const workflow = buildSigner.slice(prefix.length, buildSigner.length - suffix.length);
|
|
101
|
+
return {
|
|
102
|
+
issuer: GITHUB_ISSUER,
|
|
103
|
+
identity,
|
|
104
|
+
repository,
|
|
105
|
+
repositoryId,
|
|
106
|
+
ownerId,
|
|
107
|
+
workflow,
|
|
108
|
+
ref,
|
|
109
|
+
commit,
|
|
110
|
+
};
|
|
107
111
|
}
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const genericBuildSchema = z.object({
|
|
113
|
+
buildDefinition: z.object({
|
|
114
|
+
buildType: z.string(),
|
|
115
|
+
externalParameters: z.object({
|
|
116
|
+
workflow: z.object({ repository: z.string(), path: z.string(), ref: z.string() }),
|
|
117
|
+
}),
|
|
118
|
+
internalParameters: z.object({
|
|
119
|
+
github: z.object({ repository_id: z.string(), repository_owner_id: z.string() }),
|
|
120
|
+
}),
|
|
121
|
+
resolvedDependencies: z
|
|
122
|
+
.array(z.object({ digest: z.object({ gitCommit: z.string().regex(/^[0-9a-f]{40}$/) }) }))
|
|
123
|
+
.min(1),
|
|
124
|
+
}),
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* Checks both signatures and the transparency evidence of an npm package revision built by GitHub
|
|
128
|
+
* Actions, with the bundled roots: the registry's publish attestation (an npm registry key) and the
|
|
129
|
+
* SLSA build attestation (a Fulcio certificate from the GitHub OIDC issuer). Returns the signing
|
|
130
|
+
* certificate's identity and the build predicate, still to be checked by the caller.
|
|
131
|
+
*/
|
|
132
|
+
function attested(body, revision) {
|
|
110
133
|
const { attestations } = attestationsSchema.parse(body);
|
|
111
134
|
const [publish, ...duplicatePublish] = attestations.filter((a) => a.predicateType === NPM_PUBLISH);
|
|
112
135
|
const [build, ...duplicateBuild] = attestations.filter((a) => a.predicateType === SLSA_PROVENANCE_V1);
|
|
@@ -123,24 +146,79 @@ export function verifyOfficialPublisher(body, revision) {
|
|
|
123
146
|
}
|
|
124
147
|
verifier.verify(published.entity);
|
|
125
148
|
const built = checkEnvelope(build.bundle, SLSA_PROVENANCE_V1, revision);
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
149
|
+
return {
|
|
150
|
+
certificate: readBuildCertificate(built.entity),
|
|
151
|
+
predicate: built.predicate,
|
|
152
|
+
evidenceDigest: createHash("sha256")
|
|
153
|
+
.update(canonicalJson([publish.bundle, build.bundle]))
|
|
154
|
+
.digest("hex"),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Any GitHub Actions publisher (publisher evidence for review and continuity, plan task 1.2e):
|
|
159
|
+
* both attestations verified, and the build predicate in agreement with the certificate. The
|
|
160
|
+
* identity is returned as signed; `catalog/provenance.ts` normalizes it.
|
|
161
|
+
*/
|
|
162
|
+
export function verifyPublisher(body, revision) {
|
|
163
|
+
const { certificate, predicate, evidenceDigest } = attested(body, revision);
|
|
164
|
+
const def = genericBuildSchema.parse(predicate).buildDefinition;
|
|
165
|
+
const workflow = def.externalParameters.workflow;
|
|
166
|
+
const [source] = def.resolvedDependencies;
|
|
167
|
+
if (workflow.repository !== certificate.repository ||
|
|
168
|
+
workflow.path !== certificate.workflow ||
|
|
169
|
+
workflow.ref !== certificate.ref ||
|
|
170
|
+
def.internalParameters.github.repository_id !== certificate.repositoryId ||
|
|
171
|
+
def.internalParameters.github.repository_owner_id !== certificate.ownerId) {
|
|
172
|
+
throw new Error("The build definition does not match the signing certificate");
|
|
173
|
+
}
|
|
174
|
+
if (source?.digest.gitCommit !== certificate.commit) {
|
|
129
175
|
throw new Error("The signing certificate does not match the build's source commit");
|
|
130
176
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
177
|
+
return { revision, certificate, buildType: def.buildType, evidenceDigest };
|
|
178
|
+
}
|
|
179
|
+
const OFFICIAL_NAME = /^@capybara-hq\/plugin-[a-z0-9][a-z0-9-]*$/;
|
|
180
|
+
/**
|
|
181
|
+
* The one definition of official proof, shared by the official marketplace's admission
|
|
182
|
+
* ({@link verifyOfficialPublisher}) and publisher evidence (`classifyPublisherEvidence`): a revision
|
|
183
|
+
* whose attestations verified ({@link verifyPublisher}: the build predicate agrees with the
|
|
184
|
+
* certificate and its source commit) is official when the certificate is the official release
|
|
185
|
+
* workflow on the official repository's main ref, the build type is the GitHub Actions workflow
|
|
186
|
+
* build, and the package is in the Capybara plugin namespace. Returns why it is not, or undefined.
|
|
187
|
+
*/
|
|
188
|
+
export function officialPublisherProblem(verified) {
|
|
189
|
+
const cert = verified.certificate;
|
|
190
|
+
if (cert.ref !== MAIN_REF || cert.workflow !== WORKFLOW) {
|
|
191
|
+
return "The signing certificate does not match the official release workflow or main ref";
|
|
192
|
+
}
|
|
193
|
+
if (cert.issuer !== GITHUB_ISSUER ||
|
|
194
|
+
cert.identity !== WORKFLOW_IDENTITY ||
|
|
195
|
+
cert.repository !== REPOSITORY ||
|
|
196
|
+
cert.repositoryId !== REPOSITORY_ID ||
|
|
197
|
+
cert.ownerId !== OWNER_ID) {
|
|
198
|
+
return "The signing certificate does not match the official repository identity";
|
|
199
|
+
}
|
|
200
|
+
if (verified.buildType !== BUILD_TYPE) {
|
|
201
|
+
return "The build attestation is not a GitHub Actions workflow build";
|
|
202
|
+
}
|
|
203
|
+
if (!OFFICIAL_NAME.test(verified.revision.name)) {
|
|
204
|
+
return "An official plugin must belong to the Capybara npm namespace";
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
|
208
|
+
/** Checks both signatures, transparency evidence and publisher identity with the bundled roots. */
|
|
209
|
+
export function verifyOfficialPublisher(body, revision) {
|
|
210
|
+
const verified = verifyPublisher(body, revision);
|
|
211
|
+
const problem = officialPublisherProblem(verified);
|
|
212
|
+
if (problem)
|
|
213
|
+
throw new Error(problem);
|
|
134
214
|
return {
|
|
135
215
|
checked: true,
|
|
136
216
|
revision,
|
|
137
217
|
repository: REPOSITORY,
|
|
138
|
-
commit,
|
|
218
|
+
commit: verified.certificate.commit,
|
|
139
219
|
workflow: WORKFLOW,
|
|
140
220
|
buildType: BUILD_TYPE,
|
|
141
|
-
evidenceDigest:
|
|
142
|
-
.update(canonicalJson([publish.bundle, build.bundle]))
|
|
143
|
-
.digest("hex"),
|
|
221
|
+
evidenceDigest: verified.evidenceDigest,
|
|
144
222
|
policyVersion: POLICY_VERSION,
|
|
145
223
|
};
|
|
146
224
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.146",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"yaml": "^2.9.1",
|
|
71
71
|
"yauzl": "3.4.0",
|
|
72
72
|
"zod": "^4.6.7",
|
|
73
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
73
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.103"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|