oc-pilot 0.107.0 → 0.109.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/CHANGELOG.md +13 -0
- package/README.md +9 -5
- package/README.ru.md +8 -4
- package/dist/cli.js +9 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.test.js +24 -0
- package/dist/cli.test.js.map +1 -1
- package/dist/commands/chronos.js +81 -0
- package/dist/commands/chronos.js.map +1 -0
- package/dist/commands/cuckoo.js +96 -0
- package/dist/commands/cuckoo.js.map +1 -0
- package/dist/core/chronos.js +126 -0
- package/dist/core/chronos.js.map +1 -0
- package/dist/core/chronos.test.js +116 -0
- package/dist/core/chronos.test.js.map +1 -0
- package/dist/core/cuckoo.js +251 -0
- package/dist/core/cuckoo.js.map +1 -0
- package/dist/core/cuckoo.test.js +98 -0
- package/dist/core/cuckoo.test.js.map +1 -0
- package/dist/mcp-prompts.test.js +2 -0
- package/dist/mcp-prompts.test.js.map +1 -1
- package/dist/mcp.js +89 -0
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.test.js +10 -0
- package/dist/mcp.test.js.map +1 -1
- package/dist/skills.test.js +5 -0
- package/dist/skills.test.js.map +1 -1
- package/dist/version.js +1 -1
- package/docs/integrations.md +5 -5
- package/package.json +1 -1
- package/skills/agent-self-review/SKILL.md +1 -1
- package/skills/commit-discipline/SKILL.md +1 -1
- package/skills/oc-pilot/SKILL.md +4 -0
- package/skills/secure-diff-gate/SKILL.md +1 -1
- package/skills/stack-review-packs/SKILL.md +1 -1
- package/skills/test-failure-triage/SKILL.md +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { renderCuckoo, runCuckoo } from "../core/cuckoo.js";
|
|
2
|
+
import { PilotError } from "../core/errors.js";
|
|
3
|
+
import { writeOutput } from "../core/io.js";
|
|
4
|
+
import { log } from "../core/log.js";
|
|
5
|
+
import { COMMON_HELP, parseCommandArgs, resolveContext, withCommon } from "../core/options.js";
|
|
6
|
+
import { asBoolean, asString, parseSeconds } from "../core/parse.js";
|
|
7
|
+
const OPTIONS = withCommon({
|
|
8
|
+
file: { type: "string" },
|
|
9
|
+
"script-timeout": { type: "string" },
|
|
10
|
+
allow: { type: "string" },
|
|
11
|
+
});
|
|
12
|
+
const HELP = `Использование:
|
|
13
|
+
oc-pilot cuckoo <file> [опции]
|
|
14
|
+
oc-pilot cuckoo --file <file> [опции]
|
|
15
|
+
|
|
16
|
+
Запускает JS/ESM-файл в инструментированной vm-песочнице и показывает,
|
|
17
|
+
какие возможности он запрашивает: fs, net, child_process, env, exit,
|
|
18
|
+
require, import. Код не получает реальный доступ: моки записывают попытки,
|
|
19
|
+
а опасные операции останавливают выполнение.
|
|
20
|
+
Модель и сеть не используются.
|
|
21
|
+
|
|
22
|
+
Опции:
|
|
23
|
+
--file <file> файл для аудита
|
|
24
|
+
--script-timeout <15s> таймаут выполнения (0.1s–60s)
|
|
25
|
+
--allow <kinds> разрешённые виды через запятую; иначе любой запрос — код 1
|
|
26
|
+
${COMMON_HELP}
|
|
27
|
+
|
|
28
|
+
Коды выхода:
|
|
29
|
+
0 чисто или все запросы разрешены
|
|
30
|
+
1 [CAPABILITY DENIED] есть запрещённые возможности
|
|
31
|
+
2 ошибка файла, песочницы или таймаут
|
|
32
|
+
|
|
33
|
+
Примеры:
|
|
34
|
+
oc-pilot cuckoo dist/tool.mjs
|
|
35
|
+
oc-pilot cuckoo --file generated.mjs --allow fs,env`;
|
|
36
|
+
export async function runCuckooCommand(argv) {
|
|
37
|
+
const { values, positionals } = parseCommandArgs(argv, OPTIONS);
|
|
38
|
+
if (asBoolean(values, "help")) {
|
|
39
|
+
process.stdout.write(`${HELP}\n`);
|
|
40
|
+
return 0;
|
|
41
|
+
}
|
|
42
|
+
const fileFlag = asString(values, "file");
|
|
43
|
+
if (positionals.length > 1) {
|
|
44
|
+
throw new PilotError("cuckoo принимает один файл", {
|
|
45
|
+
hint: "Передайте путь позиционно или через --file.",
|
|
46
|
+
exitCode: 2,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const file = fileFlag ?? positionals[0];
|
|
50
|
+
if (!file) {
|
|
51
|
+
throw new PilotError("Нужен файл для аудита", {
|
|
52
|
+
hint: "Например: oc-pilot cuckoo dist/tool.mjs.",
|
|
53
|
+
exitCode: 2,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (fileFlag && positionals.length > 0) {
|
|
57
|
+
throw new PilotError("Укажите файл только один раз", {
|
|
58
|
+
hint: "Либо позиционно, либо через --file.",
|
|
59
|
+
exitCode: 2,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const ctx = resolveContext(values);
|
|
63
|
+
const timeoutRaw = asString(values, "script-timeout");
|
|
64
|
+
const allowRaw = asString(values, "allow");
|
|
65
|
+
const allow = allowRaw
|
|
66
|
+
? new Set(allowRaw
|
|
67
|
+
.split(",")
|
|
68
|
+
.map((value) => value.trim())
|
|
69
|
+
.filter(Boolean))
|
|
70
|
+
: undefined;
|
|
71
|
+
const report = runCuckoo(ctx.cwd, file, {
|
|
72
|
+
timeoutMs: timeoutRaw ? parseSeconds(timeoutRaw, "script-timeout") * 1000 : undefined,
|
|
73
|
+
});
|
|
74
|
+
const wrote = ctx.flags.json
|
|
75
|
+
? writeOutput(JSON.stringify(report, null, 2), ctx.flags.output)
|
|
76
|
+
: writeOutput(renderCuckoo(report), ctx.flags.output);
|
|
77
|
+
if (wrote)
|
|
78
|
+
log.success(`Результат сохранён: ${wrote}`);
|
|
79
|
+
if (report.status === "error" || report.status === "timeout") {
|
|
80
|
+
log.error(report.summary);
|
|
81
|
+
return 2;
|
|
82
|
+
}
|
|
83
|
+
const disallowed = allow
|
|
84
|
+
? report.capabilities.filter((capability) => !allow.has(capability.kind))
|
|
85
|
+
: report.capabilities;
|
|
86
|
+
if (disallowed.length > 0) {
|
|
87
|
+
log.error(report.summary);
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
if (report.capabilities.length > 0)
|
|
91
|
+
log.warn(report.summary);
|
|
92
|
+
else
|
|
93
|
+
log.success(report.summary);
|
|
94
|
+
return 0;
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=cuckoo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cuckoo.js","sourceRoot":"","sources":["../../src/commands/cuckoo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,EAAE,UAAU,EAAmB,MAAM,oBAAoB,CAAC;AAChH,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErE,MAAM,OAAO,GAAe,UAAU,CAAC;IACrC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxB,gBAAgB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC1B,CAAC,CAAC;AAEH,MAAM,IAAI,GAAG;;;;;;;;;;;;;;EAcX,WAAW;;;;;;;;;sDASyC,CAAC;AAEvD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,IAAc;IACnD,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,IAAI,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QAClC,OAAO,CAAC,CAAC;IACX,CAAC;IAED,MAA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@@
|
|
|
1
|
+
import { readAntibodyStore } from "./antibody.js";
|
|
2
|
+
import { runGit } from "./git.js";
|
|
3
|
+
import { readVaccineStore } from "./vaccine.js";
|
|
4
|
+
const DEFAULT_LIMIT = 20;
|
|
5
|
+
const MAX_LIMIT = 200;
|
|
6
|
+
const HOTSPOT_SCORE = 10;
|
|
7
|
+
function normalize(path) {
|
|
8
|
+
return path.replace(/\\/g, "/");
|
|
9
|
+
}
|
|
10
|
+
function flagsOf(subject) {
|
|
11
|
+
const flags = [];
|
|
12
|
+
if (/\b(?:fix|bug|hotfix|patch|repair|regression)\b/i.test(subject))
|
|
13
|
+
flags.push("fix");
|
|
14
|
+
if (/\brevert(?:s|ed|ing)?\b/i.test(subject))
|
|
15
|
+
flags.push("revert");
|
|
16
|
+
if (/\b(?:incident|outage|sev[0-9]?|rollback|production|prod)\b/i.test(subject))
|
|
17
|
+
flags.push("incident");
|
|
18
|
+
if (/\b(?:security|cve-\d+|vulnerab|xss|csrf|injection|auth)\b/i.test(subject))
|
|
19
|
+
flags.push("security");
|
|
20
|
+
return flags;
|
|
21
|
+
}
|
|
22
|
+
function shortstat(cwd, sha) {
|
|
23
|
+
const result = runGit(["show", "--shortstat", "--format=", sha], cwd);
|
|
24
|
+
if (result.status !== 0)
|
|
25
|
+
return { additions: 0, deletions: 0 };
|
|
26
|
+
const additions = /(\d+) insertions?/.exec(result.stdout)?.[1];
|
|
27
|
+
const deletions = /(\d+) deletions?/.exec(result.stdout)?.[1];
|
|
28
|
+
return {
|
|
29
|
+
additions: additions ? Number(additions) : 0,
|
|
30
|
+
deletions: deletions ? Number(deletions) : 0,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/** Reads the commit chronicle of one file and scores it as a hotspot. */
|
|
34
|
+
export function analyzeChronos(cwd, file, options = {}) {
|
|
35
|
+
const limit = Math.max(1, Math.min(MAX_LIMIT, options.limit ?? DEFAULT_LIMIT));
|
|
36
|
+
const args = [
|
|
37
|
+
"log",
|
|
38
|
+
"--follow",
|
|
39
|
+
`--max-count=${String(limit)}`,
|
|
40
|
+
"--format=%H%x1f%an%x1f%ad%x1f%s",
|
|
41
|
+
"--date=short",
|
|
42
|
+
];
|
|
43
|
+
if (options.since)
|
|
44
|
+
args.push(`--since=${options.since}`);
|
|
45
|
+
args.push("--", file);
|
|
46
|
+
const result = runGit(args, cwd);
|
|
47
|
+
const commits = [];
|
|
48
|
+
if (result.status === 0) {
|
|
49
|
+
for (const line of result.stdout.split(/\r?\n/)) {
|
|
50
|
+
if (!line.trim())
|
|
51
|
+
continue;
|
|
52
|
+
const [sha, author, date, subject] = line.split("\x1f");
|
|
53
|
+
if (!sha || !subject)
|
|
54
|
+
continue;
|
|
55
|
+
const stat = shortstat(cwd, sha);
|
|
56
|
+
commits.push({
|
|
57
|
+
sha,
|
|
58
|
+
author: author ?? "unknown",
|
|
59
|
+
date: date ?? "unknown",
|
|
60
|
+
subject,
|
|
61
|
+
additions: stat.additions,
|
|
62
|
+
deletions: stat.deletions,
|
|
63
|
+
flags: flagsOf(subject),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const totals = {
|
|
68
|
+
commits: commits.length,
|
|
69
|
+
additions: commits.reduce((sum, commit) => sum + commit.additions, 0),
|
|
70
|
+
deletions: commits.reduce((sum, commit) => sum + commit.deletions, 0),
|
|
71
|
+
fixes: commits.filter((commit) => commit.flags.includes("fix")).length,
|
|
72
|
+
reverts: commits.filter((commit) => commit.flags.includes("revert")).length,
|
|
73
|
+
incidents: commits.filter((commit) => commit.flags.includes("incident")).length,
|
|
74
|
+
security: commits.filter((commit) => commit.flags.includes("security")).length,
|
|
75
|
+
};
|
|
76
|
+
const target = normalize(file);
|
|
77
|
+
const antibodies = readAntibodyStore(cwd).signatures.filter((signature) => signature.file && normalize(signature.file) === target).length;
|
|
78
|
+
const shas = new Set(commits.map((commit) => commit.sha));
|
|
79
|
+
const vaccines = readVaccineStore(cwd).vaccines.filter((vaccine) => shas.has(vaccine.bug) || shas.has(vaccine.fix)).length;
|
|
80
|
+
const churn = Math.min(10, Math.floor((totals.additions + totals.deletions) / 100));
|
|
81
|
+
const score = totals.fixes * 3 +
|
|
82
|
+
totals.reverts * 5 +
|
|
83
|
+
totals.incidents * 4 +
|
|
84
|
+
totals.security * 2 +
|
|
85
|
+
churn +
|
|
86
|
+
antibodies * 2 +
|
|
87
|
+
vaccines * 3;
|
|
88
|
+
const hotspot = score >= HOTSPOT_SCORE;
|
|
89
|
+
const summary = totals.commits === 0
|
|
90
|
+
? `[CHRONOS]: история файла ${file} пуста.`
|
|
91
|
+
: hotspot
|
|
92
|
+
? `[HOTSPOT]: ${file} — score ${String(score)}; fixes ${String(totals.fixes)}, reverts ${String(totals.reverts)}, incidents ${String(totals.incidents)}.`
|
|
93
|
+
: `[CHRONOS]: ${file} — score ${String(score)}; явных инцидентов в истории нет.`;
|
|
94
|
+
const report = {
|
|
95
|
+
file,
|
|
96
|
+
commits,
|
|
97
|
+
totals,
|
|
98
|
+
antibodies,
|
|
99
|
+
vaccines,
|
|
100
|
+
score,
|
|
101
|
+
hotspot,
|
|
102
|
+
summary,
|
|
103
|
+
content: "",
|
|
104
|
+
};
|
|
105
|
+
report.content = renderChronos(report);
|
|
106
|
+
return report;
|
|
107
|
+
}
|
|
108
|
+
export function renderChronos(report) {
|
|
109
|
+
const lines = [
|
|
110
|
+
`Chronos: ${report.file}`,
|
|
111
|
+
`Commits: ${String(report.totals.commits)}, +${String(report.totals.additions)}/-${String(report.totals.deletions)}`,
|
|
112
|
+
`Fixes: ${String(report.totals.fixes)}, reverts: ${String(report.totals.reverts)}, incidents: ${String(report.totals.incidents)}, security: ${String(report.totals.security)}`,
|
|
113
|
+
`Antibodies: ${String(report.antibodies)}, vaccines: ${String(report.vaccines)}`,
|
|
114
|
+
`Hotspot score: ${String(report.score)}${report.hotspot ? " [HOTSPOT]" : ""}`,
|
|
115
|
+
];
|
|
116
|
+
if (report.commits.length > 0) {
|
|
117
|
+
lines.push("Recent:");
|
|
118
|
+
for (const commit of report.commits.slice(0, 10)) {
|
|
119
|
+
const flags = commit.flags.length > 0 ? ` [${commit.flags.join(",")}]` : "";
|
|
120
|
+
lines.push(` ${commit.date} ${commit.sha.slice(0, 8)}${flags} ${commit.subject} (${commit.author})`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
lines.push("", report.summary);
|
|
124
|
+
return `${lines.join("\n")}\n`;
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=chronos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chronos.js","sourceRoot":"","sources":["../../src/core/chronos.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAuChD,MAAM,aAAa,GAAG,EAAE,CAAC;AACzB,MAAM,SAAS,GAAG,GAAG,CAAC;AACtB,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,OAAO,CAAC,OAAe;IAC9B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,iDAAiD,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACvF,IAAI,0BAA0B,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACnE,IAAI,6DAA6D,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACxG,IAAI,4DAA4D,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,KAAK,CAAC,IAAI,CAA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,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import { analyzeChronos, renderChronos } from "./chronos.js";
|
|
8
|
+
function git(args, cwd) {
|
|
9
|
+
const result = spawnSync("git", args, { cwd, encoding: "utf8" });
|
|
10
|
+
if (result.status !== 0)
|
|
11
|
+
throw new Error(`git ${args.join(" ")} failed: ${result.stderr}`);
|
|
12
|
+
return result.stdout;
|
|
13
|
+
}
|
|
14
|
+
function makeRepo() {
|
|
15
|
+
const dir = mkdtempSync(join(tmpdir(), "oc-pilot-chronos-"));
|
|
16
|
+
git(["init", "-q"], dir);
|
|
17
|
+
git(["config", "user.email", "test@example.com"], dir);
|
|
18
|
+
git(["config", "user.name", "Test"], dir);
|
|
19
|
+
git(["config", "core.autocrlf", "false"], dir);
|
|
20
|
+
mkdirSync(join(dir, "src"), { recursive: true });
|
|
21
|
+
mkdirSync(join(dir, "docs"), { recursive: true });
|
|
22
|
+
writeFileSync(join(dir, "src", "app.ts"), "export const value = 1;\n", "utf8");
|
|
23
|
+
writeFileSync(join(dir, "docs", "notes.md"), "notes\n", "utf8");
|
|
24
|
+
git(["add", "."], dir);
|
|
25
|
+
git(["commit", "-m", "init"], dir);
|
|
26
|
+
writeFileSync(join(dir, "src", "app.ts"), "export const value = 2;\n", "utf8");
|
|
27
|
+
git(["add", "."], dir);
|
|
28
|
+
git(["commit", "-m", "fix: handle expired token"], dir);
|
|
29
|
+
const fixSha = git(["rev-parse", "HEAD"], dir).trim();
|
|
30
|
+
writeFileSync(join(dir, "src", "app.ts"), "export const value = 3;\n", "utf8");
|
|
31
|
+
git(["add", "."], dir);
|
|
32
|
+
git(["commit", "-m", "incident: production outage on login"], dir);
|
|
33
|
+
writeFileSync(join(dir, "src", "app.ts"), "export const value = 4;\n", "utf8");
|
|
34
|
+
git(["add", "."], dir);
|
|
35
|
+
git(["commit", "-m", "security: escape user input"], dir);
|
|
36
|
+
writeFileSync(join(dir, "src", "app.ts"), "export const value = 5;\n", "utf8");
|
|
37
|
+
git(["add", "."], dir);
|
|
38
|
+
git(["commit", "-m", 'Revert "incident: production outage on login"'], dir);
|
|
39
|
+
return { dir, fixSha };
|
|
40
|
+
}
|
|
41
|
+
test("analyzeChronos scores fixes, incidents, security and reverts as a hotspot", () => {
|
|
42
|
+
const repo = makeRepo();
|
|
43
|
+
try {
|
|
44
|
+
const report = analyzeChronos(repo.dir, "src/app.ts");
|
|
45
|
+
assert.ok(report.totals.commits >= 4);
|
|
46
|
+
assert.ok(report.totals.fixes >= 1);
|
|
47
|
+
assert.ok(report.totals.reverts >= 1);
|
|
48
|
+
assert.ok(report.totals.incidents >= 2);
|
|
49
|
+
assert.ok(report.totals.security >= 1);
|
|
50
|
+
assert.ok(report.score >= 10);
|
|
51
|
+
assert.equal(report.hotspot, true);
|
|
52
|
+
assert.match(report.summary, /\[HOTSPOT\]/);
|
|
53
|
+
assert.match(renderChronos(report), /Recent:/);
|
|
54
|
+
assert.match(renderChronos(report), /fix: handle expired token/);
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
rmSync(repo.dir, { recursive: true, force: true });
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
test("analyzeChronos limits history and treats a quiet file as stable", () => {
|
|
61
|
+
const repo = makeRepo();
|
|
62
|
+
try {
|
|
63
|
+
const limited = analyzeChronos(repo.dir, "src/app.ts", { limit: 1 });
|
|
64
|
+
assert.equal(limited.commits.length, 1);
|
|
65
|
+
const quiet = analyzeChronos(repo.dir, "docs/notes.md");
|
|
66
|
+
assert.equal(quiet.hotspot, false);
|
|
67
|
+
assert.match(quiet.summary, /\[CHRONOS\]/);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
rmSync(repo.dir, { recursive: true, force: true });
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
test("analyzeChronos counts antibodies and vaccines linked to the file history", () => {
|
|
74
|
+
const repo = makeRepo();
|
|
75
|
+
try {
|
|
76
|
+
const base = analyzeChronos(repo.dir, "src/app.ts");
|
|
77
|
+
mkdirSync(join(repo.dir, ".oc-pilot"), { recursive: true });
|
|
78
|
+
writeFileSync(join(repo.dir, ".oc-pilot", "antibodies.json"), JSON.stringify({
|
|
79
|
+
version: 1,
|
|
80
|
+
signatures: [
|
|
81
|
+
{
|
|
82
|
+
id: "ab_test",
|
|
83
|
+
rule: "sql-injection",
|
|
84
|
+
severity: "high",
|
|
85
|
+
message: "x",
|
|
86
|
+
snippet: "db.query(req.query.id)",
|
|
87
|
+
normalized: "db.query(req.query.id)",
|
|
88
|
+
file: "src/app.ts",
|
|
89
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
}), "utf8");
|
|
93
|
+
writeFileSync(join(repo.dir, ".oc-pilot", "vaccines.json"), JSON.stringify({
|
|
94
|
+
version: 1,
|
|
95
|
+
vaccines: [
|
|
96
|
+
{
|
|
97
|
+
id: "vac_test",
|
|
98
|
+
createdAt: "2026-01-01T00:00:00.000Z",
|
|
99
|
+
bug: base.commits[base.commits.length - 1]?.sha,
|
|
100
|
+
fix: base.commits[0]?.sha,
|
|
101
|
+
testFile: ".oc-pilot/vaccines/vac_test.test.mjs",
|
|
102
|
+
command: "node --test {file}",
|
|
103
|
+
reason: "regression",
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
}), "utf8");
|
|
107
|
+
const report = analyzeChronos(repo.dir, "src/app.ts");
|
|
108
|
+
assert.equal(report.antibodies, 1);
|
|
109
|
+
assert.equal(report.vaccines, 1);
|
|
110
|
+
assert.ok(report.score > base.score);
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
rmSync(repo.dir, { recursive: true, force: true });
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
//# sourceMappingURL=chronos.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chronos.test.js","sourceRoot":"","sources":["../../src/core/chronos.test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7D,SAAS,GAAG,CAAC,IAAc,EAAE,GAAW;IACtC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IACjE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3F,OAAO,MAAM,CAAC,MAAM,CAAC;AACvB,CAAC;AAED,SAAS,QAAQ;IACf,MAAM,GAAG,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,mBAAmB,CAAC,CAAC,CAAC;IAC7D,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;IACzB,GAAG,CAAC,CAAC,QAAQ,EAAE,YAAY,EAAE,kBAAkB,CAAC,EAAE,GAAG,CAAC,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QAAQ,EAAE,sCAAsC;oBAChD,OAAO,EAAE,oBAAoB;oBAC7B,MAAM,EAAE,YAAY;iBACrB;aACF;SACF,CAAC,EACF,MAAM,CACP,CAAC;QAEF,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;QACtD,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QACnC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
import { existsSync, mkdtempSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join, resolve } from "node:path";
|
|
5
|
+
import { PilotError } from "./errors.js";
|
|
6
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
7
|
+
const MAX_FILE_BYTES = 1024 * 1024;
|
|
8
|
+
const WORKER = String.raw `
|
|
9
|
+
const { readFileSync } = require("node:fs");
|
|
10
|
+
const vm = require("node:vm");
|
|
11
|
+
const payload = JSON.parse(readFileSync(process.argv[2], "utf8"));
|
|
12
|
+
const code = readFileSync(payload.file, "utf8");
|
|
13
|
+
const capabilities = [];
|
|
14
|
+
const output = [];
|
|
15
|
+
const record = (kind, detail) => {
|
|
16
|
+
const value = String(detail).slice(0, 200);
|
|
17
|
+
if (!capabilities.some((item) => item.kind === kind && item.detail === value)) {
|
|
18
|
+
capabilities.push({ kind: kind, detail: value });
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const push = (...args) => {
|
|
22
|
+
if (output.length < 60) output.push(args.map((value) => String(value)).join(" "));
|
|
23
|
+
};
|
|
24
|
+
const denied = (kind, detail) => {
|
|
25
|
+
record(kind, detail);
|
|
26
|
+
const error = new Error("CAPABILITY_DENIED");
|
|
27
|
+
error.capability = kind;
|
|
28
|
+
throw error;
|
|
29
|
+
};
|
|
30
|
+
const fakeResponse = { ok: false, status: 403, text: async () => "", json: async () => ({}) };
|
|
31
|
+
const fsMock = {
|
|
32
|
+
readFileSync: (path) => { record("fs", "read:" + path); return ""; },
|
|
33
|
+
readFile: (path, options, callback) => { record("fs", "read:" + path); const cb = typeof options === "function" ? options : callback; if (cb) cb(null, ""); },
|
|
34
|
+
writeFileSync: (path) => { record("fs", "write:" + path); },
|
|
35
|
+
appendFileSync: (path) => { record("fs", "append:" + path); },
|
|
36
|
+
unlinkSync: (path) => { record("fs", "delete:" + path); },
|
|
37
|
+
rmSync: (path) => { record("fs", "delete:" + path); },
|
|
38
|
+
mkdirSync: (path) => { record("fs", "mkdir:" + path); },
|
|
39
|
+
readdirSync: (path) => { record("fs", "readdir:" + path); return []; },
|
|
40
|
+
existsSync: (path) => { record("fs", "exists:" + path); return false; },
|
|
41
|
+
openSync: (path) => { record("fs", "open:" + path); return 0; }
|
|
42
|
+
};
|
|
43
|
+
const netMock = {
|
|
44
|
+
fetch: (url) => { record("net", "fetch:" + url); return Promise.resolve(fakeResponse); },
|
|
45
|
+
request: (options) => { record("net", "request:" + (typeof options === "string" ? options : options && options.host)); return { on: () => {}, end: () => {}, write: () => {}, destroy: () => {} }; },
|
|
46
|
+
connect: (options) => { record("net", "connect:" + (typeof options === "string" ? options : options && options.host)); return { on: () => {}, end: () => {}, write: () => {}, destroy: () => {} }; }
|
|
47
|
+
};
|
|
48
|
+
const childMock = {
|
|
49
|
+
exec: (cmd, callback) => { record("child_process", "exec:" + cmd); if (typeof callback === "function") callback(null, "", ""); },
|
|
50
|
+
execSync: (cmd) => { record("child_process", "exec:" + cmd); return ""; },
|
|
51
|
+
spawn: (cmd) => { record("child_process", "spawn:" + cmd); return { on: () => {}, stdout: { on: () => {} }, stderr: { on: () => {} }, kill: () => {} }; },
|
|
52
|
+
spawnSync: (cmd) => { record("child_process", "spawn:" + cmd); return { status: 0, stdout: "", stderr: "" }; },
|
|
53
|
+
fork: (cmd) => { record("child_process", "fork:" + cmd); return { on: () => {}, kill: () => {} }; }
|
|
54
|
+
};
|
|
55
|
+
const envProxy = new Proxy({}, {
|
|
56
|
+
get: (_target, key) => { record("env", "get:" + String(key)); return undefined; },
|
|
57
|
+
has: () => true,
|
|
58
|
+
ownKeys: () => []
|
|
59
|
+
});
|
|
60
|
+
const processMock = {
|
|
61
|
+
env: envProxy,
|
|
62
|
+
exit: (code) => denied("exit", "exit:" + code),
|
|
63
|
+
cwd: () => "/sandbox",
|
|
64
|
+
platform: process.platform,
|
|
65
|
+
argv: [],
|
|
66
|
+
version: process.version,
|
|
67
|
+
nextTick: (fn) => fn()
|
|
68
|
+
};
|
|
69
|
+
const requireMock = (id) => {
|
|
70
|
+
record("require", id);
|
|
71
|
+
if (id === "fs" || id === "node:fs") return fsMock;
|
|
72
|
+
if (id === "http" || id === "node:http" || id === "https" || id === "node:https" || id === "net" || id === "node:net" || id === "dns" || id === "node:dns") return netMock;
|
|
73
|
+
if (id === "child_process" || id === "node:child_process") return childMock;
|
|
74
|
+
return {};
|
|
75
|
+
};
|
|
76
|
+
const context = vm.createContext({
|
|
77
|
+
console: { log: push, error: push, warn: push, info: push },
|
|
78
|
+
process: processMock,
|
|
79
|
+
fs: fsMock,
|
|
80
|
+
require: requireMock,
|
|
81
|
+
fetch: netMock.fetch,
|
|
82
|
+
http: netMock,
|
|
83
|
+
https: netMock,
|
|
84
|
+
net: netMock,
|
|
85
|
+
child_process: childMock,
|
|
86
|
+
module: { exports: {} },
|
|
87
|
+
exports: {},
|
|
88
|
+
Buffer: Buffer,
|
|
89
|
+
URL: URL,
|
|
90
|
+
setTimeout: () => 0,
|
|
91
|
+
clearTimeout: () => {},
|
|
92
|
+
setInterval: () => 0,
|
|
93
|
+
clearInterval: () => {}
|
|
94
|
+
});
|
|
95
|
+
let status = "clean";
|
|
96
|
+
let error;
|
|
97
|
+
if (/^\s*(?:import|export)\s/m.test(code)) {
|
|
98
|
+
record("import", "static module syntax");
|
|
99
|
+
status = "blocked";
|
|
100
|
+
} else {
|
|
101
|
+
try {
|
|
102
|
+
vm.runInContext(code, context, { filename: payload.file, timeout: payload.scriptTimeoutMs });
|
|
103
|
+
if (capabilities.length > 0) status = "capabilities";
|
|
104
|
+
} catch (caught) {
|
|
105
|
+
if (caught && caught.capability) status = "blocked";
|
|
106
|
+
else if (caught && /timed out/i.test(String(caught.message))) status = "timeout";
|
|
107
|
+
else status = "error";
|
|
108
|
+
error = caught && caught.message ? String(caught.message) : String(caught);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
process.stdout.write(JSON.stringify({ status: status, capabilities: capabilities, output: output, error: error }));
|
|
112
|
+
`;
|
|
113
|
+
function cap(output) {
|
|
114
|
+
return output.length > 2_000 ? output.slice(0, 2_000) : output;
|
|
115
|
+
}
|
|
116
|
+
function renderSummary(status, capabilities, error) {
|
|
117
|
+
const kinds = [...new Set(capabilities.map((item) => item.kind))];
|
|
118
|
+
if (status === "clean") {
|
|
119
|
+
return "[CAPABILITY CLEAN]: код не запросил fs, net, child_process, env, exit, require или import.";
|
|
120
|
+
}
|
|
121
|
+
if (status === "timeout") {
|
|
122
|
+
return "[CUCKOO TIMEOUT]: код не завершился за отведённое время.";
|
|
123
|
+
}
|
|
124
|
+
if (status === "error") {
|
|
125
|
+
return `[CUCKOO ERROR]: ${error ?? "код завершился с ошибкой"}`;
|
|
126
|
+
}
|
|
127
|
+
const list = kinds.join(", ") || "неизвестно";
|
|
128
|
+
if (status === "blocked") {
|
|
129
|
+
return `[CAPABILITY DENIED]: выполнение остановлено; запрошены: ${list} (${String(capabilities.length)}).`;
|
|
130
|
+
}
|
|
131
|
+
return `[CAPABILITY DENIED]: код запросил: ${list} (${String(capabilities.length)}).`;
|
|
132
|
+
}
|
|
133
|
+
/** Runs a JS/ESM file in an instrumented vm sandbox and reports every capability it reaches for. */
|
|
134
|
+
export function runCuckoo(cwd, file, options = {}) {
|
|
135
|
+
const absolute = resolve(cwd, file);
|
|
136
|
+
if (!existsSync(absolute)) {
|
|
137
|
+
throw new PilotError(`Файл не найден: ${file}`, { exitCode: 2 });
|
|
138
|
+
}
|
|
139
|
+
const stats = statSync(absolute);
|
|
140
|
+
if (!stats.isFile() || stats.size > MAX_FILE_BYTES) {
|
|
141
|
+
throw new PilotError("Cuckoo принимает один JS/ESM-файл до 1 МБ", { exitCode: 2 });
|
|
142
|
+
}
|
|
143
|
+
const timeoutMs = Math.max(100, Math.min(60_000, options.timeoutMs ?? DEFAULT_TIMEOUT_MS));
|
|
144
|
+
const dir = mkdtempSync(join(tmpdir(), "oc-pilot-cuckoo-"));
|
|
145
|
+
const worker = join(dir, "worker.cjs");
|
|
146
|
+
const payload = join(dir, "payload.json");
|
|
147
|
+
writeFileSync(worker, WORKER, "utf8");
|
|
148
|
+
writeFileSync(payload, JSON.stringify({ file: absolute, scriptTimeoutMs: timeoutMs }), "utf8");
|
|
149
|
+
try {
|
|
150
|
+
const env = { ...process.env, NODE_V8_COVERAGE: "" };
|
|
151
|
+
delete env.NODE_TEST_CONTEXT;
|
|
152
|
+
const result = spawnSync(process.execPath, [worker, payload], {
|
|
153
|
+
cwd,
|
|
154
|
+
env,
|
|
155
|
+
encoding: "utf8",
|
|
156
|
+
timeout: timeoutMs + 5_000,
|
|
157
|
+
killSignal: "SIGKILL",
|
|
158
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
159
|
+
});
|
|
160
|
+
if (result.error && result.error.code === "ETIMEDOUT") {
|
|
161
|
+
const report = {
|
|
162
|
+
status: "timeout",
|
|
163
|
+
file,
|
|
164
|
+
capabilities: [],
|
|
165
|
+
output: [],
|
|
166
|
+
summary: renderSummary("timeout", []),
|
|
167
|
+
content: "",
|
|
168
|
+
};
|
|
169
|
+
report.content = renderCuckoo(report);
|
|
170
|
+
return report;
|
|
171
|
+
}
|
|
172
|
+
if (result.status !== 0) {
|
|
173
|
+
const report = {
|
|
174
|
+
status: "error",
|
|
175
|
+
file,
|
|
176
|
+
capabilities: [],
|
|
177
|
+
output: [],
|
|
178
|
+
error: cap(result.stderr.trim() || result.stdout.trim() || "worker failed"),
|
|
179
|
+
summary: "",
|
|
180
|
+
content: "",
|
|
181
|
+
};
|
|
182
|
+
report.summary = renderSummary("error", [], report.error);
|
|
183
|
+
report.content = renderCuckoo(report);
|
|
184
|
+
return report;
|
|
185
|
+
}
|
|
186
|
+
let parsed;
|
|
187
|
+
try {
|
|
188
|
+
parsed = JSON.parse(result.stdout.trim());
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
const report = {
|
|
192
|
+
status: "error",
|
|
193
|
+
file,
|
|
194
|
+
capabilities: [],
|
|
195
|
+
output: [],
|
|
196
|
+
error: "worker вернул не JSON",
|
|
197
|
+
summary: "",
|
|
198
|
+
content: "",
|
|
199
|
+
};
|
|
200
|
+
report.summary = renderSummary("error", [], report.error);
|
|
201
|
+
report.content = renderCuckoo(report);
|
|
202
|
+
return report;
|
|
203
|
+
}
|
|
204
|
+
const capabilities = Array.isArray(parsed.capabilities)
|
|
205
|
+
? parsed.capabilities.filter((item) => Boolean(item) && typeof item.kind === "string" && typeof item.detail === "string")
|
|
206
|
+
: [];
|
|
207
|
+
const status = parsed.status === "clean" ||
|
|
208
|
+
parsed.status === "capabilities" ||
|
|
209
|
+
parsed.status === "blocked" ||
|
|
210
|
+
parsed.status === "timeout" ||
|
|
211
|
+
parsed.status === "error"
|
|
212
|
+
? parsed.status
|
|
213
|
+
: "error";
|
|
214
|
+
const report = {
|
|
215
|
+
status,
|
|
216
|
+
file,
|
|
217
|
+
capabilities,
|
|
218
|
+
output: Array.isArray(parsed.output)
|
|
219
|
+
? parsed.output.filter((line) => typeof line === "string").slice(0, 60)
|
|
220
|
+
: [],
|
|
221
|
+
error: typeof parsed.error === "string" ? parsed.error : undefined,
|
|
222
|
+
summary: renderSummary(status, capabilities, parsed.error),
|
|
223
|
+
content: "",
|
|
224
|
+
};
|
|
225
|
+
report.content = renderCuckoo(report);
|
|
226
|
+
return report;
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
rmSync(dir, { recursive: true, force: true });
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export function renderCuckoo(report) {
|
|
233
|
+
const lines = [
|
|
234
|
+
`Cuckoo: ${report.status}`,
|
|
235
|
+
`File: ${report.file}`,
|
|
236
|
+
`Capabilities: ${String(report.capabilities.length)}`,
|
|
237
|
+
];
|
|
238
|
+
for (const capability of report.capabilities) {
|
|
239
|
+
lines.push(` ${capability.kind}: ${capability.detail}`);
|
|
240
|
+
}
|
|
241
|
+
if (report.output.length > 0) {
|
|
242
|
+
lines.push("Output:");
|
|
243
|
+
for (const line of report.output)
|
|
244
|
+
lines.push(` ${line}`);
|
|
245
|
+
}
|
|
246
|
+
if (report.error)
|
|
247
|
+
lines.push(`Error: ${report.error}`);
|
|
248
|
+
lines.push("", report.summary);
|
|
249
|
+
return `${lines.join("\n")}\n`;
|
|
250
|
+
}
|
|
251
|
+
//# sourceMappingURL=cuckoo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cuckoo.js","sourceRoot":"","sources":["../../src/core/cuckoo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnF,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,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