eaa-kit 0.7.0 → 0.9.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/README.md +30 -8
- package/dist/astro/index.js +1 -1
- package/dist/audit-CJDCQaFY.js +2 -0
- package/dist/{audit-DRjAY2iY.js → audit-J2jeLo-y.js} +38 -198
- package/dist/{baseline-rtnj3RHB.js → baseline-477B1CZ_.js} +1 -1
- package/dist/baseline-D9ihb-wk.js +2 -0
- package/dist/{baseline-BpE7DbDq.js → baseline-DrFh7joZ.js} +14 -3
- package/dist/baseline-wyJsSIFQ.js +127 -0
- package/dist/{checklist-DDd9jewi.js → checklist-Gx2g3LFC.js} +6 -6
- package/dist/cli/index.js +83 -143
- package/dist/{collect-Cu1q9NTB.js → collect-BJYk7_pJ.js} +1 -1
- package/dist/{command-3r4fht5f.js → command-BGGMf4vn.js} +30 -4
- package/dist/countries-DRTBubeE.js +25 -0
- package/dist/countries-Dg0BdytB.js +156 -0
- package/dist/{coverage-n1X9CkiG.js → coverage-GvaMpV64.js} +1 -1
- package/dist/{coverage-cb5kPp48.js → coverage-zdzgSKjz.js} +1 -1
- package/dist/{crawl-BHkJmUkA.js → crawl-DwdqiljK.js} +5 -3
- package/dist/{load-BaWMa-G_.js → define-Ctf2uOEh.js} +41 -94
- package/dist/eleventy/index.js +1 -1
- package/dist/entry-CjqjrUBY.js +174 -0
- package/dist/{html-BIxxF3FC.js → html-whingnfj.js} +6 -4
- package/dist/index.d.ts +42 -5
- package/dist/index.js +3 -2
- package/dist/init-CPbFVMuk.js +293 -0
- package/dist/{json-CrQmoTj6.js → json-CyLmvF5P.js} +1 -1
- package/dist/{json-Bus6YhxB.js → json-SGCgxSPT.js} +1 -1
- package/dist/load-CH-ltdlq.js +99 -0
- package/dist/load-D7lBeOsq.js +2 -0
- package/dist/nuxt/index.js +1 -1
- package/dist/pages-DxY5Z0gl.js +300 -0
- package/dist/{project-MFrXcw1M.js → project-BLFdCbOq.js} +1 -1
- package/dist/{project-CzOnkLH6.js → project-v2PoRw70.js} +18 -1
- package/dist/{remediation-C0klJblu.js → remediation-Bbs4KcX1.js} +18 -1
- package/dist/{render-C1sUZZI_.js → render-C6zYfaba.js} +29 -5
- package/dist/{review-CdMK2GpQ.js → review-Bz0fO9_I.js} +9 -1
- package/dist/{review-DIbOTmOM.js → review-a-2ghjQ5.js} +1 -1
- package/dist/{routes-CmdRUuOs.js → routes-CSctpS1P.js} +1 -1
- package/dist/{run-DrS0Komf.js → run-DzVEOkiF.js} +1 -1
- package/dist/{sarif-BNCE0PNT.js → sarif-9BAgNiOa.js} +3 -2
- package/dist/site-BHMtf3q2.js +72 -0
- package/dist/start-DzOM0p6I.js +101 -0
- package/dist/statement/templates/be.de.md +148 -0
- package/dist/statement/templates/be.en.md +142 -0
- package/dist/statement/templates/be.fr.md +146 -0
- package/dist/statement/templates/be.nl.md +147 -0
- package/dist/statement/templates/cz.cs.md +137 -0
- package/dist/statement/templates/cz.en.md +139 -0
- package/dist/statement/templates/dk.da.md +141 -0
- package/dist/statement/templates/dk.en.md +141 -0
- package/dist/statement/templates/fi.en.md +139 -0
- package/dist/statement/templates/fi.fi.md +141 -0
- package/dist/statement/templates/ie.en.md +144 -0
- package/dist/statement/templates/pl.en.md +143 -0
- package/dist/statement/templates/pl.pl.md +144 -0
- package/dist/statement/templates/pt.en.md +142 -0
- package/dist/statement/templates/pt.pt.md +145 -0
- package/dist/statement/templates/se.en.md +139 -0
- package/dist/statement/templates/se.sv.md +142 -0
- package/dist/vite/index.js +1 -1
- package/dist/watch-B2RoUbo0.js +122 -0
- package/dist/webpack/index.js +1 -1
- package/dist/{worksheet-BIxMtbUd.js → worksheet-B_kQ1pxq.js} +1 -1
- package/package.json +2 -2
- package/dist/audit-Bwm1xBdJ.js +0 -2
- package/dist/init-DrFfzjvm.js +0 -119
- package/dist/load-n62iXDq_.js +0 -2
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { n as count } from "./text-BF1LHMiV.js";
|
|
2
|
+
import { c as nextStep, d as warn, l as note, o as fail, s as failWith } from "./command-BGGMf4vn.js";
|
|
3
|
+
import { i as holdsHtml, n as collectPages, r as emptyDirectoryHint, t as BuildDirectoryError } from "./collect-BJYk7_pJ.js";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
//#region src/cli/pages.ts
|
|
6
|
+
/**
|
|
7
|
+
* Collect the pages to audit, reporting to stderr on the way.
|
|
8
|
+
*
|
|
9
|
+
* Returns undefined when there is nothing to audit, having already explained
|
|
10
|
+
* why. Every caller turns that into exit 2 — a run that reached no verdict,
|
|
11
|
+
* which is not the same as a clean one.
|
|
12
|
+
*/
|
|
13
|
+
async function resolvePages(directory, options = {}) {
|
|
14
|
+
if (directory === void 0 && options.url === void 0) return resolveAutomatically(options);
|
|
15
|
+
if (options.url !== void 0) {
|
|
16
|
+
const crawled = await crawlPages(options.url, options);
|
|
17
|
+
if (!crawled) return void 0;
|
|
18
|
+
if (crawled.pages.length === 0) {
|
|
19
|
+
warn(`No pages could be fetched from ${options.url}`);
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
pages: crawled.pages,
|
|
24
|
+
origin: crawled.origin,
|
|
25
|
+
label: options.url,
|
|
26
|
+
completeness: crawled.completeness
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const cwd = options.cwd ?? process.cwd();
|
|
30
|
+
const shown = options.label ?? directory;
|
|
31
|
+
const unreachable = [];
|
|
32
|
+
let pages;
|
|
33
|
+
try {
|
|
34
|
+
pages = await collectPages(directory, {
|
|
35
|
+
...options.include ? { include: options.include } : {},
|
|
36
|
+
...options.exclude ? { exclude: options.exclude } : {},
|
|
37
|
+
onUnreadable: (relativePath, reason) => unreachable.push({
|
|
38
|
+
location: relativePath,
|
|
39
|
+
reason
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
} catch (cause) {
|
|
43
|
+
if (!(cause instanceof BuildDirectoryError)) throw cause;
|
|
44
|
+
failWith(cause);
|
|
45
|
+
note(await emptyDirectoryHint(shown, cwd));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
if (pages.length === 0) {
|
|
49
|
+
if ((options.include !== void 0 || options.exclude !== void 0) && await holdsHtml(directory)) {
|
|
50
|
+
warn(`No page in ${shown} matched the filters, so nothing was audited.`);
|
|
51
|
+
if (options.include !== void 0) note(` --include ${options.include.join(" ")}`);
|
|
52
|
+
if (options.exclude !== void 0) note(` --exclude ${options.exclude.join(" ")}`);
|
|
53
|
+
note(" Patterns are relative to the audited directory, with POSIX separators.");
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
warn(await emptyDirectoryHint(shown, cwd));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
warnUnmeasured(unreachable, "file", "readable");
|
|
60
|
+
return {
|
|
61
|
+
pages,
|
|
62
|
+
directory,
|
|
63
|
+
label: shown,
|
|
64
|
+
completeness: {
|
|
65
|
+
discovery: "directory",
|
|
66
|
+
collected: pages.length,
|
|
67
|
+
unreachable,
|
|
68
|
+
truncated: false
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Name what was missed, up to ten of them, and count the rest.
|
|
74
|
+
*
|
|
75
|
+
* Both collectors need this and neither may skip it: a file that could not be
|
|
76
|
+
* read and a URL that could not be fetched are pages with no verdict, and a run
|
|
77
|
+
* that mentioned neither would report the rest of the site as though it were
|
|
78
|
+
* the site. Ten because the point is to make the problem recognisable, and two
|
|
79
|
+
* hundred failures usually have the one reason the first few show — the count
|
|
80
|
+
* that follows is what says the list was cut.
|
|
81
|
+
*/
|
|
82
|
+
function warnUnmeasured(missed, noun, reached) {
|
|
83
|
+
if (missed.length === 0) return;
|
|
84
|
+
warn(`${count(missed.length, noun)} ${missed.length === 1 ? "was" : "were"} not ${reached}, and so not audited:`);
|
|
85
|
+
for (const item of missed.slice(0, 10)) note(` ${item.location} — ${item.reason}`);
|
|
86
|
+
if (missed.length > 10) note(` …and ${missed.length - 10} more`);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Fetch the pages of a running site, reporting what happened on the way.
|
|
90
|
+
*
|
|
91
|
+
* Returns undefined when the crawl could not start, which the caller turns into
|
|
92
|
+
* exit 2 — a run that reached no verdict, not a clean one.
|
|
93
|
+
*/
|
|
94
|
+
async function crawlPages(url, options) {
|
|
95
|
+
const { collapsedOnto, crawlSite, CrawlError, parseEntryUrl } = await import("./crawl-DwdqiljK.js");
|
|
96
|
+
let entry;
|
|
97
|
+
try {
|
|
98
|
+
entry = parseEntryUrl(url, options.allowRemote ?? false);
|
|
99
|
+
} catch (cause) {
|
|
100
|
+
if (cause instanceof CrawlError) {
|
|
101
|
+
failWith(cause);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
throw cause;
|
|
105
|
+
}
|
|
106
|
+
note(`Crawling ${entry.origin}…`);
|
|
107
|
+
const followed = await followEntry(entry, options);
|
|
108
|
+
if (followed === void 0) return void 0;
|
|
109
|
+
entry = followed.entry;
|
|
110
|
+
const result = await crawlSite(entry, {
|
|
111
|
+
...options.allowRemote ? { allowRemote: true } : {},
|
|
112
|
+
...options.ignoreRobots ? { ignoreRobots: true } : {},
|
|
113
|
+
...options.sitemap === void 0 ? {} : { sitemap: options.sitemap },
|
|
114
|
+
...options.maxPages === void 0 ? {} : { maxPages: options.maxPages },
|
|
115
|
+
...options.maxDepth === void 0 ? {} : { maxDepth: options.maxDepth },
|
|
116
|
+
...options.timeoutMs === void 0 ? {} : { timeoutMs: options.timeoutMs },
|
|
117
|
+
...options.headers === void 0 ? {} : { headers: options.headers },
|
|
118
|
+
...options.fetchImpl === void 0 ? {} : { fetchImpl: options.fetchImpl }
|
|
119
|
+
});
|
|
120
|
+
if (result.pages.length === 0 && result.failures.length > 0) {
|
|
121
|
+
fail(`Could not fetch ${entry.href} (${result.failures[0]?.reason})`);
|
|
122
|
+
note(" Is the site running at that address?");
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const found = result.discovery === "sitemap" ? "sitemap.xml and links" : "links";
|
|
126
|
+
note(`Found ${count(result.pages.length, "page")} from ${found}`);
|
|
127
|
+
const failed = result.failures.map((failure) => ({
|
|
128
|
+
location: failure.url,
|
|
129
|
+
reason: failure.reason
|
|
130
|
+
}));
|
|
131
|
+
warnUnmeasured(failed, "URL", "fetched");
|
|
132
|
+
if (result.truncated) warn(`Stopped at ${count(result.pages.length, "page")}; the site has more. Raise --max-pages to go further.`);
|
|
133
|
+
const collapsed = collapsedOnto(result);
|
|
134
|
+
const { hasPasswordField } = await import("./entry-CjqjrUBY.js");
|
|
135
|
+
const landedOn = collapsed[0]?.landedOn ?? "";
|
|
136
|
+
const signInForm = collapsed.length > 0 && result.pages.some((page) => page.absolutePath === landedOn && hasPasswordField(page.html));
|
|
137
|
+
if (collapsed.length > 0) {
|
|
138
|
+
if (signInForm) warn(`Every page requested answered at ${landedOn}, which has a password field on it: a sign-in page stands in front of the site.`);
|
|
139
|
+
else {
|
|
140
|
+
warn(`Every page requested answered at ${landedOn}, which is not where it was asked.`);
|
|
141
|
+
note(" A sign-in page in front of the site looks like this, and so does a one-page site.");
|
|
142
|
+
}
|
|
143
|
+
nextStep({
|
|
144
|
+
command: `eaa-kit audit --url ${entry.href} --basic-auth user:password`,
|
|
145
|
+
why: "or --header \"Cookie: …\" with a signed-in session; neither is written into a report"
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
pages: result.pages,
|
|
150
|
+
origin: result.origin,
|
|
151
|
+
completeness: {
|
|
152
|
+
discovery: result.discovery,
|
|
153
|
+
collected: result.pages.length,
|
|
154
|
+
unreachable: [...failed, ...collapsed.map((redirect) => ({
|
|
155
|
+
location: redirect.requested,
|
|
156
|
+
reason: signInForm ? `answered at ${redirect.landedOn} instead, a sign-in page, so this page was not audited` : `answered at ${redirect.landedOn} instead, so this page was not audited`
|
|
157
|
+
}))],
|
|
158
|
+
truncated: result.truncated,
|
|
159
|
+
...followed.redirect === void 0 ? {} : { entryRedirect: followed.redirect }
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Where the crawl should start, once the entry's redirects are known.
|
|
165
|
+
*
|
|
166
|
+
* Returns undefined when the run must stop, having said why and what to type:
|
|
167
|
+
* a sign-in wall, or a redirect to another site nobody agreed to follow. Those
|
|
168
|
+
* are the two ways a run can audit something other than what it was sent to,
|
|
169
|
+
* and each one ends here rather than in a report about the wrong pages.
|
|
170
|
+
*/
|
|
171
|
+
async function followEntry(entry, options) {
|
|
172
|
+
const { describeSignIn, isSameSite, probeEntry } = await import("./entry-CjqjrUBY.js");
|
|
173
|
+
const { CrawlError, DEFAULT_REQUEST_TIMEOUT_MS, MAX_BODY_BYTES, parseEntryUrl } = await import("./crawl-DwdqiljK.js");
|
|
174
|
+
const probe = await probeEntry(entry, {
|
|
175
|
+
timeoutMs: options.timeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS,
|
|
176
|
+
maxBodyBytes: MAX_BODY_BYTES,
|
|
177
|
+
...options.headers === void 0 ? {} : { headers: options.headers },
|
|
178
|
+
...options.fetchImpl === void 0 ? {} : { fetchImpl: options.fetchImpl }
|
|
179
|
+
});
|
|
180
|
+
if (probe.error !== void 0 && probe.hops.length === 0) return { entry };
|
|
181
|
+
if (probe.error !== void 0) {
|
|
182
|
+
fail(`${entry.href} did not settle on a page: ${probe.error}`);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (probe.signIn !== void 0) {
|
|
186
|
+
const at = probe.final.href;
|
|
187
|
+
fail(`${entry.href} is behind a sign-in wall: ${describeSignIn(probe.signIn, at)}.`);
|
|
188
|
+
note(options.headers !== void 0 ? " The credentials that were sent were not accepted, so nothing was audited." : probe.signIn === "http-401" || probe.signIn === "http-403" ? " Nothing was audited: there is no page to audit until the site lets the run in." : " eaa-kit will not audit a sign-in form as though it were the site, so nothing was audited.");
|
|
189
|
+
nextStep(probe.signIn === "http-401" ? {
|
|
190
|
+
command: `eaa-kit audit --url ${entry.href} --basic-auth user:password`,
|
|
191
|
+
why: "send the credentials it asks for; they are never written into a report"
|
|
192
|
+
} : {
|
|
193
|
+
command: `eaa-kit audit --url ${entry.href} --header "Cookie: <session>"`,
|
|
194
|
+
why: "send a signed-in session, copied from your browser; never written into a report"
|
|
195
|
+
});
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const destination = probe.final;
|
|
199
|
+
if (destination.origin === entry.origin) return { entry };
|
|
200
|
+
const statuses = probe.hops.slice(0, -1).map((hop) => hop.status);
|
|
201
|
+
const chain = `${statuses.join(" → ")}`;
|
|
202
|
+
const sameSite = isSameSite(entry, destination);
|
|
203
|
+
const mode = options.redirects ?? "ask";
|
|
204
|
+
let because;
|
|
205
|
+
if (mode !== "stop" && sameSite) because = "same-site";
|
|
206
|
+
else if (mode === "follow") because = "flag";
|
|
207
|
+
else if (mode === "ask") {
|
|
208
|
+
const confirm = options.confirm ?? terminalConfirm();
|
|
209
|
+
if (confirm !== void 0 && await confirm(`${entry.href} redirects to ${destination.href} (${chain}). Audit ${destination.href} instead?`)) because = "prompt";
|
|
210
|
+
}
|
|
211
|
+
if (because === void 0) {
|
|
212
|
+
fail(`${entry.href} redirects to ${destination.href} (${chain}), ${sameSite ? "the same site at another address" : "which is a different site"}, so nothing was audited.`);
|
|
213
|
+
note(mode === "stop" ? " --redirects stop was asked for, so the redirect was not followed." : " eaa-kit only follows a redirect to another site when you agree to it: otherwise the\n report would describe a site you did not name.");
|
|
214
|
+
const remote = options.allowRemote ? " --allow-remote" : "";
|
|
215
|
+
nextStep({
|
|
216
|
+
command: `eaa-kit audit --url ${destination.href}${remote}`,
|
|
217
|
+
why: "audit the address it leads to"
|
|
218
|
+
});
|
|
219
|
+
nextStep({
|
|
220
|
+
command: `eaa-kit audit --url ${entry.href}${remote} --redirects follow`,
|
|
221
|
+
why: "or follow it on every run, and have each report say so"
|
|
222
|
+
});
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
let target;
|
|
226
|
+
try {
|
|
227
|
+
target = parseEntryUrl(destination.href, options.allowRemote ?? false);
|
|
228
|
+
} catch (cause) {
|
|
229
|
+
if (cause instanceof CrawlError) {
|
|
230
|
+
fail(`${entry.href} redirects to ${destination.href}.`);
|
|
231
|
+
failWith(cause);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
throw cause;
|
|
235
|
+
}
|
|
236
|
+
warn(`${entry.href} redirects to ${target.href} (${chain}). Auditing ${target.href}; every report says so.`);
|
|
237
|
+
return {
|
|
238
|
+
entry: target,
|
|
239
|
+
redirect: {
|
|
240
|
+
requested: entry.href,
|
|
241
|
+
auditedFrom: target.href,
|
|
242
|
+
statuses,
|
|
243
|
+
followedBecause: because
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
/** A yes/no question on the terminal, or nothing when there is no terminal to ask at. */
|
|
248
|
+
function terminalConfirm() {
|
|
249
|
+
if (process.stdin.isTTY !== true || process.stderr.isTTY !== true) return void 0;
|
|
250
|
+
return async (question) => {
|
|
251
|
+
const { createInterface } = await import("node:readline/promises");
|
|
252
|
+
const rl = createInterface({
|
|
253
|
+
input: process.stdin,
|
|
254
|
+
output: process.stderr
|
|
255
|
+
});
|
|
256
|
+
try {
|
|
257
|
+
const answer = await rl.question(`${question} (y/N) `);
|
|
258
|
+
return /^y(es)?$/i.test(answer.trim());
|
|
259
|
+
} finally {
|
|
260
|
+
rl.close();
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* No directory and no URL: work out what this project needs.
|
|
266
|
+
*
|
|
267
|
+
* The point is that `eaa-kit audit` on its own does something useful. Anything
|
|
268
|
+
* this starts is handed back as `cleanup` so the caller can stop it once the
|
|
269
|
+
* report is written.
|
|
270
|
+
*/
|
|
271
|
+
async function resolveAutomatically(options) {
|
|
272
|
+
const cwd = options.cwd ?? process.cwd();
|
|
273
|
+
const { autoDetectSource } = await import("./project-BLFdCbOq.js");
|
|
274
|
+
const detected = await autoDetectSource(cwd, {
|
|
275
|
+
...options.noBuild ? { noBuild: true } : {},
|
|
276
|
+
onStep: note
|
|
277
|
+
});
|
|
278
|
+
if (detected?.directory !== void 0) return resolvePages(detected.directory, {
|
|
279
|
+
...options,
|
|
280
|
+
label: path.relative(cwd, detected.directory) || "."
|
|
281
|
+
});
|
|
282
|
+
if (detected?.url !== void 0) {
|
|
283
|
+
const resolved = await resolvePages(void 0, {
|
|
284
|
+
...options,
|
|
285
|
+
url: detected.url
|
|
286
|
+
});
|
|
287
|
+
if (resolved === void 0) {
|
|
288
|
+
await detected.cleanup?.();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
return {
|
|
292
|
+
...resolved,
|
|
293
|
+
...detected.cleanup ? { cleanup: detected.cleanup } : {}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
await detected?.cleanup?.();
|
|
297
|
+
warn(await emptyDirectoryHint("./dist", cwd));
|
|
298
|
+
}
|
|
299
|
+
//#endregion
|
|
300
|
+
export { resolvePages as t };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as readPackageJson, t as autoDetectSource } from "./project-
|
|
1
|
+
import { i as readPackageJson, t as autoDetectSource } from "./project-v2PoRw70.js";
|
|
2
2
|
export { autoDetectSource, readPackageJson };
|
|
@@ -71,6 +71,14 @@ async function findBuildOutput(cwd) {
|
|
|
71
71
|
})).length > 0) return directory;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
/** Whether a folder has an HTML file directly in it, not only somewhere below. */
|
|
75
|
+
async function holdsTopLevelHtml(cwd) {
|
|
76
|
+
return (await glob(["*.html", "*.htm"], {
|
|
77
|
+
cwd,
|
|
78
|
+
onlyFiles: true,
|
|
79
|
+
dot: false
|
|
80
|
+
})).length > 0;
|
|
81
|
+
}
|
|
74
82
|
/**
|
|
75
83
|
* How to invoke a package-manager script on this platform.
|
|
76
84
|
*
|
|
@@ -232,7 +240,16 @@ async function autoDetectSource(cwd, options = {}) {
|
|
|
232
240
|
step(`${detected.framework.name} renders on a server and writes no HTML to disk`);
|
|
233
241
|
return { steps };
|
|
234
242
|
}
|
|
235
|
-
if (pkg === void 0)
|
|
243
|
+
if (pkg === void 0) {
|
|
244
|
+
if (detected === void 0 && await holdsTopLevelHtml(cwd)) {
|
|
245
|
+
step("Found hand-written HTML in this folder");
|
|
246
|
+
return {
|
|
247
|
+
directory: cwd,
|
|
248
|
+
steps
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
236
253
|
const scripts = pkg.scripts ?? {};
|
|
237
254
|
if (options.noBuild) return void 0;
|
|
238
255
|
if (scripts["build"] !== void 0) {
|
|
@@ -32,6 +32,23 @@ function reusedPart(completeness) {
|
|
|
32
32
|
return `${completeness.reused} ${pages} unchanged since the last run, so the earlier result was reused`;
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
+
* Where a followed entry redirect took the run, in one sentence every format
|
|
36
|
+
* prints. Undefined when the run went where it was sent.
|
|
37
|
+
*/
|
|
38
|
+
function redirectPart(completeness) {
|
|
39
|
+
const redirect = completeness.entryRedirect;
|
|
40
|
+
if (redirect === void 0) return void 0;
|
|
41
|
+
return `${redirect.requested} redirected to ${redirect.auditedFrom} (${redirect.statuses.join(" → ")}; ${redirectReason(redirect)}), so this report is about ${redirect.auditedFrom}`;
|
|
42
|
+
}
|
|
43
|
+
/** Why a redirect was followed, in words. */
|
|
44
|
+
function redirectReason(redirect) {
|
|
45
|
+
return {
|
|
46
|
+
"same-site": "the same site at another address",
|
|
47
|
+
flag: "followed because --redirects follow was set",
|
|
48
|
+
prompt: "followed because it was approved when asked"
|
|
49
|
+
}[redirect.followedBecause];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
35
52
|
* What was missed, as phrases both reports print.
|
|
36
53
|
*
|
|
37
54
|
* Separate clauses rather than one total, for the same reason the coverage
|
|
@@ -349,4 +366,4 @@ function remediationFor(ruleId, framework) {
|
|
|
349
366
|
};
|
|
350
367
|
}
|
|
351
368
|
//#endregion
|
|
352
|
-
export { isShared as a, missedParts as c, groupIssues as i,
|
|
369
|
+
export { isShared as a, missedParts as c, runCompleteness as d, groupIssues as i, redirectPart as l, blindRules as n, issueTotals as o, coverageParts as r, discoveryLabel as s, remediationFor as t, reusedPart as u };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as IMPACT_LEVELS, o as impactRank } from "./impact-luGCnN8F.js";
|
|
2
2
|
import { c as nullable, h as string, l as number, m as safeParse, p as record, s as isoDateTime, t as array, u as object, y as withDefault } from "./schema-DJSF4K05.js";
|
|
3
|
-
import {
|
|
3
|
+
import { s as STATEMENT_LOCALES } from "./define-Ctf2uOEh.js";
|
|
4
4
|
import { n as isDirectory } from "./fs-BmPtmFke.js";
|
|
5
5
|
import { a as isoDate, i as escapeText, n as count, r as escapeAttribute, s as standardsReference } from "./text-BF1LHMiV.js";
|
|
6
6
|
import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
|
|
@@ -19,7 +19,12 @@ import { fileURLToPath } from "node:url";
|
|
|
19
19
|
* it — nothing is emitted at all.
|
|
20
20
|
*/
|
|
21
21
|
var StatementError = class extends Error {
|
|
22
|
+
next;
|
|
22
23
|
name = "StatementError";
|
|
24
|
+
constructor(message, next) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.next = next;
|
|
27
|
+
}
|
|
23
28
|
};
|
|
24
29
|
//#endregion
|
|
25
30
|
//#region src/statement/evidence.ts
|
|
@@ -161,7 +166,10 @@ function summariseAuditReport(value, source = "audit report") {
|
|
|
161
166
|
const result = safeParse(reportSchema, value);
|
|
162
167
|
if (!result.success) throw new StatementError(`${source} is not an eaa-kit JSON report (${result.error.issues.map((issue) => `${issue.path.join(".") || "document"}: ${issue.message}`).slice(0, 5).join("; ")})`);
|
|
163
168
|
const report = result.data;
|
|
164
|
-
if (report.schemaVersion !== 2) throw new StatementError(`${source} has schemaVersion ${report.schemaVersion}; this version of eaa-kit reads 2
|
|
169
|
+
if (report.schemaVersion !== 2) throw new StatementError(`${source} has schemaVersion ${report.schemaVersion}; this version of eaa-kit reads 2`, {
|
|
170
|
+
command: `eaa-kit audit --format json --output ${source}`,
|
|
171
|
+
why: "write it again with this version"
|
|
172
|
+
});
|
|
165
173
|
const byRule = /* @__PURE__ */ new Map();
|
|
166
174
|
const rules = new Map(Object.entries(report.rules));
|
|
167
175
|
for (const page of report.pages) for (const violation of page.violations) {
|
|
@@ -199,7 +207,10 @@ async function readAuditReport(file, cwd = process.cwd()) {
|
|
|
199
207
|
try {
|
|
200
208
|
raw = await readFile(target, "utf8");
|
|
201
209
|
} catch {
|
|
202
|
-
throw new StatementError(`Could not read the audit report at ${file}
|
|
210
|
+
throw new StatementError(`Could not read the audit report at ${file}`, {
|
|
211
|
+
command: `eaa-kit audit --format json --output ${file}`,
|
|
212
|
+
why: "write the report the statement reads its barriers from"
|
|
213
|
+
});
|
|
203
214
|
}
|
|
204
215
|
let value;
|
|
205
216
|
try {
|
|
@@ -677,12 +688,18 @@ function reasonScope(reason) {
|
|
|
677
688
|
* 20 August 2026, not August 20, 2026, in a European legal document.
|
|
678
689
|
*/
|
|
679
690
|
const DATE_LOCALES = {
|
|
691
|
+
cs: "cs-CZ",
|
|
692
|
+
da: "da-DK",
|
|
680
693
|
de: "de-AT",
|
|
681
694
|
en: "en-GB",
|
|
682
695
|
es: "es-ES",
|
|
696
|
+
fi: "fi-FI",
|
|
683
697
|
fr: "fr-FR",
|
|
684
698
|
it: "it-IT",
|
|
685
|
-
nl: "nl-NL"
|
|
699
|
+
nl: "nl-NL",
|
|
700
|
+
pl: "pl-PL",
|
|
701
|
+
pt: "pt-PT",
|
|
702
|
+
sv: "sv-SE"
|
|
686
703
|
};
|
|
687
704
|
/**
|
|
688
705
|
* 2026-08-20 becomes 20. August 2026 or 20 August 2026.
|
|
@@ -733,7 +750,14 @@ async function loadTemplate(country, locale) {
|
|
|
733
750
|
const templates = (await readdir(directory)).filter((entry) => entry.endsWith(".md")).map((entry) => entry.replace(/\.md$/, "")).sort();
|
|
734
751
|
const prefix = `${country.toLowerCase()}.`;
|
|
735
752
|
const forCountry = templates.filter((entry) => entry.startsWith(prefix)).map((entry) => entry.slice(prefix.length));
|
|
736
|
-
|
|
753
|
+
const first = forCountry[0];
|
|
754
|
+
throw new StatementError(first !== void 0 ? `No ${country} statement in ${locale}. ${country} has: ${forCountry.join(", ")}` : `No statement template for ${name}. Available: ${templates.join(", ")}`, first !== void 0 ? {
|
|
755
|
+
command: `eaa-kit statement --lang ${first}`,
|
|
756
|
+
why: `the ${country} statement in ${first}`
|
|
757
|
+
} : {
|
|
758
|
+
command: "eaa-kit countries",
|
|
759
|
+
why: "the countries a statement can be written for"
|
|
760
|
+
});
|
|
737
761
|
}
|
|
738
762
|
}
|
|
739
763
|
/**
|
|
@@ -35,7 +35,12 @@ const reviewSchema = object({
|
|
|
35
35
|
criteria: withDefault(record(entrySchema), () => ({}))
|
|
36
36
|
});
|
|
37
37
|
var ReviewError = class extends Error {
|
|
38
|
+
next;
|
|
38
39
|
name = "ReviewError";
|
|
40
|
+
constructor(message, next) {
|
|
41
|
+
super(message);
|
|
42
|
+
this.next = next;
|
|
43
|
+
}
|
|
39
44
|
};
|
|
40
45
|
/**
|
|
41
46
|
* What the record says about one criterion, and whether it counts.
|
|
@@ -135,7 +140,10 @@ async function readReview(file, cwd = process.cwd()) {
|
|
|
135
140
|
try {
|
|
136
141
|
raw = await readFile(target, "utf8");
|
|
137
142
|
} catch {
|
|
138
|
-
throw new ReviewError(`Could not read the review record at ${file}
|
|
143
|
+
throw new ReviewError(`Could not read the review record at ${file}`, {
|
|
144
|
+
command: `eaa-kit checklist --record ${file}`,
|
|
145
|
+
why: "write the record and the worksheet that goes with it"
|
|
146
|
+
});
|
|
139
147
|
}
|
|
140
148
|
let value;
|
|
141
149
|
try {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as blankReview, c as readReview, d as writeReview, i as answeredCount, r as ReviewError } from "./review-
|
|
1
|
+
import { a as blankReview, c as readReview, d as writeReview, i as answeredCount, r as ReviewError } from "./review-Bz0fO9_I.js";
|
|
2
2
|
export { ReviewError, answeredCount, blankReview, readReview, writeReview };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { i as toPosix, n as isDirectory } from "./fs-BmPtmFke.js";
|
|
2
2
|
import { i as detectFramework } from "./frameworks-B4ClIJgE.js";
|
|
3
|
-
import { i as readPackageJson } from "./project-
|
|
3
|
+
import { i as readPackageJson } from "./project-v2PoRw70.js";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { glob } from "tinyglobby";
|
|
6
6
|
//#region src/audit/routes.ts
|
|
@@ -39,7 +39,7 @@ async function auditBuild(directory, options, logger) {
|
|
|
39
39
|
logger.info("skipped (enabled: false)");
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
const { runAuditCommand } = await import("./audit-
|
|
42
|
+
const { runAuditCommand } = await import("./audit-CJDCQaFY.js");
|
|
43
43
|
const { exitCode } = await runAuditCommand(directory, auditOptions);
|
|
44
44
|
if (exitCode === 0) {
|
|
45
45
|
logger.info("no violations at or above the threshold");
|
|
@@ -3,7 +3,7 @@ import { s as standardsReference } from "./text-BF1LHMiV.js";
|
|
|
3
3
|
import { t as TOOL_VERSION } from "./version-B3v4rNoG.js";
|
|
4
4
|
import { t as elementFingerprint } from "./fingerprint-BjYV_0F7.js";
|
|
5
5
|
import { m as uniqueRuleOutcomes, s as findingElements, u as runEngine } from "./result-B7_zVxAX.js";
|
|
6
|
-
import { t as buildCoverage } from "./coverage-
|
|
6
|
+
import { t as buildCoverage } from "./coverage-zdzgSKjz.js";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
//#region src/audit/report/sarif.ts
|
|
9
9
|
const SARIF_VERSION = "2.1.0";
|
|
@@ -158,7 +158,8 @@ function summaryProperties(audits, completeness, review) {
|
|
|
158
158
|
pagesReused: completeness.reused,
|
|
159
159
|
pagesErrored: completeness.errored,
|
|
160
160
|
pagesUnreachable: completeness.unreachable.length,
|
|
161
|
-
truncated: completeness.truncated
|
|
161
|
+
truncated: completeness.truncated,
|
|
162
|
+
...completeness.entryRedirect === void 0 ? {} : { entryRedirect: completeness.entryRedirect }
|
|
162
163
|
} : {}
|
|
163
164
|
};
|
|
164
165
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { glob } from "tinyglobby";
|
|
4
|
+
//#region src/audit/site.ts
|
|
5
|
+
/** The home page, or failing that the first page in path order. */
|
|
6
|
+
async function homePage(directory) {
|
|
7
|
+
for (const name of ["index.html", "index.htm"]) {
|
|
8
|
+
const candidate = path.join(directory, name);
|
|
9
|
+
try {
|
|
10
|
+
return await readFile(candidate, "utf8");
|
|
11
|
+
} catch {}
|
|
12
|
+
}
|
|
13
|
+
const first = (await glob(["**/*.html", "**/*.htm"], {
|
|
14
|
+
cwd: directory,
|
|
15
|
+
ignore: ["**/node_modules/**"],
|
|
16
|
+
onlyFiles: true,
|
|
17
|
+
dot: false
|
|
18
|
+
})).sort()[0];
|
|
19
|
+
if (first === void 0) return void 0;
|
|
20
|
+
try {
|
|
21
|
+
return await readFile(path.join(directory, first), "utf8");
|
|
22
|
+
} catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function readSiteFacts(directory) {
|
|
27
|
+
const html = await homePage(directory);
|
|
28
|
+
if (html === void 0) return {};
|
|
29
|
+
return siteFactsFrom(html);
|
|
30
|
+
}
|
|
31
|
+
function siteFactsFrom(html) {
|
|
32
|
+
const facts = {};
|
|
33
|
+
const htmlTag = /<html\b[^>]*>/i.exec(html)?.[0];
|
|
34
|
+
const lang = htmlTag === void 0 ? void 0 : attribute(htmlTag, "lang");
|
|
35
|
+
if (lang !== void 0 && /^[a-z]{2,3}(-[a-z0-9]{2,8})*$/i.test(lang)) facts.lang = lang;
|
|
36
|
+
const url = canonicalUrl(html);
|
|
37
|
+
if (url !== void 0) facts.url = url;
|
|
38
|
+
const title = /<title\b[^>]*>([^<]*)<\/title>/i.exec(html)?.[1]?.trim();
|
|
39
|
+
if (title !== void 0 && title !== "") facts.title = decodeEntities(title);
|
|
40
|
+
return facts;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The address the site gives for itself. Only an absolute http(s) URL counts:
|
|
44
|
+
* a relative canonical tells you nothing about where the site lives.
|
|
45
|
+
*/
|
|
46
|
+
function canonicalUrl(html) {
|
|
47
|
+
const candidates = [];
|
|
48
|
+
for (const tag of html.match(/<link\b[^>]*>/gi) ?? []) {
|
|
49
|
+
const rel = attribute(tag, "rel")?.toLowerCase().split(/\s+/);
|
|
50
|
+
const href = attribute(tag, "href");
|
|
51
|
+
if (rel?.includes("canonical") && href !== void 0) candidates.push(href);
|
|
52
|
+
}
|
|
53
|
+
for (const tag of html.match(/<meta\b[^>]*>/gi) ?? []) {
|
|
54
|
+
const content = attribute(tag, "content");
|
|
55
|
+
if (attribute(tag, "property") === "og:url" && content !== void 0) candidates.push(content);
|
|
56
|
+
}
|
|
57
|
+
for (const candidate of candidates) try {
|
|
58
|
+
const url = new URL(decodeEntities(candidate));
|
|
59
|
+
if (url.protocol === "http:" || url.protocol === "https:") return url.origin;
|
|
60
|
+
} catch {}
|
|
61
|
+
}
|
|
62
|
+
function attribute(tag, name) {
|
|
63
|
+
const match = new RegExp(`\\s${name}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i").exec(tag);
|
|
64
|
+
const value = match?.[1] ?? match?.[2] ?? match?.[3];
|
|
65
|
+
return value === void 0 ? void 0 : value.trim();
|
|
66
|
+
}
|
|
67
|
+
/** The five entities a title or URL realistically carries. */
|
|
68
|
+
function decodeEntities(text) {
|
|
69
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, "\"").replace(/'|'/g, "'");
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { readSiteFacts };
|