Skip to content

test(public-repository): cover the boundary errors contributors hit - #15

Open
dchaudhari7177 wants to merge 1 commit into
esherialabs:mainfrom
dchaudhari7177:test/11-public-repository-boundaries
Open

test(public-repository): cover the boundary errors contributors hit#15
dchaudhari7177 wants to merge 1 commit into
esherialabs:mainfrom
dchaudhari7177:test/11-public-repository-boundaries

Conversation

@dchaudhari7177

Copy link
Copy Markdown

Closes #11.

18 node --test cases, each building a temporary fixture tree and running the validator with --root, asserting the exact string a contributor would see.

Acceptance criteria

  • Restricted directorydocs/security/threat-model.md
  • Blocked binary extension.apk, .keystore, .safetensors, .pem
  • Missing community fileCODE_OF_CONDUCT.md, plus a case that removes every required file one at a time and asserts a specific message for each
  • Stale canonical repository URL — and the commercial esheria.ai link asserted separately
  • Generated temporary fixtures, no secrets or personal datamkdtemp per test; blocked-extension files hold the literal not-a-real-key
  • Stable, specific error messages — every assertion matches the full - <message>: <path> line, not just a substring of the category
  • Validator stays fail closed — see below
  • Ran the targeted tests and npm run public:repository:check

Also pinned, since they were equally untested and easy to break: non-text extensions correctly skipped by the URL scan, .env rejected while .env.example is allowed, truncated LICENSE, SHA256SUMS mismatch and malformed entries, and unclean provenance.

Two cases target fail-closed behaviour directly: a non-existent root must not pass, and several violations must all be reported, not just the first.

One validator change, and why it was unavoidable

To assert the stale-URL rule, the test file must itself contain github.com/esherialabs/saferider and https://esheria.ai. The validator then flagged the test file:

- stale repository URL remains in scripts/__tests__/saferide-validate-public-repository.test.mjs
- commercial Esheria site linkage remains in scripts/__tests__/saferide-validate-public-repository.test.mjs

So it is added to staleReferenceAllowlist — the list that already exists for exactly this, holding scripts/validate-public-repository.mjs and web/tests/saferide-v2.spec.ts, both of which carry those strings for the same reason.

Nothing else changes, and it stays fail closed everywhere else. Measured rather than asserted:

tree findings from npm run public:repository:check
clean main 841
this branch, before the allowlist entry 843 (the two above)
this branch, after 841

Same count as baseline — neither more nor fewer. The 841 are pre-existing SHA256SUMS drift in web/, untouched by this PR.

Result

tests 18 · pass 18 · fail 0
validate-public-repository.mjs is what stops restricted material reaching the
public mirror, and nothing tested its messages. Add 18 node --test cases that
build a temporary fixture tree and run the validator with --root, asserting
the exact string a contributor would see.

Covered, as the issue asks: a restricted directory (docs/security/), a blocked
binary extension (.apk, .keystore, .safetensors, .pem), a missing community
file, and a stale canonical repository URL. Also the neighbouring rules that
would otherwise be easy to break -- the commercial-site link reported
separately, non-text extensions correctly skipped, .env rejected while
.env.example is allowed, a truncated LICENSE, SHA256SUMS mismatch and
malformed entries, unclean provenance, and every required file enforced
individually rather than as a set.

Two cases pin fail-closed behaviour directly: a non-existent root must not
pass, and several violations must all be reported rather than only the first.

Fixtures are generated per test in a mkdtemp directory and contain no secrets
or personal data -- blocked-extension files hold the literal string
"not-a-real-key".

The test file itself has to contain the stale URL and the commercial link to
assert they are caught, which the validator then flagged in the test file. Add
it to staleReferenceAllowlist, alongside the two files already there for the
same reason. Nothing else about the validator changes, and it stays fail
closed for every path outside that list: npm run public:repository:check
reports the same 841 pre-existing findings as it does on a clean checkout,
neither more nor fewer.

Closes esherialabs#11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant