coldpin 0.0.0-stage → 1.5.1
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/ACCESSIBILITY.md +17 -0
- package/CHANGELOG.md +97 -0
- package/CONTRIBUTING.md +36 -0
- package/LICENSE +98 -0
- package/MAINTENANCE.md +33 -0
- package/README.md +142 -2
- package/SECURITY.md +34 -0
- package/TESTING.md +26 -0
- package/agents/coldpin-auditor.md +47 -0
- package/agents/coldpin-compliance.md +38 -0
- package/agents/coldpin-confusion-auditor.md +38 -0
- package/agents/coldpin-discoverer.md +37 -0
- package/agents/coldpin-forensics.md +38 -0
- package/agents/coldpin-inspector.md +37 -0
- package/agents/coldpin-manifest-auditor.md +38 -0
- package/assets/icon.svg +7 -0
- package/catalog/mcp-schema-pin.json +14 -0
- package/catalog/plugin.oms.sig +19 -0
- package/catalog/sigma/npx-suspicious-child-process-linux.yml +54 -0
- package/catalog/sigma/npx-suspicious-child-process.yml +49 -0
- package/catalog/triage-rules.json +104 -0
- package/docs/assets/readme-header.svg +21 -0
- package/docs/designs/SITEMAP.md +14 -0
- package/docs/designs/coldpin.md +68 -0
- package/docs/fact-ledger.md +36 -0
- package/docs/faq.md +31 -0
- package/docs/getting_started.md +62 -0
- package/docs/harnesses.md +45 -0
- package/docs/privacy.md +27 -0
- package/docs/verification/skill-inspector-self-audit.md +33 -0
- package/examples/.coldpin.policy.example.json +27 -0
- package/examples/.npmrc.example +8 -0
- package/examples/mcp_config.private-registry.example.json +42 -0
- package/hooks.json +47 -0
- package/lib/analysis/parity-and-bisect.mjs +1371 -0
- package/lib/analysis/static-triage.mjs +4572 -0
- package/lib/cache/sqlite-store.mjs +251 -0
- package/lib/cli.mjs +427 -0
- package/lib/compliance/audit-log.mjs +357 -0
- package/lib/config/policy.mjs +780 -0
- package/lib/core/path-confinement.mjs +289 -0
- package/lib/core/workflows.mjs +1205 -0
- package/lib/discovery/slopsquat-guard.mjs +289 -0
- package/lib/hook.mjs +1038 -0
- package/lib/intel/registry-osv.mjs +1681 -0
- package/lib/mcp/report-store.mjs +175 -0
- package/lib/mcp/server.mjs +1387 -0
- package/lib/mcp/stdio-transport.mjs +289 -0
- package/lib/mcp/tool-catalog.mjs +273 -0
- package/lib/mcp/types.mjs +95 -0
- package/lib/mcp.mjs +19 -0
- package/lib/quarantine/safe-unpack.mjs +568 -0
- package/lib/types.mjs +383 -0
- package/lib/verdict/engine-and-formatters.mjs +895 -0
- package/mcp_config.json +21 -0
- package/package.json +71 -3
- package/plugin.json +54 -0
- package/rules/AGENTS.md +18 -0
- package/rules/coldpin-incident-checklist.md +18 -0
- package/rules/coldpin-manifest-guard.md +14 -0
- package/server.json +38 -0
- package/skills/coldpin/BENCHMARK.md +166 -0
- package/skills/coldpin/SKILL.md +110 -0
- package/skills/coldpin/TEST.md +13 -0
- package/skills/coldpin/agents/openai.yaml +6 -0
- package/skills/coldpin/assets/icon.svg +7 -0
- package/skills/coldpin/assets/runtime-contract.yaml +105 -0
- package/skills/coldpin/evals/evals.json +60 -0
- package/skills/coldpin/references/aspect-compliance-audit.md +27 -0
- package/skills/coldpin/references/aspect-discovery.md +26 -0
- package/skills/coldpin/references/aspect-forensics-rea.md +26 -0
- package/skills/coldpin/references/aspect-inspection.md +26 -0
- package/skills/coldpin/references/aspect-manifest-confusion.md +26 -0
- package/skills/coldpin/references/enterprise-policy-schema.md +65 -0
- package/skills/coldpin/references/evidence-card-spec.md +27 -0
- package/skills/coldpin/references/rea-integration-playbook.md +34 -0
- package/skills/coldpin/references/threat-taxonomy.md +35 -0
- package/skills/coldpin/skill-card.md +62 -0
- package/skills/coldpin/skill.oms.sig +19 -0
- package/skills/coldpin/test_scenarios.yaml +61 -0
- package/skills/coldpin-audit/SKILL.md +39 -0
- package/skills/coldpin-incident/SKILL.md +37 -0
- package/src/analysis/parity-and-bisect.ts +1368 -0
- package/src/analysis/static-triage.ts +4569 -0
- package/src/cache/sqlite-store.ts +248 -0
- package/src/cli.ts +424 -0
- package/src/compliance/audit-log.ts +354 -0
- package/src/config/policy.ts +777 -0
- package/src/core/path-confinement.ts +286 -0
- package/src/core/workflows.ts +1202 -0
- package/src/discovery/slopsquat-guard.ts +286 -0
- package/src/hook.ts +1035 -0
- package/src/intel/registry-osv.ts +1678 -0
- package/src/mcp/report-store.ts +172 -0
- package/src/mcp/server.ts +1384 -0
- package/src/mcp/stdio-transport.ts +286 -0
- package/src/mcp/tool-catalog.ts +270 -0
- package/src/mcp/types.ts +92 -0
- package/src/mcp.ts +16 -0
- package/src/quarantine/safe-unpack.ts +565 -0
- package/src/types.ts +380 -0
- package/src/verdict/engine-and-formatters.ts +892 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const REPORT_STORE_MAX_ENTRIES = 25;
|
|
10
|
+
export const REPORT_STORE_TTL_MS = 30 * 60 * 1000;
|
|
11
|
+
export const REPORT_STORE_MAX_TOTAL_BYTES = 15 * 1024 * 1024;
|
|
12
|
+
export const REPORT_TEXT_CHUNK_MAX_BYTES = 24 * 1024;
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Slices a UTF-8 string starting at `byteOffset` up to `maxBytes` without ever
|
|
43
|
+
* splitting a multi-byte UTF-8 codepoint or surrogate pair.
|
|
44
|
+
*/
|
|
45
|
+
export function sliceUtf8Safe(
|
|
46
|
+
text ,
|
|
47
|
+
byteOffset = 0,
|
|
48
|
+
maxBytes = REPORT_TEXT_CHUNK_MAX_BYTES,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
{
|
|
56
|
+
const buf = Buffer.from(text, "utf8");
|
|
57
|
+
const totalBytes = buf.byteLength;
|
|
58
|
+
const start = Math.max(0, Math.min(Math.floor(byteOffset), totalBytes));
|
|
59
|
+
if (start >= totalBytes) {
|
|
60
|
+
return {
|
|
61
|
+
chunk: "",
|
|
62
|
+
byte_offset: start,
|
|
63
|
+
next_byte_offset: null,
|
|
64
|
+
total_bytes: totalBytes,
|
|
65
|
+
truncated: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
// Advance start if it lands on a UTF-8 continuation byte (10xxxxxx)
|
|
69
|
+
let safeStart = start;
|
|
70
|
+
while (safeStart < totalBytes && (buf[safeStart] & 0xc0) === 0x80) {
|
|
71
|
+
safeStart++;
|
|
72
|
+
}
|
|
73
|
+
let safeEnd = Math.min(totalBytes, safeStart + Math.max(1, maxBytes));
|
|
74
|
+
// Back off end if it lands inside a multi-byte sequence
|
|
75
|
+
if (safeEnd < totalBytes) {
|
|
76
|
+
while (safeEnd > safeStart && (buf[safeEnd] & 0xc0) === 0x80) {
|
|
77
|
+
safeEnd--;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const chunk = buf.subarray(safeStart, safeEnd).toString("utf8");
|
|
81
|
+
const truncated = safeEnd < totalBytes;
|
|
82
|
+
return {
|
|
83
|
+
chunk,
|
|
84
|
+
byte_offset: safeStart,
|
|
85
|
+
next_byte_offset: truncated ? safeEnd : null,
|
|
86
|
+
total_bytes: totalBytes,
|
|
87
|
+
truncated,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Session-only, byte-bounded LRU report store (`ADR-004`).
|
|
93
|
+
* Keeps full inspection/discovery/anchor reports in process memory for paginated
|
|
94
|
+
* retrieval via `get_artifact_report` without ever persisting composite verdicts to SQLite.
|
|
95
|
+
*/
|
|
96
|
+
export class BoundedReportStore {
|
|
97
|
+
entries = new Map ();
|
|
98
|
+
totalBytes = 0;
|
|
99
|
+
maxEntries ;
|
|
100
|
+
ttlMs ;
|
|
101
|
+
maxTotalBytes ;
|
|
102
|
+
|
|
103
|
+
constructor(opts ) {
|
|
104
|
+
this.maxEntries = opts?.maxEntries ?? REPORT_STORE_MAX_ENTRIES;
|
|
105
|
+
this.ttlMs = opts?.ttlMs ?? REPORT_STORE_TTL_MS;
|
|
106
|
+
this.maxTotalBytes = opts?.maxTotalBytes ?? REPORT_STORE_MAX_TOTAL_BYTES;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
pruneExpired(nowMs ) {
|
|
110
|
+
for (const [id, entry] of this.entries) {
|
|
111
|
+
if (nowMs - entry.createdAt > this.ttlMs) {
|
|
112
|
+
this.totalBytes -= entry.approxBytes;
|
|
113
|
+
this.entries.delete(id);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
put(payload , nowMs = Date.now()) {
|
|
119
|
+
this.pruneExpired(nowMs);
|
|
120
|
+
const approxBytes = Buffer.byteLength(JSON.stringify(payload), "utf8");
|
|
121
|
+
const id = `rpt_${randomUUID().slice(0, 12)}`;
|
|
122
|
+
|
|
123
|
+
// Evict oldest entries until both count and byte budgets hold
|
|
124
|
+
while (
|
|
125
|
+
this.entries.size > 0 &&
|
|
126
|
+
(this.entries.size >= this.maxEntries || this.totalBytes + approxBytes > this.maxTotalBytes)
|
|
127
|
+
) {
|
|
128
|
+
const oldestKey = this.entries.keys().next().value ;
|
|
129
|
+
if (!oldestKey) break;
|
|
130
|
+
const oldest = this.entries.get(oldestKey);
|
|
131
|
+
if (oldest) this.totalBytes -= oldest.approxBytes;
|
|
132
|
+
this.entries.delete(oldestKey);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// If a single report alone exceeds maxTotalBytes, still store it temporarily if empty or cap
|
|
136
|
+
if (approxBytes <= this.maxTotalBytes) {
|
|
137
|
+
this.entries.set(id, {
|
|
138
|
+
id,
|
|
139
|
+
payload,
|
|
140
|
+
approxBytes,
|
|
141
|
+
createdAt: nowMs,
|
|
142
|
+
lastAccessedAt: nowMs,
|
|
143
|
+
});
|
|
144
|
+
this.totalBytes += approxBytes;
|
|
145
|
+
}
|
|
146
|
+
return id;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
get(id , nowMs = Date.now()) {
|
|
150
|
+
this.pruneExpired(nowMs);
|
|
151
|
+
const entry = this.entries.get(id);
|
|
152
|
+
if (!entry) return null;
|
|
153
|
+
// Refresh LRU order (delete + re-insert moves to MRU tail of Map)
|
|
154
|
+
entry.lastAccessedAt = nowMs;
|
|
155
|
+
this.entries.delete(id);
|
|
156
|
+
this.entries.set(id, entry);
|
|
157
|
+
return entry.payload;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get size() {
|
|
161
|
+
return this.entries.size;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get bytesUsed() {
|
|
165
|
+
return this.totalBytes;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
clear() {
|
|
169
|
+
this.entries.clear();
|
|
170
|
+
this.totalBytes = 0;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
//# sourceURL=mcp/report-store.ts
|