Files
claude-seo/hooks/run-python-hook.js
DanielandClaude Opus 4.8 f78f633d3e fix(review): resolve pre-release audit findings (Tier 1+2+4)
Independently verified via two Codex gpt-5.5 xhigh reviews (commit audit +
9-phase whole-plugin) cross-checked by hand, then fixed by 5 parallel Codex
agents on isolated copies with per-file diff verification before apply.

Functionality / correctness:
- seo-local + seo-maps loaded references/*.md from dirs that do not exist;
  repoint to ../seo/references/*.md (every target verified present).
- unlighthouse extension invoked nonexistent npm package unlighthouse-cli;
  switch to the real package unlighthouse@0.13.5 (keeps unlighthouse-ci bin)
  across install.sh/.ps1, unlighthouse_run.py, docs, SKILL.
- ahrefs invoked a non-existent bin; pin @ahrefs/mcp@0.0.11 and correct the
  bin to the package's declared `mcp` across install.sh/.ps1 + docs.
- sync_flow --dry-run threw an uncaught URLError offline; handle it with a
  clean SystemExit (preserves the 403 auth-retry path).
- install slug typo claude-seo@agricidaniel-seo -> agricidaniel-claude-seo
  in docs + uninstall script comments; dataforseo cache glob wildcarded to
  work for both public and private marketplace names.

Security hardening:
- bing_webmaster: redact apikey from RequestException error strings
  (Bing requires the key in the query string; no header option).
- uninstallers + banana install probe: convert python3 -c '${VAR}'
  interpolation to argv quoted-heredoc (matches the hardened cred writers).
- dataforseo + firecrawl install.ps1: PtrToStringAuto -> PtrToStringBSTR
  (PtrToStringAuto truncates the SecureString under pwsh on Linux/macOS).
- pin dataforseo prewarm to @2.8.10.

Hygiene / docs:
- remove orphaned branding/ (referenced deleted banner.svg + diagrams/*.svg).
- CITATION.cff date-released -> 2026-06-12; README tests 316 -> 326;
  README FAQ wording -> May 7 2026 retirement; CLAUDE.md manifest v2.2.0;
  AGENTS.md 30 -> 50 scripts; user-invokable -> user-invocable.
- dependabot: drop the inactive npm watcher (no root npm manifest exists).
- run-python-hook.js: accept a status-0 probe with valid stdout even when
  spawnSync also reports EPERM (robustness; blocking semantics unchanged).
- banana validate_setup.py: --help shows usage and exits 0.
- seo orchestrator: note which extensions route via /seo vs standalone skills.
- frame curl|bash one-liners as the less-safe option in install docs.

Gates: 326 tests pass, portability 0/0/0, injection/SSRF/FAQ-hook/#130
repros re-verified on the modified tree, no em-dashes, secret scan clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-12 23:07:34 +03:00

66 lines
1.7 KiB
JavaScript

#!/usr/bin/env node
"use strict";
const { spawnSync } = require("child_process");
function stripWrappingQuotes(value) {
return value.replace(/^["']|["']$/g, "");
}
function pythonCandidates() {
const candidates = [];
if (process.env.CLAUDE_SEO_PYTHON) {
candidates.push({
label: "CLAUDE_SEO_PYTHON",
exe: stripWrappingQuotes(process.env.CLAUDE_SEO_PYTHON),
args: [],
});
}
candidates.push(
{ label: "py -3", exe: "py", args: ["-3"] },
{ label: "python3", exe: "python3", args: [] },
{ label: "python", exe: "python", args: [] },
);
return candidates;
}
function isStoreStubOutput(text) {
return /Microsoft Store|WindowsApps|App execution alias|was not found/i.test(text);
}
function probe(candidate) {
const script = "import sys; print(sys.executable); print(sys.version.split()[0])";
const result = spawnSync(candidate.exe, [...candidate.args, "-c", script], {
encoding: "utf8",
});
const output = `${result.stdout || ""}\n${result.stderr || ""}`;
return result.status === 0 && Boolean((result.stdout || "").trim()) && !isStoreStubOutput(output);
}
function main() {
const [, , hookScript, ...hookArgs] = process.argv;
if (!hookScript) {
process.exit(0);
}
for (const candidate of pythonCandidates()) {
if (!probe(candidate)) {
continue;
}
const result = spawnSync(candidate.exe, [...candidate.args, hookScript, ...hookArgs], {
stdio: "inherit",
});
if (result.error) {
continue;
}
process.exit(result.status === null ? 1 : result.status);
}
console.error(
"Claude SEO hook could not find Python. Tried CLAUDE_SEO_PYTHON, py -3, python3, python.",
);
process.exit(1);
}
main();