Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions scripts/check-publication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,44 @@ export function trackedPublicationIssues(
throw new Error("Publication refused: cannot read tracked Git content");
}
};
const names = git(
revision && revision !== ":"
? ["ls-tree", "-r", "--name-only", "-z", revision]
: ["ls-files", "-z"],
const records = git(
revision && revision !== ":" ? ["ls-tree", "-r", "-z", revision] : ["ls-files", "-s", "-z"],
)
.toString()
.split("\0")
.filter(Boolean);
return names.flatMap((path) => {
const entries = new Map(
records.map((entry) => {
const separator = entry.indexOf("\t");
return [entry.slice(separator + 1), entry.slice(0, separator).split(" ")[0]] as const;
}),
);
return [...entries].flatMap(([path, mode]) => {
const full = join(directory, path);
let body: Buffer;
if (revision) body = git(["show", `${revision === ":" ? "" : revision}:${path}`]);
else {
if (revision) {
body = git(["show", `${revision === ":" ? "" : revision}:${path}`]);
if (mode === "120000") {
return [{ path, rule: "symlink", line: 1 }];
}
if (mode !== "100644" && mode !== "100755")
return [{ path, rule: "irregular-entry", line: 1 }];
} else {
let stat: ReturnType<typeof lstatSync>;
try {
const stat = lstatSync(full);
if (stat.isSymbolicLink()) return [{ path, rule: "symlink", line: 1 }];
body = readFileSync(full);
stat = lstatSync(full);
} catch (error) {
if ((error as NodeJS.ErrnoException).code === "ENOENT") return [];
throw error;
throw new Error("Publication refused: cannot inspect tracked entry");
}
if (stat.isSymbolicLink()) {
return [{ path, rule: "symlink", line: 1 }];
}
if (!stat.isFile()) return [{ path, rule: "irregular-entry", line: 1 }];
try {
body = readFileSync(full);
} catch {
throw new Error("Publication refused: cannot read tracked file");
}
}
// Binary metadata is included; a tracked path is never skipped because it is ignored.
Expand Down
9 changes: 3 additions & 6 deletions scripts/publication-safety.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ const rules: Array<[string, RegExp]> = [
],
[
"credential",
/BEGIN (?:RSA|OPENSSH|EC|DSA)? ?PRIVATE KEY|(?:github_pat_|ghp_)[A-Za-z0-9_]{12,}/gu,
],
[
"private-workspace",
/(?:rootform-dev\/)?notes\/(?:public-separation|candidate-|ci-budget|operator-preferences|agentic-delivery|editor-qualification|site-quality|language-learning)/gu,
/BEGIN (?:RSA|OPENSSH|EC|DSA)? ?PRIVATE KEY|(?:github_pat_|gh[pousr]_|npm_)[A-Za-z0-9_]{12,}|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|xox[abprs]-[A-Za-z0-9-]{12,}|AIza[A-Za-z0-9_-]{35}|\bBearer\s+[A-Za-z0-9._~+/-]{24,}=*|\b(?:CLOUDFLARE_API_TOKEN|AWS_SECRET_ACCESS_KEY|OPENAI_API_KEY|API_TOKEN|API_KEY)\s*[:=]\s*["\x27]?[A-Za-z0-9_+./~-]{24,}/gu,
],
["private-workspace", /\b(?:rootform-dev\/)?notes\/[A-Za-z0-9][A-Za-z0-9._/-]*/gu],
[
"session-instructions",
/^\s*(?:#+\s*)?(?:system prompt|agent handoff|session report|rapport de session|instructions? (?:to|aux|pour) (?:models?|agents?)|model routing)\b|(?:Fable\s*5\.1|DeepSeek[- ]V4|Claude[- ](?:Opus|Fable)).{0,50}(?:review|revue|Max|max|instructions?)/gimu,
/^\s*(?:#+\s*)?(?:system prompt|agent handoff|session report|rapport de session|instructions? (?:to|aux|pour) (?:models?|agents?)|model routing)\b|\b[A-Z][A-Za-z0-9_-]*[- ]V?\d+\.\d+\s+(?:Max|Ultra)\b.{0,40}\b(?:review|revue|instructions?)\b|\b(?:model routing|review with|revue avec)\s*[:=]/gimu,
],
[
"private-activity",
Expand Down
Loading