lintsure 0.3.17 → 0.3.18
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/dist/src/index.js +78 -68
- package/dist/src/send.d.ts +42 -0
- package/dist/src/send.js +49 -0
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import { basename, dirname, join, resolve } from "node:path";
|
|
|
10
10
|
import { createInterface } from "node:readline/promises";
|
|
11
11
|
import { AGENTS, CONNECT_NOTE, MANUAL, callingAgent, detected, status, pick, plan, setup, undo } from "./agents.js";
|
|
12
12
|
import { parseActivity, toOtlp } from "./otel.js";
|
|
13
|
+
import { sendRun } from "./send.js";
|
|
13
14
|
import { ALL_FRAMEWORKS, BASELINE_FILE, DISCLAIMER, RULES_VERSION, classify, isHygiene, isNonShipping, isOpen, nextSteps, readConfig, scan, toAssessmentHtml, toBaseline, toMarkdown, toSarif } from "@lintsure/core";
|
|
14
15
|
import { choose, chooseMany } from "./menu.js";
|
|
15
16
|
import { installSkills, removeSkills, skillFolders, skills } from "./skills.js";
|
|
@@ -182,74 +183,79 @@ function nearest(word) {
|
|
|
182
183
|
return COMMANDS.find((c) => c === word) ?? COMMANDS.map((c) => [slips(c, word), c]).filter(([n]) => n <= 2).sort((x, y) => x[0] - y[0])[0]?.[1];
|
|
183
184
|
}
|
|
184
185
|
const startRows = () => START.map((s) => { const row = s.run ? `${s.label.padEnd(28)}lintsure ${s.show ?? s.run.join(" ")}` : s.label; return s.badge ? tint(BADGE, row) : row; });
|
|
185
|
-
const HELP = `lintsure scan [path] [options]
|
|
186
|
-
lintsure baseline [path]
|
|
187
|
-
lintsure init [path] Three questions, saved to lintsure.config.yaml
|
|
188
|
-
lintsure info [path] Show the settings a scan would use, and where each comes from
|
|
189
|
-
lintsure setup [path] Add the Lintsure MCP server to this project's agent configs
|
|
190
|
-
(with no path it asks: --everywhere for every project on this
|
|
191
|
-
machine, --here for this folder;
|
|
192
|
-
shows the change; --yes writes it; --undo takes it out;
|
|
193
|
-
--agents claude,cursor,vscode,gemini,codex;
|
|
194
|
-
--manual for an agent set up in its own settings)
|
|
195
|
-
lintsure skills [path] Add Lintsure's skills to this project: short instruction files that
|
|
196
|
-
tell your agent when to check code and how to handle findings
|
|
197
|
-
(at a terminal you pick which; --yes adds all; --only a,b;
|
|
198
|
-
--undo takes them out)
|
|
199
|
-
lintsure fix [path] [F-001 ...] Apply the change for findings whose rule knows the exact one
|
|
200
|
-
(shows it first; --all includes held-back findings; --yes writes it,
|
|
201
|
-
backs the file up, scans again,
|
|
202
|
-
and puts the file back if the finding is still there; --undo puts back
|
|
203
|
-
what the last fix changed)
|
|
204
|
-
lintsure deps [path] Look up the project's pinned packages for known vulnerabilities.
|
|
205
|
-
The only command that uses the network: it says what it will send
|
|
206
|
-
(package names and versions, never code) and sends it with --yes
|
|
207
|
-
lintsure history [path] List the records saved with scan --save-record, oldest first
|
|
208
|
-
lintsure hook [path] Check the lines you commit: adds a git pre-commit hook that runs
|
|
209
|
-
lintsure scan --staged --fail-on gap (shows it first; --yes writes it;
|
|
210
|
-
--undo removes it; an existing hook of your own is left alone)
|
|
211
|
-
lintsure plugin [path] Install the guards that run while your agent works: the full plugin
|
|
212
|
-
for Claude Code, and hooks files for Cursor, Codex and Gemini CLI
|
|
213
|
-
(shows the plan first; --agents claude,cursor,codex,gemini;
|
|
214
|
-
--yes installs; --undo takes them out)
|
|
215
|
-
lintsure status [path] Check that this project is ready: Node, config, rules, agents
|
|
216
|
-
lintsure export --otlp-json [path] Write .lintsure/activity.jsonl as an OpenTelemetry
|
|
217
|
-
traces file (lintsure.otlp.json) for your own observability tool
|
|
218
|
-
|
|
219
|
-
scan options:
|
|
220
|
-
--framework <ids> Comma list: ${ALL_FRAMEWORKS.join(", ")}
|
|
221
|
-
(default: lintsure.config.yaml if present, else all)
|
|
222
|
-
--all Also list medium-confidence findings (held back by default)
|
|
223
|
-
--diff <base> Only list findings on lines changed since <base>, e.g. origin/main
|
|
224
|
-
--staged Only list findings on lines that are staged for the next commit
|
|
225
|
-
--json Also write lintsure-report.json
|
|
226
|
-
--sarif Also write lintsure.sarif (for GitHub code scanning and editors)
|
|
227
|
-
--report Also write lintsure-assessment.html, a multi-page report
|
|
228
|
-
to review, print or save as PDF
|
|
229
|
-
--
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
--
|
|
233
|
-
|
|
234
|
-
--
|
|
235
|
-
|
|
236
|
-
--
|
|
237
|
-
|
|
238
|
-
--
|
|
239
|
-
.lintsure/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
186
|
+
const HELP = `lintsure scan [path] [options]
|
|
187
|
+
lintsure baseline [path]
|
|
188
|
+
lintsure init [path] Three questions, saved to lintsure.config.yaml
|
|
189
|
+
lintsure info [path] Show the settings a scan would use, and where each comes from
|
|
190
|
+
lintsure setup [path] Add the Lintsure MCP server to this project's agent configs
|
|
191
|
+
(with no path it asks: --everywhere for every project on this
|
|
192
|
+
machine, --here for this folder;
|
|
193
|
+
shows the change; --yes writes it; --undo takes it out;
|
|
194
|
+
--agents claude,cursor,vscode,gemini,codex;
|
|
195
|
+
--manual for an agent set up in its own settings)
|
|
196
|
+
lintsure skills [path] Add Lintsure's skills to this project: short instruction files that
|
|
197
|
+
tell your agent when to check code and how to handle findings
|
|
198
|
+
(at a terminal you pick which; --yes adds all; --only a,b;
|
|
199
|
+
--undo takes them out)
|
|
200
|
+
lintsure fix [path] [F-001 ...] Apply the change for findings whose rule knows the exact one
|
|
201
|
+
(shows it first; --all includes held-back findings; --yes writes it,
|
|
202
|
+
backs the file up, scans again,
|
|
203
|
+
and puts the file back if the finding is still there; --undo puts back
|
|
204
|
+
what the last fix changed)
|
|
205
|
+
lintsure deps [path] Look up the project's pinned packages for known vulnerabilities.
|
|
206
|
+
The only command that uses the network: it says what it will send
|
|
207
|
+
(package names and versions, never code) and sends it with --yes
|
|
208
|
+
lintsure history [path] List the records saved with scan --save-record, oldest first
|
|
209
|
+
lintsure hook [path] Check the lines you commit: adds a git pre-commit hook that runs
|
|
210
|
+
lintsure scan --staged --fail-on gap (shows it first; --yes writes it;
|
|
211
|
+
--undo removes it; an existing hook of your own is left alone)
|
|
212
|
+
lintsure plugin [path] Install the guards that run while your agent works: the full plugin
|
|
213
|
+
for Claude Code, and hooks files for Cursor, Codex and Gemini CLI
|
|
214
|
+
(shows the plan first; --agents claude,cursor,codex,gemini;
|
|
215
|
+
--yes installs; --undo takes them out)
|
|
216
|
+
lintsure status [path] Check that this project is ready: Node, config, rules, agents
|
|
217
|
+
lintsure export --otlp-json [path] Write .lintsure/activity.jsonl as an OpenTelemetry
|
|
218
|
+
traces file (lintsure.otlp.json) for your own observability tool
|
|
219
|
+
|
|
220
|
+
scan options:
|
|
221
|
+
--framework <ids> Comma list: ${ALL_FRAMEWORKS.join(", ")}
|
|
222
|
+
(default: lintsure.config.yaml if present, else all)
|
|
223
|
+
--all Also list medium-confidence findings (held back by default)
|
|
224
|
+
--diff <base> Only list findings on lines changed since <base>, e.g. origin/main
|
|
225
|
+
--staged Only list findings on lines that are staged for the next commit
|
|
226
|
+
--json Also write lintsure-report.json
|
|
227
|
+
--sarif Also write lintsure.sarif (for GitHub code scanning and editors)
|
|
228
|
+
--report Also write lintsure-assessment.html, a multi-page report
|
|
229
|
+
to review, print or save as PDF
|
|
230
|
+
--send Send this run's summary to your Lintsure workspace, so it shows on the
|
|
231
|
+
dashboard. Needs LINTSURE_API_KEY. Sends rule ids, file paths, lines,
|
|
232
|
+
severity and counts, never code
|
|
233
|
+
--project <name> Project name on the assessment cover and in the workspace
|
|
234
|
+
(default: folder name)
|
|
235
|
+
--fail-on <status> Exit 1 if any open finding is "gap" or "partial" (for CI). Held-back
|
|
236
|
+
medium-confidence findings count only with --all
|
|
237
|
+
--observe With --fail-on: say when the run would have failed, and pass anyway.
|
|
238
|
+
For watching the gate before it blocks anyone
|
|
239
|
+
--new-only With --fail-on: count only findings that are new since
|
|
240
|
+
.lintsure/baseline.json
|
|
241
|
+
--github Print GitHub Actions annotations, so findings show on the lines
|
|
242
|
+
--pick Ask which folder to check (at a terminal)
|
|
243
|
+
--save-record Also save this run's readiness check record to
|
|
244
|
+
.lintsure/records/<id>.json, building a dated history (no code inside)
|
|
245
|
+
|
|
246
|
+
baseline:
|
|
247
|
+
Saves the current open findings to .lintsure/baseline.json in the scanned folder.
|
|
248
|
+
Later scans show what is new, fixed or unchanged. The file holds rule ids, file
|
|
249
|
+
paths and one-way fingerprints, never code. You decide whether to commit it.
|
|
250
|
+
|
|
251
|
+
Accept a finding after review by adding it to .lintsure/accepted.yaml, with the
|
|
252
|
+
fingerprint from lintsure-report.json, your reason, your name and the date.
|
|
253
|
+
|
|
254
|
+
${DISCLAIMER}
|
|
255
|
+
Lintsure never sends your code anywhere. Only "lintsure deps --yes" and "scan --send"
|
|
256
|
+
(a summary with no code, to your own workspace) use the network.`;
|
|
251
257
|
const VALUE_FLAGS = ["--framework", "--fail-on", "--project", "--diff"];
|
|
252
|
-
const BOOL_FLAGS = ["--json", "--sarif", "--report", "--new-only", "--github", "--save-record", "--all", "--pick", "--staged", "--observe"];
|
|
258
|
+
const BOOL_FLAGS = ["--json", "--sarif", "--report", "--send", "--new-only", "--github", "--save-record", "--all", "--pick", "--staged", "--observe"];
|
|
253
259
|
/** Changed line numbers per file from `git diff -U0` output. Pure. */
|
|
254
260
|
export function parseDiff(text) {
|
|
255
261
|
const out = {};
|
|
@@ -823,7 +829,7 @@ async function main(argv) {
|
|
|
823
829
|
// Typed by hand with no agent named and none found here: say which one this is for, and how to pick another.
|
|
824
830
|
const me = callingAgent();
|
|
825
831
|
if (!named && me && !here.includes(me) && !raw.includes("--undo"))
|
|
826
|
-
console.log(`This is running inside ${me.name}, so ${me.name} is connected${here.length ? " too" : ""}.
|
|
832
|
+
console.log(`This is running inside ${me.name}, so ${me.name} is connected${here.length ? " too" : ""}.
|
|
827
833
|
`);
|
|
828
834
|
else if (!named && !here.length && !raw.includes("--undo"))
|
|
829
835
|
console.log(`No agent folder in this project, so this is for Claude Code. For another one: lintsure setup --agents ${AGENTS.slice(1).map((a) => a.id).join(" | ")}\nFor an agent set up in its own settings (Devin, Windsurf, Zed): lintsure setup --manual\n`);
|
|
@@ -1024,6 +1030,10 @@ async function main(argv) {
|
|
|
1024
1030
|
}
|
|
1025
1031
|
if (rest.includes("--report"))
|
|
1026
1032
|
await writeFile("lintsure-assessment.html", toAssessmentHtml(report, { project: flag("--project") ?? basename(path), date }));
|
|
1033
|
+
if (rest.includes("--send")) {
|
|
1034
|
+
const sent = await sendRun(report, path, flag("--project"));
|
|
1035
|
+
(sent.ok ? console.log : console.error)(sent.say);
|
|
1036
|
+
}
|
|
1027
1037
|
const open = report.findings.filter(isOpen);
|
|
1028
1038
|
const n = (s) => open.filter((f) => f.status === s).length;
|
|
1029
1039
|
const accepted = report.findings.length - open.length;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Report } from "@lintsure/core";
|
|
2
|
+
/** The body POST /api/v1/runs takes. Pure, so the smoke test can check that no code is in it. */
|
|
3
|
+
export declare function runPayload(report: Report, o: {
|
|
4
|
+
project: string;
|
|
5
|
+
source: "ci" | "agent";
|
|
6
|
+
commit?: string;
|
|
7
|
+
branch?: string;
|
|
8
|
+
}): {
|
|
9
|
+
checks: string[];
|
|
10
|
+
filesChecked: number;
|
|
11
|
+
held: number;
|
|
12
|
+
findings: {
|
|
13
|
+
ruleId: string;
|
|
14
|
+
title: string;
|
|
15
|
+
severity: import("@lintsure/core").Severity;
|
|
16
|
+
status: import("@lintsure/core").Status;
|
|
17
|
+
file: string;
|
|
18
|
+
line: number;
|
|
19
|
+
fix: string;
|
|
20
|
+
why: string;
|
|
21
|
+
controls: import("@lintsure/core").Control[];
|
|
22
|
+
}[];
|
|
23
|
+
scope: {
|
|
24
|
+
diffBase?: string | undefined;
|
|
25
|
+
notCovered: string[];
|
|
26
|
+
rulesOff: string[];
|
|
27
|
+
skipped: {
|
|
28
|
+
why: string;
|
|
29
|
+
n: number;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
|
+
branch?: string | undefined;
|
|
33
|
+
commit?: string | undefined;
|
|
34
|
+
project: string;
|
|
35
|
+
source: "agent" | "ci";
|
|
36
|
+
version: string;
|
|
37
|
+
};
|
|
38
|
+
/** Sends the summary. Returns a line to print; never throws, so a network problem can't fail a CI job on its own. */
|
|
39
|
+
export declare function sendRun(report: Report, path: string, project?: string): Promise<{
|
|
40
|
+
ok: boolean;
|
|
41
|
+
say: string;
|
|
42
|
+
}>;
|
package/dist/src/send.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// `lintsure scan --send`: send this run's summary to your Lintsure workspace, so CI and agents other than Claude Code
|
|
2
|
+
// show up on the dashboard. Off unless you pass --send AND set LINTSURE_API_KEY. What is sent: the project name,
|
|
3
|
+
// commit and branch, rule ids, titles, file paths and line numbers, severity, the fix text and counts. Never code.
|
|
4
|
+
import { execFileSync } from "node:child_process";
|
|
5
|
+
import { basename } from "node:path";
|
|
6
|
+
import { isOpen, RULES_VERSION } from "@lintsure/core";
|
|
7
|
+
/** The body POST /api/v1/runs takes. Pure, so the smoke test can check that no code is in it. */
|
|
8
|
+
export function runPayload(report, o) {
|
|
9
|
+
const open = report.findings.filter(isOpen);
|
|
10
|
+
return {
|
|
11
|
+
project: o.project, source: o.source, version: RULES_VERSION,
|
|
12
|
+
...(o.commit && /^[0-9a-f]{7,64}$/i.test(o.commit) ? { commit: o.commit } : {}), ...(o.branch ? { branch: o.branch } : {}),
|
|
13
|
+
checks: [...new Set([...report.met.map((m) => m.ruleId), ...report.findings.map((f) => f.ruleId)])],
|
|
14
|
+
filesChecked: report.filesChecked, held: report.held ?? 0,
|
|
15
|
+
findings: open.map((f) => ({ ruleId: f.ruleId, title: f.title, severity: f.severity, status: f.status, file: f.file, line: f.line, fix: f.fix, why: f.proposal?.why?.slice(0, 300), controls: f.controls })),
|
|
16
|
+
scope: {
|
|
17
|
+
notCovered: report.notCovered ?? [], rulesOff: report.rulesOff ?? [],
|
|
18
|
+
skipped: report.filesSkipped ? [{ why: "over 1 MB, binary or unreadable", n: report.filesSkipped }] : [],
|
|
19
|
+
...(report.diffBase ? { diffBase: report.diffBase } : {}),
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const git = (cwd, args) => { try {
|
|
24
|
+
return execFileSync("git", args, { cwd, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return "";
|
|
28
|
+
} };
|
|
29
|
+
/** Sends the summary. Returns a line to print; never throws, so a network problem can't fail a CI job on its own. */
|
|
30
|
+
export async function sendRun(report, path, project) {
|
|
31
|
+
const key = process.env.LINTSURE_API_KEY, api = (process.env.LINTSURE_URL || "https://lintsure.com").replace(/\/$/, "");
|
|
32
|
+
if (!key)
|
|
33
|
+
return { ok: false, say: "--send needs LINTSURE_API_KEY (a key from Settings, API keys in your Lintsure workspace). Nothing was sent." };
|
|
34
|
+
const ci = !!(process.env.GITHUB_ACTIONS || process.env.CI);
|
|
35
|
+
const branch = process.env.GITHUB_HEAD_REF || process.env.GITHUB_REF_NAME || git(path, ["rev-parse", "--abbrev-ref", "HEAD"]);
|
|
36
|
+
const body = runPayload(report, { project: project || basename(path), source: ci ? "ci" : "agent", commit: process.env.GITHUB_SHA || git(path, ["rev-parse", "HEAD"]), branch: branch === "HEAD" ? "" : branch });
|
|
37
|
+
try {
|
|
38
|
+
const r = await fetch(`${api}/api/v1/runs`, { method: "POST", headers: { authorization: `Bearer ${key}`, "content-type": "application/json", "user-agent": `lintsure-cli/${RULES_VERSION}` }, body: JSON.stringify(body), signal: AbortSignal.timeout(15000) });
|
|
39
|
+
if (r.status === 401)
|
|
40
|
+
return { ok: false, say: "Lintsure didn't accept that API key. Nothing was sent." };
|
|
41
|
+
if (!r.ok)
|
|
42
|
+
return { ok: false, say: `Couldn't send the summary to Lintsure (HTTP ${r.status}). The scan itself is unaffected.` };
|
|
43
|
+
const d = await r.json().catch(() => ({}));
|
|
44
|
+
return { ok: true, say: d.unchanged ? "Same as the last run sent for this commit, so Lintsure kept that one." : `Sent the summary (${body.findings.length} open finding${body.findings.length === 1 ? "" : "s"}, no code) to your Lintsure workspace.` };
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return { ok: false, say: "Couldn't reach Lintsure to send the summary. The scan itself is unaffected." };
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lintsure",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"description": "Keep your AI coding agents on track: checks the code Claude Code, Cursor and Codex write for secrets, open databases and unsafe patterns, mapped to OWASP, GDPR and the EU AI Act. Runs locally. Not an audit or legal advice.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"LICENSE"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@lintsure/core": "0.3.
|
|
17
|
+
"@lintsure/core": "0.3.18"
|
|
18
18
|
},
|
|
19
19
|
"author": "Lintsure <hello@lintsure.com>",
|
|
20
20
|
"homepage": "https://lintsure.com/docs",
|