@lintsure/core 0.1.3 → 0.2.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/assessment.js +16 -4
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.js +64 -13
- package/dist/src/record.d.ts +71 -0
- package/dist/src/record.js +80 -0
- package/dist/src/review.d.ts +31 -0
- package/dist/src/review.js +71 -0
- package/dist/src/rules/index.js +29 -4
- package/dist/src/sarif.d.ts +53 -0
- package/dist/src/sarif.js +27 -0
- package/dist/src/types.d.ts +32 -1
- package/package.json +1 -1
package/dist/src/assessment.js
CHANGED
|
@@ -14,8 +14,8 @@ function page(title, body, n, total, project) {
|
|
|
14
14
|
}
|
|
15
15
|
function findingCard(f, i) {
|
|
16
16
|
return `<article class="finding ${f.status}">
|
|
17
|
-
<p class="meta"><b class="st">${STATUS[f.status]}</b> · ${f.severity}
|
|
18
|
-
<h3>${
|
|
17
|
+
<p class="meta"><b class="st">${f.id} · ${f.status === "gap" ? "Finding" : "Observation"} (${STATUS[f.status]})</b> · risk level ${f.severity} · <code>${esc(f.ruleId)}</code></p>
|
|
18
|
+
<h3>${esc(f.title)}</h3>
|
|
19
19
|
<p class="where"><code>${esc(f.file)}:${f.line}</code></p>
|
|
20
20
|
<dl>
|
|
21
21
|
<dt>Rules it may affect</dt><dd>${f.controls.map((c) => `${NAME[c.framework]} ${esc(c.id)} (${esc(c.title)})`).join("<br>")}</dd>
|
|
@@ -30,14 +30,26 @@ export function toAssessmentHtml(r, opts) {
|
|
|
30
30
|
const n = (s) => r.findings.filter((f) => f.status === s).length;
|
|
31
31
|
const fws = r.frameworks;
|
|
32
32
|
const sorted = [...r.findings].sort((a, b) => SEV.indexOf(a.severity) - SEV.indexOf(b.severity));
|
|
33
|
+
const rec = r.record;
|
|
34
|
+
const RESULT = { finding: "Finding", observation: "Observation", "no issue found": "No issue found" };
|
|
35
|
+
const recordBody = rec ? `<p>A dated record of what this run checked and what it saw. It is a readiness record of an automated code check, not an audit.</p>
|
|
36
|
+
<table class="counts"><tr><th>Check points</th><th>Findings</th><th>Observations</th><th>Accepted</th><th>Fixed since baseline</th></tr>
|
|
37
|
+
<tr><td>${rec.counts.checkPoints}</td><td>${rec.counts.findings}</td><td>${rec.counts.observations}</td><td>${rec.counts.accepted}</td><td>${rec.counts.fixedSinceBaseline}</td></tr></table>
|
|
38
|
+
<p>Risk levels of open items: ${rec.counts.byRisk.high} high, ${rec.counts.byRisk.medium} medium, ${rec.counts.byRisk.low} low. A check point is one rule applied to one file (${rec.counts.rulesRun} rules ran).</p>
|
|
39
|
+
<h3>What applies, and why</h3><ul>${rec.applies.map((a) => `<li><b>${NAME[a.framework]}</b>: ${esc(a.why)}</li>`).join("")}</ul>
|
|
40
|
+
<h3>Results by control</h3><p class="small">Finding: a Gap the code itself shows. Observation: a Partial that depends on context a person must confirm. No issue found: the rules found nothing in the files they read, which does not mean the control is met.</p>
|
|
41
|
+
<table><tr><th>Framework</th><th>Control</th><th>Rules</th><th>Check points</th><th>Result</th><th>Items</th></tr>
|
|
42
|
+
${rec.byControl.map((b) => `<tr><td>${NAME[b.framework]}</td><td><code>${esc(b.control)}</code> ${esc(b.title)}</td><td>${b.rules.map((x) => `<code>${esc(x)}</code>`).join(" ")}</td><td>${b.checkPoints}</td><td>${RESULT[b.result]}</td><td>${b.findingIds.join(", ") || "-"}</td></tr>`).join("")}</table>` : "";
|
|
33
43
|
const cover = `<section class="page cover">
|
|
34
44
|
<p class="brand">Lintsure</p>
|
|
35
45
|
<h1>Readiness assessment</h1>
|
|
36
46
|
<p class="sub">${esc(project)}</p>
|
|
37
47
|
<table class="facts">
|
|
38
48
|
<tr><th>Date produced</th><td>${esc(opts.date)}</td></tr>
|
|
49
|
+
${rec ? `<tr><th>Record</th><td>${esc(rec.id)}, checked ${esc(rec.createdAt.replace("T", " ").slice(0, 19))} UTC</td></tr>` : ""}
|
|
50
|
+
${rec?.scope.commit ? `<tr><th>Code checked</th><td>${rec.scope.branch ? `branch <code>${esc(rec.scope.branch)}</code>, ` : ""}commit <code>${esc(rec.scope.commit)}</code></td></tr>` : ""}
|
|
39
51
|
<tr><th>Frameworks checked</th><td>${fws.map((f) => NAME[f]).join(", ") || "None"}</td></tr>
|
|
40
|
-
<tr><th>Files checked</th><td>${r.filesChecked}</td></tr>
|
|
52
|
+
<tr><th>Files checked</th><td>${r.filesChecked}${rec ? `, ${rec.counts.checkPoints} check points` : ""}</td></tr>
|
|
41
53
|
<tr><th>Rules version</th><td>${esc(r.rulesVersion)}</td></tr>
|
|
42
54
|
<tr><th>Status of this report</th><td><b>Draft.</b> Not complete until a qualified person reviews it and signs the review page.</td></tr>
|
|
43
55
|
</table>
|
|
@@ -84,7 +96,7 @@ ${r.outside.map((o) => `<tr><td>${NAME[o.framework]} <code>${esc(o.control)}</co
|
|
|
84
96
|
<tr><th>Overall notes</th><td class="tall"></td></tr><tr><th>Signature</th><td class="tall"></td></tr></table>
|
|
85
97
|
<p class="small">By signing, the reviewer confirms they reviewed this report. Signing does not turn it into an audit or certification.</p>`;
|
|
86
98
|
const pages = [
|
|
87
|
-
["Summary", summary], ["Scope and method", method], ["Possible issues and fixes", findingsBody],
|
|
99
|
+
["Summary", summary], ...(recordBody ? [["Readiness check record", recordBody]] : []), ["Scope and method", method], ["Possible issues and fixes", findingsBody],
|
|
88
100
|
["Framework by framework", byFramework || "<p>No frameworks were checked.</p>"], ["Work outside code", outside],
|
|
89
101
|
["What to do next", next], ["Human review and sign-off", signoff], ["Disclaimer", `<p>${esc(DISCLAIMER)}</p><p>${esc(NOT_A_VERDICT)}</p><p>Lintsure does not decide whether a framework applies to you or whether you meet it. A person makes the final call. Full disclaimer: https://lintsure.com/disclaimer</p>`],
|
|
90
102
|
];
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { rules } from "./rules/index.js";
|
|
2
2
|
import type { FrameworkId, Report } from "./types.js";
|
|
3
|
+
export * from "./review.js";
|
|
4
|
+
export { toSarif } from "./sarif.js";
|
|
5
|
+
import { type RecordOptions } from "./record.js";
|
|
6
|
+
export * from "./record.js";
|
|
3
7
|
/** Heading above every proposed change, in every report. Tests check it is there for each finding. */
|
|
4
8
|
export declare const PROPOSAL_HEADING = "Proposed change. Nothing changes until you approve it.";
|
|
5
9
|
export * from "./types.js";
|
|
@@ -7,7 +11,7 @@ export { rules };
|
|
|
7
11
|
export * from "./guidance.js";
|
|
8
12
|
export { toAssessmentHtml } from "./assessment.js";
|
|
9
13
|
export * from "./knowledge/index.js";
|
|
10
|
-
export declare const RULES_VERSION = "0.
|
|
14
|
+
export declare const RULES_VERSION = "0.2.0";
|
|
11
15
|
/** Shown with every result, in every interface. Lintsure prepares; people decide. */
|
|
12
16
|
export declare const DISCLAIMER: string;
|
|
13
17
|
/** What a report must never be read as. Used in the report and by the MCP server. */
|
|
@@ -29,5 +33,5 @@ export declare function readConfig(root: string): Promise<{
|
|
|
29
33
|
export declare const SKIP_DIRS: string[];
|
|
30
34
|
/** Scout: list files to check, sorted so output order never depends on the file system. */
|
|
31
35
|
export declare function listFiles(root: string, ignore?: string[]): Promise<string[]>;
|
|
32
|
-
export declare function scan(root: string, frameworks?: FrameworkId[]): Promise<Report>;
|
|
36
|
+
export declare function scan(root: string, frameworks?: FrameworkId[], opts?: RecordOptions): Promise<Report>;
|
|
33
37
|
export declare function toMarkdown(r: Report): string;
|
package/dist/src/index.js
CHANGED
|
@@ -5,6 +5,11 @@ import { extname, join, relative, sep } from "node:path";
|
|
|
5
5
|
import { outsideFor } from "./knowledge/index.js";
|
|
6
6
|
import { rules } from "./rules/index.js";
|
|
7
7
|
import { proposalFor } from "./guidance.js";
|
|
8
|
+
import { applyReview, fingerprint, isOpen } from "./review.js";
|
|
9
|
+
export * from "./review.js";
|
|
10
|
+
export { toSarif } from "./sarif.js";
|
|
11
|
+
import { buildRecord } from "./record.js";
|
|
12
|
+
export * from "./record.js";
|
|
8
13
|
/** Heading above every proposed change, in every report. Tests check it is there for each finding. */
|
|
9
14
|
export const PROPOSAL_HEADING = "Proposed change. Nothing changes until you approve it.";
|
|
10
15
|
export * from "./types.js";
|
|
@@ -12,7 +17,7 @@ export { rules };
|
|
|
12
17
|
export * from "./guidance.js";
|
|
13
18
|
export { toAssessmentHtml } from "./assessment.js";
|
|
14
19
|
export * from "./knowledge/index.js";
|
|
15
|
-
export const RULES_VERSION = "0.
|
|
20
|
+
export const RULES_VERSION = "0.2.0";
|
|
16
21
|
/** Shown with every result, in every interface. Lintsure prepares; people decide. */
|
|
17
22
|
export const DISCLAIMER = "Lintsure is a readiness tool, not an audit, a certification or legal advice. " +
|
|
18
23
|
"Its rules reflect our reading of the publicly available text of each framework, and they check code only. " +
|
|
@@ -23,12 +28,15 @@ export const NOT_A_VERDICT = "These results do not mean you are compliant, certi
|
|
|
23
28
|
"Lintsure's rules found no problem in the files they read.";
|
|
24
29
|
/** Plain next steps, so a report always ends with what a person still needs to do. */
|
|
25
30
|
export function nextSteps(r) {
|
|
26
|
-
const
|
|
27
|
-
const
|
|
31
|
+
const open = r.findings.filter(isOpen);
|
|
32
|
+
const gaps = open.filter((f) => f.status === "gap").length;
|
|
33
|
+
const partial = open.filter((f) => f.status === "partial").length;
|
|
34
|
+
const expired = r.findings.filter((f) => f.accepted?.expired).length;
|
|
28
35
|
return [
|
|
29
36
|
gaps ? `Review the ${gaps} gap${gaps === 1 ? "" : "s"} and decide how to fix each one. Approve any change before it is made.` : "No gaps were found by the current rules. Keep checking as the code changes.",
|
|
30
37
|
partial ? `Check the ${partial} partial finding${partial === 1 ? "" : "s"}: each depends on context only you can confirm.` : "",
|
|
31
38
|
`Work through the ${r.outside.length} item${r.outside.length === 1 ? "" : "s"} that live outside code. Code checks alone are not enough for a full review.`,
|
|
39
|
+
expired ? `${expired} accepted finding${expired === 1 ? " is" : "s are"} past the review date. Look again, then renew the acceptance or fix it.` : "",
|
|
32
40
|
"Ask a qualified compliance professional to review the results before you rely on them.",
|
|
33
41
|
].filter(Boolean);
|
|
34
42
|
}
|
|
@@ -104,11 +112,13 @@ export async function listFiles(root, ignore = []) {
|
|
|
104
112
|
await walk(root);
|
|
105
113
|
return out.sort();
|
|
106
114
|
}
|
|
107
|
-
export async function scan(root, frameworks = ALL_FRAMEWORKS) {
|
|
115
|
+
export async function scan(root, frameworks = ALL_FRAMEWORKS, opts = {}) {
|
|
108
116
|
const active = rules.filter((r) => r.controls.some((c) => frameworks.includes(c.framework)));
|
|
109
117
|
const findings = [];
|
|
110
|
-
let filesChecked = 0;
|
|
111
|
-
|
|
118
|
+
let filesChecked = 0, checkPoints = 0;
|
|
119
|
+
const perRule = {};
|
|
120
|
+
const { ignore } = await readConfig(root);
|
|
121
|
+
for (const abs of await listFiles(root, ignore)) {
|
|
112
122
|
const ext = extname(abs) || (abs.endsWith(".env") ? ".env" : "");
|
|
113
123
|
const relevant = active.filter((r) => r.extensions.includes(ext));
|
|
114
124
|
if (!relevant.length)
|
|
@@ -121,17 +131,21 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS) {
|
|
|
121
131
|
if (lines.some((l) => l.length > MAX_LINE))
|
|
122
132
|
continue; // minified or generated
|
|
123
133
|
filesChecked++;
|
|
124
|
-
|
|
134
|
+
checkPoints += relevant.length; // one rule applied to one file is one check point
|
|
135
|
+
for (const r of relevant)
|
|
136
|
+
perRule[r.id] = (perRule[r.id] ?? 0) + 1;
|
|
137
|
+
const add = (r, line, status = r.status) => {
|
|
125
138
|
const controls = r.controls.filter((c) => frameworks.includes(c.framework));
|
|
126
139
|
findings.push({
|
|
127
|
-
ruleId: r.id, file, line, status
|
|
140
|
+
id: "", ruleId: r.id, file, line, status, severity: r.severity, title: r.title, controls, fix: r.fix, note: r.note,
|
|
128
141
|
proposal: proposalFor({ file, line, title: r.title, fix: r.fix, note: r.note, controls }),
|
|
142
|
+
fingerprint: fingerprint(r.id, file, lines[line - 1] ?? ""),
|
|
129
143
|
});
|
|
130
144
|
};
|
|
131
145
|
for (const r of relevant) {
|
|
132
146
|
if (r.test)
|
|
133
|
-
lines.forEach((text, i) => {
|
|
134
|
-
add(r, i + 1); });
|
|
147
|
+
lines.forEach((text, i) => { const hit = r.test(text); if (hit)
|
|
148
|
+
add(r, i + 1, hit === "partial" ? "partial" : r.status); });
|
|
135
149
|
if (r.fileTest)
|
|
136
150
|
for (const n of r.fileTest(lines))
|
|
137
151
|
add(r, n);
|
|
@@ -141,8 +155,10 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS) {
|
|
|
141
155
|
const seen = new Set();
|
|
142
156
|
const deduped = findings.filter((f) => { const k = `${f.ruleId}|${f.file}|${f.line}`; return seen.has(k) ? false : (seen.add(k), true); })
|
|
143
157
|
.sort((a, b) => a.file.localeCompare(b.file) || a.line - b.line || a.ruleId.localeCompare(b.ruleId));
|
|
158
|
+
deduped.forEach((f, i) => { f.id = `F-${String(i + 1).padStart(3, "0")}`; });
|
|
144
159
|
const hit = new Set(deduped.map((f) => f.ruleId));
|
|
145
|
-
|
|
160
|
+
const now = opts.now ?? new Date();
|
|
161
|
+
const report = await applyReview({
|
|
146
162
|
rulesVersion: RULES_VERSION,
|
|
147
163
|
frameworks: [...frameworks].sort(),
|
|
148
164
|
findings: deduped,
|
|
@@ -151,21 +167,56 @@ export async function scan(root, frameworks = ALL_FRAMEWORKS) {
|
|
|
151
167
|
outside: outsideFor(frameworks),
|
|
152
168
|
filesChecked,
|
|
153
169
|
disclaimer: DISCLAIMER,
|
|
154
|
-
};
|
|
170
|
+
}, root, now.toISOString().slice(0, 10));
|
|
171
|
+
report.record = await buildRecord(report, root, checkPoints, perRule, active.map((r) => r.id), active, ignore, { ...opts, now });
|
|
172
|
+
return report;
|
|
155
173
|
}
|
|
156
174
|
const LABEL = { gap: "Gap", partial: "Partial", met: "Met", outside: "Outside code" };
|
|
175
|
+
const acceptedLine = (a) => `> Accepted by ${a.by} on ${a.date}: ${a.reason}` + (a.expired ? ` (review date ${a.reviewBy} has passed: look at it again)` : a.reviewBy ? ` (review by ${a.reviewBy})` : "");
|
|
157
176
|
const ctl = (c) => c.map((x) => `${x.framework.toUpperCase()} ${x.id}`).join(" · ");
|
|
177
|
+
const RESULT = { finding: "Finding", observation: "Observation", "no issue found": "No issue found" };
|
|
178
|
+
/** The record block: identification, scope, what applies and why, counts, and results by control. */
|
|
179
|
+
function recordLines(r) {
|
|
180
|
+
const c = r.record;
|
|
181
|
+
if (!c)
|
|
182
|
+
return [];
|
|
183
|
+
const n = c.counts;
|
|
184
|
+
return [
|
|
185
|
+
"## Readiness check record", "",
|
|
186
|
+
"This is a readiness record of an automated code check, not an audit. It is a draft until a person reviews and signs it.", "",
|
|
187
|
+
"| | |", "|---|---|",
|
|
188
|
+
`| Record | ${c.id} |`, `| Date and time (UTC) | ${c.createdAt.replace("T", " ").slice(0, 19)} |`,
|
|
189
|
+
`| Tool | ${c.tool.name} ${c.tool.version}, run from ${c.source} |`,
|
|
190
|
+
`| Scope | \`${c.scope.folder}\`${c.scope.branch ? `, branch \`${c.scope.branch}\`` : ""}${c.scope.commit ? `, commit \`${c.scope.commit}\`` : ""} |`,
|
|
191
|
+
`| Files read | ${c.scope.filesRead}${c.scope.ignored.length ? ` (ignored by config: ${c.scope.ignored.map((x) => `\`${x}\``).join(", ")})` : ""} |`,
|
|
192
|
+
`| Check points | ${n.checkPoints} (${n.rulesRun} rules, each applied to every file it reads) |`,
|
|
193
|
+
`| Results | ${n.findings} finding${n.findings === 1 ? "" : "s"}, ${n.observations} observation${n.observations === 1 ? "" : "s"}, ${n.accepted} accepted, ${n.fixedSinceBaseline} fixed since baseline, ${n.outsideCode} outside-code items |`,
|
|
194
|
+
`| Risk levels | ${n.byRisk.high} high, ${n.byRisk.medium} medium, ${n.byRisk.low} low |`,
|
|
195
|
+
`| Reviewed by | ${c.review.reviewer ?? "Not yet reviewed"} |`, "",
|
|
196
|
+
"### What applies, and why", "",
|
|
197
|
+
...c.applies.map((a) => `- **${a.framework}**: ${a.why}`), "",
|
|
198
|
+
"### Results by control", "",
|
|
199
|
+
"A finding is a Gap the code itself shows. An observation is a Partial that depends on context a person must confirm. No issue found means the rules found nothing in the files they read, not that the control is met.", "",
|
|
200
|
+
"| Framework | Control | Rules | Check points | Result | Items |", "|---|---|---|---|---|---|",
|
|
201
|
+
...c.byControl.map((b) => `| ${b.framework} | ${b.control} ${b.title} | ${b.rules.join(", ")} | ${b.checkPoints} | ${RESULT[b.result]} | ${b.findingIds.join(", ") || "-"} |`), "",
|
|
202
|
+
];
|
|
203
|
+
}
|
|
158
204
|
export function toMarkdown(r) {
|
|
159
205
|
const lines = [
|
|
160
206
|
"# Lintsure report", "",
|
|
161
207
|
`Frameworks: ${r.frameworks.join(", ")} · Rules v${r.rulesVersion}`, "",
|
|
162
208
|
`> ${DISCLAIMER}`, "",
|
|
209
|
+
...recordLines(r),
|
|
163
210
|
`## Findings (${r.findings.length})`, "",
|
|
164
211
|
];
|
|
212
|
+
if (r.baseline)
|
|
213
|
+
lines.splice(lines.length - 2, 0, `Since the baseline of ${r.baseline.created}: ${r.baseline.newCount} new, ${r.baseline.fixed.length} fixed, ${r.baseline.unchangedCount} unchanged.`, "");
|
|
165
214
|
if (!r.findings.length)
|
|
166
215
|
lines.push("No issues found by the current rules.", "");
|
|
167
216
|
for (const f of r.findings)
|
|
168
|
-
lines.push(`### ${LABEL[f.status]} · \`${f.file}:${f.line}
|
|
217
|
+
lines.push(`### ${f.id} · ${f.status === "gap" ? "Finding" : "Observation"} (${LABEL[f.status]}) · \`${f.file}:${f.line}\`${f.change === "new" ? " · New since baseline" : ""}`, `**${f.title}** · Risk level: ${f.severity}`, "", ...(f.accepted ? [acceptedLine(f.accepted), ""] : []), `- Rules: ${ctl(f.controls)}`, `- Auditor note: ${f.note}`, "", `**${PROPOSAL_HEADING}**`, "", `- Where: \`${f.proposal.where}\``, `- What: ${f.proposal.what}`, `- Why: ${f.proposal.why}`, `- Benefit: ${f.proposal.benefit}`, "");
|
|
218
|
+
if (r.baseline?.fixed.length)
|
|
219
|
+
lines.push(`## Fixed since baseline (${r.baseline.fixed.length})`, "", ...r.baseline.fixed.map((x) => `- ${x.ruleId} in \`${x.file}\``), "");
|
|
169
220
|
lines.push(`## Met (${r.met.length})`, "", ...r.met.map((m) => `- ${m.title} · ${ctl(m.controls)}`), "");
|
|
170
221
|
lines.push(`## Outside code (${r.outside.length})`, "", "Code can't prove these. They still need to be done before a full review.", "", ...r.outside.map((o) => `- ${o.framework.toUpperCase()} ${o.control} · ${o.title}: ${o.evidence}`), "");
|
|
171
222
|
lines.push("## What to do next", "", ...nextSteps(r).map((s, i) => `${i + 1}. ${s}`), "");
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { FrameworkId, Report, Severity } from "./types.js";
|
|
2
|
+
export type ControlResult = "finding" | "observation" | "no issue found";
|
|
3
|
+
export interface CheckRecord {
|
|
4
|
+
/** Stable id for this run, for example LS-20261108-1a2b3c. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** When the check ran, ISO 8601 in UTC. */
|
|
7
|
+
createdAt: string;
|
|
8
|
+
kind: "readiness check record";
|
|
9
|
+
tool: {
|
|
10
|
+
name: "Lintsure";
|
|
11
|
+
version: string;
|
|
12
|
+
};
|
|
13
|
+
/** Which interface ran it: cli, mcp or ci. */
|
|
14
|
+
source: string;
|
|
15
|
+
scope: {
|
|
16
|
+
folder: string;
|
|
17
|
+
commit?: string;
|
|
18
|
+
branch?: string;
|
|
19
|
+
filesRead: number;
|
|
20
|
+
ignored: string[];
|
|
21
|
+
};
|
|
22
|
+
/** Each framework checked, and why it was included. */
|
|
23
|
+
applies: {
|
|
24
|
+
framework: FrameworkId;
|
|
25
|
+
why: string;
|
|
26
|
+
}[];
|
|
27
|
+
/** Every control the active rules cover, with its result. */
|
|
28
|
+
byControl: {
|
|
29
|
+
framework: FrameworkId;
|
|
30
|
+
control: string;
|
|
31
|
+
title: string;
|
|
32
|
+
rules: string[];
|
|
33
|
+
checkPoints: number;
|
|
34
|
+
result: ControlResult;
|
|
35
|
+
findingIds: string[];
|
|
36
|
+
}[];
|
|
37
|
+
counts: {
|
|
38
|
+
/** One rule applied to one file is one check point. */
|
|
39
|
+
checkPoints: number;
|
|
40
|
+
rulesRun: number;
|
|
41
|
+
/** Partial results: depend on context a person must confirm. */
|
|
42
|
+
observations: number;
|
|
43
|
+
/** Gap results: the code itself shows a problem. */
|
|
44
|
+
findings: number;
|
|
45
|
+
byRisk: Record<Severity, number>;
|
|
46
|
+
accepted: number;
|
|
47
|
+
fixedSinceBaseline: number;
|
|
48
|
+
outsideCode: number;
|
|
49
|
+
};
|
|
50
|
+
/** Filled in by a person. The record is a draft until then. */
|
|
51
|
+
review: {
|
|
52
|
+
reviewer: string | null;
|
|
53
|
+
date: string | null;
|
|
54
|
+
decision: string | null;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface RecordOptions {
|
|
58
|
+
/** Why each framework was checked. A string applies to all of them. */
|
|
59
|
+
why?: string | Partial<Record<FrameworkId, string>>;
|
|
60
|
+
source?: string;
|
|
61
|
+
/** Time of the run. Defaults to now; tests pass a fixed value. */
|
|
62
|
+
now?: Date;
|
|
63
|
+
}
|
|
64
|
+
export declare function buildRecord(r: Report, root: string, checkPoints: number, perRule: Record<string, number>, rulesRun: string[], ruleControls: {
|
|
65
|
+
id: string;
|
|
66
|
+
controls: {
|
|
67
|
+
framework: FrameworkId;
|
|
68
|
+
id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
}[];
|
|
71
|
+
}[], ignored: string[], opts?: RecordOptions): Promise<CheckRecord>;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// The readiness check record: a dated, structured account of one run. What was checked, against which
|
|
2
|
+
// rules, what applies and why, how many check points, and what was found. It is a readiness record, not
|
|
3
|
+
// an audit: no auditor examined anything, and a person still has to review and sign it.
|
|
4
|
+
// It never contains source code.
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
6
|
+
import { readFile } from "node:fs/promises";
|
|
7
|
+
import { basename, join } from "node:path";
|
|
8
|
+
/** Reads the current commit and branch from .git without running git or using the network. */
|
|
9
|
+
async function gitInfo(root) {
|
|
10
|
+
try {
|
|
11
|
+
const head = (await readFile(join(root, ".git", "HEAD"), "utf8")).trim();
|
|
12
|
+
if (!head.startsWith("ref:"))
|
|
13
|
+
return { commit: head.slice(0, 12) };
|
|
14
|
+
const ref = head.slice(5).trim(), branch = ref.replace(/^refs\/heads\//, "");
|
|
15
|
+
try {
|
|
16
|
+
return { branch, commit: (await readFile(join(root, ".git", ref), "utf8")).trim().slice(0, 12) };
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
const packed = await readFile(join(root, ".git", "packed-refs"), "utf8").catch(() => "");
|
|
20
|
+
const line = packed.split(/\r?\n/).find((l) => l.endsWith(` ${ref}`));
|
|
21
|
+
return { branch, commit: line?.slice(0, 12) };
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export async function buildRecord(r, root, checkPoints, perRule, rulesRun, ruleControls, ignored, opts = {}) {
|
|
29
|
+
const now = opts.now ?? new Date();
|
|
30
|
+
const createdAt = now.toISOString();
|
|
31
|
+
const hash = createHash("sha256").update(createdAt + r.findings.map((f) => f.fingerprint).join(",")).digest("hex").slice(0, 6);
|
|
32
|
+
const why = (f) => typeof opts.why === "string" ? opts.why : opts.why?.[f] ?? "Checked by default: no framework list was given.";
|
|
33
|
+
const controls = new Map();
|
|
34
|
+
for (const rule of ruleControls)
|
|
35
|
+
for (const c of rule.controls) {
|
|
36
|
+
if (!r.frameworks.includes(c.framework))
|
|
37
|
+
continue;
|
|
38
|
+
const key = `${c.framework}|${c.id}`;
|
|
39
|
+
const row = controls.get(key) ?? { framework: c.framework, control: c.id, title: c.title, rules: [], checkPoints: 0, result: "no issue found", findingIds: [] };
|
|
40
|
+
row.rules.push(rule.id);
|
|
41
|
+
row.checkPoints += perRule[rule.id] ?? 0;
|
|
42
|
+
controls.set(key, row);
|
|
43
|
+
}
|
|
44
|
+
for (const f of r.findings) {
|
|
45
|
+
if (f.accepted && !f.accepted.expired)
|
|
46
|
+
continue;
|
|
47
|
+
for (const c of f.controls) {
|
|
48
|
+
const row = controls.get(`${c.framework}|${c.id}`);
|
|
49
|
+
if (!row)
|
|
50
|
+
continue;
|
|
51
|
+
row.findingIds.push(f.id);
|
|
52
|
+
if (f.status === "gap")
|
|
53
|
+
row.result = "finding";
|
|
54
|
+
else if (row.result !== "finding")
|
|
55
|
+
row.result = "observation";
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const open = r.findings.filter((f) => !f.accepted || f.accepted.expired);
|
|
59
|
+
const byRisk = { high: 0, medium: 0, low: 0 };
|
|
60
|
+
for (const f of open)
|
|
61
|
+
byRisk[f.severity]++;
|
|
62
|
+
return {
|
|
63
|
+
id: `LS-${createdAt.slice(0, 10).replace(/-/g, "")}-${hash}`,
|
|
64
|
+
createdAt, kind: "readiness check record",
|
|
65
|
+
tool: { name: "Lintsure", version: r.rulesVersion },
|
|
66
|
+
source: opts.source ?? "cli",
|
|
67
|
+
scope: { folder: basename(root), ...(await gitInfo(root)), filesRead: r.filesChecked, ignored },
|
|
68
|
+
applies: r.frameworks.map((f) => ({ framework: f, why: why(f) })),
|
|
69
|
+
byControl: [...controls.values()].sort((a, b) => a.framework.localeCompare(b.framework) || a.control.localeCompare(b.control, undefined, { numeric: true })),
|
|
70
|
+
counts: {
|
|
71
|
+
checkPoints, rulesRun: rulesRun.length,
|
|
72
|
+
observations: open.filter((f) => f.status === "partial").length,
|
|
73
|
+
findings: open.filter((f) => f.status === "gap").length,
|
|
74
|
+
byRisk, accepted: r.findings.length - open.length,
|
|
75
|
+
fixedSinceBaseline: r.baseline?.fixed.length ?? 0,
|
|
76
|
+
outsideCode: r.outside.length,
|
|
77
|
+
},
|
|
78
|
+
review: { reviewer: null, date: null, decision: null },
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Finding, Report } from "./types.js";
|
|
2
|
+
export declare const BASELINE_FILE = ".lintsure/baseline.json";
|
|
3
|
+
export declare const ACCEPTED_FILE = ".lintsure/accepted.yaml";
|
|
4
|
+
/** A short one-way hash of the rule, file and the flagged line with spacing normalised. Moving the line keeps it; editing it changes it. */
|
|
5
|
+
export declare function fingerprint(ruleId: string, file: string, lineText: string): string;
|
|
6
|
+
export interface Baseline {
|
|
7
|
+
version: 1;
|
|
8
|
+
created: string;
|
|
9
|
+
findings: {
|
|
10
|
+
ruleId: string;
|
|
11
|
+
file: string;
|
|
12
|
+
fingerprint: string;
|
|
13
|
+
}[];
|
|
14
|
+
}
|
|
15
|
+
export interface AcceptedEntry {
|
|
16
|
+
rule: string;
|
|
17
|
+
where: string;
|
|
18
|
+
fingerprint: string;
|
|
19
|
+
reason: string;
|
|
20
|
+
accepted_by: string;
|
|
21
|
+
date: string;
|
|
22
|
+
review_by?: string;
|
|
23
|
+
}
|
|
24
|
+
/** The baseline to write for a report: every open finding, without code. Accepted findings are left out. */
|
|
25
|
+
export declare function toBaseline(r: Report, created: string): Baseline;
|
|
26
|
+
/** Reads the simple list form of accepted.yaml: "- key: value" items with indented "key: value" lines. */
|
|
27
|
+
export declare function parseAccepted(text: string): AcceptedEntry[];
|
|
28
|
+
/** Adds acceptances, new/unchanged marks and the list of fixed findings, from the repo's .lintsure/ files. */
|
|
29
|
+
export declare function applyReview(r: Report, root: string, today: string): Promise<Report>;
|
|
30
|
+
/** Findings still needing a decision: not accepted, or accepted but past the review date. */
|
|
31
|
+
export declare const isOpen: (f: Finding) => boolean;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Baseline and accepted findings, read from the repo's own .lintsure/ folder. Nothing is sent anywhere:
|
|
2
|
+
// these are files in the user's folder, and the user decides whether to commit them.
|
|
3
|
+
// Neither file contains code: only rule ids, file paths, fingerprints (one-way hashes) and people's reasons.
|
|
4
|
+
import { createHash } from "node:crypto";
|
|
5
|
+
import { readFile } from "node:fs/promises";
|
|
6
|
+
import { join } from "node:path";
|
|
7
|
+
export const BASELINE_FILE = ".lintsure/baseline.json";
|
|
8
|
+
export const ACCEPTED_FILE = ".lintsure/accepted.yaml";
|
|
9
|
+
/** A short one-way hash of the rule, file and the flagged line with spacing normalised. Moving the line keeps it; editing it changes it. */
|
|
10
|
+
export function fingerprint(ruleId, file, lineText) {
|
|
11
|
+
return createHash("sha256").update(`${ruleId}\n${file}\n${lineText.trim().replace(/\s+/g, " ")}`).digest("hex").slice(0, 16);
|
|
12
|
+
}
|
|
13
|
+
/** The baseline to write for a report: every open finding, without code. Accepted findings are left out. */
|
|
14
|
+
export function toBaseline(r, created) {
|
|
15
|
+
return { version: 1, created, findings: r.findings.filter((f) => !f.accepted || f.accepted.expired).map(({ ruleId, file, fingerprint }) => ({ ruleId, file, fingerprint })) };
|
|
16
|
+
}
|
|
17
|
+
/** Reads the simple list form of accepted.yaml: "- key: value" items with indented "key: value" lines. */
|
|
18
|
+
export function parseAccepted(text) {
|
|
19
|
+
const out = [];
|
|
20
|
+
for (const raw of text.split(/\r?\n/)) {
|
|
21
|
+
const line = raw.replace(/\s+#.*$/, "").replace(/^#.*$/, "");
|
|
22
|
+
const m = line.match(/^(\s*)(-\s+)?([a-z_]+)\s*:\s*(.*)$/);
|
|
23
|
+
if (!m)
|
|
24
|
+
continue;
|
|
25
|
+
if (m[2])
|
|
26
|
+
out.push({});
|
|
27
|
+
if (!out.length)
|
|
28
|
+
continue;
|
|
29
|
+
out[out.length - 1][m[3]] = m[4].trim().replace(/^["']|["']$/g, "");
|
|
30
|
+
}
|
|
31
|
+
return out.filter((e) => e.rule && e.fingerprint && e.reason && e.accepted_by);
|
|
32
|
+
}
|
|
33
|
+
async function readText(path) { try {
|
|
34
|
+
return await readFile(path, "utf8");
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
} }
|
|
39
|
+
/** Adds acceptances, new/unchanged marks and the list of fixed findings, from the repo's .lintsure/ files. */
|
|
40
|
+
export async function applyReview(r, root, today) {
|
|
41
|
+
const acceptedText = await readText(join(root, ACCEPTED_FILE));
|
|
42
|
+
const accepted = acceptedText ? parseAccepted(acceptedText) : [];
|
|
43
|
+
for (const f of r.findings) {
|
|
44
|
+
const a = accepted.find((e) => e.rule === f.ruleId && e.fingerprint === f.fingerprint);
|
|
45
|
+
if (a)
|
|
46
|
+
f.accepted = { reason: a.reason, by: a.accepted_by, date: a.date, reviewBy: a.review_by, expired: !!a.review_by && a.review_by < today };
|
|
47
|
+
}
|
|
48
|
+
const baseText = await readText(join(root, BASELINE_FILE));
|
|
49
|
+
if (baseText) {
|
|
50
|
+
let base = null;
|
|
51
|
+
try {
|
|
52
|
+
base = JSON.parse(baseText);
|
|
53
|
+
}
|
|
54
|
+
catch { /* unreadable baseline: treat as none */ }
|
|
55
|
+
if (base?.findings) {
|
|
56
|
+
const known = new Set(base.findings.map((b) => b.fingerprint));
|
|
57
|
+
const now = new Set(r.findings.map((f) => f.fingerprint));
|
|
58
|
+
for (const f of r.findings)
|
|
59
|
+
f.change = known.has(f.fingerprint) ? "unchanged" : "new";
|
|
60
|
+
r.baseline = {
|
|
61
|
+
created: base.created,
|
|
62
|
+
newCount: r.findings.filter((f) => f.change === "new" && !(f.accepted && !f.accepted.expired)).length,
|
|
63
|
+
unchangedCount: r.findings.filter((f) => f.change === "unchanged").length,
|
|
64
|
+
fixed: base.findings.filter((b) => !now.has(b.fingerprint)),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return r;
|
|
69
|
+
}
|
|
70
|
+
/** Findings still needing a decision: not accepted, or accepted but past the review date. */
|
|
71
|
+
export const isOpen = (f) => !f.accepted || f.accepted.expired;
|
package/dist/src/rules/index.js
CHANGED
|
@@ -5,6 +5,23 @@ const LOG_CALL = /\b(console\.(log|info|warn|error|debug)|logger\.\w+|log\.(info
|
|
|
5
5
|
// Drops the text of string literals but keeps interpolations, so "email error" is ignored and `${user.email}` or f"{user.email}" is not.
|
|
6
6
|
const codeOnly = (l) => l.replace(/(["'`])(?:\\.|(?!\1).)*\1/g, (s) => (s.match(/\{[^}]*\}/g) ?? []).join(" "));
|
|
7
7
|
const PII = /\b(e-?mail|phone|ssn|social_?security|passport|date_?of_?birth|dob|password|passwd|credit_?card|card_?number|iban)\b/i;
|
|
8
|
+
// The arguments of the first log call on a line, up to its matching ")". Other code on the same line is ignored.
|
|
9
|
+
function logArgs(l) {
|
|
10
|
+
const m = LOG_CALL.exec(l);
|
|
11
|
+
if (!m)
|
|
12
|
+
return null;
|
|
13
|
+
let depth = 0, i = m.index + m[0].length - 1;
|
|
14
|
+
for (let j = i; j < l.length; j++) {
|
|
15
|
+
if (l[j] === "(")
|
|
16
|
+
depth++;
|
|
17
|
+
else if (l[j] === ")" && --depth === 0)
|
|
18
|
+
return l.slice(i + 1, j);
|
|
19
|
+
}
|
|
20
|
+
return l.slice(i + 1);
|
|
21
|
+
}
|
|
22
|
+
// Values that usually come from a request or the user. SQL built from them is a Gap; from other values, Partial.
|
|
23
|
+
const USER_INPUT = /\b(req|request|params|query|body|input|args|form|ctx|event|payload|searchParams|user_input)\b/;
|
|
24
|
+
const SQL_PARTS = /\$\{([^}]*)\}|\bf["'][^"']*\{([^}]*)\}|["']\s*\+\s*([\w.[\]]+)|\.format\(([^)]*)\)|%s["']\s*%\s*([^\n]+)/g;
|
|
8
25
|
export const rules = [
|
|
9
26
|
{
|
|
10
27
|
id: "pii.logged",
|
|
@@ -18,7 +35,7 @@ export const rules = [
|
|
|
18
35
|
fix: "Mask or remove the personal field before logging, for example mask(user.email).",
|
|
19
36
|
note: "Logs are copied to many places and kept for a long time. Personal data in them is hard to find and delete.",
|
|
20
37
|
extensions: CODE,
|
|
21
|
-
test: (l) =>
|
|
38
|
+
test: (l) => { const a = logArgs(l); return a !== null && PII.test(codeOnly(a)); },
|
|
22
39
|
...DRAFT,
|
|
23
40
|
},
|
|
24
41
|
{
|
|
@@ -121,10 +138,18 @@ export const rules = [
|
|
|
121
138
|
{ framework: "iso-27001", id: "A.8.28", title: "Secure coding" },
|
|
122
139
|
{ framework: "gdpr", id: "Art. 32", title: "Security of processing" },
|
|
123
140
|
],
|
|
124
|
-
fix: "Use parameterized queries or your ORM's query builder.",
|
|
125
|
-
note: "String-built SQL can let an attacker read or change your data (SQL injection).",
|
|
141
|
+
fix: "Use parameterized queries or your ORM's query builder. If the inserted value is fixed text from your own code, confirm it can never come from a user.",
|
|
142
|
+
note: "String-built SQL can let an attacker read or change your data (SQL injection). Marked Gap when the inserted value looks like user input, Partial when it may be fixed text from your code.",
|
|
126
143
|
extensions: CODE,
|
|
127
|
-
test: (l) =>
|
|
144
|
+
test: (l) => {
|
|
145
|
+
// SQL keywords are written in UPPER or lower case; "Select a plan from..." in a sentence is not SQL.
|
|
146
|
+
if (!/\b(SELECT|INSERT|UPDATE|DELETE|select|insert|update|delete)\b[^"'`]*\b(FROM|INTO|SET|WHERE|from|into|set|where)\b/.test(l))
|
|
147
|
+
return false;
|
|
148
|
+
const parts = [...l.matchAll(SQL_PARTS)].map((m) => m.slice(1).find(Boolean) ?? "");
|
|
149
|
+
if (!parts.length)
|
|
150
|
+
return false;
|
|
151
|
+
return parts.some((p) => USER_INPUT.test(p)) ? true : "partial";
|
|
152
|
+
},
|
|
128
153
|
...DRAFT,
|
|
129
154
|
},
|
|
130
155
|
{
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { Report } from "./types.js";
|
|
2
|
+
export declare function toSarif(r: Report, version: string): {
|
|
3
|
+
$schema: string;
|
|
4
|
+
version: string;
|
|
5
|
+
runs: {
|
|
6
|
+
tool: {
|
|
7
|
+
driver: {
|
|
8
|
+
name: string;
|
|
9
|
+
version: string;
|
|
10
|
+
informationUri: string;
|
|
11
|
+
rules: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
shortDescription: {
|
|
15
|
+
text: string;
|
|
16
|
+
};
|
|
17
|
+
help: {
|
|
18
|
+
text: string;
|
|
19
|
+
};
|
|
20
|
+
helpUri: string;
|
|
21
|
+
properties: {
|
|
22
|
+
tags: string[];
|
|
23
|
+
};
|
|
24
|
+
}[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
results: {
|
|
28
|
+
suppressions?: {
|
|
29
|
+
kind: string;
|
|
30
|
+
justification: string;
|
|
31
|
+
}[] | undefined;
|
|
32
|
+
baselineState?: "new" | "unchanged" | undefined;
|
|
33
|
+
ruleId: string;
|
|
34
|
+
level: string;
|
|
35
|
+
message: {
|
|
36
|
+
text: string;
|
|
37
|
+
};
|
|
38
|
+
locations: {
|
|
39
|
+
physicalLocation: {
|
|
40
|
+
artifactLocation: {
|
|
41
|
+
uri: string;
|
|
42
|
+
};
|
|
43
|
+
region: {
|
|
44
|
+
startLine: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}[];
|
|
48
|
+
partialFingerprints: {
|
|
49
|
+
"lintsure/v1": string;
|
|
50
|
+
};
|
|
51
|
+
}[];
|
|
52
|
+
}[];
|
|
53
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { rules } from "./rules/index.js";
|
|
2
|
+
export function toSarif(r, version) {
|
|
3
|
+
const used = [...new Set(r.findings.map((f) => f.ruleId))];
|
|
4
|
+
return {
|
|
5
|
+
$schema: "https://json.schemastore.org/sarif-2.1.0.json",
|
|
6
|
+
version: "2.1.0",
|
|
7
|
+
runs: [{
|
|
8
|
+
tool: { driver: {
|
|
9
|
+
name: "Lintsure", version, informationUri: "https://lintsure.com",
|
|
10
|
+
rules: used.map((id) => {
|
|
11
|
+
const rule = rules.find((x) => x.id === id);
|
|
12
|
+
return { id, name: id, shortDescription: { text: rule.title }, help: { text: `${rule.fix} ${rule.note}` },
|
|
13
|
+
helpUri: `https://lintsure.com/rules/${id.split(".").join("-")}`, properties: { tags: rule.controls.map((c) => `${c.framework} ${c.id}`) } };
|
|
14
|
+
}),
|
|
15
|
+
} },
|
|
16
|
+
results: r.findings.map((f) => ({
|
|
17
|
+
ruleId: f.ruleId,
|
|
18
|
+
level: f.status === "gap" ? "error" : "warning",
|
|
19
|
+
message: { text: `${f.title}. Proposed change (needs your approval): ${f.proposal.what} Why: ${f.proposal.why}` },
|
|
20
|
+
locations: [{ physicalLocation: { artifactLocation: { uri: f.file }, region: { startLine: f.line } } }],
|
|
21
|
+
partialFingerprints: { "lintsure/v1": f.fingerprint },
|
|
22
|
+
...(f.change ? { baselineState: f.change } : {}),
|
|
23
|
+
...(f.accepted && !f.accepted.expired ? { suppressions: [{ kind: "external", justification: `${f.accepted.reason} (accepted by ${f.accepted.by}, ${f.accepted.date})` }] } : {}),
|
|
24
|
+
})),
|
|
25
|
+
}],
|
|
26
|
+
};
|
|
27
|
+
}
|
package/dist/src/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface Rule {
|
|
|
18
18
|
/** Files this rule reads, by extension. */
|
|
19
19
|
extensions: string[];
|
|
20
20
|
/** Line rule: true when the line breaks the rule. Must be pure: same line, same answer. */
|
|
21
|
-
test?(line: string): boolean;
|
|
21
|
+
test?(line: string): boolean | "partial";
|
|
22
22
|
/** File rule, for checks that need context (e.g. "an AI call with no logging in this file").
|
|
23
23
|
* Returns 1-based line numbers to flag. Must be pure. */
|
|
24
24
|
fileTest?(lines: string[]): number[];
|
|
@@ -39,6 +39,8 @@ export interface Proposal {
|
|
|
39
39
|
needsApproval: true;
|
|
40
40
|
}
|
|
41
41
|
export interface Finding {
|
|
42
|
+
/** Finding number within this run, for example F-003. */
|
|
43
|
+
id: string;
|
|
42
44
|
ruleId: string;
|
|
43
45
|
file: string;
|
|
44
46
|
line: number;
|
|
@@ -50,6 +52,31 @@ export interface Finding {
|
|
|
50
52
|
note: string;
|
|
51
53
|
/** The suggested change, laid out for a person to approve or decline. */
|
|
52
54
|
proposal: Proposal;
|
|
55
|
+
/** Stable id: rule, file and the flagged line's content (not its number). Contains no code. */
|
|
56
|
+
fingerprint: string;
|
|
57
|
+
/** Set when .lintsure/baseline.json exists: whether the finding is new since then. */
|
|
58
|
+
change?: "new" | "unchanged";
|
|
59
|
+
/** Set when a person accepted this finding in .lintsure/accepted.yaml. */
|
|
60
|
+
accepted?: Acceptance;
|
|
61
|
+
}
|
|
62
|
+
/** A person's decision to accept a finding, with their reason. Expired acceptances count as open again. */
|
|
63
|
+
export interface Acceptance {
|
|
64
|
+
reason: string;
|
|
65
|
+
by: string;
|
|
66
|
+
date: string;
|
|
67
|
+
reviewBy?: string;
|
|
68
|
+
expired: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** What changed since the baseline: findings that were in the baseline and are now gone. */
|
|
71
|
+
export interface BaselineDiff {
|
|
72
|
+
created: string;
|
|
73
|
+
newCount: number;
|
|
74
|
+
unchangedCount: number;
|
|
75
|
+
fixed: {
|
|
76
|
+
ruleId: string;
|
|
77
|
+
file: string;
|
|
78
|
+
fingerprint: string;
|
|
79
|
+
}[];
|
|
53
80
|
}
|
|
54
81
|
export interface OutsideItem {
|
|
55
82
|
framework: FrameworkId;
|
|
@@ -73,4 +100,8 @@ export interface Report {
|
|
|
73
100
|
disclaimer: string;
|
|
74
101
|
/** Files the rules actually read (after skipping folders, large and binary files). */
|
|
75
102
|
filesChecked: number;
|
|
103
|
+
/** Present when the repo has a .lintsure/baseline.json. */
|
|
104
|
+
baseline?: BaselineDiff;
|
|
105
|
+
/** The dated record of this run: scope, what applies and why, check points, results by control, counts. */
|
|
106
|
+
record?: import("./record.js").CheckRecord;
|
|
76
107
|
}
|
package/package.json
CHANGED