loadwise 0.9.0 → 0.10.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 +88 -19
- package/agent/hooks/check-edited-file.mjs +146 -28
- package/dist/bin/github-action.js +3 -74
- package/dist/bin/loadwise.js +12 -12
- package/dist/lib/accessibility/aria-tables.js +10 -6
- package/dist/lib/accessibility/document-reference-rules.js +13 -3
- package/dist/lib/accessibility/jsx-elements.js +34 -16
- package/dist/lib/accessibility/native-interactive.js +51 -13
- package/dist/lib/accessibility/rules.js +4 -2
- package/dist/lib/accessibility/site-fixes/aria-typo.js +65 -0
- package/dist/lib/accessibility/site-fixes/html-language.js +45 -9
- package/dist/lib/accessibility/template-elements.js +5 -3
- package/dist/lib/editor/actions.js +15 -9
- package/dist/lib/editor/diagnostics.js +110 -107
- package/dist/lib/editor/finding-comparison.js +4 -25
- package/dist/lib/editor/hover-markdown.js +104 -0
- package/dist/lib/editor/inline-fix.js +50 -0
- package/dist/lib/editor/inline-recommendation.js +27 -0
- package/dist/lib/editor/language-server.js +94 -18
- package/dist/lib/editor/scan-session.js +2 -1
- package/dist/lib/editor/standalone-performance-examples.js +48 -0
- package/dist/lib/maintainability/analysis/analyze-source.js +2 -0
- package/dist/lib/maintainability/architecture/architecture.js +50 -2
- package/dist/lib/maintainability/cli/inputs.js +12 -5
- package/dist/lib/maintainability/cli/site-fix.js +3 -0
- package/dist/lib/maintainability/cli.js +6 -3
- package/dist/lib/maintainability/examples.js +48 -0
- package/dist/lib/maintainability/quality/modern-node-callbacks.js +188 -0
- package/dist/lib/maintainability/quality/modern-syntax.js +301 -0
- package/dist/lib/maintainability/quality/tsconfig-strict.js +307 -15
- package/dist/lib/maintainability/rule-ids.js +18 -0
- package/dist/lib/maintainability/scan-changed.js +33 -2
- package/dist/lib/maintainability/scan.js +10 -1
- package/dist/lib/maintainability/site-fixes/unused-bindings.js +15 -6
- package/dist/lib/maintainability/unused/module-usage-signatures.js +116 -0
- package/dist/lib/maintainability/unused/module-usage.js +67 -106
- package/dist/lib/maintainability/unused/unused-bindings.js +143 -8
- package/dist/lib/maintainability/unused/unused-dependencies.js +218 -0
- package/dist/lib/maintainability/unused/unused-modules.js +4 -0
- package/dist/lib/performance/analysis/missing-packages.js +3 -0
- package/dist/lib/performance/analysis/source-text.js +2 -2
- package/dist/lib/performance/analyze.js +4 -1
- package/dist/lib/performance/async/floating-promises.js +25 -4
- package/dist/lib/performance/cli/cli-output.js +9 -3
- package/dist/lib/performance/cli/cli-policy.js +25 -2
- package/dist/lib/performance/cli/cli-scan.js +25 -24
- package/dist/lib/performance/cli/scan-outcome.js +19 -1
- package/dist/lib/performance/cli/shared-security-inputs.js +27 -0
- package/dist/lib/performance/cli/watch.js +27 -8
- package/dist/lib/performance/collections/collection-lookups.js +27 -10
- package/dist/lib/performance/collections/collection-reduce.js +32 -2
- package/dist/lib/performance/collections/collections.js +28 -0
- package/dist/lib/performance/collections/repeated.js +25 -1
- package/dist/lib/performance/contracts/cli.js +22 -11
- package/dist/lib/performance/contracts/git-files.js +46 -1
- package/dist/lib/performance/datastores/pooling.js +1 -17
- package/dist/lib/performance/datastores/postgres.js +41 -33
- package/dist/lib/performance/engine/native.js +5 -1
- package/dist/lib/performance/frontend/angular-template-calls.js +187 -0
- package/dist/lib/performance/frontend/frontend-dom-perf.js +68 -8
- package/dist/lib/performance/frontend/frontend-perf.js +115 -171
- package/dist/lib/performance/frontend/frontend-render-perf.js +7 -3
- package/dist/lib/performance/frontend/jsx-element-perf.js +171 -0
- package/dist/lib/performance/frontend/next-fetch-waterfall.js +346 -29
- package/dist/lib/performance/frontend/rxjs-subscriptions.js +155 -0
- package/dist/lib/performance/frontend/seo/client-fetched-content.js +196 -0
- package/dist/lib/performance/frontend/seo/navigation-without-link.js +116 -0
- package/dist/lib/performance/frontend/seo/next-routes.js +114 -0
- package/dist/lib/performance/frontend/seo/route-metadata.js +158 -0
- package/dist/lib/performance/frontend/seo/seo-rules.js +9 -0
- package/dist/lib/performance/frontend/seo/sitewide-noindex.js +103 -0
- package/dist/lib/performance/frontend/template-tracking.js +86 -2
- package/dist/lib/performance/frontend/vue-options-hooks.js +108 -0
- package/dist/lib/performance/orm/prisma.js +1 -25
- package/dist/lib/performance/projects.js +3 -2
- package/dist/lib/performance/query-loops/service-loops.js +38 -8
- package/dist/lib/performance/request/json-stringify-output.js +82 -4
- package/dist/lib/performance/request/promise-schedulers.js +180 -0
- package/dist/lib/performance/request/request-handlers.js +43 -4
- package/dist/lib/performance/request/unbounded-promise-all.js +13 -52
- package/dist/lib/performance/rule-ids.js +26 -2
- package/dist/lib/performance/site-fix.js +1 -0
- package/dist/lib/reliability/react-bugs.js +9 -0
- package/dist/lib/reliability/react-state-aliases.js +94 -4
- package/dist/lib/reliability/react-state.js +24 -5
- package/dist/lib/security/auth-crypto/secrets.js +121 -16
- package/dist/lib/security/cli.js +1 -1
- package/dist/lib/security/credential-entropy.js +12 -0
- package/dist/lib/security/deps/lockfiles.js +3 -1
- package/dist/lib/security/examples/files.js +110 -0
- package/dist/lib/security/examples/request-forgery.js +1 -1
- package/dist/lib/security/exposure/frontend-security.js +11 -2
- package/dist/lib/security/exposure/prototype-pollution.js +73 -4
- package/dist/lib/security/files/azure-pipelines.js +69 -0
- package/dist/lib/security/files/bitbucket-pipelines.js +32 -0
- package/dist/lib/security/files/ci-platforms.js +16 -0
- package/dist/lib/security/files/ci-shared.js +260 -0
- package/dist/lib/security/files/circleci.js +81 -0
- package/dist/lib/security/files/dockerfile.js +188 -3
- package/dist/lib/security/files/github-actions.js +490 -0
- package/dist/lib/security/files/gitlab-ci.js +90 -0
- package/dist/lib/security/files/hcl.js +264 -0
- package/dist/lib/security/files/hosting-config.js +159 -0
- package/dist/lib/security/files/http-headers.js +65 -0
- package/dist/lib/security/files/index.js +62 -7
- package/dist/lib/security/files/jenkinsfile.js +482 -0
- package/dist/lib/security/files/json-nodes.js +67 -0
- package/dist/lib/security/files/nginx.js +501 -0
- package/dist/lib/security/files/package-scripts.js +175 -0
- package/dist/lib/security/files/rule-ids.js +29 -0
- package/dist/lib/security/files/secret-values.js +31 -5
- package/dist/lib/security/files/secrets.js +44 -13
- package/dist/lib/security/files/terraform.js +345 -0
- package/dist/lib/security/injection/nosql.js +2 -1
- package/dist/lib/security/injection/sql.js +2 -2
- package/dist/lib/security/lexical-declaration.js +28 -0
- package/dist/lib/security/pg-identifier-guards.js +90 -1
- package/dist/lib/security/request-forgery/member-chain.js +41 -0
- package/dist/lib/security/request-forgery/open-redirect.js +45 -8
- package/dist/lib/security/request-forgery/shared.js +18 -3
- package/dist/lib/security/rule-descriptions.js +29 -0
- package/dist/lib/security/rule-ids.js +29 -0
- package/dist/lib/security/taint/original-string-validation.js +229 -0
- package/dist/lib/security/taint/validators.js +1 -1
- package/dist/lib/shared/agent/review-delivery.js +3 -1
- package/dist/lib/shared/analysis/ast-semantics.js +17 -1
- package/dist/lib/shared/analysis/hot-path-graph.js +55 -19
- package/dist/lib/shared/analysis/next-env-config.js +232 -0
- package/dist/lib/shared/analysis/scan-cache-git.js +114 -0
- package/dist/lib/shared/analysis/scan-cache-loadwise-packages.js +54 -0
- package/dist/lib/shared/analysis/scan-cache-project-inputs.js +221 -0
- package/dist/lib/shared/analysis/scan-cache-sources.js +235 -0
- package/dist/lib/shared/analysis/scan-cache-storage.js +24 -0
- package/dist/lib/shared/analysis/scan-cache.js +158 -174
- package/dist/lib/shared/check-watch.js +3 -3
- package/dist/lib/shared/check.js +25 -4
- package/dist/lib/shared/config.js +1 -1
- package/dist/lib/shared/conventional-projects.js +40 -0
- package/dist/lib/shared/fix/fix-command.js +2 -0
- package/dist/lib/shared/fix/fix-usage.js +47 -0
- package/dist/lib/shared/fix/project-file-access.js +43 -20
- package/dist/lib/shared/fix.js +4 -35
- package/dist/lib/shared/formats/security-cwe.js +29 -0
- package/dist/lib/shared/project-root.js +1 -1
- package/dist/lib/shared/reporting/action-comparison.js +78 -0
- package/dist/lib/shared/reporting/automatic-fix-signal.js +7 -2
- package/dist/lib/shared/reporting/check-text.js +7 -5
- package/dist/lib/shared/reporting/pillars.js +28 -8
- package/dist/lib/shared/reporting/source-report.js +4 -4
- package/dist/lib/shared/system/git.js +31 -16
- package/dist/lib/shared/system/glob.js +146 -19
- package/dist/lib/shared/system/terminal-style.js +2 -2
- package/dist/lib/shared/workspaces.js +6 -1
- package/package.json +4 -1
- package/schema/loadwise.config.schema.json +86 -0
|
@@ -9,7 +9,7 @@ import { resolveFormat, renderReports } from '../formats/index.js';
|
|
|
9
9
|
import { impactByRule } from '../../security/rule-ids.js';
|
|
10
10
|
import { findProjectRoot } from '../../performance/schema/context.js';
|
|
11
11
|
import { terminalPrinter, terminalSafe } from '../system/terminal-safe.js';
|
|
12
|
-
import {
|
|
12
|
+
import { reportTextFindings } from './automatic-fix-signal.js';
|
|
13
13
|
import { assignFindingIds as assignFindingIdsFindingIds } from '../../performance/cli/finding-ids.js';
|
|
14
14
|
import { keepChangedFindings } from '../../performance/cli/changed-lines.js';
|
|
15
15
|
import { attachExample, printFindings, findingLabel } from '../../performance/cli/finding-text.js';
|
|
@@ -124,7 +124,7 @@ function printSourceReport(result, values, baseline, format, print) {
|
|
|
124
124
|
else
|
|
125
125
|
printTextSummary(result, values, terminalPrinter(print));
|
|
126
126
|
if (format === 'text') {
|
|
127
|
-
|
|
127
|
+
reportTextFindings(result.findings);
|
|
128
128
|
if (baseline)
|
|
129
129
|
for (const line of baselineNoteLines(baseline))
|
|
130
130
|
print(line);
|
|
@@ -158,14 +158,14 @@ function dismissCommentPrefix(file) {
|
|
|
158
158
|
function printChangedFindings(findings, fixCommand, print) {
|
|
159
159
|
for (const finding of findings) {
|
|
160
160
|
print(`${finding.file}:${finding.line} ${findingLabel(finding)} ${finding.impactLevel}: ${finding.message}`);
|
|
161
|
-
if (finding.fixable)
|
|
161
|
+
if (fixCommand && finding.fixable)
|
|
162
162
|
print(` fix: ${fixCommand} --fix --only ${finding.id}`);
|
|
163
163
|
print(` dismiss: ${dismissCommentPrefix(finding.file)} loadwise-reviewed ${finding.ruleId} -- <reason>`);
|
|
164
164
|
}
|
|
165
165
|
const fixableIds = findings
|
|
166
166
|
.filter((finding) => finding.fixable && !finding.fix?.requiresReview)
|
|
167
167
|
.map((finding) => finding.id);
|
|
168
|
-
if (fixableIds.length > 1)
|
|
168
|
+
if (fixCommand && fixableIds.length > 1)
|
|
169
169
|
print(`Fix all: ${fixCommand} --fix --only ${fixableIds.join(',')}`);
|
|
170
170
|
print(findings.length
|
|
171
171
|
? `${findings.length} new finding(s) in changed lines. Apply fixes, then \`git add\` the files and commit again.`
|
|
@@ -3,25 +3,30 @@
|
|
|
3
3
|
import { spawnSync } from 'node:child_process';
|
|
4
4
|
import { errorCode } from './error-code.js';
|
|
5
5
|
import { findGitRoot, killOrphanedDescendants } from './windows-orphans.js';
|
|
6
|
+
function spawnOptions(directory, { timeoutMs, maxBuffer, useCwd = false }) {
|
|
7
|
+
return { cwd: useCwd ? directory : undefined, maxBuffer, timeout: timeoutMs, windowsHide: true };
|
|
8
|
+
}
|
|
9
|
+
function gitArguments(directory, args, { useCwd = false }) {
|
|
10
|
+
return useCwd ? [...args] : ['-C', directory, ...args];
|
|
11
|
+
}
|
|
12
|
+
// On Windows `git` is often a wrapper that starts the real git; Node's kill reaches only the wrapper.
|
|
13
|
+
// Only that Git installation's own programs are ever stopped; without a known root nothing more is stopped.
|
|
14
|
+
function stopOrphans(run, startedAt) {
|
|
15
|
+
if (process.platform !== 'win32' || !run.error || !run.pid)
|
|
16
|
+
return;
|
|
17
|
+
const endedAt = new Date();
|
|
18
|
+
const gitRoot = findGitRoot();
|
|
19
|
+
if (gitRoot)
|
|
20
|
+
killOrphanedDescendants(run.pid, startedAt, endedAt, gitRoot);
|
|
21
|
+
}
|
|
6
22
|
function runGit(directory, args, options = {}) {
|
|
7
|
-
const { timeoutMs, maxBuffer, input, useCwd = false } = options;
|
|
8
23
|
const startedAt = new Date();
|
|
9
|
-
const run = spawnSync('git',
|
|
10
|
-
|
|
24
|
+
const run = spawnSync('git', gitArguments(directory, args, options), {
|
|
25
|
+
...spawnOptions(directory, options),
|
|
11
26
|
encoding: 'utf8',
|
|
12
|
-
input,
|
|
13
|
-
maxBuffer,
|
|
14
|
-
timeout: timeoutMs,
|
|
15
|
-
windowsHide: true,
|
|
27
|
+
input: options.input,
|
|
16
28
|
});
|
|
17
|
-
|
|
18
|
-
// Only that Git installation's own programs are ever stopped; without a known root nothing more is stopped.
|
|
19
|
-
if (process.platform === 'win32' && run.error && run.pid) {
|
|
20
|
-
const endedAt = new Date();
|
|
21
|
-
const gitRoot = findGitRoot();
|
|
22
|
-
if (gitRoot)
|
|
23
|
-
killOrphanedDescendants(run.pid, startedAt, endedAt, gitRoot);
|
|
24
|
-
}
|
|
29
|
+
stopOrphans(run, startedAt);
|
|
25
30
|
return {
|
|
26
31
|
ok: !run.error && run.status === 0,
|
|
27
32
|
status: run.status,
|
|
@@ -32,6 +37,16 @@ function runGit(directory, args, options = {}) {
|
|
|
32
37
|
notFound: errorCode(run.error) === 'ENOENT',
|
|
33
38
|
};
|
|
34
39
|
}
|
|
40
|
+
// Raw stdout for output measured in bytes, such as `git cat-file --batch`; undefined unless git exited with 0.
|
|
41
|
+
function gitBytes(directory, args, options = {}) {
|
|
42
|
+
const startedAt = new Date();
|
|
43
|
+
const run = spawnSync('git', gitArguments(directory, args, options), {
|
|
44
|
+
...spawnOptions(directory, options),
|
|
45
|
+
input: options.input === undefined ? undefined : Buffer.from(options.input),
|
|
46
|
+
});
|
|
47
|
+
stopOrphans(run, startedAt);
|
|
48
|
+
return !run.error && run.status === 0 ? run.stdout : undefined;
|
|
49
|
+
}
|
|
35
50
|
/** Git's stdout, or the error `execFileSync` would have thrown for the same failure. */
|
|
36
51
|
function gitOutputOrThrow(directory, args, options = {}) {
|
|
37
52
|
const result = runGit(directory, args, options);
|
|
@@ -44,4 +59,4 @@ function gitOutputOrThrow(directory, args, options = {}) {
|
|
|
44
59
|
}
|
|
45
60
|
return result.stdout;
|
|
46
61
|
}
|
|
47
|
-
export { gitOutputOrThrow, runGit };
|
|
62
|
+
export { gitBytes, gitOutputOrThrow, runGit };
|
|
@@ -55,50 +55,177 @@ function pairBraces(pattern, options = {}) {
|
|
|
55
55
|
}
|
|
56
56
|
return pairs;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
const lineTerminators = new Set(['\n', '\r', '\u2028', '\u2029']);
|
|
59
|
+
const notSlash = (character) => character !== '/';
|
|
60
|
+
// What a regular expression's `.` reads without the dotAll flag, which the earlier compiled patterns used.
|
|
61
|
+
const notLineTerminator = (character) => !lineTerminators.has(character);
|
|
62
|
+
const anything = () => true;
|
|
63
|
+
function literal(expected) {
|
|
64
|
+
return { kind: 'one', accepts: (character) => character === expected };
|
|
65
|
+
}
|
|
66
|
+
function characterClassTest(source) {
|
|
67
|
+
const expression = new RegExp(`^${source}$`);
|
|
68
|
+
return (character) => expression.test(character);
|
|
69
|
+
}
|
|
70
|
+
function parseGlob(rawPattern, options = {}) {
|
|
59
71
|
const pattern = rawPattern.replaceAll(/(?:\*\*\/)+/g, '**/').replaceAll(/\*{3,}/g, '**');
|
|
60
|
-
let
|
|
72
|
+
let sequence = [];
|
|
61
73
|
const bracePairs = pairBraces(pattern, options);
|
|
62
|
-
|
|
74
|
+
// Literal braces only mark their nesting; a group keeps its finished alternatives and the enclosing sequence.
|
|
75
|
+
const openBraces = [];
|
|
63
76
|
for (let index = 0; index < pattern.length; index++) {
|
|
64
77
|
const character = pattern[index];
|
|
65
78
|
const characterClass = characterClassAt(pattern, index, options);
|
|
79
|
+
const innermost = openBraces.at(-1);
|
|
66
80
|
if (characterClass) {
|
|
67
|
-
|
|
81
|
+
sequence.push({ kind: 'one', accepts: characterClassTest(characterClass.source) });
|
|
68
82
|
index = characterClass.end;
|
|
69
83
|
}
|
|
70
84
|
else if (character === '*' && pattern[index + 1] === '*') {
|
|
71
85
|
const slashFollows = pattern[index + 2] === '/';
|
|
72
|
-
|
|
86
|
+
const anyDepth = { kind: 'many', accepts: notLineTerminator };
|
|
87
|
+
sequence.push(slashFollows ? { kind: 'either', options: [[], [anyDepth, literal('/')]] } : anyDepth);
|
|
73
88
|
index += slashFollows ? 2 : 1;
|
|
74
89
|
}
|
|
75
90
|
else if (character === '*')
|
|
76
|
-
|
|
91
|
+
sequence.push({ kind: 'many', accepts: notSlash });
|
|
77
92
|
else if (character === '?')
|
|
78
|
-
|
|
93
|
+
sequence.push({ kind: 'one', accepts: notSlash });
|
|
79
94
|
else if (character === '{' && bracePairs.has(index)) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
if (bracePairs.get(index) === true) {
|
|
96
|
+
openBraces.push({ group: true, options: [], enclosing: sequence });
|
|
97
|
+
sequence = [];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
openBraces.push({ group: false });
|
|
101
|
+
sequence.push(literal('{'));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (character === ',' && innermost?.group) {
|
|
105
|
+
innermost.options.push(sequence);
|
|
106
|
+
sequence = [];
|
|
83
107
|
}
|
|
84
|
-
else if (character === '
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
108
|
+
else if (character === '}' && innermost) {
|
|
109
|
+
openBraces.pop();
|
|
110
|
+
if (innermost.group) {
|
|
111
|
+
innermost.options.push(sequence);
|
|
112
|
+
sequence = innermost.enclosing;
|
|
113
|
+
sequence.push({ kind: 'either', options: innermost.options });
|
|
114
|
+
}
|
|
115
|
+
else
|
|
116
|
+
sequence.push(literal('}'));
|
|
88
117
|
}
|
|
89
118
|
else
|
|
90
|
-
|
|
119
|
+
sequence.push(literal(character));
|
|
120
|
+
}
|
|
121
|
+
return sequence;
|
|
122
|
+
}
|
|
123
|
+
// Builds the states for `nodes` that continue to state `next`, and returns the first one.
|
|
124
|
+
function compileSequence(nodes, next, states) {
|
|
125
|
+
let start = next;
|
|
126
|
+
for (let index = nodes.length - 1; index >= 0; index--) {
|
|
127
|
+
const node = nodes[index];
|
|
128
|
+
if (node.kind === 'one')
|
|
129
|
+
start = states.push({ accepts: node.accepts, next: [start] }) - 1;
|
|
130
|
+
else if (node.kind === 'either') {
|
|
131
|
+
const options = node.options.map((option) => compileSequence(option, start, states));
|
|
132
|
+
start = states.push({ next: options }) - 1;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
const loop = states.push({ next: [] }) - 1;
|
|
136
|
+
const body = states.push({ accepts: node.accepts, next: [loop] }) - 1;
|
|
137
|
+
states[loop].next = [body, start];
|
|
138
|
+
start = loop;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return start;
|
|
142
|
+
}
|
|
143
|
+
// Paths share few distinct characters and state sets, so a few hundred cached steps cover a scan. Past any limit,
|
|
144
|
+
// new steps and transitions are still computed but no longer cached, which bounds the memory of one pattern.
|
|
145
|
+
const MAX_CACHED_STEPS = 512;
|
|
146
|
+
const MAX_CACHED_TRANSITIONS = 4096;
|
|
147
|
+
// The automaton states that all cached steps hold together, so wide brace groups cannot fill the cache with large sets.
|
|
148
|
+
const MAX_CACHED_STATES = 65_536;
|
|
149
|
+
// A compiled pattern. Matching follows every position of the pattern at once (a Thompson automaton), so its time is
|
|
150
|
+
// linear in the path for any pattern: a regular expression of several `*` backtracks polynomially on a near miss,
|
|
151
|
+
// and config ignores, workspace lists and tool configs from a scanned repository all supply patterns. Each set of
|
|
152
|
+
// positions and its transitions are cached as they are met (a lazily built DFA), so a repeated match costs about one
|
|
153
|
+
// map lookup per character.
|
|
154
|
+
class GlobPattern {
|
|
155
|
+
states = [{ next: [] }];
|
|
156
|
+
steps = new Map();
|
|
157
|
+
initial;
|
|
158
|
+
cachedTransitions = 0;
|
|
159
|
+
cachedStates = 0;
|
|
160
|
+
constructor(nodes) {
|
|
161
|
+
this.initial = this.step([compileSequence(nodes, 0, this.states)]);
|
|
162
|
+
}
|
|
163
|
+
test(text) {
|
|
164
|
+
let current = this.initial;
|
|
165
|
+
// Code units, as a regular expression without the unicode flag reads them.
|
|
166
|
+
for (let index = 0; index < text.length && current.states.length; index++) {
|
|
167
|
+
const character = text[index];
|
|
168
|
+
let following = current.next.get(character);
|
|
169
|
+
if (!following) {
|
|
170
|
+
following = this.advance(current, character);
|
|
171
|
+
// A transition to an uncached step would keep that step alive outside the caps.
|
|
172
|
+
if (following.cached && this.cachedTransitions < MAX_CACHED_TRANSITIONS) {
|
|
173
|
+
current.next.set(character, following);
|
|
174
|
+
this.cachedTransitions++;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
current = following;
|
|
178
|
+
}
|
|
179
|
+
return current.accepting;
|
|
180
|
+
}
|
|
181
|
+
advance(current, character) {
|
|
182
|
+
const targets = [];
|
|
183
|
+
for (const state of current.states) {
|
|
184
|
+
const { accepts, next } = this.states[state];
|
|
185
|
+
if (accepts?.(character))
|
|
186
|
+
for (const target of next)
|
|
187
|
+
targets.push(target);
|
|
188
|
+
}
|
|
189
|
+
return this.step(targets);
|
|
190
|
+
}
|
|
191
|
+
// The step for the reading states and the accepting state reachable from `from` without reading a character.
|
|
192
|
+
step(from) {
|
|
193
|
+
const reached = new Set();
|
|
194
|
+
const pending = [...from];
|
|
195
|
+
for (let state = pending.pop(); state !== undefined; state = pending.pop()) {
|
|
196
|
+
if (reached.has(state))
|
|
197
|
+
continue;
|
|
198
|
+
reached.add(state);
|
|
199
|
+
if (!this.states[state].accepts)
|
|
200
|
+
for (const target of this.states[state].next)
|
|
201
|
+
pending.push(target);
|
|
202
|
+
}
|
|
203
|
+
const states = [...reached]
|
|
204
|
+
.filter((state) => state === 0 || this.states[state].accepts)
|
|
205
|
+
.sort((left, right) => left - right);
|
|
206
|
+
const key = states.join(',');
|
|
207
|
+
const cached = this.steps.get(key);
|
|
208
|
+
if (cached)
|
|
209
|
+
return cached;
|
|
210
|
+
const cache = this.steps.size < MAX_CACHED_STEPS && this.cachedStates + states.length <= MAX_CACHED_STATES;
|
|
211
|
+
const created = { states, accepting: states.includes(0), cached: cache, next: new Map() };
|
|
212
|
+
if (cache) {
|
|
213
|
+
this.steps.set(key, created);
|
|
214
|
+
this.cachedStates += states.length;
|
|
215
|
+
}
|
|
216
|
+
return created;
|
|
91
217
|
}
|
|
92
|
-
return source;
|
|
93
218
|
}
|
|
94
219
|
function globExpression(pattern, options = {}) {
|
|
95
|
-
return new
|
|
220
|
+
return new GlobPattern(parseGlob(pattern, options));
|
|
96
221
|
}
|
|
97
222
|
function normalizeGlob(pattern) {
|
|
98
223
|
return normalizeSlashes(pattern).replace(/^\.\//, '').replace(/\/$/, '');
|
|
99
224
|
}
|
|
225
|
+
// The pattern itself or anything below the folder it names.
|
|
100
226
|
function globOrDescendant(pattern) {
|
|
101
|
-
|
|
227
|
+
const below = { kind: 'either', options: [[], [literal('/'), { kind: 'many', accepts: anything }]] };
|
|
228
|
+
return new GlobPattern([...parseGlob(pattern), below]);
|
|
102
229
|
}
|
|
103
230
|
// A pattern also matches everything below a folder it names, so "generated" and "generated/**"
|
|
104
231
|
// agree.
|
|
@@ -154,4 +281,4 @@ function createIgnoreMatcher(patterns) {
|
|
|
154
281
|
return false;
|
|
155
282
|
};
|
|
156
283
|
}
|
|
157
|
-
export { createGlobMatcher, createIgnoreMatcher, globExpression };
|
|
284
|
+
export { createGlobMatcher, createIgnoreMatcher, GlobPattern, globExpression };
|
|
@@ -96,10 +96,10 @@ function styleTerminalLine(line, enabled = supportsColor()) {
|
|
|
96
96
|
return `${indent}${ansi.dimCyan}${label}${ansi.reset}${rest}`;
|
|
97
97
|
}
|
|
98
98
|
// Checker summary lines
|
|
99
|
-
if (
|
|
99
|
+
if (/^(?:[A-Za-z]+: )?\d+ (?:(?:source|graph) )?file(?:s|\(s\))?\b.*\b0 finding(?:s|\(s\))/.test(line)) {
|
|
100
100
|
return `${ansi.boldGreen}✓ ${line}${ansi.reset}`;
|
|
101
101
|
}
|
|
102
|
-
if (
|
|
102
|
+
if (/^(?:[A-Za-z]+: )?\d+ (?:(?:source|graph) )?file(?:s|\(s\))?\b.*\b[1-9]\d* finding(?:s|\(s\))?/.test(line)) {
|
|
103
103
|
return `${ansi.boldYellow}${line}${ansi.reset}`;
|
|
104
104
|
}
|
|
105
105
|
return line;
|
|
@@ -152,6 +152,11 @@ function workspacePatterns(root, resolvePath = declaredPath) {
|
|
|
152
152
|
const lerna = readJson(resolvePath(lernaFile));
|
|
153
153
|
return lerna?.packages === undefined ? [] : patternList(lerna.packages, 'packages', lernaFile);
|
|
154
154
|
}
|
|
155
|
+
function hasWorkspaceDeclaration(root) {
|
|
156
|
+
return (readJson(path.join(root, 'package.json'))?.workspaces !== undefined ||
|
|
157
|
+
fs.existsSync(path.join(root, 'pnpm-workspace.yaml')) ||
|
|
158
|
+
fs.existsSync(path.join(root, 'lerna.json')));
|
|
159
|
+
}
|
|
155
160
|
function subdirectories(directory) {
|
|
156
161
|
if (directory === undefined)
|
|
157
162
|
return [];
|
|
@@ -585,4 +590,4 @@ function missingPackageBase(diagnostic) {
|
|
|
585
590
|
const missing = /'([^']+)'/.exec(ts.flattenDiagnosticMessageText(diagnostic.messageText, ' '))?.[1];
|
|
586
591
|
return missing !== undefined && !/^(?:\.|\/|[a-z]:)/i.test(missing) ? missing : undefined;
|
|
587
592
|
}
|
|
588
|
-
export { declaredWorkspaceDirectories, coveringConfig, discoverResolvedWorkspaces, discoverWorkspaces, missingPackageBase, projectConfig, projectPathWithin, selectWorkspaces, configlessSources, configlessCoverage, requireCompleteConfiglessSources, requireCompleteWorkspaceSources, hasWorkspaceSources, missingSourcesDetail, uncheckedWorkspaces, workspacePackageCoverage, isProjectDirectory, workspaceFileInventory, isWorkspaceMember, workspacePackagesAround, workspaceRootSources, workspaceSourceEntry, };
|
|
593
|
+
export { declaredWorkspaceDirectories, coveringConfig, discoverResolvedWorkspaces, discoverWorkspaces, missingPackageBase, projectConfig, projectPathWithin, selectWorkspaces, configlessSources, configlessCoverage, requireCompleteConfiglessSources, requireCompleteWorkspaceSources, hasWorkspaceSources, missingSourcesDetail, uncheckedWorkspaces, workspacePackageCoverage, isProjectDirectory, workspaceFileInventory, isWorkspaceMember, hasWorkspaceDeclaration, implementationSource, subdirectories, workspacePackagesAround, workspaceRootSources, workspaceSourceEntry, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "loadwise",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/lib/shared/node-scan.js",
|
|
6
6
|
"types": "./types/scan.d.ts",
|
|
@@ -98,6 +98,7 @@
|
|
|
98
98
|
"check": "npm run format:check && npm run lint && npm test",
|
|
99
99
|
"typecheck": "tsc -p tsconfig.typecheck.json",
|
|
100
100
|
"test": "npm run build && node dist/scripts/run-tests.js",
|
|
101
|
+
"test:unit": "npm run build && node dist/scripts/run-tests.js --unit",
|
|
101
102
|
"selfscan:baseline": "node dist/bin/loadwise.js check . --config scripts/self-scan/loadwise.config.json --write-baseline scripts/self-scan/loadwise-baseline.json",
|
|
102
103
|
"bench:corpus": "node dist/scripts/score-corpus.js",
|
|
103
104
|
"bench:scorecard": "node dist/scripts/score-corpus.js --scorecard",
|
|
@@ -108,6 +109,8 @@
|
|
|
108
109
|
"bench:scan": "node dist/bench/scanner.js",
|
|
109
110
|
"bench:security": "node dist/bench/security.js",
|
|
110
111
|
"bench:traces": "node dist/bench/traces.js",
|
|
112
|
+
"bench:incremental": "node dist/bench/incremental.js",
|
|
113
|
+
"bench:detection": "node dist/bench/detection/runner.js",
|
|
111
114
|
"bench:recall:smoke": "node dist/bench/recall/runner.js --case source-json-stringify-in-loop --case source-async-callback-rejection --case source-dependency-cycle --case a11y-workshop-button-missing-type --case source-bcrypt-low-cost --case polyglot-python-growing-list",
|
|
112
115
|
"bench:recall": "node dist/bench/recall/runner.js",
|
|
113
116
|
"bench:evidence": "node dist/bench/evidence/runner.js",
|