Skip to content

feat(cli): loopback-only skills source test hook (#590) - #1362

Closed
nc9 wants to merge 3 commits into
mainfrom
feat/skills-loopback-source-590
Closed

nc9 wants to merge 3 commits into
mainfrom
feat/skills-loopback-source-590

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Refs #590

  • SQUIRREL_SKILLS_TEST_SOURCE points squirrel skills install/update at a local fixture server. Env only (never config, URL or manifest); honoured only for literal loopback IPs (127.0.0.0/8, [::1]), no credentials/query, no name to resolve; redirects refused; sha256 verification unchanged. Anything else is ignored with one warning and the GitHub hosts are used.
  • Design note / threat model is the doc comment in skills-manifest.ts and docs/cli/skills.mdx (documented as a test hook, not a mirror setting).
  • Tests: parse matrix (hostname tricks, userinfo, localhost, 0.0.0.0, other schemes), non-loopback falls back to default hosts with one warning, real Bun.serve install end to end, redirect refused, tampered file rejected.

Not in this PR (AC 4): wiring skills install into the release install workflows on every platform; that edits test-install.yml for 4+ runners and needs its own review, so #590 stays open for it.

Skill change: none.

nik

@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Reviewed the diff. The loopback restriction holds up and I found no blocking problems.

  • (low) skills-manifest.ts parseLoopbackSource: the https: scheme is accepted, but a loopback fixture would need a self-signed cert, and the docs only mention http. Restricting to http: would be simpler, or document it. Not a security issue.
  • (low) skills-manifest.ts parseLoopbackSource: the IPv4 octet check <= 255 is redundant, since WHATWG URL already rejects out-of-range octets. It is harmless. new URL also normalizes forms like 127.1 to 127.0.0.1, which is fine here.
  • (low) skills-manifest.ts skillsSource: warnedValues is module-level state, so the warning is once per process per value. That is intended, but tests that reuse the same bad value in one process will see no warning. The current test relies on the order of its calls.
  • (low) skills-test-source.test.ts tampered-file test: FILES["references/a.md"] = "ref a"; is a no-op reassignment. The test passes because the manifest hash is bogus, which is the intent, so delete the line. The test is also the only guard that sha256 verification survives the local path, so keep it.
  • (low) Tests: the redirect-refusal test only asserts rejects.toThrow(). It would pass for any failure, such as a connection error. Assert on the error message or on the server's hit count. Prove it bites by dropping redirect: "error": the fetch would then follow the 302 to the real GitHub host. In an offline CI that could still throw, so the test could pass either way.
  • (nit) resolveSkillsRef returns the sentinel "local" as a ref. That is fine, but a SKILLS_LOCAL_REF constant would avoid the magic string, since it ends up in result.ref.
  • (nit) The CHANGELOG bullet and docs read well and follow the house style. A docs/cli/skills.mdx note about https would be useful if it stays supported.

Not run locally: tests and CI checks, because this review environment is read-only.

@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Reviewed the diff. The loopback validation is sound: WHATWG URL parsing normalizes forms like 127.1, userinfo tricks and trailing-dot hosts, and the test matrix covers the common bypasses. I didn't run the tests. Findings:

  • (low) apps/cli/src/self/skills-manifest.ts (skillsSource) / docs/cli/skills.mdx: the docs say every file is "still checked against its sha256 in the manifest". With the local source, the manifest comes from the same server, so the check gives no integrity. Anyone who controls the env var and a loopback listener controls the skill content, which is agent instructions. That needs local env control, so the threat is small, but the docs and doc comment should say the check only catches corruption in this mode.
  • (low) apps/cli/src/cli/commands/skills.ts:333: printSkillsStatus calls fetchSkillsManifest({ fetch: deps.fetch }) with no env, so it reads process.env while deps.e.env is ignored. It is inconsistent with syncSkills, and a test injecting e.env would still hit GitHub for status. Pass env: e.env.
  • (nit) warnedValues is module-level state, so the one-warning test depends on no earlier test in the same process using the same value. Use a unique value per test or export a reset.
  • (nit) In the tampered-file test, FILES["references/a.md"] = "ref a" is a no-op. The test also restarts the server inside the beforeEach setup, which is clumsy.
  • (nit) The resolveSkillsRef local ref is the magic string "local". It ends up in result.ref and possibly in persisted state. Check that nothing later treats it as a git ref.

Test coverage is good overall: parse matrix, fallback warning, a real Bun.serve install, redirect refusal and a tampered file. Docs and CHANGELOG are present.

@nc9
nc9 force-pushed the feat/skills-loopback-source-590 branch from f27b77e to e8616c5 Compare October 30, 2026 19:20
@claude

claude Bot commented Oct 30, 2026

Copy link
Copy Markdown

Review of the loopback-only skills test hook. The threat model is sound: env only, literal loopback IPs, no userinfo/query, redirects refused, sha256 still checked. I found nothing that should block merge.

  • (low) apps/cli/src/cli/commands/skills.ts:333: printSkillsStatus calls fetchSkillsManifest({ fetch: deps.fetch }) and never passes env. It reads process.env while syncSkills reads e.env, so the two paths can disagree about the source. Pass env: e.env there for consistency. The bare catch there also hides the ignored-override warning, but that is minor.
  • (low) skills-manifest.ts (skillsSource): noticed and warnedValues are module-level sets, so the "announced on stderr every time" claim in the doc comment and the docs only holds once per process. For one CLI invocation that is fine. Reword the comment ("once per process"), and be aware these sets leak state between tests in the same process.
  • (nit) The skillsSource doc comment is awkwardly line-wrapped mid-sentence ("honoured only / when the host..."). Reflow it.
  • (nit) skills-test-source.test.ts: the tampered-file test writes FILES["references/a.md"] = "ref a". That line is a no-op that looks like leftover state restoration. Also, isolateSquirrelHome is not called, although the test builds its own e. Run apps/cli/tests/squirrel-home-guard.test.ts to confirm it passes.
  • (nit) parseLoopbackSource is exported. Add a test that https://[::1] normalises as intended, and one for 127.0.0.1:80, where url.origin drops the default port.

Docs and CHANGELOG are present. The CHANGELOG bullet ends with (#590), as the guidelines ask.

@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.145 as 112ee0c1 5551452c 12e21100 via #1377. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.145. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant