@mago-foundation/mago-ski 0.4.0 → 0.5.0-beta.1
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 +5 -3
- package/action.yml +21 -2
- package/dist/hosts/github/check.d.ts +21 -0
- package/dist/hosts/github/check.js +124 -0
- package/dist/hosts/github/publish.d.ts +7 -0
- package/dist/hosts/github/publish.js +52 -0
- package/dist/hosts/github/run.d.ts +12 -0
- package/dist/hosts/github/run.js +32 -18
- package/dist/hosts/pi/index.js +40 -18
- package/dist/src/admin.d.ts +2 -1
- package/dist/src/admin.js +3 -2
- package/dist/src/admission-evidence.d.ts +15 -0
- package/dist/src/admission-evidence.js +48 -0
- package/dist/src/admission.d.ts +102 -0
- package/dist/src/admission.js +316 -0
- package/dist/src/canonical-json.d.ts +6 -0
- package/dist/src/canonical-json.js +11 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +229 -5
- package/dist/src/diff.d.ts +9 -0
- package/dist/src/diff.js +3 -2
- package/dist/src/dsse.js +2 -2
- package/dist/src/experimental/sigstore.d.ts +30 -0
- package/dist/src/experimental/sigstore.js +35 -5
- package/dist/src/fs-safe.d.ts +15 -2
- package/dist/src/fs-safe.js +68 -50
- package/dist/src/gate/adapters/claude-code.js +8 -5
- package/dist/src/gate/adapters/codex.js +5 -6
- package/dist/src/gate/generations.js +2 -0
- package/dist/src/gate/instance.js +7 -7
- package/dist/src/gate/proc.d.ts +6 -0
- package/dist/src/gate/proc.js +14 -3
- package/dist/src/gate/service.js +3 -0
- package/dist/src/gate/setup.d.ts +5 -5
- package/dist/src/gate/setup.js +128 -88
- package/dist/src/policy.d.ts +7 -0
- package/dist/src/policy.js +19 -2
- package/dist/src/profile.d.ts +34 -0
- package/dist/src/profile.js +182 -0
- package/dist/src/published-by.d.ts +64 -0
- package/dist/src/published-by.js +227 -0
- package/dist/src/recovery-admin.js +7 -4
- package/dist/src/root-events.d.ts +2 -0
- package/dist/src/root-events.js +61 -4
- package/dist/src/tree-digest.d.ts +6 -0
- package/dist/src/tree-digest.js +8 -0
- package/dist/src/usf-check.d.ts +28 -0
- package/dist/src/usf-check.js +128 -0
- package/dist/src/usf.d.ts +48 -0
- package/dist/src/usf.js +238 -0
- package/docs/hosts/publish.md +65 -0
- package/docs/hosts/skill-check.md +91 -0
- package/docs/spec/admission-v0.md +84 -0
- package/docs/spec/gui-admin-rack-v1.md +1 -1
- package/docs/spec/observed-profile-v1.md +51 -0
- package/docs/spec/root-recovery-v1.md +3 -2
- package/docs/spec/trust-documents-v1.md +1 -1
- package/docs/threat-model.md +12 -0
- package/package.json +5 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type ObservedProfile } from './profile.ts';
|
|
2
|
+
import { type UsfManifest } from './usf.ts';
|
|
3
|
+
export declare const PUBLISHED_BY_PREDICATE_TYPE = "https://magofoundation.dev/attestation/published-by/v1";
|
|
4
|
+
export declare const GITHUB_OIDC_ISSUER = "https://token.actions.githubusercontent.com";
|
|
5
|
+
export interface PublishedSkill {
|
|
6
|
+
/** Skill folder, relative to the repository root, with `/` separators. */
|
|
7
|
+
path: string;
|
|
8
|
+
/** Tree digest (mago.skill-tree/v2): the attestation subject. */
|
|
9
|
+
digest: string;
|
|
10
|
+
skill_md_sha256: string;
|
|
11
|
+
/** The USF declaration as read (see usf.ts), or null with the reason. */
|
|
12
|
+
declaration: UsfManifest | null;
|
|
13
|
+
declaration_error: string | null;
|
|
14
|
+
profile: ObservedProfile;
|
|
15
|
+
}
|
|
16
|
+
export interface PublishedByPredicate {
|
|
17
|
+
generator: {
|
|
18
|
+
name: 'mago-ski';
|
|
19
|
+
version: string;
|
|
20
|
+
};
|
|
21
|
+
skills: PublishedSkill[];
|
|
22
|
+
}
|
|
23
|
+
export declare function packageVersion(): string;
|
|
24
|
+
/** The record for one Skill folder, computed from its bytes. */
|
|
25
|
+
export declare function describeSkill(skillDir: string, root: string): Promise<PublishedSkill>;
|
|
26
|
+
/** Subject lines for actions/attest's `subject-checksums` input: `<hex> <name>`. */
|
|
27
|
+
export declare function subjectChecksums(skills: readonly PublishedSkill[]): string;
|
|
28
|
+
/** The Fulcio identity fields of a signing certificate. The certificate itself was verified by Cosign. */
|
|
29
|
+
export declare function fulcioIdentity(certificateDer: Buffer): Record<string, string>;
|
|
30
|
+
export interface VerifyPublishedByOptions {
|
|
31
|
+
bundlePath: string;
|
|
32
|
+
trustedRootPath: string;
|
|
33
|
+
cosignPath: string;
|
|
34
|
+
/** The publishing repository, `OWNER/NAME`; the signer's workflow must belong to it. Without it any GitHub repository is accepted and reported. */
|
|
35
|
+
repository?: string;
|
|
36
|
+
/** Optional workflow file inside it, e.g. `.github/workflows/publish.yml`. */
|
|
37
|
+
workflow?: string;
|
|
38
|
+
/** Optional numeric repository id: survives renames and cannot be claimed by a fork or a new repository of the same name. */
|
|
39
|
+
repositoryId?: string;
|
|
40
|
+
}
|
|
41
|
+
/** The normalised publisher identity (R7): ids and the workflow path survive renames; names are informational. */
|
|
42
|
+
export interface Publisher {
|
|
43
|
+
repository_id: string;
|
|
44
|
+
owner_id: string;
|
|
45
|
+
repository: string;
|
|
46
|
+
workflow: string;
|
|
47
|
+
commit: string;
|
|
48
|
+
ref: string;
|
|
49
|
+
trigger: string;
|
|
50
|
+
}
|
|
51
|
+
export declare function publisherOf(fields: Record<string, string>): Publisher;
|
|
52
|
+
export interface PublishedByFacts {
|
|
53
|
+
digest: string;
|
|
54
|
+
publisher: Record<string, string>;
|
|
55
|
+
/** The record the publisher's CI wrote for these bytes. */
|
|
56
|
+
recorded: PublishedSkill;
|
|
57
|
+
/** Differences between that record and what this verifier computed; empty when they agree. */
|
|
58
|
+
differences: string[];
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Checks a published-by bundle for a Skill folder. Throws when the bundle does not verify for these exact bytes and
|
|
62
|
+
* this publisher. Returns the publisher facts and any difference between the recorded and the recomputed record.
|
|
63
|
+
*/
|
|
64
|
+
export declare function verifyPublishedBy(skillDir: string, options: VerifyPublishedByOptions): Promise<PublishedByFacts>;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// published-by (mago.published-by/v1): a publisher's CI states, with its own repository identity and no stored key,
|
|
2
|
+
// "this repository published these exact Skill bytes, with this declaration as read and this observed profile".
|
|
3
|
+
// Signing is done by GitHub's actions/attest (keyless Sigstore, public log for public repositories); this module
|
|
4
|
+
// builds the statement's content and verifies a bundle offline. A verifier recomputes everything from the bytes and
|
|
5
|
+
// never trusts what the publisher's CI computed. The output is facts about who published what; never "safe".
|
|
6
|
+
import { createHash, X509Certificate } from 'node:crypto';
|
|
7
|
+
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { createRequire } from 'node:module';
|
|
9
|
+
import os from 'node:os';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import { verifySigstoreAttestation } from "./experimental/sigstore.js";
|
|
12
|
+
import { readRegularFile } from "./fs-safe.js";
|
|
13
|
+
import { profileTree } from "./profile.js";
|
|
14
|
+
import { collectSkillTree, SKILL_FILENAME } from "./tree-digest.js";
|
|
15
|
+
import { readUsf } from "./usf.js";
|
|
16
|
+
export const PUBLISHED_BY_PREDICATE_TYPE = 'https://magofoundation.dev/attestation/published-by/v1';
|
|
17
|
+
export const GITHUB_OIDC_ISSUER = 'https://token.actions.githubusercontent.com';
|
|
18
|
+
const IN_TOTO_STATEMENT_V1 = 'https://in-toto.io/Statement/v1';
|
|
19
|
+
const IN_TOTO_PAYLOAD_TYPE = 'application/vnd.in-toto+json';
|
|
20
|
+
const MAX_BUNDLE_BYTES = 16 * 1024 * 1024;
|
|
21
|
+
export function packageVersion() {
|
|
22
|
+
return createRequire(import.meta.url)('#package.json').version ?? 'unknown';
|
|
23
|
+
}
|
|
24
|
+
/** The record for one Skill folder, computed from its bytes. */
|
|
25
|
+
export async function describeSkill(skillDir, root) {
|
|
26
|
+
const tree = await collectSkillTree(skillDir, { includeContents: true });
|
|
27
|
+
const skillMd = tree.contents.get(SKILL_FILENAME);
|
|
28
|
+
const reading = readUsf(skillMd.toString('utf8'));
|
|
29
|
+
return {
|
|
30
|
+
path: path.relative(root, skillDir).split(path.sep).join('/') || '.',
|
|
31
|
+
digest: tree.digest,
|
|
32
|
+
skill_md_sha256: `sha256:${createHash('sha256').update(skillMd).digest('hex')}`,
|
|
33
|
+
declaration: reading.manifest,
|
|
34
|
+
declaration_error: reading.error,
|
|
35
|
+
profile: profileTree(tree),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Subject lines for actions/attest's `subject-checksums` input: `<hex> <name>`. */
|
|
39
|
+
export function subjectChecksums(skills) {
|
|
40
|
+
return skills.map((skill) => {
|
|
41
|
+
const name = `skill:${skill.path}`;
|
|
42
|
+
// One subject per line: a name with a line break (or other control character) would add a subject.
|
|
43
|
+
if (/[\u0000-\u001f\u007f]/u.test(name))
|
|
44
|
+
throw new Error(`Skill path ${JSON.stringify(skill.path)} contains a control character`);
|
|
45
|
+
return `${skill.digest.slice('sha256:'.length)} ${name}\n`;
|
|
46
|
+
}).join('');
|
|
47
|
+
}
|
|
48
|
+
function parseJson(bytes, label) {
|
|
49
|
+
try {
|
|
50
|
+
return JSON.parse(bytes.toString('utf8'));
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
throw new Error(`${label} is not JSON`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function bundleParts(bundle) {
|
|
57
|
+
const b = bundle;
|
|
58
|
+
const envelope = b?.dsseEnvelope;
|
|
59
|
+
if (typeof envelope?.payload !== 'string' || envelope.payloadType !== IN_TOTO_PAYLOAD_TYPE)
|
|
60
|
+
throw new Error('the bundle holds no in-toto DSSE envelope');
|
|
61
|
+
const raw = b.verificationMaterial?.certificate?.rawBytes ?? b.verificationMaterial?.x509CertificateChain?.certificates?.[0]?.rawBytes;
|
|
62
|
+
if (typeof raw !== 'string')
|
|
63
|
+
throw new Error('the bundle holds no signing certificate');
|
|
64
|
+
const statement = parseJson(Buffer.from(envelope.payload, 'base64'), 'the in-toto statement');
|
|
65
|
+
if (statement?._type !== IN_TOTO_STATEMENT_V1 || !Array.isArray(statement.subject))
|
|
66
|
+
throw new Error('the payload is not an in-toto v1 statement');
|
|
67
|
+
return { statement, certificate: Buffer.from(raw, 'base64') };
|
|
68
|
+
}
|
|
69
|
+
function tlv(der, offset, limit) {
|
|
70
|
+
if (offset + 2 > limit)
|
|
71
|
+
throw new Error('certificate DER is truncated');
|
|
72
|
+
const tag = der[offset];
|
|
73
|
+
let length = der[offset + 1];
|
|
74
|
+
let start = offset + 2;
|
|
75
|
+
if (length & 0x80) {
|
|
76
|
+
const bytes = length & 0x7f;
|
|
77
|
+
if (bytes === 0 || bytes > 4 || start + bytes > limit)
|
|
78
|
+
throw new Error('certificate DER has an unsupported length');
|
|
79
|
+
length = 0;
|
|
80
|
+
for (let index = 0; index < bytes; index += 1)
|
|
81
|
+
length = length * 256 + der[start + index];
|
|
82
|
+
start += bytes;
|
|
83
|
+
}
|
|
84
|
+
if (start + length > limit)
|
|
85
|
+
throw new Error('certificate DER is truncated');
|
|
86
|
+
return { tag, start, end: start + length, next: start + length };
|
|
87
|
+
}
|
|
88
|
+
function children(der, parent) {
|
|
89
|
+
const out = [];
|
|
90
|
+
for (let offset = parent.start; offset < parent.end; offset = out[out.length - 1].next)
|
|
91
|
+
out.push(tlv(der, offset, parent.end));
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
function oidString(bytes) {
|
|
95
|
+
const parts = [Math.floor(bytes[0] / 40), bytes[0] % 40];
|
|
96
|
+
let value = 0;
|
|
97
|
+
for (const byte of bytes.subarray(1)) {
|
|
98
|
+
value = value * 128 + (byte & 0x7f);
|
|
99
|
+
if ((byte & 0x80) === 0) {
|
|
100
|
+
parts.push(value);
|
|
101
|
+
value = 0;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return parts.join('.');
|
|
105
|
+
}
|
|
106
|
+
const FULCIO = '1.3.6.1.4.1.57264.1.';
|
|
107
|
+
/** Fulcio's provider-neutral extensions (1.3.6.1.4.1.57264.1.8 onwards), each a DER UTF8String. */
|
|
108
|
+
const FULCIO_FIELDS = {
|
|
109
|
+
'8': 'issuer', '9': 'build_signer_uri', '10': 'build_signer_digest', '11': 'runner_environment', '12': 'source_repository_uri',
|
|
110
|
+
'13': 'source_repository_digest', '14': 'source_repository_ref', '15': 'source_repository_id', '16': 'source_repository_owner_uri',
|
|
111
|
+
'17': 'source_repository_owner_id', '18': 'build_config_uri', '19': 'build_config_digest', '20': 'build_trigger', '21': 'run_invocation_uri',
|
|
112
|
+
};
|
|
113
|
+
/** The Fulcio identity fields of a signing certificate. The certificate itself was verified by Cosign. */
|
|
114
|
+
export function fulcioIdentity(certificateDer) {
|
|
115
|
+
const certificate = tlv(certificateDer, 0, certificateDer.length);
|
|
116
|
+
const tbs = children(certificateDer, certificate)[0];
|
|
117
|
+
if (!tbs)
|
|
118
|
+
throw new Error('certificate has no TBSCertificate');
|
|
119
|
+
const extensionsWrapper = children(certificateDer, tbs).find((item) => item.tag === 0xa3);
|
|
120
|
+
const fields = {};
|
|
121
|
+
if (!extensionsWrapper)
|
|
122
|
+
return fields;
|
|
123
|
+
const [extensions] = children(certificateDer, extensionsWrapper);
|
|
124
|
+
for (const extension of extensions ? children(certificateDer, extensions) : []) {
|
|
125
|
+
const parts = children(certificateDer, extension);
|
|
126
|
+
const oid = parts[0];
|
|
127
|
+
const value = parts[parts.length - 1];
|
|
128
|
+
if (!oid || oid.tag !== 0x06 || !value || value.tag !== 0x04)
|
|
129
|
+
continue;
|
|
130
|
+
const id = oidString(certificateDer.subarray(oid.start, oid.end));
|
|
131
|
+
if (!id.startsWith(FULCIO))
|
|
132
|
+
continue;
|
|
133
|
+
const name = FULCIO_FIELDS[id.slice(FULCIO.length)];
|
|
134
|
+
if (!name)
|
|
135
|
+
continue;
|
|
136
|
+
const inner = tlv(certificateDer, value.start, value.end);
|
|
137
|
+
if (inner.tag !== 0x0c)
|
|
138
|
+
continue;
|
|
139
|
+
fields[name] = certificateDer.subarray(inner.start, inner.end).toString('utf8');
|
|
140
|
+
}
|
|
141
|
+
return fields;
|
|
142
|
+
}
|
|
143
|
+
export function publisherOf(fields) {
|
|
144
|
+
const config = /^https:\/\/github\.com\/[^/]+\/[^/]+\/(\.github\/workflows\/[^@]+)@/u.exec(fields.build_config_uri ?? '');
|
|
145
|
+
const required = {
|
|
146
|
+
repository_id: fields.source_repository_id, owner_id: fields.source_repository_owner_id, repository: fields.source_repository_uri,
|
|
147
|
+
workflow: config?.[1], commit: fields.source_repository_digest, ref: fields.source_repository_ref, trigger: fields.build_trigger,
|
|
148
|
+
};
|
|
149
|
+
for (const [name, value] of Object.entries(required))
|
|
150
|
+
if (!value)
|
|
151
|
+
throw new Error(`the signing certificate has no ${name}`);
|
|
152
|
+
return required;
|
|
153
|
+
}
|
|
154
|
+
const escapeRegexp = (text) => text.replace(/[\\^$.*+?()[\]{}|/]/gu, '\\$&');
|
|
155
|
+
/**
|
|
156
|
+
* Checks a published-by bundle for a Skill folder. Throws when the bundle does not verify for these exact bytes and
|
|
157
|
+
* this publisher. Returns the publisher facts and any difference between the recorded and the recomputed record.
|
|
158
|
+
*/
|
|
159
|
+
export async function verifyPublishedBy(skillDir, options) {
|
|
160
|
+
if (options.repository !== undefined && !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/u.test(options.repository))
|
|
161
|
+
throw new RangeError('--repo must be OWNER/NAME');
|
|
162
|
+
if (options.workflow !== undefined && !/^\.github\/workflows\/[A-Za-z0-9_.\-/]+\.ya?ml$/u.test(options.workflow))
|
|
163
|
+
throw new RangeError('--workflow must be a path such as .github/workflows/publish.yml');
|
|
164
|
+
if (options.repositoryId !== undefined && !/^[0-9]{1,20}$/u.test(options.repositoryId))
|
|
165
|
+
throw new RangeError('--repo-id must be the numeric repository id');
|
|
166
|
+
const mine = await describeSkill(skillDir, path.dirname(path.resolve(skillDir)));
|
|
167
|
+
const digestHex = mine.digest.slice('sha256:'.length);
|
|
168
|
+
// Cosign checks a private copy, and the statement is read from the same bytes: the file cannot change in between.
|
|
169
|
+
const bytes = await readRegularFile(options.bundlePath, 'Sigstore bundle', MAX_BUNDLE_BYTES);
|
|
170
|
+
const parts = bundleParts(parseJson(bytes, 'the Sigstore bundle'));
|
|
171
|
+
// Plain-words reasons for the common refusals, read before Cosign runs. Cosign still decides; these only explain.
|
|
172
|
+
if (!parts.statement.subject.some((subject) => subject?.digest?.sha256 === digestHex))
|
|
173
|
+
throw new Error(`the attestation is for other bytes: it does not name this Skill's digest ${mine.digest}`);
|
|
174
|
+
const claimed = fulcioIdentity(parts.certificate);
|
|
175
|
+
if (options.repository !== undefined && !(claimed.build_signer_uri ?? '').toLowerCase().startsWith(`https://github.com/${options.repository.toLowerCase()}/`))
|
|
176
|
+
throw new Error(`the attestation was signed by ${claimed.build_signer_uri ?? 'an unknown signer'}, not by a workflow of ${options.repository}`);
|
|
177
|
+
if (options.workflow !== undefined && !(claimed.build_signer_uri ?? '').includes(`/${options.workflow}@`))
|
|
178
|
+
throw new Error(`the attestation was signed by ${claimed.build_signer_uri ?? 'an unknown signer'}, not by ${options.workflow}`);
|
|
179
|
+
const scratch = await mkdtemp(path.join(os.tmpdir(), 'mago-ski-bundle-'));
|
|
180
|
+
try {
|
|
181
|
+
const copy = path.join(scratch, 'bundle.json');
|
|
182
|
+
await writeFile(copy, bytes, { mode: 0o600, flag: 'wx' });
|
|
183
|
+
const workflow = options.workflow === undefined ? '\\.github/workflows/[^@]+' : escapeRegexp(options.workflow);
|
|
184
|
+
await verifySigstoreAttestation({
|
|
185
|
+
binaryPath: options.cosignPath, bundlePath: copy, trustedRootPath: options.trustedRootPath, digestHex,
|
|
186
|
+
predicateType: PUBLISHED_BY_PREDICATE_TYPE, issuer: GITHUB_OIDC_ISSUER,
|
|
187
|
+
identityRegexp: `^https://github\\.com/${options.repository === undefined ? '[^/]+/[^/]+' : escapeRegexp(options.repository)}/${workflow}@`,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
finally {
|
|
191
|
+
await rm(scratch, { recursive: true, force: true });
|
|
192
|
+
}
|
|
193
|
+
const { statement, certificate } = parts;
|
|
194
|
+
if (statement.predicateType !== PUBLISHED_BY_PREDICATE_TYPE)
|
|
195
|
+
throw new Error('the statement is not a published-by statement');
|
|
196
|
+
if (!statement.subject.some((subject) => subject?.digest?.sha256 === digestHex))
|
|
197
|
+
throw new Error('the statement does not name this Skill\'s digest');
|
|
198
|
+
const predicate = statement.predicate;
|
|
199
|
+
const recorded = Array.isArray(predicate?.skills) ? predicate.skills.find((skill) => skill?.digest === mine.digest) : undefined;
|
|
200
|
+
if (!recorded)
|
|
201
|
+
throw new Error('the statement has no record for this Skill\'s digest');
|
|
202
|
+
new X509Certificate(certificate); // a parse check only: Cosign verified the chain
|
|
203
|
+
const publisher = fulcioIdentity(certificate);
|
|
204
|
+
if (publisher.issuer !== GITHUB_OIDC_ISSUER)
|
|
205
|
+
throw new Error('the signing certificate was not issued for a GitHub Actions identity');
|
|
206
|
+
// Cosign matched the signing workflow (the certificate's SAN). The repository whose code ran and the top-level workflow
|
|
207
|
+
// are separate fields: with a reusable workflow they differ, so both are required to match as well.
|
|
208
|
+
const normalised = publisherOf(publisher);
|
|
209
|
+
const asciiLower = (value) => value.replace(/[A-Z]/gu, (c) => c.toLowerCase());
|
|
210
|
+
if (options.repository !== undefined && asciiLower(normalised.repository) !== asciiLower(`https://github.com/${options.repository}`))
|
|
211
|
+
throw new Error(`the signed code came from ${normalised.repository}, not ${options.repository}`);
|
|
212
|
+
if (options.workflow !== undefined && normalised.workflow !== options.workflow)
|
|
213
|
+
throw new Error(`the top-level workflow is ${normalised.workflow}, not ${options.workflow}`);
|
|
214
|
+
if (options.repositoryId !== undefined && publisher.source_repository_id !== options.repositoryId)
|
|
215
|
+
throw new Error(`the signer's repository id is ${publisher.source_repository_id ?? 'missing'}, not ${options.repositoryId}`);
|
|
216
|
+
const differences = [];
|
|
217
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
218
|
+
if (recorded.profile?.profile !== mine.profile.profile)
|
|
219
|
+
differences.push(`the record uses ${String(recorded.profile?.profile)}; this verifier computes ${mine.profile.profile}`);
|
|
220
|
+
else if (!same(recorded.profile, mine.profile))
|
|
221
|
+
differences.push('the recorded observed profile differs from the one computed from these bytes');
|
|
222
|
+
if (!same(recorded.declaration, mine.declaration))
|
|
223
|
+
differences.push('the recorded declaration differs from the one read from these bytes');
|
|
224
|
+
if (recorded.skill_md_sha256 !== mine.skill_md_sha256)
|
|
225
|
+
differences.push('the recorded SKILL.md hash differs');
|
|
226
|
+
return { digest: mine.digest, publisher, recorded, differences };
|
|
227
|
+
}
|
|
@@ -372,8 +372,10 @@ export async function adoptTrustDocuments(options) {
|
|
|
372
372
|
const root = await loadPrivateKey(options.rootKeyPath);
|
|
373
373
|
if (root.keyId === options.fromRootKeyId)
|
|
374
374
|
throw new Error('The new root key is the same as the current one; nothing to adopt');
|
|
375
|
-
const
|
|
376
|
-
const
|
|
375
|
+
const trustRead = await readRegularFile(options.trustRootPath, 'Trust root', 4 * 1024 * 1024);
|
|
376
|
+
const listRead = await readRegularFile(options.revocationsPath, 'Revocation list', 8 * 1024 * 1024);
|
|
377
|
+
const currentTrust = readTrustRootForUpdate(trustRead, options.fromRootKeyId);
|
|
378
|
+
const currentList = readRevocationsForUpdate(listRead, options.fromRootKeyId, currentTrust.root.publicKey);
|
|
377
379
|
if (currentTrust.approvers.some((approver) => approver.keyId === root.keyId))
|
|
378
380
|
throw new Error('The new root key is listed as an approver; remove it first');
|
|
379
381
|
const issuedAt = truncateToSecond(options.now);
|
|
@@ -393,8 +395,9 @@ export async function adoptTrustDocuments(options) {
|
|
|
393
395
|
};
|
|
394
396
|
const trustBytes = signTrustRoot(trustRoot, root.privateKey);
|
|
395
397
|
const listBytes = signRevocations(revocations, root.privateKey);
|
|
396
|
-
|
|
397
|
-
await writeFileAtomic(options.
|
|
398
|
+
// Each file is replaced only if it is still the one that was read and re-signed (like every other root write).
|
|
399
|
+
await writeFileAtomic(options.trustRootPath, trustBytes, undefined, { expectSha256: `sha256:${sha256Hex(trustRead)}` });
|
|
400
|
+
await writeFileAtomic(options.revocationsPath, listBytes, undefined, { expectSha256: `sha256:${sha256Hex(listRead)}` });
|
|
398
401
|
return { trustRoot, trustRootVersion: trustRoot.version, revocationsVersion: revocations.version };
|
|
399
402
|
}
|
|
400
403
|
export { recoverySetJson };
|
|
@@ -95,6 +95,8 @@ export declare function parseRootEventLog(bytes: Uint8Array): Array<MultiEnvelop
|
|
|
95
95
|
/**
|
|
96
96
|
* Walks the root event log from the policy's starting point. Throws (the log is UNVERIFIABLE) if any event after
|
|
97
97
|
* `eventsAfter` breaks a rule; events are never skipped. Hashes every event so rollback and fork checks can use them.
|
|
98
|
+
* Keys that left a role in the events before `eventsAfter` are read without checking signatures and used only to refuse
|
|
99
|
+
* (see keysLeftBeforeStart).
|
|
98
100
|
*/
|
|
99
101
|
export declare function walkRootEvents(bytes: Uint8Array, start: RootStart, now: Date): RootWalk;
|
|
100
102
|
/**
|
package/dist/src/root-events.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// policy, signs numbered root events that revoke or replace the root key. Hosts walk the log from the policy's
|
|
3
3
|
// starting point at every trust check; one event that breaks a rule makes the whole log UNVERIFIABLE.
|
|
4
4
|
import { sign, verify } from 'node:crypto';
|
|
5
|
-
import { canonicalBytes, exactKeys, isRecord, parseCanonicalJsonBytes, requireArray, requirePositiveInteger, requireString } from "./canonical-json.js";
|
|
5
|
+
import { canonicalBytes, exactKeys, isRecord, readableCanonicalBytes, parseCanonicalJsonBytes, requireArray, requirePositiveInteger, requireString } from "./canonical-json.js";
|
|
6
6
|
import { preAuthEncoding } from "./dsse.js";
|
|
7
7
|
import { parseSpki, validateKeyId } from "./keys.js";
|
|
8
8
|
import { CLOCK_SKEW_MS, formatTimestamp, parseTimestamp, requireValidDate } from "./time.js";
|
|
@@ -177,7 +177,7 @@ export function emptyRootEventLog() {
|
|
|
177
177
|
return canonicalBytes({ events: [], type: ROOT_EVENTS_TYPE });
|
|
178
178
|
}
|
|
179
179
|
export function rootEventLogBytes(envelopes) {
|
|
180
|
-
return
|
|
180
|
+
return readableCanonicalBytes({ events: envelopes, type: ROOT_EVENTS_TYPE }, 'The root event log');
|
|
181
181
|
}
|
|
182
182
|
/** `sha256:` + the SHA-256 of the envelope as canonical JSON with its trailing LF (the host state's event_digest). */
|
|
183
183
|
export function eventDigest(envelope) {
|
|
@@ -307,9 +307,65 @@ function applyEvent(state, envelope, sequence, now) {
|
|
|
307
307
|
}
|
|
308
308
|
return next;
|
|
309
309
|
}
|
|
310
|
+
/**
|
|
311
|
+
* Keys that left a role in the events before `root_events_after`. Those events are not checked (the policy pins the
|
|
312
|
+
* state after them, not the keys that signed them), so what they say is used only to refuse: a key named here can never
|
|
313
|
+
* be an approver or take a role in a walked event, and nothing is ever accepted because of them. Someone who can change
|
|
314
|
+
* the log can make a host refuse more, which they can already do by deleting the log; with freshness, the timestamp
|
|
315
|
+
* covers the whole file anyway. An event here that retires a key the policy pins contradicts the policy and throws.
|
|
316
|
+
*/
|
|
317
|
+
function keysLeftBeforeStart(envelopes, start) {
|
|
318
|
+
const retired = new Set();
|
|
319
|
+
const formerRecovery = new Set();
|
|
320
|
+
let recovery = null;
|
|
321
|
+
let timestampKeyId = null;
|
|
322
|
+
for (let index = 0; index < start.eventsAfter; index += 1) {
|
|
323
|
+
const label = `root event ${index + 1} (before root_events_after)`;
|
|
324
|
+
const envelope = envelopes[index];
|
|
325
|
+
if (envelope.payloadType !== ROOT_EVENT_PAYLOAD_TYPE)
|
|
326
|
+
throw new Error(`${label} has the wrong payload type`);
|
|
327
|
+
let event;
|
|
328
|
+
try {
|
|
329
|
+
event = parseRootEventPayload(envelope.payloadBytes);
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
throw new Error(`${label}: ${error.message}`);
|
|
333
|
+
}
|
|
334
|
+
if (event.sequence !== index + 1)
|
|
335
|
+
throw new Error(`${label} carries sequence ${event.sequence}`);
|
|
336
|
+
if (event.action === 'revoke') {
|
|
337
|
+
retired.add(event.rootKeyId);
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const newRecovery = event.newRecovery.keyIds;
|
|
341
|
+
if (event.newRoot.keyId !== event.rootKeyId)
|
|
342
|
+
retired.add(event.rootKeyId);
|
|
343
|
+
if (event.newTimestamp) {
|
|
344
|
+
if (timestampKeyId !== null && timestampKeyId !== event.newTimestamp.keyId)
|
|
345
|
+
retired.add(timestampKeyId);
|
|
346
|
+
timestampKeyId = event.newTimestamp.keyId;
|
|
347
|
+
}
|
|
348
|
+
// Signers not in the new set come from the set this event replaces, as does every key of an earlier new set.
|
|
349
|
+
for (const keyId of [...event.signers.map((key) => key.keyId), ...(recovery ?? [])])
|
|
350
|
+
if (!newRecovery.includes(keyId))
|
|
351
|
+
formerRecovery.add(keyId);
|
|
352
|
+
recovery = newRecovery;
|
|
353
|
+
}
|
|
354
|
+
for (const keyId of recovery ?? [])
|
|
355
|
+
if (!start.recovery.keyIds.includes(keyId))
|
|
356
|
+
formerRecovery.add(keyId);
|
|
357
|
+
for (const keyId of retired) {
|
|
358
|
+
const pinned = keyId === start.rootKeyId ? 'root' : keyId === start.timestampKeyId ? 'timestamp' : start.recovery.keyIds.includes(keyId) ? 'recovery' : null;
|
|
359
|
+
if (pinned)
|
|
360
|
+
throw new Error(`the events before root_events_after show key ${keyId} leaving the root or timestamp role, but the policy pins it as the ${pinned} key`);
|
|
361
|
+
}
|
|
362
|
+
return { retired, formerRecovery };
|
|
363
|
+
}
|
|
310
364
|
/**
|
|
311
365
|
* Walks the root event log from the policy's starting point. Throws (the log is UNVERIFIABLE) if any event after
|
|
312
366
|
* `eventsAfter` breaks a rule; events are never skipped. Hashes every event so rollback and fork checks can use them.
|
|
367
|
+
* Keys that left a role in the events before `eventsAfter` are read without checking signatures and used only to refuse
|
|
368
|
+
* (see keysLeftBeforeStart).
|
|
313
369
|
*/
|
|
314
370
|
export function walkRootEvents(bytes, start, now) {
|
|
315
371
|
requireValidDate(now, 'Verification time');
|
|
@@ -317,13 +373,14 @@ export function walkRootEvents(bytes, start, now) {
|
|
|
317
373
|
const envelopes = parseRootEventLog(bytes);
|
|
318
374
|
if (envelopes.length < start.eventsAfter)
|
|
319
375
|
throw new Error(`root event log has ${envelopes.length} event(s), fewer than root_events_after (${start.eventsAfter})`);
|
|
376
|
+
const before = keysLeftBeforeStart(envelopes, start);
|
|
320
377
|
let state = {
|
|
321
378
|
activeRootKeyId: start.rootKeyId,
|
|
322
379
|
recovery: start.recovery,
|
|
323
380
|
timestampKeyId: start.timestampKeyId,
|
|
324
381
|
revoked: null,
|
|
325
|
-
retired:
|
|
326
|
-
formerRecovery:
|
|
382
|
+
retired: before.retired,
|
|
383
|
+
formerRecovery: before.formerRecovery,
|
|
327
384
|
lastIssuedAt: null,
|
|
328
385
|
};
|
|
329
386
|
for (let index = start.eventsAfter; index < envelopes.length; index += 1)
|
|
@@ -2,6 +2,12 @@ import { type BigIntStats } from 'node:fs';
|
|
|
2
2
|
export declare const TREE_PROFILE = "mago.skill-tree/v2";
|
|
3
3
|
export declare const CERTIFICATE_FILENAME = ".mago-ski-cert.json";
|
|
4
4
|
export declare const IGNORE_FILENAME = ".skilldigestignore";
|
|
5
|
+
/**
|
|
6
|
+
* The paths a `.skilldigestignore` keeps out of the digest (the built-in exclusions, `.git/` and the certificate file, are
|
|
7
|
+
* left out). A certificate says nothing about these: they can change, or be added, without invalidating it. Every command
|
|
8
|
+
* that tells a person "approved" or "unchanged" must show them.
|
|
9
|
+
*/
|
|
10
|
+
export declare function pathsNotCovered(excluded: readonly string[]): string[];
|
|
5
11
|
/** Always covered: it holds the instructions and the description hosts show the model. */
|
|
6
12
|
export declare const SKILL_FILENAME = "SKILL.md";
|
|
7
13
|
export declare const MAX_TREE_FILES = 20000;
|
package/dist/src/tree-digest.js
CHANGED
|
@@ -6,6 +6,14 @@ import { canonicalBytes } from "./canonical-json.js";
|
|
|
6
6
|
export const TREE_PROFILE = 'mago.skill-tree/v2';
|
|
7
7
|
export const CERTIFICATE_FILENAME = '.mago-ski-cert.json';
|
|
8
8
|
export const IGNORE_FILENAME = '.skilldigestignore';
|
|
9
|
+
/**
|
|
10
|
+
* The paths a `.skilldigestignore` keeps out of the digest (the built-in exclusions, `.git/` and the certificate file, are
|
|
11
|
+
* left out). A certificate says nothing about these: they can change, or be added, without invalidating it. Every command
|
|
12
|
+
* that tells a person "approved" or "unchanged" must show them.
|
|
13
|
+
*/
|
|
14
|
+
export function pathsNotCovered(excluded) {
|
|
15
|
+
return excluded.filter((item) => item !== '.git/' && item !== CERTIFICATE_FILENAME);
|
|
16
|
+
}
|
|
9
17
|
/** Always covered: it holds the instructions and the description hosts show the model. */
|
|
10
18
|
export const SKILL_FILENAME = 'SKILL.md';
|
|
11
19
|
export const MAX_TREE_FILES = 20_000;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ObservedProfile } from './profile.ts';
|
|
2
|
+
import { USF_FORMAT, type UsfManifest } from './usf.ts';
|
|
3
|
+
export interface CheckOptions {
|
|
4
|
+
/** Fail Skills that have no USF manifest (or one that cannot be read). Default false: they are reported. */
|
|
5
|
+
requireManifest?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface SkillCheck {
|
|
8
|
+
format: typeof USF_FORMAT;
|
|
9
|
+
/** Directory relative to the checked root. */
|
|
10
|
+
dir: string;
|
|
11
|
+
ok: boolean;
|
|
12
|
+
/** Null only when the Skill folder could not be read at all. */
|
|
13
|
+
profile: ObservedProfile | null;
|
|
14
|
+
manifest: UsfManifest | null;
|
|
15
|
+
/** Whether SKILL.md has a `permissions` block, readable or not. */
|
|
16
|
+
declared: boolean;
|
|
17
|
+
manifestError: string | null;
|
|
18
|
+
undeclaredHosts: string[];
|
|
19
|
+
/** Plain-word reasons the check failed; empty when it passed. */
|
|
20
|
+
problems: string[];
|
|
21
|
+
/** Plain-word remarks that do not fail the check. */
|
|
22
|
+
notes: string[];
|
|
23
|
+
}
|
|
24
|
+
/** The `permissions` block a Skill could paste, filled in from its profile. */
|
|
25
|
+
export declare function suggestedManifest(check: Pick<SkillCheck, 'profile' | 'manifest'>): string;
|
|
26
|
+
export declare function checkSkill(skillDir: string, root: string, options?: CheckOptions): Promise<SkillCheck>;
|
|
27
|
+
/** What a pull request adds to a Skill, in plain words, compared with the base revision. */
|
|
28
|
+
export declare function describeAdditions(base: SkillCheck | null, head: SkillCheck): string[];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// The free Skill check. Every Skill gets its observed profile (what its bytes show). When the Skill also declares
|
|
2
|
+
// its needs in an OWASP USF manifest, the declaration must cover the profile: a web address on a site that
|
|
3
|
+
// `network.allow` does not list, or scripts and shell code while `shell` is not true, fail the check.
|
|
4
|
+
// A Skill without a manifest passes with its profile shown, unless the repository requires a manifest.
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
import { profileTree } from "./profile.js";
|
|
7
|
+
import { collectSkillTree, SKILL_FILENAME } from "./tree-digest.js";
|
|
8
|
+
import { hostAllowed, readUsf, USF_FORMAT } from "./usf.js";
|
|
9
|
+
function list(values, limit = 10) {
|
|
10
|
+
const shown = values.slice(0, limit).join(', ');
|
|
11
|
+
return values.length > limit ? `${shown} and ${values.length - limit} more` : shown;
|
|
12
|
+
}
|
|
13
|
+
/** The `permissions` block a Skill could paste, filled in from its profile. */
|
|
14
|
+
export function suggestedManifest(check) {
|
|
15
|
+
// Host names pass the URL parser, which still allows characters such as backticks; only plain names are suggested.
|
|
16
|
+
const hosts = [...new Set([...(check.manifest?.network.allow ?? []), ...(check.profile?.web_hosts ?? [])])]
|
|
17
|
+
.filter((host) => /^(?:\*|(?:\*\.)?[a-z0-9.-]+|\[[0-9a-f:.]+\])$/u.test(host)).sort();
|
|
18
|
+
const shell = check.manifest?.shell === true || (check.profile?.scripts.length ?? 0) > 0;
|
|
19
|
+
return [
|
|
20
|
+
'permissions:',
|
|
21
|
+
' network:',
|
|
22
|
+
` allow: [${hosts.map((host) => JSON.stringify(host)).join(', ')}]`,
|
|
23
|
+
' deny: "*"',
|
|
24
|
+
` shell: ${shell}`,
|
|
25
|
+
].join('\n');
|
|
26
|
+
}
|
|
27
|
+
export async function checkSkill(skillDir, root, options = {}) {
|
|
28
|
+
const result = {
|
|
29
|
+
format: USF_FORMAT, dir: path.relative(root, skillDir) || '.', ok: false, profile: null, manifest: null, declared: false,
|
|
30
|
+
manifestError: null, undeclaredHosts: [], problems: [], notes: [],
|
|
31
|
+
};
|
|
32
|
+
let tree;
|
|
33
|
+
try {
|
|
34
|
+
tree = await collectSkillTree(skillDir, { includeContents: true });
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
result.problems.push(`the Skill folder could not be read: ${error.message}`);
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
const profile = profileTree(tree);
|
|
41
|
+
result.profile = profile;
|
|
42
|
+
const reading = readUsf(tree.contents.get(SKILL_FILENAME).toString('utf8'));
|
|
43
|
+
result.manifest = reading.manifest;
|
|
44
|
+
result.declared = reading.declared;
|
|
45
|
+
result.manifestError = reading.error;
|
|
46
|
+
const gaps = [];
|
|
47
|
+
if (profile.not_searched.unreadable.length > 0)
|
|
48
|
+
gaps.push(`files that cannot be searched (binary, not UTF-8 text, or larger than 2 MiB): ${list(profile.not_searched.unreadable)}`);
|
|
49
|
+
if (profile.not_searched.ignored.length > 0)
|
|
50
|
+
gaps.push(`files left out by .skilldigestignore: ${list(profile.not_searched.ignored)}`);
|
|
51
|
+
if (!profile.complete && gaps.length === 0)
|
|
52
|
+
gaps.push('too many web addresses to check them all (more than 128 different sites, or more than 100,000 addresses)');
|
|
53
|
+
if (profile.not_searched.media.length > 0)
|
|
54
|
+
result.notes.push(`images, fonts and media files were not searched: ${list(profile.not_searched.media)}`);
|
|
55
|
+
const manifest = reading.manifest;
|
|
56
|
+
if (manifest) {
|
|
57
|
+
// A declaration is only worth something when it covers everything: gaps fail here.
|
|
58
|
+
result.problems.push(...gaps.map((gap) => `the declaration cannot be checked against ${gap}`));
|
|
59
|
+
result.undeclaredHosts = profile.web_hosts.filter((host) => !hostAllowed(manifest.network.allow, host));
|
|
60
|
+
if (result.undeclaredHosts.length > 0)
|
|
61
|
+
result.problems.push(`uses web addresses on sites it does not declare in permissions.network.allow: ${list(result.undeclaredHosts)}`);
|
|
62
|
+
if (manifest.shell !== true && profile.scripts.length > 0)
|
|
63
|
+
result.problems.push(`contains scripts or shell commands, but permissions.shell is ${manifest.shell === false ? 'false' : 'not set'}: ${list(profile.scripts.map((script) => `${script.path} (${script.reason})`), 5)}`);
|
|
64
|
+
const undeclaredPrograms = profile.programs.filter((program) => !manifest.requires.binaries.includes(program));
|
|
65
|
+
if (manifest.requires.binaries.length > 0 && undeclaredPrograms.length > 0)
|
|
66
|
+
result.notes.push(`shell code blocks name programs not in requires.binaries (not checked): ${list(undeclaredPrograms)}`);
|
|
67
|
+
if (manifest.network.allow.includes('*'))
|
|
68
|
+
result.notes.push('declares that it may contact any website (network.allow: "*")');
|
|
69
|
+
if (manifest.network.deny !== null && manifest.network.deny !== '*')
|
|
70
|
+
result.notes.push(`network.deny is "${manifest.network.deny}"; USF expects "*"`);
|
|
71
|
+
if (manifest.unknownKeys.length > 0)
|
|
72
|
+
result.notes.push(`keys this check does not know were not checked: ${list(manifest.unknownKeys)}`);
|
|
73
|
+
}
|
|
74
|
+
else if (reading.declared) {
|
|
75
|
+
// The author meant to declare, but the declaration cannot be read one way only.
|
|
76
|
+
result.problems.push(`the USF declaration in ${SKILL_FILENAME} cannot be read reliably: ${reading.error}`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
if (reading.error)
|
|
80
|
+
result.notes.push(`${SKILL_FILENAME} frontmatter: ${reading.error}. Hosts may not read this Skill's name and description`);
|
|
81
|
+
const missing = `${SKILL_FILENAME} has no USF "permissions" block, so only what its files show is reported`;
|
|
82
|
+
if (options.requireManifest)
|
|
83
|
+
result.problems.push(missing, ...gaps);
|
|
84
|
+
else
|
|
85
|
+
result.notes.push(missing, ...gaps);
|
|
86
|
+
}
|
|
87
|
+
result.ok = result.problems.length === 0;
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
/** What a pull request adds to a Skill, in plain words, compared with the base revision. */
|
|
91
|
+
export function describeAdditions(base, head) {
|
|
92
|
+
if (base === null)
|
|
93
|
+
return ['adds this Skill'];
|
|
94
|
+
const added = (before, after) => after.filter((value) => !before.includes(value));
|
|
95
|
+
const lines = [];
|
|
96
|
+
const before = base.manifest;
|
|
97
|
+
const after = head.manifest;
|
|
98
|
+
const newSites = added(base.profile?.web_hosts ?? [], head.profile?.web_hosts ?? []);
|
|
99
|
+
if (newSites.length > 0)
|
|
100
|
+
lines.push(`uses new websites: ${list(newSites)}`);
|
|
101
|
+
const newAllowed = added(before?.network.allow ?? [], after?.network.allow ?? []);
|
|
102
|
+
if (newAllowed.length > 0)
|
|
103
|
+
lines.push(`declares permission for new websites: ${list(newAllowed)}`);
|
|
104
|
+
if (before?.shell !== true && after?.shell === true)
|
|
105
|
+
lines.push('asks for permission to run commands (shell: true)');
|
|
106
|
+
const newScripts = added((base.profile?.scripts ?? []).map((script) => script.path), (head.profile?.scripts ?? []).map((script) => script.path));
|
|
107
|
+
if (newScripts.length > 0)
|
|
108
|
+
lines.push(`adds scripts or shell commands: ${list(newScripts)}`);
|
|
109
|
+
const newPrograms = added(base.profile?.programs ?? [], head.profile?.programs ?? []);
|
|
110
|
+
if (newPrograms.length > 0)
|
|
111
|
+
lines.push(`names new programs in shell code: ${list(newPrograms)}`);
|
|
112
|
+
const newReads = added(before?.files.read ?? [], after?.files.read ?? []);
|
|
113
|
+
if (newReads.length > 0)
|
|
114
|
+
lines.push(`asks to read new files: ${list(newReads)}`);
|
|
115
|
+
const newWrites = added(before?.files.write ?? [], after?.files.write ?? []);
|
|
116
|
+
if (newWrites.length > 0)
|
|
117
|
+
lines.push(`asks to write new files: ${list(newWrites)}`);
|
|
118
|
+
const unprotected = (before?.files.deny_write ?? []).filter((file) => !(after?.files.deny_write ?? []).includes(file));
|
|
119
|
+
if (unprotected.length > 0)
|
|
120
|
+
lines.push(`no longer protects these files from writes: ${list(unprotected)}`);
|
|
121
|
+
const newTools = added(before?.tools ?? [], after?.tools ?? []);
|
|
122
|
+
if (newTools.length > 0)
|
|
123
|
+
lines.push(`asks for new tools: ${list(newTools)}`);
|
|
124
|
+
const newBinaries = added(before?.requires.binaries ?? [], after?.requires.binaries ?? []);
|
|
125
|
+
if (newBinaries.length > 0)
|
|
126
|
+
lines.push(`needs new programs: ${list(newBinaries)}`);
|
|
127
|
+
return lines;
|
|
128
|
+
}
|