monkeypatchlist 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/NOTICE +61 -0
- package/README.md +183 -2
- package/catalog/catalog.json +552211 -0
- package/catalog/catalog.schema.json +787 -0
- package/catalog/changelog.json +3 -0
- package/dist/bin/monkeypatchlist.d.ts +2 -0
- package/dist/bin/monkeypatchlist.js +3 -0
- package/dist/catalog.d.ts +561 -0
- package/dist/catalog.js +58 -0
- package/dist/cli.d.ts +84 -0
- package/dist/cli.js +470 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/lockfile-input.d.ts +9 -0
- package/dist/lockfile-input.js +91 -0
- package/dist/packages/analysis/binding.d.ts +2 -0
- package/dist/packages/analysis/binding.js +5 -0
- package/dist/packages/analysis/index.d.ts +10 -0
- package/dist/packages/analysis/index.js +13 -0
- package/dist/packages/analysis/job.d.ts +33 -0
- package/dist/packages/analysis/job.js +85 -0
- package/dist/packages/analysis/lib/absence-tags.d.ts +34 -0
- package/dist/packages/analysis/lib/absence-tags.js +340 -0
- package/dist/packages/analysis/lib/ast.d.ts +28 -0
- package/dist/packages/analysis/lib/ast.js +64 -0
- package/dist/packages/analysis/lib/binding.d.ts +36 -0
- package/dist/packages/analysis/lib/binding.js +66 -0
- package/dist/packages/analysis/lib/budget.d.ts +80 -0
- package/dist/packages/analysis/lib/budget.js +31 -0
- package/dist/packages/analysis/lib/catch-arms.d.ts +19 -0
- package/dist/packages/analysis/lib/catch-arms.js +351 -0
- package/dist/packages/analysis/lib/chunk-loads.d.ts +160 -0
- package/dist/packages/analysis/lib/chunk-loads.js +882 -0
- package/dist/packages/analysis/lib/chunk-registry.d.ts +45 -0
- package/dist/packages/analysis/lib/chunk-registry.js +334 -0
- package/dist/packages/analysis/lib/code-routes.d.ts +52 -0
- package/dist/packages/analysis/lib/code-routes.js +921 -0
- package/dist/packages/analysis/lib/collisions.d.ts +22 -0
- package/dist/packages/analysis/lib/collisions.js +103 -0
- package/dist/packages/analysis/lib/definitions.d.ts +76 -0
- package/dist/packages/analysis/lib/definitions.js +782 -0
- package/dist/packages/analysis/lib/early-exits.d.ts +39 -0
- package/dist/packages/analysis/lib/early-exits.js +161 -0
- package/dist/packages/analysis/lib/effect.d.ts +138 -0
- package/dist/packages/analysis/lib/effect.js +800 -0
- package/dist/packages/analysis/lib/global-object.d.ts +581 -0
- package/dist/packages/analysis/lib/global-object.js +8240 -0
- package/dist/packages/analysis/lib/keys.d.ts +33 -0
- package/dist/packages/analysis/lib/keys.js +82 -0
- package/dist/packages/analysis/lib/line-starts.d.ts +41 -0
- package/dist/packages/analysis/lib/line-starts.js +79 -0
- package/dist/packages/analysis/lib/link-group.d.ts +51 -0
- package/dist/packages/analysis/lib/link-group.js +487 -0
- package/dist/packages/analysis/lib/module-links.d.ts +117 -0
- package/dist/packages/analysis/lib/module-links.js +1060 -0
- package/dist/packages/analysis/lib/nested-code.d.ts +38 -0
- package/dist/packages/analysis/lib/nested-code.js +200 -0
- package/dist/packages/analysis/lib/numeric.d.ts +16 -0
- package/dist/packages/analysis/lib/numeric.js +216 -0
- package/dist/packages/analysis/lib/once-flags.d.ts +12 -0
- package/dist/packages/analysis/lib/once-flags.js +190 -0
- package/dist/packages/analysis/lib/parameter-arguments.d.ts +12 -0
- package/dist/packages/analysis/lib/parameter-arguments.js +34 -0
- package/dist/packages/analysis/lib/parse.d.ts +10 -0
- package/dist/packages/analysis/lib/parse.js +39 -0
- package/dist/packages/analysis/lib/partial.d.ts +60 -0
- package/dist/packages/analysis/lib/partial.js +518 -0
- package/dist/packages/analysis/lib/print.d.ts +3 -0
- package/dist/packages/analysis/lib/print.js +150 -0
- package/dist/packages/analysis/lib/reachability.d.ts +137 -0
- package/dist/packages/analysis/lib/reachability.js +1295 -0
- package/dist/packages/analysis/lib/resolver.d.ts +13 -0
- package/dist/packages/analysis/lib/resolver.js +2886 -0
- package/dist/packages/analysis/lib/restores.d.ts +42 -0
- package/dist/packages/analysis/lib/restores.js +482 -0
- package/dist/packages/analysis/lib/rewritten-deletes.d.ts +6 -0
- package/dist/packages/analysis/lib/rewritten-deletes.js +142 -0
- package/dist/packages/analysis/lib/scope.d.ts +110 -0
- package/dist/packages/analysis/lib/scope.js +443 -0
- package/dist/packages/analysis/lib/script-loads.d.ts +56 -0
- package/dist/packages/analysis/lib/script-loads.js +359 -0
- package/dist/packages/analysis/lib/summaries.d.ts +177 -0
- package/dist/packages/analysis/lib/summaries.js +498 -0
- package/dist/packages/analysis/lib/types.d.ts +632 -0
- package/dist/packages/analysis/lib/types.js +128 -0
- package/dist/packages/analysis/lib/wrap.d.ts +34 -0
- package/dist/packages/analysis/lib/wrap.js +407 -0
- package/dist/packages/analysis/lib/writes.d.ts +358 -0
- package/dist/packages/analysis/lib/writes.js +1612 -0
- package/dist/packages/analysis/visit-order.d.ts +3 -0
- package/dist/packages/analysis/visit-order.js +23 -0
- package/dist/packages/attribution/index.d.ts +233 -0
- package/dist/packages/attribution/index.js +444 -0
- package/dist/packages/attribution/lib/containing-package.d.ts +76 -0
- package/dist/packages/attribution/lib/containing-package.js +304 -0
- package/dist/packages/attribution/lib/first-party.d.ts +37 -0
- package/dist/packages/attribution/lib/first-party.js +153 -0
- package/dist/packages/attribution/lib/lockfile-graph.d.ts +99 -0
- package/dist/packages/attribution/lib/lockfile-graph.js +158 -0
- package/dist/packages/attribution/lib/lockfile.d.ts +33 -0
- package/dist/packages/attribution/lib/lockfile.js +330 -0
- package/dist/packages/attribution/lib/path-rules.d.ts +29 -0
- package/dist/packages/attribution/lib/path-rules.js +84 -0
- package/dist/packages/attribution/lib/pnpm.d.ts +4 -0
- package/dist/packages/attribution/lib/pnpm.js +133 -0
- package/dist/packages/attribution/lib/remote-url.d.ts +7 -0
- package/dist/packages/attribution/lib/remote-url.js +24 -0
- package/dist/packages/attribution/lib/source-map.d.ts +51 -0
- package/dist/packages/attribution/lib/source-map.js +125 -0
- package/dist/packages/attribution/lib/yaml.d.ts +9 -0
- package/dist/packages/attribution/lib/yaml.js +277 -0
- package/dist/packages/attribution/lib/yarn.d.ts +7 -0
- package/dist/packages/attribution/lib/yarn.js +227 -0
- package/dist/packages/baseline/index.d.ts +45 -0
- package/dist/packages/baseline/index.js +41 -0
- package/dist/packages/baseline/lib/error.d.ts +15 -0
- package/dist/packages/baseline/lib/error.js +25 -0
- package/dist/packages/baseline/lib/format.d.ts +49 -0
- package/dist/packages/baseline/lib/format.js +22 -0
- package/dist/packages/baseline/lib/migrations.d.ts +19 -0
- package/dist/packages/baseline/lib/migrations.js +7 -0
- package/dist/packages/baseline/lib/previous.d.ts +23 -0
- package/dist/packages/baseline/lib/previous.js +64 -0
- package/dist/packages/baseline/lib/read.d.ts +39 -0
- package/dist/packages/baseline/lib/read.js +219 -0
- package/dist/packages/baseline/lib/report.d.ts +25 -0
- package/dist/packages/baseline/lib/report.js +104 -0
- package/dist/packages/baseline/lib/skew.d.ts +51 -0
- package/dist/packages/baseline/lib/skew.js +75 -0
- package/dist/packages/compare/index.d.ts +120 -0
- package/dist/packages/compare/index.js +274 -0
- package/dist/packages/compare/lib/catalog-notes.d.ts +73 -0
- package/dist/packages/compare/lib/catalog-notes.js +224 -0
- package/dist/packages/completeness/index.d.ts +246 -0
- package/dist/packages/completeness/index.js +249 -0
- package/dist/packages/confidence/index.d.ts +54 -0
- package/dist/packages/confidence/index.js +71 -0
- package/dist/packages/config/index.d.ts +107 -0
- package/dist/packages/config/index.js +95 -0
- package/dist/packages/config/lib/command-line.d.ts +23 -0
- package/dist/packages/config/lib/command-line.js +239 -0
- package/dist/packages/config/lib/config-file.d.ts +11 -0
- package/dist/packages/config/lib/config-file.js +119 -0
- package/dist/packages/config/lib/scan-config-id.d.ts +28 -0
- package/dist/packages/config/lib/scan-config-id.js +54 -0
- package/dist/packages/config/lib/schema.d.ts +2 -0
- package/dist/packages/config/lib/schema.js +31 -0
- package/dist/packages/config/lib/types.d.ts +64 -0
- package/dist/packages/config/lib/types.js +6 -0
- package/dist/packages/config/lib/urls.d.ts +6 -0
- package/dist/packages/config/lib/urls.js +9 -0
- package/dist/packages/discovery/index.d.ts +277 -0
- package/dist/packages/discovery/index.js +1950 -0
- package/dist/packages/discovery/lib/import-map.d.ts +68 -0
- package/dist/packages/discovery/lib/import-map.js +180 -0
- package/dist/packages/discovery/lib/requests.d.ts +58 -0
- package/dist/packages/discovery/lib/requests.js +591 -0
- package/dist/packages/discovery/lib/scopes.d.ts +6 -0
- package/dist/packages/discovery/lib/scopes.js +286 -0
- package/dist/packages/discovery/lib/source-maps.d.ts +56 -0
- package/dist/packages/discovery/lib/source-maps.js +209 -0
- package/dist/packages/discovery/lib/swept-code.d.ts +27 -0
- package/dist/packages/discovery/lib/swept-code.js +107 -0
- package/dist/packages/discovery/lib/syntax.d.ts +17 -0
- package/dist/packages/discovery/lib/syntax.js +39 -0
- package/dist/packages/findings/index.d.ts +106 -0
- package/dist/packages/findings/index.js +254 -0
- package/dist/packages/findings/lib/scope.d.ts +38 -0
- package/dist/packages/findings/lib/scope.js +110 -0
- package/dist/packages/parallel/index.d.ts +2 -0
- package/dist/packages/parallel/index.js +5 -0
- package/dist/packages/parallel/lib/protocol.d.ts +15 -0
- package/dist/packages/parallel/lib/protocol.js +2 -0
- package/dist/packages/parallel/lib/runner.d.ts +36 -0
- package/dist/packages/parallel/lib/runner.js +96 -0
- package/dist/packages/parallel/lib/schedule.d.ts +16 -0
- package/dist/packages/parallel/lib/schedule.js +52 -0
- package/dist/packages/parallel/lib/worker.d.ts +1 -0
- package/dist/packages/parallel/lib/worker.js +18 -0
- package/dist/packages/policy/index.d.ts +36 -0
- package/dist/packages/policy/index.js +22 -0
- package/dist/packages/report/explain.d.ts +26 -0
- package/dist/packages/report/explain.js +99 -0
- package/dist/packages/report/index.d.ts +210 -0
- package/dist/packages/report/index.js +388 -0
- package/dist/packages/report/terminal.d.ts +11 -0
- package/dist/packages/report/terminal.js +331 -0
- package/dist/packages/source-store/fixture.d.ts +22 -0
- package/dist/packages/source-store/fixture.js +58 -0
- package/dist/packages/source-store/index.d.ts +278 -0
- package/dist/packages/source-store/index.js +322 -0
- package/dist/packages/source-store/lib/addresses.d.ts +6 -0
- package/dist/packages/source-store/lib/addresses.js +91 -0
- package/dist/packages/source-store/lib/connection.d.ts +15 -0
- package/dist/packages/source-store/lib/connection.js +135 -0
- package/dist/packages/source-store/lib/content-types.d.ts +16 -0
- package/dist/packages/source-store/lib/content-types.js +75 -0
- package/dist/packages/source-store/lib/data-urls.d.ts +10 -0
- package/dist/packages/source-store/lib/data-urls.js +85 -0
- package/dist/packages/source-store/lib/deadline.d.ts +18 -0
- package/dist/packages/source-store/lib/deadline.js +44 -0
- package/dist/packages/source-store/lib/exchange.d.ts +29 -0
- package/dist/packages/source-store/lib/exchange.js +112 -0
- package/dist/packages/source-store/lib/integrity.d.ts +19 -0
- package/dist/packages/source-store/lib/integrity.js +86 -0
- package/dist/packages/source-store/lib/outcomes.d.ts +12 -0
- package/dist/packages/source-store/lib/outcomes.js +22 -0
- package/dist/packages/source-store/lib/proxy.d.ts +11 -0
- package/dist/packages/source-store/lib/proxy.js +53 -0
- package/dist/packages/source-store/lib/session.d.ts +12 -0
- package/dist/packages/source-store/lib/session.js +139 -0
- package/dist/packages/source-store/lib/urls.d.ts +6 -0
- package/dist/packages/source-store/lib/urls.js +15 -0
- package/dist/packages/source-store/resolve.d.ts +59 -0
- package/dist/packages/source-store/resolve.js +45 -0
- package/dist/scan.d.ts +65 -0
- package/dist/scan.js +592 -0
- package/package.json +95 -4
- package/schema/config.schema.json +133 -0
- package/schema/report.schema.json +1905 -0
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import type { Holder, Realm, SerializedCatalog } from '../../../catalog.ts';
|
|
2
|
+
import type { Dimension, Level, MutationReason, TargetReason } from '../../confidence/index.ts';
|
|
3
|
+
import type { Budget } from './budget.ts';
|
|
4
|
+
/** What a mutation does to its target (§8). It is part of identity. */
|
|
5
|
+
export declare const effects: readonly ["replace", "wrap", "add", "delete", "descriptor-change", "prototype-change"];
|
|
6
|
+
export type Effect = (typeof effects)[number];
|
|
7
|
+
/** The syntactic means of a mutation (§3). It is evidence, not identity. */
|
|
8
|
+
export declare const mechanisms: readonly ["assign", "define-property", "define-properties", "reflect-define", "bulk-assign", "delete", "set-prototype", "declare"];
|
|
9
|
+
export type Mechanism = (typeof mechanisms)[number];
|
|
10
|
+
/** The closed list of resolution-trace step kinds (§14). A new kind needs a spec change. */
|
|
11
|
+
export declare const traceStepKinds: readonly ["binding", "alias", "fold", "call", "module-link", "catalog-holder", "enumeration", "guard", "prune", "creation-site", "outcome", "restore", "token-check", "path-rule", "confidence-reason", "note"];
|
|
12
|
+
export type TraceStepKind = (typeof traceStepKinds)[number];
|
|
13
|
+
/** The closed list of limitation kinds (§13). A new kind needs a spec change. */
|
|
14
|
+
export declare const limitationKinds: readonly ["parse-failure", "unreadable", "source-maps-unpaired", "fetch-failed", "sri-mismatch", "remote-refused", "offline-skipped", "dynamic-code", "unresolved-reference", "realm-uncertain", "unresolved-holder", "unlinked-module-call", "analysis-budget"];
|
|
15
|
+
export type LimitationKind = (typeof limitationKinds)[number];
|
|
16
|
+
/**
|
|
17
|
+
* Whether a mutation leaves its target non-configurable or non-writable (§8): `unknown` when the resolver can't tell,
|
|
18
|
+
* as for a define whose descriptor it can't see (§3).
|
|
19
|
+
*/
|
|
20
|
+
export type Locks = boolean | 'unknown';
|
|
21
|
+
/** Whether a write reaches the artifact's own global, another window's, or one the analyzer can't tell (§4). */
|
|
22
|
+
export type RealmInstance = 'current' | 'other' | 'unknown';
|
|
23
|
+
/**
|
|
24
|
+
* The declarations that bind a property of the global object (§5): a classic script's top-level `var` or `function`,
|
|
25
|
+
* or a block-level function Annex B hoists to the global object (`block-function`). A classic script's top-level `let`,
|
|
26
|
+
* `const` or `class` binds no property, but hides the global object's from bare-name callers (§3 Declarations in
|
|
27
|
+
* classic scripts): a write it makes names it as its declaration.
|
|
28
|
+
*/
|
|
29
|
+
export type GlobalDeclarationKind = 'var' | 'function' | 'block-function' | 'let' | 'const' | 'class';
|
|
30
|
+
/**
|
|
31
|
+
* The syntactic forms a write reaches the global object through without a call (§5 Global resolution):
|
|
32
|
+
* - `global-property`: a free name that is the global object's property, as a bare global (`fetch` in `fetch = w`) or
|
|
33
|
+
* a bare constructor or namespace (`XMLHttpRequest` in `XMLHttpRequest.prototype.send = w`)
|
|
34
|
+
* - `global-name`: a free `window`, `self` or `globalThis`, the realm's names for its global object, and in the window
|
|
35
|
+
* realm a free `frames`, which is the window itself (§5 Other windows)
|
|
36
|
+
* - `guarded-global`: a free `global` under a `typeof global` guard
|
|
37
|
+
* - `top-level-this`: `this` at the top level of a classic script, as UMD wrappers pass it
|
|
38
|
+
* - `function-return-this`: `Function('return this')()`
|
|
39
|
+
* - `sloppy-this`: `this` in a sloppy function that a call the resolver evaluates calls without a `this`, or with `null`
|
|
40
|
+
* or `undefined` as its `thisArg`: `(function(){ return this })()`, `f()`, `f.call(null)`, an iteration
|
|
41
|
+
* native's callback with no `thisArg`
|
|
42
|
+
* - `other-window`: a window reached from another value: through `parent`, `top` or `opener` from a window, as a child
|
|
43
|
+
* window through a constant index read on a window (`window[0]`, named `[0]`) or any index read on a window spelled
|
|
44
|
+
* as the frames collection (`frames[i]`, named `[i]`), or through `defaultView` or `contentWindow` on any object
|
|
45
|
+
* (§5 Other windows). This window's `document.defaultView`, and a child's `parent` of this window, are this window.
|
|
46
|
+
* - `singleton`: a platform singleton, read from a window or another singleton through an access path in its alias
|
|
47
|
+
* group (§4): `localStorage` in `window.localStorage`, `location` in `document.location`
|
|
48
|
+
*/
|
|
49
|
+
export declare const globalForms: readonly ["global-property", "global-name", "guarded-global", "top-level-this", "function-return-this", "sloppy-this", "other-window", "singleton"];
|
|
50
|
+
export type GlobalForm = (typeof globalForms)[number];
|
|
51
|
+
/**
|
|
52
|
+
* A `binding` trace step (§14): how a name resolved, the form the global object was recognized in, and its realm and
|
|
53
|
+
* realm instance.
|
|
54
|
+
* - `global`: to no declaration, so the name is the global object's property of that name (`fetch` in `fetch = w`).
|
|
55
|
+
* When that property's value is a native holder, `holds` names it: the catalog's holder (`XMLHttpRequest`), or a
|
|
56
|
+
* platform singleton (`localStorage`).
|
|
57
|
+
* - `alias`: to no declaration, and the name is an alias of a holder, named in `aliasOf`: `window`, `self`,
|
|
58
|
+
* `globalThis`, a guarded `global`, a top-level `this`, `Function('return this')()` and another window are aliases
|
|
59
|
+
* of the global object (`Window`). A member read through an access path in a singleton's alias group is an alias of
|
|
60
|
+
* the singleton, and `path` is that access path (`location` in `document.location`).
|
|
61
|
+
* - `declaration`: to a declaration that binds the global object's property, recorded in `declaration`. It is an alias
|
|
62
|
+
* too when the name is one (`var self; self.fetch = w`).
|
|
63
|
+
*
|
|
64
|
+
* A step from a value (`parent` in `window.parent`, `location` in `document.location`) follows the steps of the value
|
|
65
|
+
* it is read from. `realmInstance` is the window the name's value belongs to (§4 Other windows). `chain` locates the
|
|
66
|
+
* outermost `?:`, `||`, `&&` or `??` chain the name was selected through, as in
|
|
67
|
+
* `("undefined" != typeof globalThis ? globalThis : …).fetch = w`.
|
|
68
|
+
*/
|
|
69
|
+
export interface BindingStep {
|
|
70
|
+
kind: 'binding';
|
|
71
|
+
name: string;
|
|
72
|
+
resolution: 'global' | 'alias' | 'declaration';
|
|
73
|
+
form: GlobalForm;
|
|
74
|
+
aliasOf?: string;
|
|
75
|
+
holds?: string;
|
|
76
|
+
path?: string;
|
|
77
|
+
declaration?: {
|
|
78
|
+
kind: GlobalDeclarationKind;
|
|
79
|
+
generated: GeneratedLocation;
|
|
80
|
+
};
|
|
81
|
+
chain?: GeneratedLocation;
|
|
82
|
+
realm: Realm;
|
|
83
|
+
realmInstance: RealmInstance;
|
|
84
|
+
text: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A `confidence-reason` trace step (§14): the evidence behind a target or mutation confidence reason the occurrence
|
|
88
|
+
* carries (§9). For `with-scope` and `direct-eval-scope`, it names the name whose resolution path the evidence is on,
|
|
89
|
+
* and the `with` statements or direct `eval` calls there, in document order. For `outcome-undecidable`, `sites` locates
|
|
90
|
+
* what the outcome depends on and the analyzer can't see or decide (§3 Undecidable outcomes): the parts of a define's
|
|
91
|
+
* descriptor, or the object a `Reflect.set` looks its member up on.
|
|
92
|
+
*/
|
|
93
|
+
export interface ConfidenceReasonStep {
|
|
94
|
+
kind: 'confidence-reason';
|
|
95
|
+
dimension: 'target' | 'mutation';
|
|
96
|
+
reason: TargetReason | MutationReason;
|
|
97
|
+
level: Exclude<Level, 'high'>;
|
|
98
|
+
name?: string;
|
|
99
|
+
sites?: GeneratedLocation[];
|
|
100
|
+
/** For `holder-alternatives` and `member-alternatives`, the site's other candidate targets (§5 Candidate sets). */
|
|
101
|
+
alternatives?: string[];
|
|
102
|
+
text: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The natives that compile code from strings (§2 Content that isn't JavaScript): `eval`, the `Function` constructor
|
|
106
|
+
* (called or constructed), and string timers.
|
|
107
|
+
*/
|
|
108
|
+
export declare const codeCallees: readonly ["eval", "Function", "setTimeout", "setInterval"];
|
|
109
|
+
export type CodeCallee = (typeof codeCallees)[number];
|
|
110
|
+
/**
|
|
111
|
+
* A `note` trace step (§14) that says the write is in nested code (§2): code the native `callee` compiles from a string
|
|
112
|
+
* literal in the call at `call`, or, for `script`, the literal text of a script element the code creates and inserts
|
|
113
|
+
* with the call at `call`, which runs as a classic script. `scope` says where its names resolve: in the caller's
|
|
114
|
+
* scope (a direct eval), or in the global scope (an indirect eval, a string timer, a function the `Function`
|
|
115
|
+
* constructor makes, or a script). Code nested in nested code gives a note per level, outermost first.
|
|
116
|
+
*/
|
|
117
|
+
export interface NestedCodeStep {
|
|
118
|
+
kind: 'note';
|
|
119
|
+
about: 'nested-code';
|
|
120
|
+
callee: CodeCallee | 'script';
|
|
121
|
+
scope: 'caller' | 'global';
|
|
122
|
+
call: GeneratedLocation;
|
|
123
|
+
text: string;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* A `note` trace step (§14) that says a delete of the same slot came first (§3 A delete that is always rewritten): the
|
|
127
|
+
* delete at `delete`, which the same function follows on every path with this write, so it gives no finding of its own.
|
|
128
|
+
*/
|
|
129
|
+
export interface RewrittenDeleteStep {
|
|
130
|
+
kind: 'note';
|
|
131
|
+
about: 'rewritten-delete';
|
|
132
|
+
delete: GeneratedLocation;
|
|
133
|
+
text: string;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A `note` trace step (§14) that says another classic script in the realm declares a name the write reads bare at the
|
|
137
|
+
* top level with `let`, `const` or `class` (§3 Declarations in classic scripts): the scan-wide lexical-name check. At
|
|
138
|
+
* runtime that name reaches the other script's lexical binding, not the global object's property, when both load.
|
|
139
|
+
* `name` is the bare name: the one written (`fetch = w`), or the one the holder chain starts at (`Node` in
|
|
140
|
+
* `Node.prototype.foo = f`). `artifact` is the declaring script's URL, and `generated` locates the bound
|
|
141
|
+
* identifier there. The finding is kept, since there is no evaluation-order modelling between scripts.
|
|
142
|
+
*/
|
|
143
|
+
export interface LexicalCollisionStep {
|
|
144
|
+
kind: 'note';
|
|
145
|
+
about: 'lexical-collision';
|
|
146
|
+
name: string;
|
|
147
|
+
declaration: 'let' | 'const' | 'class';
|
|
148
|
+
artifact: string;
|
|
149
|
+
generated: GeneratedLocation;
|
|
150
|
+
text: string;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* A top-level `let`, `const` or `class` declaration of a classic script (§3 Declarations in classic scripts), which
|
|
154
|
+
* the scan-wide lexical-name check collects per realm: the declaring artifact's URL, the bound name, and where the
|
|
155
|
+
* identifier is.
|
|
156
|
+
*/
|
|
157
|
+
export interface LexicalDeclaration {
|
|
158
|
+
artifact: string;
|
|
159
|
+
name: string;
|
|
160
|
+
kind: 'let' | 'const' | 'class';
|
|
161
|
+
generated: GeneratedLocation;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A `fold` trace step (§14): an expression folded to a constant, such as `"add" + "EventListener"` to
|
|
165
|
+
* `"addEventListener"`. For a `const` read through its name, `name` is the name, and the expression is the one its value
|
|
166
|
+
* comes from: its initializer, the element or property it destructures, or its default. `expression` is printed from
|
|
167
|
+
* the syntax and cut at 120 characters, and `generated` locates it. The constant is its `value`, or for a well-known
|
|
168
|
+
* symbol read from `Symbol` (§4 Property keys), `symbol`: the symbol's member spelling in the catalog, `@@iterator`.
|
|
169
|
+
*/
|
|
170
|
+
export type FoldStep = {
|
|
171
|
+
kind: 'fold';
|
|
172
|
+
name?: string;
|
|
173
|
+
expression: string;
|
|
174
|
+
generated: GeneratedLocation;
|
|
175
|
+
text: string;
|
|
176
|
+
} & ({
|
|
177
|
+
value: string | number | boolean | null;
|
|
178
|
+
} | {
|
|
179
|
+
symbol: string;
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* An `alias` trace step (§14): the value was read through the variable `name`, from its definition that reaches the
|
|
183
|
+
* read (§5 Resolver capabilities 2): a declarator, an assignment, an update or a loop head. `expression` is the
|
|
184
|
+
* definition, printed from the syntax and cut at 120 characters, and `generated` locates it.
|
|
185
|
+
*/
|
|
186
|
+
export interface AliasStep {
|
|
187
|
+
kind: 'alias';
|
|
188
|
+
name: string;
|
|
189
|
+
expression: string;
|
|
190
|
+
generated: GeneratedLocation;
|
|
191
|
+
text: string;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A `catalog-holder` trace step (§14): a holder the unmutated catalog chose (§4). `expression` is printed from the
|
|
195
|
+
* syntax and cut at 120 characters, and `generated` locates it. It is one of:
|
|
196
|
+
* - a prototype step: `Object.getPrototypeOf(h)` (or `h.__proto__`) of the native holder `prototypeOf` is `holder`, its
|
|
197
|
+
* prototype in the unmutated catalog: `Object.getPrototypeOf(console)` is `console.[[Prototype]]`
|
|
198
|
+
* - an own-property test: whether the native holder `tested` `owns` the catalog `member`, which chose the holder the
|
|
199
|
+
* runtime choice takes (`hasOwnProperty.call(history, m) ? history : History.prototype`). With no `member`, the key
|
|
200
|
+
* didn't fold, and `tested` owns only structural members, so it owns none that counts
|
|
201
|
+
* - a prototype walk to the first owner: the holders `walk` visits from its start value, in order, and `holder`, the
|
|
202
|
+
* first that owns `member`. With no `member`, the key didn't fold, and `holder` is one holder that may own it
|
|
203
|
+
*/
|
|
204
|
+
export type CatalogHolderStep = {
|
|
205
|
+
kind: 'catalog-holder';
|
|
206
|
+
expression: string;
|
|
207
|
+
generated: GeneratedLocation;
|
|
208
|
+
text: string;
|
|
209
|
+
} & ({
|
|
210
|
+
prototypeOf: string;
|
|
211
|
+
holder: string;
|
|
212
|
+
} | {
|
|
213
|
+
tested: string;
|
|
214
|
+
member?: string;
|
|
215
|
+
owns: boolean;
|
|
216
|
+
} | {
|
|
217
|
+
walk: string[];
|
|
218
|
+
member?: string;
|
|
219
|
+
holder: string;
|
|
220
|
+
});
|
|
221
|
+
/**
|
|
222
|
+
* An `enumeration` trace step (§14), in one of two shapes:
|
|
223
|
+
* - a member sweep the catalog expanded (§5 Resolver capabilities 9). The enumeration `expression` at `generated` (the
|
|
224
|
+
* call, or a `for…in` loop's object), printed from the syntax and cut at 120 characters, swept the native `holder` by
|
|
225
|
+
* `enumeration`, and gave the catalog `member`. `filters` are the filters the key went through, in order, each `kept`
|
|
226
|
+
* when it keeps the member and `undecided` when the analyzer can't tell, which makes reachability `conditional`.
|
|
227
|
+
* - a configurable wildcard prefix (§5 Pattern wildcards): the key `expression` at `generated`, written on
|
|
228
|
+
* `holder`, starts with a prefix whose other alternatives the analyzer can't resolve, which give nothing, and
|
|
229
|
+
* `prefix` is its default, the literal alternative this wildcard comes from.
|
|
230
|
+
*/
|
|
231
|
+
export type EnumerationStep = {
|
|
232
|
+
kind: 'enumeration';
|
|
233
|
+
expression: string;
|
|
234
|
+
generated: GeneratedLocation;
|
|
235
|
+
holder: string;
|
|
236
|
+
text: string;
|
|
237
|
+
} & ({
|
|
238
|
+
enumeration: 'for-in' | 'Object.keys' | 'Object.getOwnPropertyNames' | 'Object.entries' | 'Object.getOwnPropertyDescriptors' | 'Reflect.ownKeys' | 'Object.getOwnPropertySymbols';
|
|
239
|
+
member: string;
|
|
240
|
+
filters: {
|
|
241
|
+
expression: string;
|
|
242
|
+
generated: GeneratedLocation;
|
|
243
|
+
result: 'kept' | 'undecided';
|
|
244
|
+
}[];
|
|
245
|
+
} | {
|
|
246
|
+
prefix: string;
|
|
247
|
+
configurable: true;
|
|
248
|
+
});
|
|
249
|
+
/**
|
|
250
|
+
* A `call` trace step (§14): a summarized call (§5 Resolver capabilities 3). A value came into the function at
|
|
251
|
+
* `function` through the call at `generated`, whose `callee` is printed from the syntax, as a parameter bound to an
|
|
252
|
+
* argument, as its `this`, or as what the function returns. `bindings` pairs each parameter, printed, with the argument
|
|
253
|
+
* the call passes it, printed, or null when it passes none. `this` is the receiver the call dispatches through, printed:
|
|
254
|
+
* the object a method is read from, or a `thisArg`; a `new`'s is the instance it makes. Printed expressions are cut at
|
|
255
|
+
* 120 characters.
|
|
256
|
+
*/
|
|
257
|
+
export interface CallStep {
|
|
258
|
+
kind: 'call';
|
|
259
|
+
callee: string;
|
|
260
|
+
generated: GeneratedLocation;
|
|
261
|
+
function: GeneratedLocation;
|
|
262
|
+
bindings: {
|
|
263
|
+
parameter: string;
|
|
264
|
+
argument: string | null;
|
|
265
|
+
}[];
|
|
266
|
+
this?: string;
|
|
267
|
+
text: string;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A `creation-site` trace step (§14): the write is in a function object that no resolved call reaches, judged from
|
|
271
|
+
* where it was created (§5 Resolver capabilities 3, §7). `function` locates the function, and `generated` where the
|
|
272
|
+
* object was made: the function or class itself, or for a method assumed to run with an object it is held on, that
|
|
273
|
+
* object's allocation site, which `this` prints. Its creation bindings are in the `call` steps of the calls that made
|
|
274
|
+
* it.
|
|
275
|
+
*/
|
|
276
|
+
export interface CreationSiteStep {
|
|
277
|
+
kind: 'creation-site';
|
|
278
|
+
function: GeneratedLocation;
|
|
279
|
+
generated: GeneratedLocation;
|
|
280
|
+
this?: string;
|
|
281
|
+
text: string;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* A `module-link` trace step (§6, §14): a module-link hop the value came through. `idiom` is the module-linking idiom:
|
|
285
|
+
* `factory-table` for a require call that runs a module's factory, `lazy-thunk` and `memoized-getter` for a call of a
|
|
286
|
+
* module's thunk or getter that runs it, `interop` for an interop wrapper's call over one, and `getter-export` for an
|
|
287
|
+
* export a getter export definer defines. `module` is the module's build-local id or name, `export` the export's name,
|
|
288
|
+
* `artifact` the artifact the module is in, and `generated` where the hop is: the call, or the export's getter or value.
|
|
289
|
+
*/
|
|
290
|
+
export interface ModuleLinkStep {
|
|
291
|
+
kind: 'module-link';
|
|
292
|
+
idiom: 'factory-table' | 'getter-export' | 'interop' | 'lazy-thunk' | 'memoized-getter';
|
|
293
|
+
module: string;
|
|
294
|
+
export?: string;
|
|
295
|
+
artifact: string;
|
|
296
|
+
generated: GeneratedLocation;
|
|
297
|
+
text: string;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Whether a platform mutation happens (§7 Values), judged by the guards on its path:
|
|
301
|
+
* - `unconditional`: no guard that matters
|
|
302
|
+
* - `guarded-native-absence`: it runs only when some native, not necessarily the target, is missing
|
|
303
|
+
* - `conditional`: a recognized guard that can't be decided statically
|
|
304
|
+
* - `unknown`: control flow the analyzer couldn't model
|
|
305
|
+
*
|
|
306
|
+
* It is not identity, and in R1 it doesn't make a finding `changed` (§11, ADR 0014).
|
|
307
|
+
*/
|
|
308
|
+
export declare const reachabilities: readonly ["unconditional", "guarded-native-absence", "conditional", "unknown"];
|
|
309
|
+
export type Reachability = (typeof reachabilities)[number];
|
|
310
|
+
/**
|
|
311
|
+
* How an occurrence's reachability was judged (§7 Where reachability is judged from): `call-path`, along resolved calls
|
|
312
|
+
* out to its install entry, or `creation-site`, from where a function no resolved call reaches was created. Evidence,
|
|
313
|
+
* never identity: it decides nothing in R1.
|
|
314
|
+
*/
|
|
315
|
+
export type ReachabilityBasis = 'call-path' | 'creation-site';
|
|
316
|
+
/**
|
|
317
|
+
* Whether a mutation runs at load or later (§7 Install context): `load` when a resolved synchronous chain reaches
|
|
318
|
+
* top-level code, `deferred` when only a later call of its install entry reaches it. Evidence, never identity: it
|
|
319
|
+
* doesn't make a finding `changed` in R1 (§11, ADR 0014).
|
|
320
|
+
*/
|
|
321
|
+
export declare const installContexts: readonly ["load", "deferred"];
|
|
322
|
+
export type InstallContext = (typeof installContexts)[number];
|
|
323
|
+
/**
|
|
324
|
+
* The class of a guard (§14 `guard`): `transparent` (it leaves the mutation `unconditional`: the written target's own
|
|
325
|
+
* presence, a once-flag, a writability check, a test decided as a constant), `absence` (a native is missing),
|
|
326
|
+
* `broken-native` (a native is judged broken rather than missing), `config` (a config or option flag),
|
|
327
|
+
* `other-target` (the presence of a native other than the target), `unknown` (a guard the analyzer doesn't recognize,
|
|
328
|
+
* an unresolved call, or `with` or direct-`eval` taint) and `undecided` (a recognized guard that can't be decided).
|
|
329
|
+
*/
|
|
330
|
+
export declare const guardClasses: readonly ["transparent", "absence", "broken-native", "config", "other-target", "unknown", "undecided"];
|
|
331
|
+
export type GuardClass = (typeof guardClasses)[number];
|
|
332
|
+
/**
|
|
333
|
+
* A `guard` trace step (§14): a guard on the write's path, the `expression` at `generated`, printed from the syntax and
|
|
334
|
+
* cut at 120 characters; its class; the native it tests, by target name (`Window.fetch` for `!g.fetch`), when it tests
|
|
335
|
+
* one; and the reachability it gives on its own.
|
|
336
|
+
*/
|
|
337
|
+
export interface GuardStep {
|
|
338
|
+
kind: 'guard';
|
|
339
|
+
expression: string;
|
|
340
|
+
generated: GeneratedLocation;
|
|
341
|
+
class: GuardClass;
|
|
342
|
+
tested?: string;
|
|
343
|
+
result: Reachability;
|
|
344
|
+
text: string;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* A `prune` trace step (§7, §14): the finding occurrences a statically false catalog check pruned, `count` of them,
|
|
348
|
+
* and the guard: the test `expression` at `generated`, printed from the syntax and cut at 120 characters. It follows
|
|
349
|
+
* that guard's `guard` step on each surviving occurrence the same guard is on. With `judgement`, it is instead the writes
|
|
350
|
+
* a `catch` arm whose `try` can't throw dropped (§5 Resolver capabilities 9), or those an arm a call argument
|
|
351
|
+
* literal's field rules out alone reaches (§5 Resolver capabilities 5).
|
|
352
|
+
*/
|
|
353
|
+
export interface PruneStep {
|
|
354
|
+
kind: 'prune';
|
|
355
|
+
count: number;
|
|
356
|
+
expression: string;
|
|
357
|
+
generated: GeneratedLocation;
|
|
358
|
+
/**
|
|
359
|
+
* Set when a `catch` arm's `try` judged unable to throw dropped the writes (§5 Resolver capabilities 9): then
|
|
360
|
+
* `expression` and `generated` are the `try`'s, and `count` the writes in the arm it dropped. Set to `argument-literal`
|
|
361
|
+
* when a call argument literal's field settled the test `expression` at `generated`: `count` is then the writes
|
|
362
|
+
* the arm it rules out alone reaches.
|
|
363
|
+
*/
|
|
364
|
+
judgement?: 'try-cannot-throw' | 'argument-literal';
|
|
365
|
+
/**
|
|
366
|
+
* With `judgement` `argument-literal` (§5 Resolver capabilities 5): the call argument object literal whose
|
|
367
|
+
* field settled the test `expression` at `generated`, printed and cut at 120 characters, and where it is. `count` is
|
|
368
|
+
* the writes the arm the test rules out alone reaches.
|
|
369
|
+
*/
|
|
370
|
+
literal?: {
|
|
371
|
+
expression: string;
|
|
372
|
+
generated: GeneratedLocation;
|
|
373
|
+
};
|
|
374
|
+
text: string;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* A `restore` trace step (§3 Restores, §14): a proven restore in the install occurrence's chain, which writes the
|
|
378
|
+
* unmutated native of the same object and member back at `generated`. `guard` is `identity` when the restore runs only
|
|
379
|
+
* if the slot still holds the code's own value (`if (window.fetch === ours)`), and `none` when it writes whatever is
|
|
380
|
+
* there. `leavesOwnShadow` is true when it writes the native back into an own property the install created, which
|
|
381
|
+
* shadows the inherited member (`history.pushState`). It is evidence, never identity.
|
|
382
|
+
*/
|
|
383
|
+
export interface RestoreStep {
|
|
384
|
+
kind: 'restore';
|
|
385
|
+
generated: GeneratedLocation;
|
|
386
|
+
guard: 'identity' | 'none';
|
|
387
|
+
leavesOwnShadow: boolean;
|
|
388
|
+
text: string;
|
|
389
|
+
}
|
|
390
|
+
/** One step of an occurrence's resolution trace (§14). Tests assert on `kind` and fields, never on `text`. */
|
|
391
|
+
export type TraceStep = AliasStep | BindingStep | CallStep | CatalogHolderStep | ConfidenceReasonStep | CreationSiteStep | EnumerationStep | FoldStep | GuardStep | LexicalCollisionStep | ModuleLinkStep | NestedCodeStep | OutcomeStep | PruneStep | RestoreStep | RewrittenDeleteStep;
|
|
392
|
+
/**
|
|
393
|
+
* An artifact as the resolver sees it: its URL, content hash, `sourceType` and realm (§19), and how the realm is known
|
|
394
|
+
* (§2 Realm): from how the artifact was referenced, or assumed to be `window` because only the sweep found it. The
|
|
395
|
+
* occurrences of a group whose realm is assumed carry the target-confidence reason `realm-assumed` (§9).
|
|
396
|
+
*/
|
|
397
|
+
export interface ArtifactRef {
|
|
398
|
+
url: string;
|
|
399
|
+
hash: string;
|
|
400
|
+
sourceType: 'script' | 'module';
|
|
401
|
+
realm: Realm;
|
|
402
|
+
realmBasis: 'reference' | 'assumed';
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* An artifact's source text, as the resolver pulls it through `artifact(url)`, and where it is served from (§8 Origin),
|
|
406
|
+
* which bounds how far a helper write's lookup crosses artifacts (§10).
|
|
407
|
+
*/
|
|
408
|
+
export interface ArtifactSource extends ArtifactRef {
|
|
409
|
+
text: string;
|
|
410
|
+
origin?: 'local-build' | 'same-origin' | 'cross-origin' | 'inline';
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* A position in an artifact's generated code (§5): a UTF-16 range, and its start as a 1-based line and a 0-based
|
|
414
|
+
* column, through the artifact's line-start table.
|
|
415
|
+
*/
|
|
416
|
+
export interface GeneratedLocation {
|
|
417
|
+
start: number;
|
|
418
|
+
end: number;
|
|
419
|
+
line: number;
|
|
420
|
+
column: number;
|
|
421
|
+
}
|
|
422
|
+
/** A target (§4): `{ realm, holder, name, shadows? }`. Realm and name are identity. */
|
|
423
|
+
export interface Target {
|
|
424
|
+
realm: Realm;
|
|
425
|
+
holder: Holder;
|
|
426
|
+
name: string;
|
|
427
|
+
shadows?: string;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Where attribution looks a write up in its artifact's source map (§10 lookup point), and the token the token check
|
|
431
|
+
* looks for there. `token` is null when the site has none, and the check doesn't apply.
|
|
432
|
+
* - The write's member token, written at the site as an identifier, a string or a template with no substitutions:
|
|
433
|
+
* `fetch` in `window.fetch = w`, `window["fetch"] = w` or ``window[`fetch`] = w``, the `'fetch'` argument of
|
|
434
|
+
* `Object.defineProperty`, a key in `Object.defineProperties` or `Object.assign`.
|
|
435
|
+
* - Otherwise its holder argument: for a write with no member (`setPrototypeOf`, `__proto__`), or a member that isn't
|
|
436
|
+
* written at the site as a token (`window[k] = w`, `h[0] = w`). Its token is its name only when it is written as a
|
|
437
|
+
* free global (`window`) or a literal property name (`history` in `window.history`), never as a local binding.
|
|
438
|
+
* - A write in nested code (§2): the start of its enclosing literal in the host artifact's own code, with no token.
|
|
439
|
+
* - A write inside a helper: the outermost call on the chain whose arguments carry both the holder and the member
|
|
440
|
+
* (§10): the holder came through one of them, and one of them is the member's key. Its token is that key when it is
|
|
441
|
+
* written at the call as a string or a template with no substitutions. The occurrence keeps the helper's write as its
|
|
442
|
+
* position.
|
|
443
|
+
*/
|
|
444
|
+
export interface Lookup {
|
|
445
|
+
/**
|
|
446
|
+
* The URL of the artifact the lookup point is in, when it isn't the write's: a call in another artifact of the link
|
|
447
|
+
* group with the write's origin (§10).
|
|
448
|
+
*/
|
|
449
|
+
artifact?: string;
|
|
450
|
+
generated: GeneratedLocation;
|
|
451
|
+
token: string | null;
|
|
452
|
+
}
|
|
453
|
+
/** The fields the resolver owns on an occurrence (§19 Raw occurrences). No later module changes them. */
|
|
454
|
+
export interface RawOccurrence {
|
|
455
|
+
/** The URL of the artifact the write is in. */
|
|
456
|
+
artifact: string;
|
|
457
|
+
generated: GeneratedLocation;
|
|
458
|
+
/** Where attribution looks the write up (§10), which may differ from where the write is. */
|
|
459
|
+
lookup: Lookup;
|
|
460
|
+
target: Target;
|
|
461
|
+
effect: Effect;
|
|
462
|
+
mechanism: Mechanism;
|
|
463
|
+
/**
|
|
464
|
+
* Whether the write reaches the artifact's own global object, another window's, or one the analyzer can't tell (§4
|
|
465
|
+
* Other windows). It is evidence, never identity.
|
|
466
|
+
*/
|
|
467
|
+
realmInstance: RealmInstance;
|
|
468
|
+
/** Whether the mutation leaves the target non-configurable or non-writable (§8). */
|
|
469
|
+
locks: Locks;
|
|
470
|
+
/** Whether the mutation happens, judged by the guards on its path (§7). */
|
|
471
|
+
reachability: Reachability;
|
|
472
|
+
/** How its reachability was judged (§7). */
|
|
473
|
+
reachabilityBasis: ReachabilityBasis;
|
|
474
|
+
/** Whether it runs at load or later (§7 Install context). */
|
|
475
|
+
installContext: InstallContext;
|
|
476
|
+
/**
|
|
477
|
+
* The name of the install entry a `deferred` mutation waits on (`init`), or null: for a `load` one, or an entry that
|
|
478
|
+
* has no name (an anonymous callback).
|
|
479
|
+
*/
|
|
480
|
+
installEntry: string | null;
|
|
481
|
+
/** The confidence dimensions the resolver owns (§9, §19 Raw occurrences). Attribution adds the third. */
|
|
482
|
+
confidence: {
|
|
483
|
+
target: Dimension<TargetReason>;
|
|
484
|
+
mutation: Dimension<MutationReason>;
|
|
485
|
+
};
|
|
486
|
+
trace: TraceStep[];
|
|
487
|
+
/**
|
|
488
|
+
* For a wildcard whose matched set a candidate set narrows (§5), the catalog targets it matches, by name, as data
|
|
489
|
+
* for `--surface` (§12). It never crosses into the report.
|
|
490
|
+
*/
|
|
491
|
+
matches?: string[];
|
|
492
|
+
}
|
|
493
|
+
/** A coverage limitation record (§13): `{ kind, artifact, location, detail }`. */
|
|
494
|
+
export interface Limitation {
|
|
495
|
+
kind: LimitationKind;
|
|
496
|
+
artifact: {
|
|
497
|
+
url: string;
|
|
498
|
+
hash: string;
|
|
499
|
+
};
|
|
500
|
+
location?: GeneratedLocation;
|
|
501
|
+
detail: string;
|
|
502
|
+
/**
|
|
503
|
+
* For an `unresolved-holder` record, the candidate targets its `detail` lists, in the artifact's realm, as data for
|
|
504
|
+
* the surface filter (§12): `detail` ends with them, joined by `, `, so the findings stage can list only the ones it
|
|
505
|
+
* keeps. They don't cross into the report.
|
|
506
|
+
*/
|
|
507
|
+
candidates?: string[];
|
|
508
|
+
}
|
|
509
|
+
/** The per-artifact module-linking summary (§6). */
|
|
510
|
+
export interface ModuleLinking {
|
|
511
|
+
idioms: string[];
|
|
512
|
+
modules: number;
|
|
513
|
+
unlinked: number;
|
|
514
|
+
linkGroups: number;
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* A reference only the resolver can see (§19 Discovery): its URL as the code builds it, unresolved, its kind, and where
|
|
518
|
+
* it is: the group member it is in, as the group names it, and its location there. A `chunk` reference also says how
|
|
519
|
+
* its load site loads it (`load`): a created script element's `src`, `importScripts` or `import()`. When some
|
|
520
|
+
* alternative of the URL doesn't fold to a constant, the record is `partial`: a chunk's `url` is then only the constant
|
|
521
|
+
* prefix that alternative starts with ('' for none), which decides whether a chunk URL that doesn't fold is local
|
|
522
|
+
* (§2), and an injected script's or worker's is '', with `alternative` locating the alternative that doesn't fold. An
|
|
523
|
+
* `injected` reference also carries its element's `type` as it folds (absent when none is set, null when it doesn't
|
|
524
|
+
* fold), its `integrity` constants when they fold (§17) and whether its `noModule` is set. A `worker` reference's
|
|
525
|
+
* location is the worker URL argument of the call that discovery recognizes as a worker call.
|
|
526
|
+
*/
|
|
527
|
+
export interface DiscoveredReference {
|
|
528
|
+
url: string;
|
|
529
|
+
kind: 'injected' | 'worker' | 'chunk';
|
|
530
|
+
artifact: string;
|
|
531
|
+
location: GeneratedLocation;
|
|
532
|
+
load?: 'element' | 'import-scripts' | 'import';
|
|
533
|
+
partial?: true;
|
|
534
|
+
alternative?: GeneratedLocation;
|
|
535
|
+
/** For a `worker` site: its URL folds to no value, as when it throws (`new URL("x.js")`), so it loads nothing. */
|
|
536
|
+
none?: true;
|
|
537
|
+
type?: string | null;
|
|
538
|
+
/** The integrity value code sets on a chunk's script element, when it folds to a constant (§17 Integrity). */
|
|
539
|
+
integrity?: string;
|
|
540
|
+
/** For an `injected` reference: the constants its element's `integrity` may be, when each write folds. */
|
|
541
|
+
integrityAlternatives?: string[];
|
|
542
|
+
/** For an `injected` reference: its element's `noModule` is set (`yes`), or may be (`maybe`). */
|
|
543
|
+
noModule?: 'yes' | 'maybe';
|
|
544
|
+
}
|
|
545
|
+
/** Why a write can't change its target (§3 Ineffective writes). */
|
|
546
|
+
export declare const ineffectiveReasons: readonly ["readonly", "lenient-setter", "non-writable", "non-configurable", "immutable-prototype"];
|
|
547
|
+
export type IneffectiveReason = (typeof ineffectiveReasons)[number];
|
|
548
|
+
/**
|
|
549
|
+
* Whether an ineffective write throws (§3): `always` in sloppy and strict code alike, at parse or instantiation or when
|
|
550
|
+
* the write runs; `strict-only`; or `never`, as the `Reflect` forms return false.
|
|
551
|
+
*/
|
|
552
|
+
export declare const throwsValues: readonly ["always", "strict-only", "never"];
|
|
553
|
+
export type Throws = (typeof throwsValues)[number];
|
|
554
|
+
/** Whether the code a write is in is sloppy or strict mode code. */
|
|
555
|
+
export type Strictness = 'sloppy' | 'strict';
|
|
556
|
+
/**
|
|
557
|
+
* An `outcome` trace step (§14): the outcome table's decision on an ineffective write (§3). `mayChangeNothing` says
|
|
558
|
+
* the write's every other outcome, on a value the analyzer can't see, changes nothing (§3 No-op or ineffective).
|
|
559
|
+
*/
|
|
560
|
+
export interface OutcomeStep {
|
|
561
|
+
kind: 'outcome';
|
|
562
|
+
result: 'ineffective';
|
|
563
|
+
reason: IneffectiveReason;
|
|
564
|
+
throws: Throws;
|
|
565
|
+
mayChangeNothing: boolean;
|
|
566
|
+
text: string;
|
|
567
|
+
}
|
|
568
|
+
/**
|
|
569
|
+
* An occurrence of a write that cannot change its target (§3 Ineffective writes): where it is, the target it would
|
|
570
|
+
* have changed, its intended effect and mechanism, why it can't, whether it throws, and the strictness of its code. It
|
|
571
|
+
* is never a finding, and has no `locks` or confidence of its own.
|
|
572
|
+
*/
|
|
573
|
+
export interface IneffectiveWrite extends Omit<RawOccurrence, 'locks' | 'confidence'> {
|
|
574
|
+
reason: IneffectiveReason;
|
|
575
|
+
throws: Throws;
|
|
576
|
+
strictness: Strictness;
|
|
577
|
+
}
|
|
578
|
+
export interface AnalyzeGroupInput {
|
|
579
|
+
/** The group's entry artifact. */
|
|
580
|
+
entry: ArtifactRef;
|
|
581
|
+
/** Synchronous: the build's artifacts and fetched remote artifacts in this realm. */
|
|
582
|
+
artifact(url: string): ArtifactSource | undefined;
|
|
583
|
+
/**
|
|
584
|
+
* Synchronous: the URL a module request in the code of the artifact at `from` names (§6 Module links), as discovery
|
|
585
|
+
* resolved it, or undefined when it resolves to none.
|
|
586
|
+
*/
|
|
587
|
+
resolveImport?(from: string, specifier: string): string | undefined;
|
|
588
|
+
/**
|
|
589
|
+
* Synchronous: the build-directory artifacts in this realm whose code pushes chunk `id` (any chunk, for `null`) into
|
|
590
|
+
* the chunk registry named `registry` (§6 idiom 6), named as `artifact` names them, in URL order.
|
|
591
|
+
*/
|
|
592
|
+
chunks?(registry: string, id: string | null): readonly string[];
|
|
593
|
+
/**
|
|
594
|
+
* Synchronous: the other classic scripts the entry's document references that push into the chunk registry named
|
|
595
|
+
* `registry` (§6): the initial chunks a loader there links, which run at load. In URL order.
|
|
596
|
+
*/
|
|
597
|
+
initialChunks?(registry: string): readonly string[];
|
|
598
|
+
catalog: SerializedCatalog;
|
|
599
|
+
/** The step budget per source byte, and the caps (§18). */
|
|
600
|
+
budget: Budget;
|
|
601
|
+
}
|
|
602
|
+
export interface AnalyzeGroupOutput {
|
|
603
|
+
/** The group's actual members (§6). */
|
|
604
|
+
members: ArtifactRef[];
|
|
605
|
+
occurrences: RawOccurrence[];
|
|
606
|
+
ineffectiveWrites: IneffectiveWrite[];
|
|
607
|
+
limitations: Limitation[];
|
|
608
|
+
references: DiscoveredReference[];
|
|
609
|
+
moduleLinking: Record<string, ModuleLinking>;
|
|
610
|
+
/**
|
|
611
|
+
* The top-level `let`, `const` and `class` declarations of the group's classic scripts, in document order, for the
|
|
612
|
+
* scan-wide lexical-name check (§3). None when the group has none, or is modules only.
|
|
613
|
+
*/
|
|
614
|
+
lexicalDeclarations?: LexicalDeclaration[];
|
|
615
|
+
/**
|
|
616
|
+
* The group's work (§13 Scan statistics, §18): the steps it took, its step budget, whether it exhausted that budget,
|
|
617
|
+
* each cap's hits, and how many finding occurrences statically false catalog checks pruned (§7) plus writes `catch`
|
|
618
|
+
* arms whose `try` can't throw dropped, when any did.
|
|
619
|
+
*/
|
|
620
|
+
stats: {
|
|
621
|
+
steps: number;
|
|
622
|
+
budget: number;
|
|
623
|
+
exhausted: boolean;
|
|
624
|
+
caps: Record<string, number>;
|
|
625
|
+
pruned?: number;
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
/** The resolver seam (§19). Each release ships exactly one implementation (ADR 0018). */
|
|
629
|
+
export interface Resolver {
|
|
630
|
+
readonly analyzerVersion: string;
|
|
631
|
+
analyzeGroup(input: AnalyzeGroupInput): AnalyzeGroupOutput;
|
|
632
|
+
}
|