ceulen 0.29.1 → 0.30.0

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.
@@ -0,0 +1,93 @@
1
+ #!/bin/sh
2
+ # Re-run BOTH provenance matchers over the exact fixture bodies printed in
3
+ # AGENTS.md's "What a raw grep gets wrong" table.
4
+ #
5
+ # The table is the claim; this script is its check. It extracts each row's JSON
6
+ # literal straight out of AGENTS.md — no fixtures duplicated here, so the table
7
+ # cannot drift from the measurement — then runs the historical substring matcher
8
+ # and the documented parse matcher on that literal and compares both results
9
+ # with the row's own columns.
10
+ #
11
+ # Usage: scripts/check-provenance-fixtures.sh [path-to-AGENTS.md]
12
+ # Exit: 0 = every row reproduced; 1 = a row disagreed or the table changed shape.
13
+ #
14
+ # NOTE: this checks the REPO's documentation, so it needs AGENTS.md — which is
15
+ # deliberately not in package.json `files` (npm ships extensions/skills/themes/
16
+ # scripts + README/LICENSE/CHANGELOG). In an npm-installed copy there is no
17
+ # table to check and the script fails with "no such file"; run it from a
18
+ # checkout. `verify-provenance.sh` and `audit-attestations.sh` have no such
19
+ # dependency and work from an installed package.
20
+ set -eu
21
+
22
+ DOC="${1:-$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)/AGENTS.md}"
23
+ [ -f "$DOC" ] || { echo "FAIL: no such file: $DOC" >&2; exit 1; }
24
+
25
+ # Emit one TSV row per fixture: number <TAB> body <TAB> grep-claim <TAB> correct-claim
26
+ rows=$(node -e '
27
+ const fs = require("fs");
28
+ const lines = fs.readFileSync(process.argv[1], "utf8").split("\n");
29
+ const head = lines.findIndex((l) => l.includes("body (exact fixture)"));
30
+ if (head < 0) { console.error("FAIL: fixture table not found"); process.exit(1); }
31
+ const out = [];
32
+ for (let i = head + 2; i < lines.length; i++) {
33
+ if (!lines[i].startsWith("|")) break;
34
+ const cells = lines[i].split("|").map((c) => c.trim());
35
+ const n = cells[1];
36
+ const m = /^`(.+)`$/.exec(cells[2] || "");
37
+ if (!m) { console.error("FAIL: row " + n + " body is not one backticked literal"); process.exit(1); }
38
+ out.push([n, m[1], cells[3], cells[4]].join("\t"));
39
+ }
40
+ if (!out.length) { console.error("FAIL: fixture table has no rows"); process.exit(1); }
41
+ console.log(out.join("\n"));
42
+ ' "$DOC") || exit 1
43
+
44
+ parse() {
45
+ node -e '
46
+ let s = "";
47
+ process.stdin.on("data", (d) => { s += d; }).on("end", () => {
48
+ let j;
49
+ try { j = JSON.parse(s); } catch (e) { process.exit(1); }
50
+ const l = j.attestations;
51
+ if (!Array.isArray(l)) process.exit(1);
52
+ process.exit(l.some((a) => a && a.predicateType === "https://slsa.dev/provenance/v1") ? 0 : 1);
53
+ });
54
+ '
55
+ }
56
+
57
+ fail=0
58
+ printf '%-3s %-10s %-10s %-10s %-10s %s\n' ROW GREP-MEAS GREP-DOC PARSE-MEAS PARSE-DOC VERDICT
59
+ printf '%s\n' "$rows" | while IFS="$(printf '\t')" read -r n body grepClaim correctClaim; do
60
+ [ -n "${n:-}" ] || continue
61
+ if printf '%s' "$body" | grep -q 'https://slsa.dev/provenance/v1'; then measuredGrep="match"; else measuredGrep="no match"; fi
62
+ if printf '%s' "$body" | parse; then measuredParse="pass"; else measuredParse="fail"; fi
63
+
64
+ # A "false positive" is a COMPOUND claim, not a synonym for "match": grep must
65
+ # match AND the correct answer must be fail. Normalizing it to "match" would
66
+ # let a genuine-provenance row be relabelled a false positive and still pass.
67
+ case "$grepClaim" in
68
+ *"false positive"*) expectGrep="match"; expectParseForFalsePositive="fail" ;;
69
+ *) expectGrep="$grepClaim"; expectParseForFalsePositive="" ;;
70
+ esac
71
+
72
+ verdict=ok
73
+ [ "$measuredGrep" = "$expectGrep" ] || { verdict="MISMATCH(grep)"; fail=1; }
74
+ [ "$measuredParse" = "$correctClaim" ] || { verdict="MISMATCH(parse)"; fail=1; }
75
+ if [ -n "$expectParseForFalsePositive" ] && [ "$measuredParse" != "$expectParseForFalsePositive" ]; then
76
+ verdict="BAD(false-positive-claim)"; fail=1
77
+ fi
78
+ printf '%-3s %-10s %-10s %-10s %-10s %s\n' "$n" "$measuredGrep" "$grepClaim" "$measuredParse" "$correctClaim" "$verdict"
79
+ # Signal out of the subshell via a file so the exit status survives the pipe.
80
+ [ "$verdict" = ok ] || echo "$n" >> "${TMP:-/tmp}/.prov-fixture-fails.$$"
81
+ done
82
+
83
+ status=0
84
+ if [ -f "${TMP:-/tmp}/.prov-fixture-fails.$$" ]; then
85
+ echo >&2
86
+ echo "FAIL: rows $(tr '\n' ' ' < "${TMP:-/tmp}/.prov-fixture-fails.$$")disagree with the table" >&2
87
+ rm -f "${TMP:-/tmp}/.prov-fixture-fails.$$"
88
+ status=1
89
+ else
90
+ echo
91
+ echo "OK: every table row reproduced (grep claim AND parse result)"
92
+ fi
93
+ exit "$status"
@@ -0,0 +1,90 @@
1
+ #!/bin/sh
2
+ # Smoke-test the npm-installable tarball: install into a throwaway directory and
3
+ # assert the payload, with a non-zero exit for EVERY kind of wrong answer.
4
+ #
5
+ # Exists because AGENTS.md tells you to "install it from a clean directory and
6
+ # assert the payload" before calling a release shipped, and hand-rolling that
7
+ # check has repeatedly produced exit codes that meant nothing — capturing $?
8
+ # after a pipeline, or a node -e that only printed results without calling
9
+ # process.exit. Every assertion here is fatal.
10
+ #
11
+ # Checks, each independently fatal:
12
+ # - npm install's own exit status (captured without a pipe)
13
+ # - installed package.json version == the requested version
14
+ # - every --require path exists in the installed package
15
+ # - every --forbid path is ABSENT (deleted files must stay deleted)
16
+ #
17
+ # Usage: scripts/smoke-install.sh <version> [package]
18
+ # [--require <path-in-package>]...
19
+ # [--forbid <path-in-package>]...
20
+ # Exit: 0 = installed and every assertion held; 1 = a check failed; 2 = bad usage.
21
+ set -eu
22
+
23
+ VERSION=""
24
+ PACKAGE="ceulen"
25
+ REQUIRE=""
26
+ FORBID=""
27
+ # Version the installed package.json must report. Defaults to the version we
28
+ # install; --expect-version exists so the mismatch guard is testable through the
29
+ # real CLI instead of by poking at internals.
30
+ EXPECT_VERSION=""
31
+ while [ $# -gt 0 ]; do
32
+ case "$1" in
33
+ --require) REQUIRE="$REQUIRE $2"; shift 2 ;;
34
+ --forbid) FORBID="$FORBID $2"; shift 2 ;;
35
+ --package) PACKAGE="$2"; shift 2 ;;
36
+ --expect-version) EXPECT_VERSION="$2"; shift 2 ;;
37
+ -*) echo "unknown option: $1" >&2; exit 2 ;;
38
+ *) [ -z "$VERSION" ] && VERSION="$1" || { echo "unexpected argument: $1" >&2; exit 2; }; shift ;;
39
+ esac
40
+ done
41
+ [ -n "$VERSION" ] || { echo "usage: smoke-install.sh <version> [package] [--require p]... [--forbid p]... [--expect-version v]" >&2; exit 2; }
42
+ [ -n "$EXPECT_VERSION" ] || EXPECT_VERSION="$VERSION"
43
+
44
+ WORK=$(mktemp -d)
45
+ trap 'rm -rf "$WORK"' EXIT INT TERM
46
+ cd "$WORK"
47
+
48
+ # npm's OWN exit status — no pipeline, so nothing can mask it.
49
+ if ! npm install "$PACKAGE@$VERSION" --no-save --loglevel=error > install.log 2>&1; then
50
+ echo "FAIL: npm install $PACKAGE@$VERSION exited non-zero" >&2
51
+ tail -20 install.log >&2
52
+ exit 1
53
+ fi
54
+ echo "ok npm install $PACKAGE@$VERSION — exit 0"
55
+
56
+ BASE="node_modules/$PACKAGE"
57
+ SMOKE_BASE="$BASE" SMOKE_VERSION="$EXPECT_VERSION" SMOKE_REQUIRE="$REQUIRE" SMOKE_FORBID="$FORBID" node -e '
58
+ const fs = require("fs");
59
+ const path = require("path");
60
+ const base = process.env.SMOKE_BASE;
61
+ const want = process.env.SMOKE_VERSION;
62
+ const split = (s) => (s || "").trim().split(/\s+/).filter(Boolean);
63
+ const require_ = split(process.env.SMOKE_REQUIRE);
64
+ const forbid = split(process.env.SMOKE_FORBID);
65
+
66
+ let bad = 0;
67
+ const fail = (m) => { console.error("FAIL: " + m); bad = 1; };
68
+
69
+ let pkg;
70
+ try {
71
+ pkg = JSON.parse(fs.readFileSync(path.join(base, "package.json"), "utf8"));
72
+ } catch (e) {
73
+ console.error("FAIL: cannot read the installed package.json — extraction failed");
74
+ process.exit(1);
75
+ }
76
+
77
+ if (pkg.version !== want) fail("installed version " + pkg.version + " != requested " + want);
78
+ else console.log("ok version " + pkg.version);
79
+
80
+ for (const f of require_) {
81
+ if (fs.existsSync(path.join(base, f))) console.log("ok present " + f);
82
+ else fail("missing " + f);
83
+ }
84
+ for (const f of forbid) {
85
+ if (fs.existsSync(path.join(base, f))) fail("unexpected " + f + " (should not ship)");
86
+ else console.log("ok absent " + f);
87
+ }
88
+
89
+ process.exit(bad ? 1 : 0);
90
+ '
@@ -0,0 +1,45 @@
1
+ #!/bin/sh
2
+ # Verify a ceulen release carries SLSA provenance, not just an npm signature.
3
+ #
4
+ # HTTP 200 alone is NOT sufficient. The endpoint can carry two DISTINCT
5
+ # attestations: npm's own publish recording
6
+ # (`https://github.com/npm/attestation/.../publish/v0.1`) and the SLSA build
7
+ # provenance. Only the latter is a build-provenance claim, so a 200 — or a
8
+ # `publish/v0.1` by itself — does not establish it. The claim is satisfied only
9
+ # by the presence of the `https://slsa.dev/provenance/v1` predicate.
10
+ #
11
+ # Usage: scripts/verify-provenance.sh <version> [package]
12
+ set -eu
13
+
14
+ VERSION="${1:?usage: verify-provenance.sh <version> [package]}"
15
+ PACKAGE="${2:-ceulen}"
16
+ SLSA="https://slsa.dev/provenance/v1"
17
+ URL="https://registry.npmjs.org/-/npm/v1/attestations/${PACKAGE}@${VERSION}"
18
+
19
+ body=$(curl -sS -w '\n%{http_code}' "$URL") || { echo "FAIL $PACKAGE@$VERSION: request failed" >&2; exit 1; }
20
+ code=$(printf '%s\n' "$body" | tail -1)
21
+ payload=$(printf '%s\n' "$body" | sed '$d')
22
+
23
+ if [ "$code" != "200" ]; then
24
+ echo "FAIL $PACKAGE@$VERSION: attestation endpoint returned HTTP $code" >&2
25
+ exit 1
26
+ fi
27
+
28
+ printf '%s' "$payload" | node -e '
29
+ let s = "";
30
+ process.stdin.on("data", (d) => { s += d; }).on("end", () => {
31
+ const want = process.argv[1];
32
+ let preds = [];
33
+ try { preds = (JSON.parse(s).attestations || []).map((a) => a.predicateType); } catch (e) {
34
+ console.error("FAIL: response is not valid JSON");
35
+ process.exit(1);
36
+ }
37
+ const hasSlsa = preds.includes(want);
38
+ console.log("predicates:", preds.join(", ") || "(none)");
39
+ if (!hasSlsa) {
40
+ console.error(`FAIL: HTTP 200 but no ${want} predicate — a publish-only attestation does not establish provenance`);
41
+ process.exit(1);
42
+ }
43
+ console.log(`OK: ${want} present`);
44
+ });
45
+ ' "$SLSA"