lintsure 0.1.3 → 0.3.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/dist/src/index.js +65 -18
- package/package.json +2 -2
package/dist/src/index.js
CHANGED
|
@@ -1,29 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// npx lintsure scan [path] [
|
|
3
|
-
// Writes
|
|
4
|
-
import { writeFile } from "node:fs/promises";
|
|
5
|
-
import { basename, resolve } from "node:path";
|
|
6
|
-
import { ALL_FRAMEWORKS, DISCLAIMER, nextSteps, readConfig, scan, toAssessmentHtml, toMarkdown } from "@lintsure/core";
|
|
2
|
+
// npx lintsure scan [path] [options] npx lintsure baseline [path]
|
|
3
|
+
// Writes reports into the current folder. Never sends anything over the network.
|
|
4
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
6
|
+
import { ALL_FRAMEWORKS, BASELINE_FILE, DISCLAIMER, RULES_VERSION, isOpen, nextSteps, readConfig, scan, toAssessmentHtml, toBaseline, toMarkdown, toSarif } from "@lintsure/core";
|
|
7
7
|
const HELP = `lintsure scan [path] [options]
|
|
8
|
+
lintsure baseline [path]
|
|
8
9
|
|
|
10
|
+
scan options:
|
|
9
11
|
--framework <ids> Comma list: ${ALL_FRAMEWORKS.join(", ")}
|
|
10
12
|
(default: lintsure.config.yaml if present, else all)
|
|
11
13
|
--json Also write lintsure-report.json
|
|
14
|
+
--sarif Also write lintsure.sarif (for GitHub code scanning and editors)
|
|
12
15
|
--report Also write lintsure-assessment.html, a multi-page report
|
|
13
16
|
to review, print or save as PDF
|
|
14
17
|
--project <name> Project name on the assessment cover (default: folder name)
|
|
15
|
-
--fail-on <status> Exit 1 if any finding is "gap" or "partial" (for CI)
|
|
18
|
+
--fail-on <status> Exit 1 if any open finding is "gap" or "partial" (for CI)
|
|
19
|
+
--new-only With --fail-on: count only findings that are new since
|
|
20
|
+
.lintsure/baseline.json
|
|
21
|
+
--github Print GitHub Actions annotations, so findings show on the lines
|
|
22
|
+
--save-record Also save this run's readiness check record to
|
|
23
|
+
.lintsure/records/<id>.json, building a dated history (no code inside)
|
|
24
|
+
|
|
25
|
+
baseline:
|
|
26
|
+
Saves the current open findings to .lintsure/baseline.json in the scanned folder.
|
|
27
|
+
Later scans show what is new, fixed or unchanged. The file holds rule ids, file
|
|
28
|
+
paths and one-way fingerprints, never code. You decide whether to commit it.
|
|
29
|
+
|
|
30
|
+
Accept a finding after review by adding it to .lintsure/accepted.yaml, with the
|
|
31
|
+
fingerprint from lintsure-report.json, your reason, your name and the date.
|
|
16
32
|
|
|
17
33
|
${DISCLAIMER}
|
|
18
|
-
Lintsure never
|
|
34
|
+
Lintsure never sends your code anywhere.`;
|
|
35
|
+
const VALUE_FLAGS = ["--framework", "--fail-on", "--project"];
|
|
19
36
|
async function main(argv) {
|
|
20
37
|
const [cmd, ...rest] = argv;
|
|
21
|
-
if (cmd !== "scan") {
|
|
38
|
+
if (cmd !== "scan" && cmd !== "baseline") {
|
|
22
39
|
console.log(HELP);
|
|
23
40
|
return cmd ? 2 : 0;
|
|
24
41
|
}
|
|
25
42
|
const flag = (n) => { const i = rest.indexOf(n); return i >= 0 ? rest[i + 1] : undefined; };
|
|
26
|
-
const path = resolve(rest.find((a, i) => !a.startsWith("--") && !
|
|
43
|
+
const path = resolve(rest.find((a, i) => !a.startsWith("--") && !VALUE_FLAGS.includes(rest[i - 1])) ?? ".");
|
|
27
44
|
const wanted = flag("--framework")?.split(",").map((s) => s.trim());
|
|
28
45
|
const bad = wanted?.filter((f) => !ALL_FRAMEWORKS.includes(f));
|
|
29
46
|
if (bad?.length) {
|
|
@@ -33,18 +50,47 @@ async function main(argv) {
|
|
|
33
50
|
const config = wanted ? null : await readConfig(path);
|
|
34
51
|
if (config?.skipped.length)
|
|
35
52
|
console.log(`Skipping, not checked yet: ${config.skipped.join(", ")}`);
|
|
36
|
-
const
|
|
53
|
+
const why = wanted ? "Chosen with --framework on the command line." : config?.frameworks ? "Listed in lintsure.config.yaml." : undefined;
|
|
54
|
+
const source = process.env.GITHUB_ACTIONS || process.env.CI ? "ci" : "cli";
|
|
55
|
+
const report = await scan(path, wanted ?? config?.frameworks ?? ALL_FRAMEWORKS, { why, source });
|
|
56
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
57
|
+
if (cmd === "baseline") {
|
|
58
|
+
const file = join(path, BASELINE_FILE);
|
|
59
|
+
await mkdir(dirname(file), { recursive: true });
|
|
60
|
+
const b = toBaseline(report, date);
|
|
61
|
+
await writeFile(file, JSON.stringify(b, null, 2) + "\n");
|
|
62
|
+
console.log(`Saved ${b.findings.length} open finding${b.findings.length === 1 ? "" : "s"} to ${BASELINE_FILE}.`);
|
|
63
|
+
console.log("Later scans will show what is new, fixed or unchanged. The file contains no code; commit it if your team and CI should share it.");
|
|
64
|
+
return 0;
|
|
65
|
+
}
|
|
37
66
|
await writeFile("lintsure-report.md", toMarkdown(report));
|
|
38
67
|
if (rest.includes("--json"))
|
|
39
68
|
await writeFile("lintsure-report.json", JSON.stringify(report, null, 2));
|
|
40
|
-
if (rest.includes("--
|
|
41
|
-
|
|
42
|
-
|
|
69
|
+
if (rest.includes("--sarif"))
|
|
70
|
+
await writeFile("lintsure.sarif", JSON.stringify(toSarif(report, RULES_VERSION), null, 2));
|
|
71
|
+
if (rest.includes("--save-record") && report.record) {
|
|
72
|
+
const file = join(path, ".lintsure", "records", `${report.record.id}.json`);
|
|
73
|
+
await mkdir(dirname(file), { recursive: true });
|
|
74
|
+
await writeFile(file, JSON.stringify({ record: report.record, findings: report.findings.map(({ id, ruleId, file, line, status, severity, fingerprint, change, accepted }) => ({ id, ruleId, file, line, status, severity, fingerprint, change, accepted })) }, null, 2) + "\n");
|
|
75
|
+
console.log(`Record saved to .lintsure/records/${report.record.id}.json (no code inside).`);
|
|
43
76
|
}
|
|
44
|
-
|
|
45
|
-
|
|
77
|
+
if (rest.includes("--report"))
|
|
78
|
+
await writeFile("lintsure-assessment.html", toAssessmentHtml(report, { project: flag("--project") ?? basename(path), date }));
|
|
79
|
+
const open = report.findings.filter(isOpen);
|
|
80
|
+
const n = (s) => open.filter((f) => f.status === s).length;
|
|
81
|
+
const accepted = report.findings.length - open.length;
|
|
82
|
+
if (report.record)
|
|
83
|
+
console.log(`Record ${report.record.id} · ${report.record.createdAt.replace("T", " ").slice(0, 16)} UTC · ${report.record.counts.checkPoints} check points`);
|
|
84
|
+
console.log(`✓ ${open.length} open findings · ${n("gap")} gap · ${n("partial")} partial${accepted ? ` · ${accepted} accepted` : ""} · ${report.met.length} rules met · ${report.outside.length} outside code`);
|
|
85
|
+
if (report.baseline)
|
|
86
|
+
console.log(` Since the baseline of ${report.baseline.created}: ${report.baseline.newCount} new, ${report.baseline.fixed.length} fixed, ${report.baseline.unchangedCount} unchanged`);
|
|
46
87
|
for (const f of report.findings)
|
|
47
|
-
console.log(`${f.status.padEnd(8)} ${f.file}:${f.line} ${f.title}`);
|
|
88
|
+
console.log(`${(f.accepted && !f.accepted.expired ? "accepted" : f.status).padEnd(8)} ${f.file}:${f.line} ${f.title}${f.change === "new" ? " (new)" : ""}`);
|
|
89
|
+
if (rest.includes("--github"))
|
|
90
|
+
for (const f of open) {
|
|
91
|
+
const msg = `${f.title}. Proposed change, needs your approval: ${f.proposal.what}`.replace(/%/g, "%25").replace(/\r?\n/g, " ");
|
|
92
|
+
console.log(`::${f.status === "gap" ? "error" : "warning"} file=${f.file},line=${f.line},title=Lintsure ${f.ruleId}::${msg}`);
|
|
93
|
+
}
|
|
48
94
|
console.log("Report saved to lintsure-report.md");
|
|
49
95
|
if (rest.includes("--report"))
|
|
50
96
|
console.log("Assessment saved to lintsure-assessment.html (open it in a browser to read, print or save as PDF). It is a draft until a qualified person reviews and signs it.");
|
|
@@ -52,9 +98,10 @@ async function main(argv) {
|
|
|
52
98
|
nextSteps(report).forEach((x, i) => console.log(` ${i + 1}. ${x}`));
|
|
53
99
|
console.log(`\n${DISCLAIMER}`);
|
|
54
100
|
const failOn = flag("--fail-on");
|
|
55
|
-
|
|
101
|
+
const counted = rest.includes("--new-only") && report.baseline ? open.filter((f) => f.change === "new") : open;
|
|
102
|
+
if (failOn === "gap" && counted.some((f) => f.status === "gap"))
|
|
56
103
|
return 1;
|
|
57
|
-
if (failOn === "partial" &&
|
|
104
|
+
if (failOn === "partial" && counted.length)
|
|
58
105
|
return 1;
|
|
59
106
|
return 0;
|
|
60
107
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lintsure",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Readiness checks for the code your AI writes: EU AI Act, GDPR, SOC 2, ISO 27001. Runs locally. Not an audit or legal advice.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"LICENSE"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@lintsure/core": "0.
|
|
16
|
+
"@lintsure/core": "0.3.0"
|
|
17
17
|
},
|
|
18
18
|
"author": "Lintsure <hello@lintsure.com>",
|
|
19
19
|
"homepage": "https://lintsure.com/docs",
|