impeccable 3.5.0 → 3.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/README.npm.md +4 -4
- package/README.repo.md +61 -10
- package/cli/bin/cli.js +6 -0
- package/cli/bin/commands/ignores.mjs +4 -0
- package/cli/bin/commands/skills.mjs +294 -82
- package/cli/engine/browser/injected/index.mjs +192 -11
- package/cli/engine/cli/main.mjs +10 -16
- package/cli/engine/design-system.mjs +339 -11
- package/cli/engine/detect-antipatterns-browser.js +1482 -722
- package/cli/engine/detect-antipatterns.mjs +1 -0
- package/cli/engine/engines/browser/detect-url.mjs +64 -2
- package/cli/engine/engines/regex/detect-text.mjs +580 -29
- package/cli/engine/engines/static-html/css-cascade.mjs +62 -7
- package/cli/engine/engines/static-html/detect-html.mjs +31 -7
- package/cli/engine/node/file-system.mjs +23 -22
- package/cli/engine/registry/antipatterns.mjs +18 -0
- package/cli/engine/rules/checks.mjs +471 -370
- package/cli/engine/shared/color.mjs +474 -2
- package/cli/engine/shared/constants.mjs +17 -2
- package/cli/lib/download-providers.js +8 -0
- package/cli/lib/impeccable-config.mjs +41 -59
- package/package.json +5 -4
|
@@ -35,6 +35,7 @@ export { detectUrl, createBrowserDetector } from './engines/browser/detect-url.m
|
|
|
35
35
|
export { detectText, extractStyleBlocks, extractCSSinJS } from './engines/regex/detect-text.mjs';
|
|
36
36
|
export {
|
|
37
37
|
walkDir,
|
|
38
|
+
hasScannableExtension,
|
|
38
39
|
SCANNABLE_EXTENSIONS,
|
|
39
40
|
SKIP_DIRS,
|
|
40
41
|
buildImportGraph,
|
|
@@ -162,7 +162,68 @@ async function runVisualContrastFallback(page, serializedGroups, options, profil
|
|
|
162
162
|
// Puppeteer detection (for URLs)
|
|
163
163
|
// ---------------------------------------------------------------------------
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
function decodeUrlComponent(value) {
|
|
166
|
+
try {
|
|
167
|
+
return decodeURIComponent(value);
|
|
168
|
+
} catch {
|
|
169
|
+
return value;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function splitScanUrl(url) {
|
|
174
|
+
let parsed;
|
|
175
|
+
try {
|
|
176
|
+
parsed = new URL(url);
|
|
177
|
+
} catch {
|
|
178
|
+
return { href: url, credentials: null };
|
|
179
|
+
}
|
|
180
|
+
if (!parsed.username && !parsed.password) {
|
|
181
|
+
return { href: url, credentials: null };
|
|
182
|
+
}
|
|
183
|
+
const credentials =
|
|
184
|
+
parsed.protocol === 'http:' || parsed.protocol === 'https:'
|
|
185
|
+
? {
|
|
186
|
+
username: decodeUrlComponent(parsed.username),
|
|
187
|
+
password: decodeUrlComponent(parsed.password),
|
|
188
|
+
}
|
|
189
|
+
: null;
|
|
190
|
+
parsed.username = '';
|
|
191
|
+
parsed.password = '';
|
|
192
|
+
return { href: parsed.href, credentials };
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function basicAuthHeader(credentials) {
|
|
196
|
+
return `Basic ${Buffer.from(`${credentials.username}:${credentials.password}`).toString('base64')}`;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// page.authenticate is page-wide: a cross-origin redirect that then 401s
|
|
200
|
+
// would receive these credentials. Attach Authorization only to the scan origin.
|
|
201
|
+
async function applyOriginScopedAuth(page, href, credentials) {
|
|
202
|
+
if (!credentials) return;
|
|
203
|
+
let origin = '';
|
|
204
|
+
try {
|
|
205
|
+
origin = new URL(href).origin;
|
|
206
|
+
} catch {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (!origin) return;
|
|
210
|
+
const header = basicAuthHeader(credentials);
|
|
211
|
+
await page.setRequestInterception(true);
|
|
212
|
+
page.on('request', (request) => {
|
|
213
|
+
let headers;
|
|
214
|
+
try {
|
|
215
|
+
if (new URL(request.url()).origin === origin) {
|
|
216
|
+
headers = { ...request.headers(), authorization: header };
|
|
217
|
+
}
|
|
218
|
+
} catch {
|
|
219
|
+
// invalid request URL: continue without auth
|
|
220
|
+
}
|
|
221
|
+
void request.continue(headers ? { headers } : undefined).catch(() => {});
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async function detectUrl(rawUrl, options = {}) {
|
|
226
|
+
const { href: url, credentials } = splitScanUrl(rawUrl);
|
|
166
227
|
const profile = options?.profile;
|
|
167
228
|
const waitUntil = options?.waitUntil || 'networkidle0';
|
|
168
229
|
const settleMs = Number.isFinite(options?.settleMs) ? options.settleMs : 0;
|
|
@@ -238,6 +299,7 @@ async function detectUrl(url, options = {}) {
|
|
|
238
299
|
ruleId: 'set-viewport',
|
|
239
300
|
target: url,
|
|
240
301
|
}, () => page.setViewport(viewport));
|
|
302
|
+
await applyOriginScopedAuth(page, url, credentials);
|
|
241
303
|
await profileStepAsync(profile, {
|
|
242
304
|
engine: 'browser',
|
|
243
305
|
phase: 'load',
|
|
@@ -369,4 +431,4 @@ async function createBrowserDetector(options = {}) {
|
|
|
369
431
|
};
|
|
370
432
|
}
|
|
371
433
|
|
|
372
|
-
export { runVisualContrastFallback, detectUrl, createBrowserDetector, launchBrowser };
|
|
434
|
+
export { runVisualContrastFallback, detectUrl, createBrowserDetector, launchBrowser, splitScanUrl };
|