@eagleoutice/flowr 2.17.7 → 2.17.9
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/abstract-interpretation/branch-paths.d.ts +10 -0
- package/abstract-interpretation/branch-paths.js +104 -10
- package/config.d.ts +1 -1
- package/config.js +40 -8
- package/control-flow/control-flow-graph.js +18 -2
- package/data/r-base-guards.generated.js +2 -2
- package/dataflow/environments/ambient-effect.js +4 -1
- package/dataflow/environments/built-in-props.d.ts +8 -2
- package/dataflow/environments/built-in-props.js +16 -5
- package/dataflow/environments/default-builtin-config/base-functions.js +1 -1
- package/dataflow/environments/default-builtin-config/guards.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/guards.js +28 -0
- package/dataflow/environments/default-builtin-config/index.d.ts +8 -4
- package/dataflow/environments/default-builtin-config/index.js +9 -5
- package/dataflow/environments/default-builtin-config/parallel-execution.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/parallel-execution.js +25 -0
- package/dataflow/environments/guard-facts.d.ts +28 -1
- package/dataflow/environments/pkg-name.d.ts +2 -0
- package/dataflow/environments/query-fn-props.d.ts +19 -15
- package/dataflow/environments/query-fn-props.js +46 -36
- package/dataflow/environments/removal-marker.d.ts +1 -1
- package/dataflow/environments/removal-marker.js +18 -3
- package/dataflow/environments/reserved-names.d.ts +6 -0
- package/dataflow/environments/reserved-names.js +14 -0
- package/dataflow/environments/resolve-by-name.js +5 -10
- package/dataflow/eval/resolve/alias-tracking.js +23 -6
- package/dataflow/extractor.js +103 -28
- package/dataflow/fn/argument-roles.d.ts +3 -0
- package/dataflow/fn/argument-roles.js +5 -5
- package/dataflow/fn/exceptions-of-function.d.ts +7 -0
- package/dataflow/fn/exceptions-of-function.js +15 -2
- package/dataflow/fn/function-props.d.ts +1 -1
- package/dataflow/fn/function-props.js +40 -18
- package/dataflow/fn/function-semantics.d.ts +3 -1
- package/dataflow/fn/function-semantics.js +2 -0
- package/dataflow/fn/guards/built-in-guards.js +2 -1
- package/dataflow/fn/guards/condition-grouping.d.ts +11 -0
- package/dataflow/fn/guards/condition-grouping.js +50 -3
- package/dataflow/fn/guards/function-guards.d.ts +10 -0
- package/dataflow/fn/guards/function-guards.js +130 -14
- package/dataflow/fn/guards/guard-claims.d.ts +2 -0
- package/dataflow/fn/guards/guard-claims.js +42 -2
- package/dataflow/fn/guards/guard-knowledge.d.ts +7 -1
- package/dataflow/fn/guards/guard-knowledge.js +50 -4
- package/dataflow/fn/guards/guard-term.js +10 -1
- package/dataflow/fn/higher-order-function.d.ts +15 -1
- package/dataflow/fn/higher-order-function.js +54 -10
- package/dataflow/graph/call-graph.d.ts +5 -0
- package/dataflow/graph/call-graph.js +51 -15
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +4 -2
- package/dataflow/graph/graph.d.ts +21 -0
- package/dataflow/graph/graph.js +63 -2
- package/dataflow/internal/linker.d.ts +20 -0
- package/dataflow/internal/linker.js +190 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +20 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +5 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +7 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +12 -5
- package/dataflow/internal/process/functions/call/deferred.d.ts +7 -2
- package/dataflow/internal/process/functions/call/deferred.js +63 -28
- package/dataflow/internal/process/functions/call/quoted.js +33 -7
- package/documentation/data/dfg/doc-ambient.js +3 -1
- package/documentation/wiki-normalized-ast.js +1 -1
- package/documentation/wiki-query.js +9 -3
- package/package.json +5 -3
- package/project/context/flowr-analyzer-context.d.ts +7 -4
- package/project/context/flowr-analyzer-context.js +8 -3
- package/project/context/flowr-analyzer-files-context.js +1 -0
- package/project/context/flowr-analyzer-functions-context.d.ts +2 -1
- package/project/context/flowr-analyzer-functions-context.js +9 -8
- package/project/flowr-analyzer.d.ts +7 -4
- package/project/flowr-analyzer.js +37 -8
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +22 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +34 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +4 -1
- package/project/plugins/plugin-registry.d.ts +2 -2
- package/project/plugins/plugin-registry.js +1 -1
- package/project/sigdb/build.js +41 -2
- package/project/sigdb/decode.d.ts +3 -1
- package/project/sigdb/decode.js +45 -1
- package/project/sigdb/decompress.d.ts +5 -0
- package/project/sigdb/decompress.js +17 -1
- package/project/sigdb/manifest.d.ts +2 -1
- package/project/sigdb/manifest.js +12 -5
- package/project/sigdb/native-routines.d.ts +82 -0
- package/project/sigdb/native-routines.js +178 -0
- package/project/sigdb/reader.d.ts +21 -3
- package/project/sigdb/reader.js +35 -3
- package/project/sigdb/schema.d.ts +107 -3
- package/project/sigdb/schema.js +8 -2
- package/project/sigdb/sigdb-download.js +1 -1
- package/project/sigdb/sigdb-version.d.ts +7 -1
- package/project/sigdb/sigdb-version.js +12 -9
- package/project/sigdb/spec-query.d.ts +9 -4
- package/project/sigdb/spec-query.js +71 -45
- package/queries/catalog/call-context-query/call-context-query-executor.js +76 -29
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -12
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-guards-query/inspect-fn-guards-query-format.js +3 -2
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.d.ts +3 -0
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +3 -1
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +4 -2
- package/queries/catalog/signature-query/signature-query-executor.js +6 -2
- package/queries/catalog/signature-query/signature-query-format.d.ts +4 -0
- package/util/collections/bounded-map.d.ts +9 -0
- package/util/collections/bounded-map.js +22 -0
- package/util/collections/defaultmap.d.ts +5 -0
- package/util/collections/defaultmap.js +10 -0
- package/util/fixpoint.d.ts +6 -1
- package/util/fixpoint.js +45 -3
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/global-caches.d.ts +26 -0
- package/util/global-caches.js +43 -0
- package/util/monoid.js +2 -2
- package/util/quads.js +11 -3
- package/util/r-package-urls.d.ts +19 -0
- package/util/r-package-urls.js +41 -0
|
@@ -20,6 +20,16 @@ export declare class BranchPathDomain extends BoundedSetDomain<string> {
|
|
|
20
20
|
constructor(value: BoundedSetLift<string> | string[], limit?: number);
|
|
21
21
|
/** Past the limit, the paths are the one path of the steps all of them take, which still holds whichever way the node was reached. */
|
|
22
22
|
create(value: BoundedSetLift<string> | string[]): this;
|
|
23
|
+
/**
|
|
24
|
+
* the steps all paths take, as each join past the limit needs them of both sides: carried along by the operations
|
|
25
|
+
* when known, which is cheap (see {@link withCommon}), else worked out once per value
|
|
26
|
+
*/
|
|
27
|
+
private common;
|
|
28
|
+
private commonSteps;
|
|
29
|
+
/** The domain, knowing that its paths all take the `common` steps (if given) and no other step all of them take. */
|
|
30
|
+
private static withCommon;
|
|
31
|
+
/** Past the limit, the joined paths are the one path of the steps both sides' paths all take, so only those are intersected. */
|
|
32
|
+
protected joinValue(this: this & BranchPathDomain, other: BoundedSetDomain<string>): this;
|
|
23
33
|
/** Reached without any branch, as the start of a function body is. */
|
|
24
34
|
static start(): BranchPathDomain;
|
|
25
35
|
protected meetValue(this: this & BranchPathDomain, other: BoundedSetDomain<string>): this;
|
|
@@ -5,6 +5,8 @@ const assert_1 = require("../util/assert");
|
|
|
5
5
|
const lattice_1 = require("./domains/lattice");
|
|
6
6
|
const bounded_set_domain_1 = require("./domains/bounded-set-domain");
|
|
7
7
|
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
8
|
+
const global_caches_1 = require("../util/global-caches");
|
|
9
|
+
const defaultmap_1 = require("../util/collections/defaultmap");
|
|
8
10
|
/** How many paths are told apart before nothing is known about how a node is reached. */
|
|
9
11
|
const MaxPaths = 64;
|
|
10
12
|
const StepSeparator = '\u0002';
|
|
@@ -20,8 +22,60 @@ function decodeStep(step) {
|
|
|
20
22
|
function encodePath(steps) {
|
|
21
23
|
return [...steps].sort().join(StepSeparator);
|
|
22
24
|
}
|
|
25
|
+
/* both memos hold node ids of the analyzed code, so a reset releases them, and are bounded, so a large package does not hold every path it saw */
|
|
26
|
+
const MaxParsedPaths = 100_000;
|
|
27
|
+
/** the sorted steps of each path seen lately: the same paths flow through the whole interpretation, so they are split once */
|
|
28
|
+
const parsedPaths = global_caches_1.GlobalCaches.map('branch-paths', global_caches_1.CacheScope.Analysis, MaxParsedPaths);
|
|
29
|
+
/** per path and step, the path taking it: a loop is interpreted until nothing changes, so the same continuations come up again */
|
|
30
|
+
const continued = global_caches_1.GlobalCaches.map('branch-path-steps', global_caches_1.CacheScope.Analysis, MaxParsedPaths);
|
|
31
|
+
/** The steps of the path, sorted as {@link encodePath} sorts them. */
|
|
32
|
+
function sortedSteps(path) {
|
|
33
|
+
return (0, defaultmap_1.getOrSet)(parsedPaths, path, () => path === '' ? [] : path.split(StepSeparator));
|
|
34
|
+
}
|
|
23
35
|
function stepsOf(path) {
|
|
24
|
-
return new Set(path
|
|
36
|
+
return new Set(sortedSteps(path));
|
|
37
|
+
}
|
|
38
|
+
/** The path with `step` taken as well, the same string as `encodePath(stepsOf(path).add(step))` without splitting and sorting again. */
|
|
39
|
+
function withStep(path, step) {
|
|
40
|
+
return (0, defaultmap_1.getOrSet)((0, defaultmap_1.getOrSet)(continued, path, () => new Map()), step, () => insertStep(path, step));
|
|
41
|
+
}
|
|
42
|
+
/** Where `step` is or belongs in the sorted `steps`. */
|
|
43
|
+
function positionOf(steps, step) {
|
|
44
|
+
let low = 0;
|
|
45
|
+
let high = steps.length;
|
|
46
|
+
while (low < high) {
|
|
47
|
+
const mid = (low + high) >>> 1;
|
|
48
|
+
if (steps[mid] < step) {
|
|
49
|
+
low = mid + 1;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
high = mid;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return low;
|
|
56
|
+
}
|
|
57
|
+
function insertStep(path, step) {
|
|
58
|
+
const steps = sortedSteps(path);
|
|
59
|
+
const low = positionOf(steps, step);
|
|
60
|
+
return steps[low] === step ? path : [...steps.slice(0, low), step, ...steps.slice(low)].join(StepSeparator);
|
|
61
|
+
}
|
|
62
|
+
/** Whether the sorted `steps` have `step`. */
|
|
63
|
+
function hasStep(steps, step) {
|
|
64
|
+
return steps[positionOf(steps, step)] === step;
|
|
65
|
+
}
|
|
66
|
+
/** The steps all of the paths take: what is common shrinks fast, so each further path is only searched for what is left, never split into a set. */
|
|
67
|
+
function stepsInAll(paths) {
|
|
68
|
+
let common;
|
|
69
|
+
for (const path of paths) {
|
|
70
|
+
const steps = sortedSteps(path);
|
|
71
|
+
common = common === undefined ? [...steps] : common.filter(step => hasStep(steps, step));
|
|
72
|
+
}
|
|
73
|
+
return common ?? [];
|
|
74
|
+
}
|
|
75
|
+
/** The steps all of the paths take, encoded as a path. */
|
|
76
|
+
function commonPath(paths) {
|
|
77
|
+
/* the steps stay sorted, so they already are the path */
|
|
78
|
+
return stepsInAll(paths).join(StepSeparator);
|
|
25
79
|
}
|
|
26
80
|
/** The other way the step goes, the same branch taken the other way. */
|
|
27
81
|
function flipped(step) {
|
|
@@ -65,23 +119,62 @@ class BranchPathDomain extends bounded_set_domain_1.BoundedSetDomain {
|
|
|
65
119
|
create(value) {
|
|
66
120
|
const paths = value === lattice_1.Top ? undefined : [...value];
|
|
67
121
|
if (paths !== undefined && paths.length > this.limit) {
|
|
68
|
-
|
|
69
|
-
|
|
122
|
+
return new BranchPathDomain([commonPath(paths)], this.limit);
|
|
123
|
+
}
|
|
124
|
+
/* a domain never changes its paths, so a copy of the same ones (as a product copies its entries) is the domain itself */
|
|
125
|
+
return value === this.value ? this : new BranchPathDomain(value, this.limit);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* the steps all paths take, as each join past the limit needs them of both sides: carried along by the operations
|
|
129
|
+
* when known, which is cheap (see {@link withCommon}), else worked out once per value
|
|
130
|
+
*/
|
|
131
|
+
common;
|
|
132
|
+
commonSteps() {
|
|
133
|
+
this.common ??= new Set(stepsInAll(this.value));
|
|
134
|
+
return this.common;
|
|
135
|
+
}
|
|
136
|
+
/** The domain, knowing that its paths all take the `common` steps (if given) and no other step all of them take. */
|
|
137
|
+
static withCommon(domain, common) {
|
|
138
|
+
if (common !== undefined && domain.isValue()) {
|
|
139
|
+
domain.common ??= common;
|
|
70
140
|
}
|
|
71
|
-
return
|
|
141
|
+
return domain;
|
|
142
|
+
}
|
|
143
|
+
/** Past the limit, the joined paths are the one path of the steps both sides' paths all take, so only those are intersected. */
|
|
144
|
+
joinValue(other) {
|
|
145
|
+
if (!other.isValue() || !(other instanceof BranchPathDomain)) {
|
|
146
|
+
return super.joinValue(other);
|
|
147
|
+
}
|
|
148
|
+
const union = this.value.union(other.value);
|
|
149
|
+
if (union.size <= this.limit) {
|
|
150
|
+
/* the steps all paths of either side take */
|
|
151
|
+
return BranchPathDomain.withCommon(this.create(union), this.common !== undefined && other.common !== undefined ? this.common.intersection(other.common) : undefined);
|
|
152
|
+
}
|
|
153
|
+
const common = this.commonSteps().intersection(other.commonSteps());
|
|
154
|
+
const collapsed = new BranchPathDomain([encodePath(common)], this.limit);
|
|
155
|
+
/* its one path is these steps, so its own next join past the limit need not split it again */
|
|
156
|
+
collapsed.common = common;
|
|
157
|
+
return collapsed;
|
|
72
158
|
}
|
|
73
159
|
/** Reached without any branch, as the start of a function body is. */
|
|
74
160
|
static start() {
|
|
75
|
-
return new BranchPathDomain(['']);
|
|
161
|
+
return BranchPathDomain.withCommon(new BranchPathDomain(['']), new Set());
|
|
76
162
|
}
|
|
77
163
|
meetValue(other) {
|
|
78
164
|
if (!other.isValue()) {
|
|
79
165
|
return this.create(other.value);
|
|
80
166
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
167
|
+
/*
|
|
168
|
+
* past the limit, `create` keeps only the steps every pair takes, which are the steps all of mine take together with the steps
|
|
169
|
+
* all of theirs take, as `(a1 | b1) & (a1 | b2) & ... = (a1 & a2 ...) | (b1 & b2 ...)`; so the pairs are not built at all
|
|
170
|
+
*/
|
|
171
|
+
if (this.value.size * other.value.size > this.limit) {
|
|
172
|
+
const common = new Set(stepsInAll(this.value)).union(new Set(stepsInAll(other.value)));
|
|
173
|
+
return new BranchPathDomain([encodePath(common)], this.limit);
|
|
174
|
+
}
|
|
175
|
+
const theirs = [...other.value].map(stepsOf);
|
|
176
|
+
const mine = [...this.value].map(stepsOf);
|
|
177
|
+
return this.create(mine.flatMap(a => theirs.map(b => encodePath(a.union(b)))));
|
|
85
178
|
}
|
|
86
179
|
/** Every path continued by taking the branch. */
|
|
87
180
|
taking(step) {
|
|
@@ -89,7 +182,8 @@ class BranchPathDomain extends bounded_set_domain_1.BoundedSetDomain {
|
|
|
89
182
|
return this;
|
|
90
183
|
}
|
|
91
184
|
const taken = encodeStep(step);
|
|
92
|
-
|
|
185
|
+
const common = this.common;
|
|
186
|
+
return BranchPathDomain.withCommon(this.create([...this.value].map(path => withStep(path, taken))), common === undefined ? undefined : new Set(common).add(taken));
|
|
93
187
|
}
|
|
94
188
|
/**
|
|
95
189
|
* The paths, each a list of the branches it takes, `undefined` for Top. Two paths that only differ in which way one branch
|
package/config.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface FlowrLaxSourcingOptions extends MergeableRecord {
|
|
|
66
66
|
readonly applyReplacements?: Record<string, string>[];
|
|
67
67
|
readonly assumeFilesExist?: boolean;
|
|
68
68
|
}
|
|
69
|
-
export type ConfigPlugin<T extends BuiltInFlowrPluginName | string> = T | string | (T extends BuiltInFlowrPluginName ? [T, BuiltInFlowrPluginArgs<T
|
|
69
|
+
export type ConfigPlugin<T extends BuiltInFlowrPluginName | string> = T | string | (T extends BuiltInFlowrPluginName ? [T, BuiltInFlowrPluginArgs<T>?] : [string, unknown[]?]);
|
|
70
70
|
/** One {@link FlowrConfig.specializeConfig} entry: a config overwrite, optionally `inherit`ing another kind's overwrite (own keys win). */
|
|
71
71
|
export type SpecializeConfigEntry = DeepPartial<FlowrConfig> & {
|
|
72
72
|
readonly inherit?: ProjectKind;
|
package/config.js
CHANGED
|
@@ -21,6 +21,7 @@ const gas_1 = require("./gas");
|
|
|
21
21
|
const input_types_1 = require("./queries/catalog/input-sources-query/input-types");
|
|
22
22
|
const arrays_1 = require("./util/collections/arrays");
|
|
23
23
|
const secure_mode_1 = require("./util/secure-mode");
|
|
24
|
+
const global_caches_1 = require("./util/global-caches");
|
|
24
25
|
/** Marks an option that decides what flowR executes or loads, it is dropped from untrusted configs (see {@link FlowrConfig.fromFile}). */
|
|
25
26
|
function securitySensitive(schema) {
|
|
26
27
|
return schema.meta({ securitySensitive: true });
|
|
@@ -73,6 +74,11 @@ var DropPathsOption;
|
|
|
73
74
|
/** try to drop every folder of the path */
|
|
74
75
|
DropPathsOption["All"] = "all";
|
|
75
76
|
})(DropPathsOption || (exports.DropPathsOption = DropPathsOption = {}));
|
|
77
|
+
/**
|
|
78
|
+
* A plugin name or a `[name, args]` tuple. The args reach the plugin constructor and override what the config
|
|
79
|
+
* says (e.g., the on-demand mirrors), so an untrusted config keeps the plugin but loses its args.
|
|
80
|
+
*/
|
|
81
|
+
const ConfigPluginsSchema = joi_1.default.array().items(joi_1.default.alternatives().try(joi_1.default.string(), joi_1.default.array().ordered(joi_1.default.string().required(), securitySensitive(joi_1.default.array().items(joi_1.default.any()))).min(1).max(2)));
|
|
76
82
|
/** Whether library exports should be resolved from a signature database (`solver.sigdb.enabled`). */
|
|
77
83
|
function isSigDbEnabled(config) {
|
|
78
84
|
return config?.solver.sigdb.enabled === true;
|
|
@@ -373,12 +379,12 @@ exports.FlowrConfig = {
|
|
|
373
379
|
drawingWritesDevice: joi_1.default.boolean().optional().description('Whether calls drawing on a graphics device (e.g., `plot`) count as writing to it, which the ambient state queries then report.')
|
|
374
380
|
}).optional().description('Semantics regarding the global state (options, devices, files, ...) calls access.')
|
|
375
381
|
}).description('Configure language semantics and how flowR handles them.'),
|
|
376
|
-
defaultPlugins:
|
|
382
|
+
defaultPlugins: ConfigPluginsSchema.optional().description('The default plugins to load when creating a new instance of FlowrAnalyzer'),
|
|
377
383
|
repl: joi_1.default.object({
|
|
378
384
|
quickStats: joi_1.default.boolean().optional().description('Whether to show quick stats in the REPL after each evaluation.'),
|
|
379
385
|
dfProcessorHeat: joi_1.default.boolean().optional().description('This instruments the dataflow processors to count how often each processor is called.'),
|
|
380
386
|
hints: joi_1.default.boolean().optional().description('Whether to show dim inline hints on the empty prompt (automatically disabled on non-interactive terminals).'),
|
|
381
|
-
plugins:
|
|
387
|
+
plugins: ConfigPluginsSchema.optional().description('The plugins to load in REPL mode'),
|
|
382
388
|
autoUseFileProtocol: joi_1.default.boolean().optional().description('Prepend the file protocol to a repl input that looks like a path, instead of only warning about it.'),
|
|
383
389
|
queryStats: joi_1.default.boolean().optional().description('Whether `:query` closes with the line stating how long the queries took (`:query*` never prints it).'),
|
|
384
390
|
showPlugins: joi_1.default.boolean().optional().description('Whether `:version` grays out the plugins that did not activate during the last analysis.')
|
|
@@ -447,7 +453,7 @@ exports.FlowrConfig = {
|
|
|
447
453
|
warmInBackground: joi_1.default.boolean().optional().description('Decompress the hot shards (base + most-downloaded) in a background task on startup so the first library() lookup is warm (default false; for long-running servers/REPLs).'),
|
|
448
454
|
additionalPaths: securitySensitive(joi_1.default.array().items(joi_1.default.string()).optional()).description('Extra directories or bundle/manifest files searched for signature databases (alongside the shipped default and $FLOWR_SIGDB_DIR); a downloaded full-history bundle placed here is mounted automatically.'),
|
|
449
455
|
downloadRepo: securitySensitive(joi_1.default.string().optional()).description('GitHub owner/repo the full-history bundle is downloaded from via ":signature download" (default "flowr-analysis/flowr"; the release tag comes from the committed sigdb.remote.json unless a version is given).'),
|
|
450
|
-
autoSync: joi_1.default.boolean().optional().description('On startup, re-download shards whose committed sigdb.remote.json hash no longer matches the cache, in the background (default false; opt-in network sync after a git pull).'),
|
|
456
|
+
autoSync: securitySensitive(joi_1.default.boolean().optional()).description('On startup, re-download shards whose committed sigdb.remote.json hash no longer matches the cache, in the background (default false; opt-in network sync after a git pull).'),
|
|
451
457
|
installedLibrary: joi_1.default.object({
|
|
452
458
|
enabled: joi_1.default.boolean().required().description('Recover packages no signature database knows from their installed copy (default false).'),
|
|
453
459
|
paths: securitySensitive(joi_1.default.array().items(joi_1.default.string()).optional()).description('Library directories to search; when empty they are discovered from the environment and the project.'),
|
|
@@ -482,7 +488,7 @@ exports.FlowrConfig = {
|
|
|
482
488
|
transitiveSideEffectRounds: joi_1.default.number().min(1).optional().description(`How many rounds the transitive side-effect fixpoint may run before it is cut off (default ${exports.DefaultTransitiveSideEffectRounds}); the propagation stops on its own as soon as a round adds nothing.`),
|
|
483
489
|
maxOverlayDepth: joi_1.default.number().min(0).optional().description(`How many binding overlays may stack on one environment frame before a write flattens them (default ${frame_memory_1.DefaultMaxOverlayDepth}); a pure performance knob, trading lookup cost against copy cost without changing any result.`),
|
|
484
490
|
instrument: joi_1.default.object({
|
|
485
|
-
dataflowExtractors: joi_1.default.any().optional().description('These keys are only intended for use within code, allowing to instrument the dataflow analyzer!')
|
|
491
|
+
dataflowExtractors: securitySensitive(joi_1.default.any().optional()).description('These keys are only intended for use within code, allowing to instrument the dataflow analyzer!')
|
|
486
492
|
}),
|
|
487
493
|
resolveSource: joi_1.default.object({
|
|
488
494
|
dropPaths: joi_1.default.string().valid(...Object.values(DropPathsOption)).description('Allow to drop the first or all parts of the sourced path, if it is relative.'),
|
|
@@ -599,7 +605,7 @@ exports.FlowrConfig = {
|
|
|
599
605
|
},
|
|
600
606
|
/** Like {@link FlowrConfig.dropSecuritySensitive}, but in {@link SecureMode} also drops the {@link FlowrConfig.regexPaths}. */
|
|
601
607
|
dropUntrusted(raw) {
|
|
602
|
-
const dropped = exports.FlowrConfig.dropSecuritySensitive(raw);
|
|
608
|
+
const dropped = [...dropPrototypeKeys(raw, ''), ...exports.FlowrConfig.dropSecuritySensitive(raw)];
|
|
603
609
|
return secure_mode_1.SecureMode.isEnabled() ? [...dropped, ...exports.FlowrConfig.regexPaths().flatMap(p => dropPath(raw, p, ''))] : dropped;
|
|
604
610
|
},
|
|
605
611
|
/** Creates a new flowr config that has the updated values. */
|
|
@@ -763,7 +769,8 @@ function persistSigDbPathToGlobalConfig(dbPath) {
|
|
|
763
769
|
fs_1.default.writeFileSync(file, JSON.stringify(raw, null, '\t') + '\n');
|
|
764
770
|
return file;
|
|
765
771
|
}
|
|
766
|
-
|
|
772
|
+
/** per schema meta tag, of which there are a handful */
|
|
773
|
+
const taggedPathsCache = global_caches_1.GlobalCaches.map('config-tagged-paths', global_caches_1.CacheScope.Process, 64);
|
|
767
774
|
function taggedPaths(meta) {
|
|
768
775
|
let paths = taggedPathsCache.get(meta);
|
|
769
776
|
if (paths === undefined) {
|
|
@@ -783,9 +790,32 @@ function collectTaggedPaths(d, meta, at = []) {
|
|
|
783
790
|
return [
|
|
784
791
|
...Object.entries(d.keys ?? {}).flatMap(([k, v]) => collectTaggedPaths(v, meta, [...at, k])),
|
|
785
792
|
...(d.items ?? []).flatMap(i => collectTaggedPaths(i, meta, [...at, '*'])),
|
|
793
|
+
...(d.ordered ?? []).flatMap((o, i) => collectTaggedPaths(o, meta, [...at, String(i)])),
|
|
786
794
|
...(d.matches ?? []).flatMap(m => collectTaggedPaths(m.schema, meta, at))
|
|
787
795
|
];
|
|
788
796
|
}
|
|
797
|
+
/**
|
|
798
|
+
* Removes every own `__proto__` key: merging the config assigns it as the prototype, which hides the options below it
|
|
799
|
+
* from {@link dropPath} while reads still find them (e.g. `specializeConfig.package.solver.sigdb.__proto__.downloadRepo`).
|
|
800
|
+
*/
|
|
801
|
+
function dropPrototypeKeys(obj, at) {
|
|
802
|
+
if (obj === null || typeof obj !== 'object') {
|
|
803
|
+
return [];
|
|
804
|
+
}
|
|
805
|
+
const record = obj;
|
|
806
|
+
const dropped = [];
|
|
807
|
+
for (const key of Object.keys(record)) {
|
|
808
|
+
const next = at === '' ? key : `${at}.${key}`;
|
|
809
|
+
if (key === '__proto__') {
|
|
810
|
+
Reflect.deleteProperty(record, key);
|
|
811
|
+
dropped.push(next);
|
|
812
|
+
}
|
|
813
|
+
else {
|
|
814
|
+
dropped.push(...dropPrototypeKeys(record[key], next));
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
return dropped;
|
|
818
|
+
}
|
|
789
819
|
function dropPath(obj, path, at) {
|
|
790
820
|
if (obj === null || typeof obj !== 'object' || path.length === 0) {
|
|
791
821
|
return [];
|
|
@@ -793,12 +823,14 @@ function dropPath(obj, path, at) {
|
|
|
793
823
|
const [head, ...rest] = path;
|
|
794
824
|
const record = obj;
|
|
795
825
|
const dropped = [];
|
|
796
|
-
|
|
826
|
+
const keys = head === '*' ? Object.keys(record) : Object.hasOwn(record, head) ? [head] : [];
|
|
827
|
+
// back to front, so removing an array element does not shift the ones still to visit
|
|
828
|
+
for (const key of Array.isArray(obj) ? keys.reverse() : keys) {
|
|
797
829
|
const next = at === '' ? key : `${at}.${key}`;
|
|
798
830
|
if (rest.length > 0) {
|
|
799
831
|
dropped.push(...dropPath(record[key], rest, next));
|
|
800
832
|
}
|
|
801
|
-
else if (Reflect.deleteProperty(record, key)) {
|
|
833
|
+
else if (Array.isArray(obj) ? obj.splice(Number(key), 1).length > 0 : Reflect.deleteProperty(record, key)) {
|
|
802
834
|
dropped.push(next);
|
|
803
835
|
}
|
|
804
836
|
}
|
|
@@ -415,10 +415,10 @@ class ControlFlowGraph {
|
|
|
415
415
|
return this.revEdgeInfos;
|
|
416
416
|
}
|
|
417
417
|
outgoingEdges(node) {
|
|
418
|
-
return this.isView ?
|
|
418
|
+
return this.isView ? viewEdges(this.dfg, ViewOutgoing, node, dfg => dfg.outgoingEdges(node)) : this.edgeInfos.get(node);
|
|
419
419
|
}
|
|
420
420
|
ingoingEdges(node) {
|
|
421
|
-
return this.isView ?
|
|
421
|
+
return this.isView ? viewEdges(this.dfg, ViewIngoing, node, dfg => dfg.ingoingEdges(node)) : this.reverse().get(node);
|
|
422
422
|
}
|
|
423
423
|
/** @see {@link ReadOnlyControlFlowGraph#edgesFrom|edgesFrom()} */
|
|
424
424
|
edgesFrom(node) {
|
|
@@ -618,6 +618,22 @@ function deleteNestedEdge(map, from, to) {
|
|
|
618
618
|
map.delete(from);
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
+
/** the keys under which a view keeps the control flow part of each vertex's edges with the dataflow graph, see {@link viewEdges} */
|
|
622
|
+
const ViewOutgoing = Symbol('cfg-view-outgoing');
|
|
623
|
+
const ViewIngoing = Symbol('cfg-view-ingoing');
|
|
624
|
+
/**
|
|
625
|
+
* The control flow part of the edges `edgesOf` gives for `node`, filtered once per vertex until the graph changes:
|
|
626
|
+
* a vertex read from many places has thousands of dataflow edges, and walks over the control flow ask for them again and again.
|
|
627
|
+
*/
|
|
628
|
+
function viewEdges(dfg, key, node, edgesOf) {
|
|
629
|
+
const known = dfg.derivedUntilChanged(key, () => new Map());
|
|
630
|
+
if (known.has(node)) {
|
|
631
|
+
return known.get(node);
|
|
632
|
+
}
|
|
633
|
+
const edges = controlFlowEdges(edgesOf(dfg));
|
|
634
|
+
known.set(node, edges);
|
|
635
|
+
return edges;
|
|
636
|
+
}
|
|
621
637
|
/** The control flow part of the given edges, or `undefined` if none of them carries any. */
|
|
622
638
|
function controlFlowEdges(edges) {
|
|
623
639
|
let result = undefined;
|