@eagleoutice/flowr 2.16.7 → 2.17.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 +16 -10
- package/abstract-interpretation/absint-inference.d.ts +17 -1
- package/abstract-interpretation/absint-inference.js +118 -3
- package/abstract-interpretation/data-frame/arguments.d.ts +11 -1
- package/abstract-interpretation/data-frame/arguments.js +12 -0
- package/abstract-interpretation/domains/lattice.d.ts +2 -0
- package/abstract-interpretation/domains/lattice.js +0 -6
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +2 -1
- package/abstract-interpretation/domains/multi-value-state-domain.js +7 -3
- package/abstract-interpretation/domains/partial-product-domain.js +2 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +6 -3
- package/abstract-interpretation/domains/state-abstract-domain.js +13 -7
- package/abstract-interpretation/domains/state-domain.d.ts +4 -0
- package/config.js +1 -1
- package/control-flow/useless-loop.js +10 -8
- package/data/r-primitives.generated.d.ts +1 -0
- package/data/r-primitives.generated.js +9 -0
- package/data/sigdb/sigdb.remote.json +110 -110
- package/dataflow/environments/identifier.d.ts +1 -1
- package/dataflow/environments/query-fn-props.d.ts +9 -3
- package/dataflow/environments/query-fn-props.js +13 -5
- package/dataflow/environments/reference-to-maybe.js +1 -6
- package/dataflow/fn/class-declaration.js +1 -8
- package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +7 -0
- package/dataflow/graph/graph.js +3 -10
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/hooks.d.ts +1 -1
- package/dataflow/info.d.ts +3 -3
- package/dataflow/internal/linker.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -7
- package/dataflow/processor.d.ts +1 -1
- package/documentation/wiki-linter.js +29 -0
- package/documentation/wiki-query.js +20 -1
- package/linter/linter-executor.js +2 -1
- package/linter/linter-rules.d.ts +65 -0
- package/linter/linter-rules.js +5 -1
- package/linter/rules/cmd-check/global-environment-modification.d.ts +14 -1
- package/linter/rules/cmd-check/global-environment-modification.js +15 -7
- package/linter/rules/no-leaked-credentials.d.ts +1 -0
- package/linter/rules/no-leaked-credentials.js +3 -3
- package/linter/rules/process-state-in-session.d.ts +71 -0
- package/linter/rules/process-state-in-session.js +267 -0
- package/linter/rules/secret-exfiltration.d.ts +80 -0
- package/linter/rules/secret-exfiltration.js +183 -0
- package/package.json +1 -1
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +4 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -3
- package/project/sigdb/decompress.d.ts +4 -0
- package/project/sigdb/decompress.js +60 -25
- package/project/sigdb/manifest.d.ts +1 -1
- package/project/sigdb/manifest.js +2 -5
- package/project/sigdb/reader.js +15 -6
- package/project/sigdb/sigdb-download.d.ts +3 -7
- package/project/sigdb/sigdb-download.js +71 -72
- package/queries/catalog/taint-query/taint-query-executor.d.ts +7 -0
- package/queries/catalog/taint-query/taint-query-executor.js +30 -0
- package/queries/catalog/taint-query/taint-query-format.d.ts +29 -0
- package/queries/catalog/taint-query/taint-query-format.js +124 -0
- package/queries/query.d.ts +12 -1
- package/queries/query.js +2 -0
- package/taint-analysis/builder/domain.d.ts +14 -0
- package/taint-analysis/builder/domain.js +69 -0
- package/taint-analysis/builder/report-template.d.ts +50 -0
- package/taint-analysis/builder/report-template.js +46 -0
- package/taint-analysis/builder/taint-analysis-definition.d.ts +108 -0
- package/taint-analysis/builder/taint-analysis-definition.js +128 -0
- package/taint-analysis/builder/taint-analysis.d.ts +124 -0
- package/taint-analysis/builder/taint-analysis.js +93 -0
- package/taint-analysis/builtin-index-bridge.d.ts +20 -0
- package/taint-analysis/builtin-index-bridge.js +48 -0
- package/taint-analysis/eval/eval.d.ts +1 -0
- package/taint-analysis/eval/eval.js +124 -0
- package/taint-analysis/eval/instrumentation.d.ts +59 -0
- package/taint-analysis/eval/instrumentation.js +124 -0
- package/taint-analysis/finite-domain.d.ts +41 -0
- package/taint-analysis/finite-domain.js +118 -0
- package/taint-analysis/function-categories.d.ts +31 -0
- package/taint-analysis/function-categories.js +61 -0
- package/taint-analysis/logger.d.ts +1 -0
- package/taint-analysis/logger.js +6 -0
- package/taint-analysis/predefined/determinism.d.ts +6 -0
- package/taint-analysis/predefined/determinism.js +14 -0
- package/taint-analysis/predefined/normalization.d.ts +17 -0
- package/taint-analysis/predefined/normalization.js +150 -0
- package/taint-analysis/predefined/predefined.d.ts +12 -0
- package/taint-analysis/predefined/predefined.js +18 -0
- package/taint-analysis/predefined/randomness-analysis.d.ts +6 -0
- package/taint-analysis/predefined/randomness-analysis.js +124 -0
- package/taint-analysis/predefined/secret-analysis.d.ts +77 -0
- package/taint-analysis/predefined/secret-analysis.js +165 -0
- package/taint-analysis/predefined/security-analysis.d.ts +7 -0
- package/taint-analysis/predefined/security-analysis.js +91 -0
- package/taint-analysis/taint-mapping.d.ts +86 -0
- package/taint-analysis/taint-mapping.js +70 -0
- package/taint-analysis/taint-resolve.d.ts +26 -0
- package/taint-analysis/taint-resolve.js +86 -0
- package/taint-analysis/taint-visitor.d.ts +80 -0
- package/taint-analysis/taint-visitor.js +82 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ It offers a wide variety of features, for example:
|
|
|
38
38
|
|
|
39
39
|
```shell
|
|
40
40
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
41
|
-
flowR repl v2.16.
|
|
41
|
+
flowR repl v2.16.8, R grammar v14 (tree-sitter engine)
|
|
42
42
|
R> :query @linter "read.csv(\"/root/x.txt\")"
|
|
43
43
|
```
|
|
44
44
|
|
|
@@ -46,7 +46,7 @@ It offers a wide variety of features, for example:
|
|
|
46
46
|
<summary style='color:gray'>Output</summary>
|
|
47
47
|
|
|
48
48
|
```text
|
|
49
|
-
Query: linter (
|
|
49
|
+
Query: linter (29 ms)
|
|
50
50
|
╰ Deprecated Functions (deprecated-functions): no findings
|
|
51
51
|
╰ File Path Validity (file-path-validity):
|
|
52
52
|
╰ certain:
|
|
@@ -70,7 +70,9 @@ It offers a wide variety of features, for example:
|
|
|
70
70
|
╰ Overwritten File (overwritten-file): no findings
|
|
71
71
|
╰ Unescaped Arguments (unescaped-arguments): no findings
|
|
72
72
|
╰ Namespace Access Validity (namespace-access): no findings
|
|
73
|
-
|
|
73
|
+
╰ Secret Exfiltration (secret-exfiltration): no findings
|
|
74
|
+
╰ Process State in Session (process-state-in-session): no findings
|
|
75
|
+
All queries together required ≈29 ms (1ms accuracy, total 29 ms)
|
|
74
76
|
```
|
|
75
77
|
|
|
76
78
|
The linter will analyze the code and return any issues found.
|
|
@@ -84,7 +86,7 @@ It offers a wide variety of features, for example:
|
|
|
84
86
|
|
|
85
87
|
_Results (prettified and summarized):_
|
|
86
88
|
|
|
87
|
-
Query: **linter** (
|
|
89
|
+
Query: **linter** (22 ms)\
|
|
88
90
|
╰ **Deprecated Functions** (deprecated-functions): _no findings_\
|
|
89
91
|
╰ **File Path Validity** (file-path-validity):\
|
|
90
92
|
╰ certain:\
|
|
@@ -108,7 +110,9 @@ It offers a wide variety of features, for example:
|
|
|
108
110
|
╰ **Overwritten File** (overwritten-file): _no findings_\
|
|
109
111
|
╰ **Unescaped Arguments** (unescaped-arguments): _no findings_\
|
|
110
112
|
╰ **Namespace Access Validity** (namespace-access): _no findings_\
|
|
111
|
-
|
|
113
|
+
╰ **Secret Exfiltration** (secret-exfiltration): _no findings_\
|
|
114
|
+
╰ **Process State in Session** (process-state-in-session): _no findings_\
|
|
115
|
+
_All queries together required ≈23 ms (1ms accuracy, total 23 ms)_
|
|
112
116
|
|
|
113
117
|
<details> <summary style="color:gray">Show Detailed Results as Json</summary>
|
|
114
118
|
|
|
@@ -151,7 +155,9 @@ It offers a wide variety of features, for example:
|
|
|
151
155
|
"unclosed-connection": {"results":[],".meta":{"totalOpened":0,"totalClosed":0}},
|
|
152
156
|
"overwritten-file": {"results":[],".meta":{"totalFiles":0}},
|
|
153
157
|
"unescaped-arguments": {"results":[],".meta":{"totalCriticalArguments":0,"totalEscapedArguments":0}},
|
|
154
|
-
"namespace-access": {"results":[],".meta":{"unresolved":0}}
|
|
158
|
+
"namespace-access": {"results":[],".meta":{"unresolved":0}},
|
|
159
|
+
"secret-exfiltration": {"results":[],".meta":{"secretSinkCalls":0}},
|
|
160
|
+
"process-state-in-session": {"results":[],".meta":{"sessionFunctions":0}}
|
|
155
161
|
},
|
|
156
162
|
".meta": {}
|
|
157
163
|
},
|
|
@@ -199,7 +205,7 @@ It offers a wide variety of features, for example:
|
|
|
199
205
|
|
|
200
206
|
```shell
|
|
201
207
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
202
|
-
flowR repl v2.16.
|
|
208
|
+
flowR repl v2.16.8, R grammar v14 (tree-sitter engine)
|
|
203
209
|
R> :query @static-slice (11@sum) file://test/testfiles/example.R
|
|
204
210
|
```
|
|
205
211
|
|
|
@@ -212,7 +218,7 @@ It offers a wide variety of features, for example:
|
|
|
212
218
|
N <- 10
|
|
213
219
|
for(i in 1:(N-1)) sum <- sum + i + w
|
|
214
220
|
sum
|
|
215
|
-
All queries together required ≈
|
|
221
|
+
All queries together required ≈6 ms (1ms accuracy, total 6 ms)
|
|
216
222
|
```
|
|
217
223
|
|
|
218
224
|
</details>
|
|
@@ -220,7 +226,7 @@ It offers a wide variety of features, for example:
|
|
|
220
226
|
</details>
|
|
221
227
|
|
|
222
228
|
* 🚀 **fast call-graph, data-, and control-flow graphs**\
|
|
223
|
-
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">
|
|
229
|
+
Within just [<i><span title="This measurement is automatically fetched from the latest benchmark!">130.2 ms</span></i> (as of Oct 30, 2026)](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark),
|
|
224
230
|
_flowR_ can analyze the data- and control-flow of the average real-world R script. See the [benchmarks](https://flowr-analysis.github.io/flowr/wiki/stats/benchmark) for more information,
|
|
225
231
|
and consult the [wiki pages](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) for more details on the [dataflow graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph) as well as [call graphs](https://github.com/flowr-analysis/flowr/wiki/Dataflow-Graph#perspectives-cg).
|
|
226
232
|
( [▶ Explore in Browser](https://flowr-analysis.github.io/flowr/wiki/playground/#c=zDYSwRgTghhCeAUATADsWECUAoLBnAxlMAKYD6ALgPakC2UAHgAQA8AtIwGYCuAdvuSEo949DIyYB6RnXojsWaAHdGKlW0aIo5KADoO0GsXghEjALyMAjAC4AbABpGANyJdi5xvngBmRwA5HAHZHACZHAE5HABYMbHwSKB5VdQ4QYHJiCHglRxdgN0YAPkYQuISeABICImJTdWqSCmoZeHjiRIq8t3lcLho6OFJcbXJcFnZe-pgQXCM2xMdDRI8l4Qba2KxeLlnEJu1gNQm%2B7KhFTtdieUUIEAydfFwneEmB2CGR3EcAIleYWAeT2%2B2FQlHIrXKVUIJEQIMoIB4owh7UqJgwQA&p=13:1 "run this script in flowR's playground, no setup") )
|
|
@@ -251,7 +257,7 @@ It offers a wide variety of features, for example:
|
|
|
251
257
|
|
|
252
258
|
```shell
|
|
253
259
|
$ docker run -it --rm eagleoutice/flowr # or npm run flowr
|
|
254
|
-
flowR repl v2.16.
|
|
260
|
+
flowR repl v2.16.8, R grammar v14 (tree-sitter engine)
|
|
255
261
|
R> :dataflow* test/testfiles/example.R
|
|
256
262
|
```
|
|
257
263
|
|
|
@@ -4,7 +4,7 @@ import { BuiltInProcName } from '../dataflow/environments/built-in-proc-name';
|
|
|
4
4
|
import { type DataflowGraph, FunctionArgument } from '../dataflow/graph/graph';
|
|
5
5
|
import { type DataflowGraphVertexArgument, type DataflowGraphVertexFunctionCall, type DataflowGraphVertexFunctionDefinition, type DataflowGraphVertexUse, type DataflowGraphVertexValue, type DataflowGraphVertexVariableDefinition } from '../dataflow/graph/vertex';
|
|
6
6
|
import type { ControlDependency } from '../dataflow/info';
|
|
7
|
-
import type
|
|
7
|
+
import { type NoInfo } from '../r-bridge/lang-4.x/ast/model/model';
|
|
8
8
|
import type { RLogical } from '../r-bridge/lang-4.x/ast/model/nodes/r-logical';
|
|
9
9
|
import type { RNumber } from '../r-bridge/lang-4.x/ast/model/nodes/r-number';
|
|
10
10
|
import type { RString } from '../r-bridge/lang-4.x/ast/model/nodes/r-string';
|
|
@@ -36,6 +36,8 @@ export interface AbsintAnalysis<Domains extends AbstractProduct> {
|
|
|
36
36
|
readonly semantics: DomainSemantics<Domains>;
|
|
37
37
|
/** Optional reduction functions of the reduced product domain, refining the inferred abstract values based on the values of the other abstract domains */
|
|
38
38
|
readonly reductions?: readonly ProductReduction<Partial<Domains>>[];
|
|
39
|
+
/** Whether a node inferred as Bottom collapses the whole state to Bottom (default), or stays a regular entry, e.g. to mark the findings of a taint analysis */
|
|
40
|
+
readonly collapseOnBottom?: boolean;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* The configuration of an {@link AbstractInterpreter},
|
|
@@ -122,6 +124,13 @@ export declare class AbstractInterpreter<Domains extends AbstractProduct, Config
|
|
|
122
124
|
private readonly returns;
|
|
123
125
|
/** The calls that lead back into a definition still being interpreted, and the definition they reach. */
|
|
124
126
|
private readonly recursiveCalls;
|
|
127
|
+
/**
|
|
128
|
+
* The runs of each definition, so a call reading the same as an earlier one reuses it instead of running the body
|
|
129
|
+
* again: calls nested in calls would otherwise run every body once per call path. Dropped when a pass is over.
|
|
130
|
+
*/
|
|
131
|
+
private readonly summaries;
|
|
132
|
+
/** Everything a run of a definition may read: its body, the definitions that reads, and the same for what it calls. */
|
|
133
|
+
private readonly inputsOf;
|
|
125
134
|
/**
|
|
126
135
|
* Creates an abstract interpretation visitor performing the given analysis.
|
|
127
136
|
* @param config - The configuration of the visitor (containing the normalized AST, the dataflow graph, and the control flow graph of the program to analyze)
|
|
@@ -183,6 +192,7 @@ export declare class AbstractInterpreter<Domains extends AbstractProduct, Config
|
|
|
183
192
|
/** What a definition currently being interpreted was last seen to leave behind, projected to one of the domains if asked for one. */
|
|
184
193
|
private getReturnValue;
|
|
185
194
|
start(): void;
|
|
195
|
+
private dropSummaries;
|
|
186
196
|
protected startVisitor(start: readonly NodeId[]): void;
|
|
187
197
|
protected visitNode(vertexId: NodeId): boolean;
|
|
188
198
|
protected onDispatchFunctionCallOrigin(call: DataflowGraphVertexFunctionCall, origin: BuiltInProcName): void;
|
|
@@ -286,6 +296,8 @@ export declare class AbstractInterpreter<Domains extends AbstractProduct, Config
|
|
|
286
296
|
* Built-in functions have no definition in the source, so they are not part of this.
|
|
287
297
|
*/
|
|
288
298
|
protected getCallTargets(callId: NodeId): readonly NodeId[];
|
|
299
|
+
/** Interprets function bodies no call reached, from the state at their definition (e.g., a Shiny server). */
|
|
300
|
+
protected interpretUncalledFunctions(): void;
|
|
289
301
|
/** Where a function definition starts, i.e. the first thing that runs when it is called. */
|
|
290
302
|
protected getFunctionEntry(defId: NodeId): NodeId | undefined;
|
|
291
303
|
/** Where a function definition is left, i.e. its last expressions and `return` calls. */
|
|
@@ -306,6 +318,10 @@ export declare class AbstractInterpreter<Domains extends AbstractProduct, Config
|
|
|
306
318
|
* @returns the states at the exit points, and what the definition leaves behind if every way out says
|
|
307
319
|
*/
|
|
308
320
|
private runFunction;
|
|
321
|
+
/** What a run of `def` starting in `state` reads, `undefined` if the run depends on a recursion and must not be reused. */
|
|
322
|
+
private summaryKey;
|
|
323
|
+
/** See {@link inputsOf}, collected over the bodies of `def` and of everything it may call. */
|
|
324
|
+
private inputs;
|
|
309
325
|
/** What the parameters of a definition are worth in the state they were just bound in. */
|
|
310
326
|
private parameterValues;
|
|
311
327
|
/** How often each vertex of a function has been visited, so one call does not widen the next one early. */
|
|
@@ -11,6 +11,7 @@ const df_helper_1 = require("../dataflow/graph/df-helper");
|
|
|
11
11
|
const edge_1 = require("../dataflow/graph/edge");
|
|
12
12
|
const graph_1 = require("../dataflow/graph/graph");
|
|
13
13
|
const vertex_1 = require("../dataflow/graph/vertex");
|
|
14
|
+
const model_1 = require("../r-bridge/lang-4.x/ast/model/model");
|
|
14
15
|
const r_access_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
15
16
|
const r_argument_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
17
|
const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
@@ -22,6 +23,7 @@ const r_pipe_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-pipe");
|
|
|
22
23
|
const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
23
24
|
const node_id_1 = require("../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
24
25
|
const convert_values_1 = require("../r-bridge/lang-4.x/convert-values");
|
|
26
|
+
const lattice_1 = require("./domains/lattice");
|
|
25
27
|
const assert_1 = require("../util/assert");
|
|
26
28
|
const record_1 = require("../util/record");
|
|
27
29
|
const abstract_domain_1 = require("./domains/abstract-domain");
|
|
@@ -100,6 +102,13 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
100
102
|
returns = new Map();
|
|
101
103
|
/** The calls that lead back into a definition still being interpreted, and the definition they reach. */
|
|
102
104
|
recursiveCalls = new Map();
|
|
105
|
+
/**
|
|
106
|
+
* The runs of each definition, so a call reading the same as an earlier one reuses it instead of running the body
|
|
107
|
+
* again: calls nested in calls would otherwise run every body once per call path. Dropped when a pass is over.
|
|
108
|
+
*/
|
|
109
|
+
summaries = new Map();
|
|
110
|
+
/** Everything a run of a definition may read: its body, the definitions that reads, and the same for what it calls. */
|
|
111
|
+
inputsOf = new Map();
|
|
103
112
|
/**
|
|
104
113
|
* Creates an abstract interpretation visitor performing the given analysis.
|
|
105
114
|
* @param config - The configuration of the visitor (containing the normalized AST, the dataflow graph, and the control flow graph of the program to analyze)
|
|
@@ -108,7 +117,7 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
108
117
|
constructor(config, analysis) {
|
|
109
118
|
super({ ...config, defaultVisitingOrder: 'forward' });
|
|
110
119
|
this.analysis = analysis;
|
|
111
|
-
this.stateDomain = new multi_value_state_domain_1.MultiValueStateDomain(new Map(), analysis.domains, analysis.reductions);
|
|
120
|
+
this.stateDomain = new multi_value_state_domain_1.MultiValueStateDomain(new Map(), analysis.domains, analysis.reductions, analysis.collapseOnBottom);
|
|
112
121
|
this.currentState = this.stateDomain.top();
|
|
113
122
|
}
|
|
114
123
|
/** Applies a handler to the abstract semantics of every domain of the analysis, together with the state view and context of that domain. */
|
|
@@ -159,7 +168,8 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
159
168
|
set: (id, value) => state.setValue(id, type, value),
|
|
160
169
|
remove: id => state.removeValue(id, type),
|
|
161
170
|
entries: () => state.entries(type),
|
|
162
|
-
isBottom: () => state.isBottom()
|
|
171
|
+
isBottom: () => state.isBottom(),
|
|
172
|
+
getBottomNodes: () => state.entries(type).filter(([, value]) => value?.isBottom()).map(([id]) => id)
|
|
163
173
|
};
|
|
164
174
|
}
|
|
165
175
|
getAbstractValue(nodeId, type, state) {
|
|
@@ -263,6 +273,11 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
263
273
|
super.start();
|
|
264
274
|
this.unassigned.clear();
|
|
265
275
|
this.lastState.clear();
|
|
276
|
+
this.dropSummaries();
|
|
277
|
+
}
|
|
278
|
+
dropSummaries() {
|
|
279
|
+
this.summaries.clear();
|
|
280
|
+
this.inputsOf.clear();
|
|
266
281
|
}
|
|
267
282
|
startVisitor(start) {
|
|
268
283
|
this.stack = Array.from(start);
|
|
@@ -388,8 +403,9 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
388
403
|
if (target === undefined || source === undefined) {
|
|
389
404
|
return;
|
|
390
405
|
}
|
|
391
|
-
|
|
406
|
+
/* the source is read before the target counts as assigned, so `x <- x` reads the `x` from before */
|
|
392
407
|
this.applySemantics((semantics, state, ctx) => semantics.handleAssignmentCall?.(state, call, ctx, target, source));
|
|
408
|
+
this.unassigned.delete(target);
|
|
393
409
|
// the assignment target is visited before the assignment, so we update its state with the assigned values
|
|
394
410
|
this.trace.set(target, this.currentState);
|
|
395
411
|
}
|
|
@@ -571,6 +587,26 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
571
587
|
const targets = control_flow_graph_1.CfgVertex.getCallTargets(this.getCfgVertex(callId));
|
|
572
588
|
return targets === undefined ? control_flow_graph_1.NoNeighbors : [...targets];
|
|
573
589
|
}
|
|
590
|
+
/** Interprets function bodies no call reached, from the state at their definition (e.g., a Shiny server). */
|
|
591
|
+
interpretUncalledFunctions() {
|
|
592
|
+
const pending = [...this.config.dfg.verticesOfType(vertex_1.VertexType.FunctionDefinition)].map(([id]) => id);
|
|
593
|
+
for (let progress = true; progress;) {
|
|
594
|
+
progress = false;
|
|
595
|
+
for (const def of pending) {
|
|
596
|
+
const entry = this.getFunctionEntry(def);
|
|
597
|
+
if (entry === undefined || this.trace.has(entry) || !this.trace.has(def)) {
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
600
|
+
progress = true;
|
|
601
|
+
this.enteredFrom.set(entry, def);
|
|
602
|
+
const outerStack = this.stack;
|
|
603
|
+
this.startVisitor([entry]);
|
|
604
|
+
this.stack = outerStack;
|
|
605
|
+
this.enteredFrom.delete(entry);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
this.dropSummaries();
|
|
609
|
+
}
|
|
574
610
|
/** Where a function definition starts, i.e. the first thing that runs when it is called. */
|
|
575
611
|
getFunctionEntry(defId) {
|
|
576
612
|
const def = this.getDataflowGraph(defId);
|
|
@@ -664,6 +700,13 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
664
700
|
}
|
|
665
701
|
const handed = this.parameterValues(def);
|
|
666
702
|
this.trace.set(callId, inner);
|
|
703
|
+
const key = round === 0 ? this.summaryKey(def, inner) : undefined;
|
|
704
|
+
const known = key === undefined ? undefined : this.summaries.get(def)?.find(s => s.key.status === key.status && sameValues(s.key.values, key.values));
|
|
705
|
+
if (known !== undefined) {
|
|
706
|
+
return { states: known.exits.map(exit => applyExit(inner, exit)), value: known.value };
|
|
707
|
+
}
|
|
708
|
+
const before = key === undefined ? undefined : new Map(inner.value === lattice_1.Bottom ? [] : inner.value);
|
|
709
|
+
const recursiveCallCount = this.recursiveCalls.size;
|
|
667
710
|
this.enteredFrom.set(entry, callId);
|
|
668
711
|
/* what a recursive call is worth is no part of the state, so the traversal has to be made to re-read */
|
|
669
712
|
if (round > 0) {
|
|
@@ -695,6 +738,10 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
695
738
|
const left = complete && exits.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(exits) : undefined;
|
|
696
739
|
if (!this.recursive.has(def)) {
|
|
697
740
|
this.restoreVisits(counts);
|
|
741
|
+
if (key !== undefined && before !== undefined && this.recursiveCalls.size === recursiveCallCount) {
|
|
742
|
+
const summary = { key, exits: states.map(state => exitDelta(before, state)), value: left };
|
|
743
|
+
this.summaries.set(def, [...this.summaries.get(def) ?? [], summary]);
|
|
744
|
+
}
|
|
698
745
|
return { states, value: left };
|
|
699
746
|
}
|
|
700
747
|
else if (left === undefined) {
|
|
@@ -714,6 +761,50 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
714
761
|
}
|
|
715
762
|
}
|
|
716
763
|
}
|
|
764
|
+
/** What a run of `def` starting in `state` reads, `undefined` if the run depends on a recursion and must not be reused. */
|
|
765
|
+
summaryKey(def, state) {
|
|
766
|
+
if (state.isBottom()) {
|
|
767
|
+
return undefined;
|
|
768
|
+
}
|
|
769
|
+
const inputs = this.inputs(def);
|
|
770
|
+
if (inputs.some(id => this.recursiveCalls.has(id))) {
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
const status = inputs.map(id => {
|
|
774
|
+
const traced = this.trace.get(id);
|
|
775
|
+
return `${traced === undefined ? 0 : this.unassigned.has(id) ? 2 : traced.isBottom() ? 3 : 1}${this.visited.get(id) ?? ''}`;
|
|
776
|
+
}).join(',');
|
|
777
|
+
return { values: inputs.map(id => state.get(id)), status };
|
|
778
|
+
}
|
|
779
|
+
/** See {@link inputsOf}, collected over the bodies of `def` and of everything it may call. */
|
|
780
|
+
inputs(def) {
|
|
781
|
+
let inputs = this.inputsOf.get(def);
|
|
782
|
+
if (inputs !== undefined) {
|
|
783
|
+
return inputs;
|
|
784
|
+
}
|
|
785
|
+
const ids = new Set();
|
|
786
|
+
const defs = [def];
|
|
787
|
+
const seen = new Set(defs);
|
|
788
|
+
for (let next = defs.pop(); next !== undefined; next = defs.pop()) {
|
|
789
|
+
for (const id of model_1.RNode.collectAllIds(this.getNormalizedAst(next))) {
|
|
790
|
+
ids.add(id);
|
|
791
|
+
for (const origin of df_helper_1.Dataflow.origin(this.config.dfg, id) ?? []) {
|
|
792
|
+
if (origin.type === 0 /* OriginType.ReadVariableOrigin */) {
|
|
793
|
+
ids.add(origin.id);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
for (const target of this.getCallTargets(id)) {
|
|
797
|
+
if (!seen.has(target)) {
|
|
798
|
+
seen.add(target);
|
|
799
|
+
defs.push(target);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
inputs = [...ids];
|
|
805
|
+
this.inputsOf.set(def, inputs);
|
|
806
|
+
return inputs;
|
|
807
|
+
}
|
|
717
808
|
/** What the parameters of a definition are worth in the state they were just bound in. */
|
|
718
809
|
parameterValues(defId) {
|
|
719
810
|
const definition = this.getDataflowGraph(defId);
|
|
@@ -869,4 +960,28 @@ class AbstractInterpreter extends semantic_cfg_guided_visitor_1.SemanticCfgGuide
|
|
|
869
960
|
}
|
|
870
961
|
}
|
|
871
962
|
exports.AbstractInterpreter = AbstractInterpreter;
|
|
963
|
+
/** What an exit state changed relative to the state the run started in. */
|
|
964
|
+
function exitDelta(before, exit) {
|
|
965
|
+
if (exit.value === lattice_1.Bottom) {
|
|
966
|
+
return lattice_1.Bottom;
|
|
967
|
+
}
|
|
968
|
+
const delta = new Map();
|
|
969
|
+
for (const [id, value] of exit.value) {
|
|
970
|
+
if (before.get(id) !== value) {
|
|
971
|
+
delta.set(id, value);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
return delta;
|
|
975
|
+
}
|
|
976
|
+
/** The exit state of a reused run, for a call starting in `state`. */
|
|
977
|
+
function applyExit(state, delta) {
|
|
978
|
+
if (delta === lattice_1.Bottom) {
|
|
979
|
+
return state.bottom();
|
|
980
|
+
}
|
|
981
|
+
const exit = state.create(state.value);
|
|
982
|
+
for (const [id, value] of delta) {
|
|
983
|
+
exit.set(id, value);
|
|
984
|
+
}
|
|
985
|
+
return exit;
|
|
986
|
+
}
|
|
872
987
|
//# sourceMappingURL=absint-inference.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type BrandedIdentifier } from '../../dataflow/environments/identifier';
|
|
2
2
|
import type { ResolveInfo } from '../../dataflow/eval/resolve/alias-tracking';
|
|
3
3
|
import { type DataflowGraph } from '../../dataflow/graph/graph';
|
|
4
|
+
import { type DataflowGraphVertexFunctionCall } from '../../dataflow/graph/vertex';
|
|
4
5
|
import { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
5
6
|
import { RArgument } from '../../r-bridge/lang-4.x/ast/model/nodes/r-argument';
|
|
6
7
|
import type { PotentiallyEmptyRArgument, RFunctionCall } from '../../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
|
|
7
8
|
import { RSymbol } from '../../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
|
|
8
|
-
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
|
+
import type { AstIdMap, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
9
10
|
import { RNull } from '../../r-bridge/lang-4.x/convert-values';
|
|
10
11
|
import type { RParseRequest } from '../../r-bridge/retriever';
|
|
11
12
|
import type { AbsintContext } from '../abstract-semantics';
|
|
@@ -69,6 +70,15 @@ export declare function getFunctionArgument(args: readonly PotentiallyEmptyRArgu
|
|
|
69
70
|
* @returns The arguments of the function call in the data flow graph
|
|
70
71
|
*/
|
|
71
72
|
export declare function getFunctionArguments(node: RFunctionCall<ParentInformation>, dfg: DataflowGraph): readonly PotentiallyEmptyRArgument<ParentInformation>[];
|
|
73
|
+
/**
|
|
74
|
+
* Reconstruct the AST-level arguments of a function call vertex from the data flow graph. Unlike
|
|
75
|
+
* {@link getFunctionArguments}, this works directly on the call vertex, so it also serves calls whose AST node is
|
|
76
|
+
* not a {@link RFunctionCall} (e.g. binary operators).
|
|
77
|
+
* @param vertex - The function call vertex to get the arguments for
|
|
78
|
+
* @param idMap - The id map to resolve the argument node ids against
|
|
79
|
+
* @returns The arguments of the function call in the data flow graph
|
|
80
|
+
*/
|
|
81
|
+
export declare function getVertexArguments(vertex: DataflowGraphVertexFunctionCall, idMap: AstIdMap): readonly PotentiallyEmptyRArgument<ParentInformation>[];
|
|
72
82
|
/**
|
|
73
83
|
* Gets all nested symbols in an expression that have no outgoing edges in the data flow graph.
|
|
74
84
|
* @param expression - The expression to get the symbols from
|
|
@@ -6,6 +6,7 @@ exports.getArgumentValue = getArgumentValue;
|
|
|
6
6
|
exports.getEffectiveArgs = getEffectiveArgs;
|
|
7
7
|
exports.getFunctionArgument = getFunctionArgument;
|
|
8
8
|
exports.getFunctionArguments = getFunctionArguments;
|
|
9
|
+
exports.getVertexArguments = getVertexArguments;
|
|
9
10
|
exports.getUnresolvedSymbolsInExpression = getUnresolvedSymbolsInExpression;
|
|
10
11
|
exports.hasCriticalArgument = hasCriticalArgument;
|
|
11
12
|
exports.isDataFrameArgument = isDataFrameArgument;
|
|
@@ -129,6 +130,17 @@ function getFunctionArguments(node, dfg) {
|
|
|
129
130
|
if (!vertex_1.DfgVertex.isFunctionCall(vertex) || idMap === undefined) {
|
|
130
131
|
return node.arguments;
|
|
131
132
|
}
|
|
133
|
+
return getVertexArguments(vertex, idMap);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Reconstruct the AST-level arguments of a function call vertex from the data flow graph. Unlike
|
|
137
|
+
* {@link getFunctionArguments}, this works directly on the call vertex, so it also serves calls whose AST node is
|
|
138
|
+
* not a {@link RFunctionCall} (e.g. binary operators).
|
|
139
|
+
* @param vertex - The function call vertex to get the arguments for
|
|
140
|
+
* @param idMap - The id map to resolve the argument node ids against
|
|
141
|
+
* @returns The arguments of the function call in the data flow graph
|
|
142
|
+
*/
|
|
143
|
+
function getVertexArguments(vertex, idMap) {
|
|
132
144
|
return vertex.args
|
|
133
145
|
.map(arg => graph_1.FunctionArgument.isEmpty(arg) ? arg : idMap.get(arg.nodeId))
|
|
134
146
|
.map(arg => r_argument_1.RArgument.isEmpty(arg) || r_argument_1.RArgument.is(arg) ? arg : (0, make_argument_1.toUnnamedArgument)(arg, idMap));
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Top symbol to represent the Top element of complete lattices (e.g. of abstract domains).
|
|
3
3
|
*/
|
|
4
|
+
export type Top = typeof Top;
|
|
4
5
|
export declare const Top: unique symbol;
|
|
5
6
|
export declare const TopSymbol = "\u22A4";
|
|
6
7
|
/**
|
|
7
8
|
* The Bottom symbol to represent the Bottom element of complete lattices (e.g. of abstract domains).
|
|
8
9
|
*/
|
|
10
|
+
export type Bottom = typeof Bottom;
|
|
9
11
|
export declare const Bottom: unique symbol;
|
|
10
12
|
export declare const BottomSymbol = "\u22A5";
|
|
11
13
|
/**
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BottomSymbol = exports.Bottom = exports.TopSymbol = exports.Top = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* The Top symbol to represent the Top element of complete lattices (e.g. of abstract domains).
|
|
6
|
-
*/
|
|
7
4
|
exports.Top = Symbol('top');
|
|
8
5
|
exports.TopSymbol = '⊤';
|
|
9
|
-
/**
|
|
10
|
-
* The Bottom symbol to represent the Bottom element of complete lattices (e.g. of abstract domains).
|
|
11
|
-
*/
|
|
12
6
|
exports.Bottom = Symbol('bottom');
|
|
13
7
|
exports.BottomSymbol = '⊥';
|
|
14
8
|
//# sourceMappingURL=lattice.js.map
|
|
@@ -7,7 +7,7 @@ import { type StateDomainLift, StateAbstractDomain } from './state-abstract-doma
|
|
|
7
7
|
* @see {@link NodeId} for the node IDs of the AST nodes
|
|
8
8
|
*/
|
|
9
9
|
export declare class MultiValueStateDomain<Product extends PartialProduct, Value extends StateDomainLift<MultiValueDomain<Product>> = StateDomainLift<MultiValueDomain<Product>>> extends StateAbstractDomain<MultiValueDomain<Product>, Value> {
|
|
10
|
-
constructor(value: Value, domain: Required<Product>, reductions?: readonly ProductReduction<Product>[]);
|
|
10
|
+
constructor(value: Value, domain: Required<Product>, reductions?: readonly ProductReduction<Product>[], collapseOnBottom?: boolean);
|
|
11
11
|
create(value: StateDomainLift<MultiValueDomain<Product>>): this;
|
|
12
12
|
getValue<Key extends keyof Product>(node: NodeId, property: Key): Product[Key] | undefined;
|
|
13
13
|
hasValue(node: NodeId, property: keyof Product): boolean;
|
|
@@ -15,6 +15,7 @@ export declare class MultiValueStateDomain<Product extends PartialProduct, Value
|
|
|
15
15
|
removeValue<Key extends keyof Product>(node: NodeId, property: Key): void;
|
|
16
16
|
entries(): readonly [NodeId, MultiValueDomain<Product>][];
|
|
17
17
|
entries<Key extends keyof Product>(property: Key): readonly [NodeId, Product[Key]][];
|
|
18
|
+
getBottomNodes(): NodeId[];
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* A multi-value abstract domain as a (partial) product domain that combines multiple abstract domains.
|
|
@@ -4,17 +4,18 @@ exports.MultiValueDomain = exports.MultiValueStateDomain = void 0;
|
|
|
4
4
|
const lattice_1 = require("./lattice");
|
|
5
5
|
const partial_product_domain_1 = require("./partial-product-domain");
|
|
6
6
|
const state_abstract_domain_1 = require("./state-abstract-domain");
|
|
7
|
+
const record_1 = require("../../util/record");
|
|
7
8
|
/**
|
|
8
9
|
* A multi-value state abstract domain that maps AST node IDs to multiple abstract values from different abstract domains.
|
|
9
10
|
* @template Product - Type of the abstract product of the multi-value domain combining multiple abstract values
|
|
10
11
|
* @see {@link NodeId} for the node IDs of the AST nodes
|
|
11
12
|
*/
|
|
12
13
|
class MultiValueStateDomain extends state_abstract_domain_1.StateAbstractDomain {
|
|
13
|
-
constructor(value, domain, reductions = []) {
|
|
14
|
-
super(value, new MultiValueDomain(domain, domain, reductions));
|
|
14
|
+
constructor(value, domain, reductions = [], collapseOnBottom = true) {
|
|
15
|
+
super(value, new MultiValueDomain(domain, domain, reductions), collapseOnBottom);
|
|
15
16
|
}
|
|
16
17
|
create(value) {
|
|
17
|
-
return new MultiValueStateDomain(value, this.domain.domain, this.domain.reductions);
|
|
18
|
+
return new MultiValueStateDomain(value, this.domain.domain, this.domain.reductions, this.collapseOnBottom);
|
|
18
19
|
}
|
|
19
20
|
getValue(node, property) {
|
|
20
21
|
if (this.value === lattice_1.Bottom) {
|
|
@@ -52,6 +53,9 @@ class MultiValueStateDomain extends state_abstract_domain_1.StateAbstractDomain
|
|
|
52
53
|
}
|
|
53
54
|
return super.entries().map(([id, domain]) => [id, domain.value[property]]);
|
|
54
55
|
}
|
|
56
|
+
getBottomNodes() {
|
|
57
|
+
return this.value === lattice_1.Bottom ? [] : this.value.entries().filter(([, entry]) => record_1.Record.values(entry.value).some(value => value?.isBottom())).map(([key]) => key).toArray();
|
|
58
|
+
}
|
|
55
59
|
}
|
|
56
60
|
exports.MultiValueStateDomain = MultiValueStateDomain;
|
|
57
61
|
/**
|
|
@@ -100,7 +100,8 @@ class PartialProductDomain extends abstract_domain_1.AbstractDomain {
|
|
|
100
100
|
return !record_1.Record.values(this.value).some(assert_1.isNotUndefined);
|
|
101
101
|
}
|
|
102
102
|
isBottom() {
|
|
103
|
-
|
|
103
|
+
const values = record_1.Record.values(this.value);
|
|
104
|
+
return values.length > 0 && values.every(value => value.isBottom());
|
|
104
105
|
}
|
|
105
106
|
isValue() {
|
|
106
107
|
return true;
|
|
@@ -18,10 +18,12 @@ export type StateDomainLift<Domain extends AnyAbstractDomain> = StateDomainValue
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class StateAbstractDomain<Domain extends AnyAbstractDomain, Value extends StateDomainLift<Domain> = StateDomainLift<Domain>> extends AbstractDomain<StateDomainValue<Domain>, StateDomainTop, StateDomainBottom, Value> implements StateDomain<Domain> {
|
|
20
20
|
readonly domain: Domain;
|
|
21
|
-
|
|
21
|
+
/** Whether mapping a single {@link NodeId} to Bottom collapses the whole state to Bottom or keeps it as a regular entry */
|
|
22
|
+
readonly collapseOnBottom: boolean;
|
|
23
|
+
constructor(value: Value, domain: Domain, collapseOnBottom?: boolean);
|
|
22
24
|
create(value: StateDomainLift<Domain>): this;
|
|
23
|
-
static top<Domain extends AnyAbstractDomain, StateDomain extends StateAbstractDomain<Domain, StateDomainTop>>(this: new (value: StateDomainTop, domain: Domain) => StateDomain, domain: Domain): StateDomain;
|
|
24
|
-
static bottom<Domain extends AnyAbstractDomain, StateDomain extends StateAbstractDomain<Domain, StateDomainBottom>>(this: new (value: StateDomainBottom, domain: Domain) => StateDomain, domain: Domain): StateDomain;
|
|
25
|
+
static top<Domain extends AnyAbstractDomain, StateDomain extends StateAbstractDomain<Domain, StateDomainTop>>(this: new (value: StateDomainTop, domain: Domain, collapseOnBottom?: boolean) => StateDomain, domain: Domain, collapseOnBottom?: boolean): StateDomain;
|
|
26
|
+
static bottom<Domain extends AnyAbstractDomain, StateDomain extends StateAbstractDomain<Domain, StateDomainBottom>>(this: new (value: StateDomainBottom, domain: Domain, collapseOnBottom?: boolean) => StateDomain, domain: Domain, collapseOnBottom?: boolean): StateDomain;
|
|
25
27
|
get(node: NodeId): Domain | undefined;
|
|
26
28
|
has(node: NodeId): boolean;
|
|
27
29
|
set(node: NodeId, value: Domain): void;
|
|
@@ -46,4 +48,5 @@ export declare class StateAbstractDomain<Domain extends AnyAbstractDomain, Value
|
|
|
46
48
|
isTop(): this is this & StateAbstractDomain<Domain, StateDomainTop>;
|
|
47
49
|
isBottom(): this is this & StateAbstractDomain<Domain, StateDomainBottom>;
|
|
48
50
|
isValue(): this is this & StateAbstractDomain<Domain, StateDomainValue<Domain>>;
|
|
51
|
+
getBottomNodes(): NodeId[];
|
|
49
52
|
}
|
|
@@ -11,23 +11,26 @@ const lattice_1 = require("./lattice");
|
|
|
11
11
|
*/
|
|
12
12
|
class StateAbstractDomain extends abstract_domain_1.AbstractDomain {
|
|
13
13
|
domain;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/** Whether mapping a single {@link NodeId} to Bottom collapses the whole state to Bottom or keeps it as a regular entry */
|
|
15
|
+
collapseOnBottom;
|
|
16
|
+
constructor(value, domain, collapseOnBottom = true) {
|
|
17
|
+
if (value === lattice_1.Bottom || (collapseOnBottom && value.values().some(entry => entry.isBottom()))) {
|
|
16
18
|
super(lattice_1.Bottom);
|
|
17
19
|
}
|
|
18
20
|
else {
|
|
19
21
|
super(new Map(value));
|
|
20
22
|
}
|
|
21
23
|
this.domain = domain;
|
|
24
|
+
this.collapseOnBottom = collapseOnBottom;
|
|
22
25
|
}
|
|
23
26
|
create(value) {
|
|
24
|
-
return new StateAbstractDomain(value, this.domain);
|
|
27
|
+
return new StateAbstractDomain(value, this.domain, this.collapseOnBottom);
|
|
25
28
|
}
|
|
26
|
-
static top(domain) {
|
|
27
|
-
return new this(new Map(), domain);
|
|
29
|
+
static top(domain, collapseOnBottom = true) {
|
|
30
|
+
return new this(new Map(), domain, collapseOnBottom);
|
|
28
31
|
}
|
|
29
|
-
static bottom(domain) {
|
|
30
|
-
return new this(lattice_1.Bottom, domain);
|
|
32
|
+
static bottom(domain, collapseOnBottom = true) {
|
|
33
|
+
return new this(lattice_1.Bottom, domain, collapseOnBottom);
|
|
31
34
|
}
|
|
32
35
|
get(node) {
|
|
33
36
|
return this.value === lattice_1.Bottom ? this.domain.bottom() : this.value.get(node);
|
|
@@ -125,6 +128,9 @@ class StateAbstractDomain extends abstract_domain_1.AbstractDomain {
|
|
|
125
128
|
isValue() {
|
|
126
129
|
return this.value !== lattice_1.Bottom;
|
|
127
130
|
}
|
|
131
|
+
getBottomNodes() {
|
|
132
|
+
return this.value === lattice_1.Bottom ? [] : this.value.entries().filter(([, entry]) => entry.isBottom()).map(([key]) => key).toArray();
|
|
133
|
+
}
|
|
128
134
|
}
|
|
129
135
|
exports.StateAbstractDomain = StateAbstractDomain;
|
|
130
136
|
//# sourceMappingURL=state-abstract-domain.js.map
|
|
@@ -24,6 +24,10 @@ export interface StateDomain<Domain extends AnyAbstractDomain = AnyAbstractDomai
|
|
|
24
24
|
* Sets the inferred value for an AST node ID from the state domain.
|
|
25
25
|
*/
|
|
26
26
|
set(node: NodeId, value: Domain): void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the AST node IDs in the state domain that are mapped to Bottom.
|
|
29
|
+
*/
|
|
30
|
+
getBottomNodes(): NodeId[];
|
|
27
31
|
/**
|
|
28
32
|
* Returns all node-value pairs of the state domain.
|
|
29
33
|
*/
|
package/config.js
CHANGED
|
@@ -471,7 +471,7 @@ exports.FlowrConfig = {
|
|
|
471
471
|
linkDescriptionDependencies: joi_1.default.boolean().optional().description('Eagerly attach the namespaces of the project\'s declared DESCRIPTION dependencies (Imports/Depends) so their exports resolve without an explicit library() (default false).'),
|
|
472
472
|
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).'),
|
|
473
473
|
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.'),
|
|
474
|
-
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"
|
|
474
|
+
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).'),
|
|
475
475
|
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).'),
|
|
476
476
|
installedLibrary: joi_1.default.object({
|
|
477
477
|
enabled: joi_1.default.boolean().required().description('Recover packages no signature database knows from their installed copy (default false).'),
|
|
@@ -63,6 +63,8 @@ class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.Seman
|
|
|
63
63
|
loopCds = undefined;
|
|
64
64
|
encounteredLoopBreaker = false;
|
|
65
65
|
onlyLoopyOnce = false;
|
|
66
|
+
withinLoop = new Set();
|
|
67
|
+
what;
|
|
66
68
|
constructor(loopToCheck, config) {
|
|
67
69
|
super(config);
|
|
68
70
|
this.loopToCheck = loopToCheck;
|
|
@@ -71,29 +73,29 @@ class CfgSingleIterationLoopDetector extends semantic_cfg_guided_visitor_1.Seman
|
|
|
71
73
|
const g = this.config.controlFlow.graph;
|
|
72
74
|
const loopNode = this.getNormalizedAst(this.loopToCheck);
|
|
73
75
|
(0, assert_1.guard)(loopNode !== undefined, "Can't find the loop to check");
|
|
74
|
-
const withinLoop = [];
|
|
75
76
|
new visitor_1.NodeVisitor(node => {
|
|
76
77
|
if (r_function_definition_1.RFunctionDefinition.is(node)) {
|
|
77
78
|
/* a jump within a nested closure leaves that closure, not the loop around it */
|
|
78
79
|
return true;
|
|
79
80
|
}
|
|
80
|
-
withinLoop.
|
|
81
|
+
this.withinLoop.add(node.info.id);
|
|
81
82
|
}).visit(loopNode);
|
|
83
|
+
// We use withinLoop to filter the cds to only cds that are inside the loop
|
|
84
|
+
this.withinLoop.delete(this.loopToCheck);
|
|
82
85
|
/*
|
|
83
86
|
* Everything the loop is made of is inspected rather than followed through the graph: a loop that always
|
|
84
87
|
* jumps out never reaches its own vertex, so a walk from there would not find what breaks it.
|
|
85
88
|
*/
|
|
86
|
-
for (const current of withinLoop) {
|
|
87
|
-
if (
|
|
88
|
-
|
|
89
|
+
for (const current of this.withinLoop.values()) {
|
|
90
|
+
if (g.hasVertex(current)) {
|
|
91
|
+
this.visitNode(current);
|
|
89
92
|
}
|
|
90
|
-
this.onlyLoopyOnce ||= this.encounteredLoopBreaker && (0, info_1.happensInEveryBranch)(this.loopCds?.filter(c => !c.byIteration));
|
|
91
93
|
}
|
|
92
|
-
this.onlyLoopyOnce
|
|
94
|
+
this.onlyLoopyOnce = this.encounteredLoopBreaker && (0, info_1.happensInEveryBranch)(this.loopCds?.filter(c => !c.byIteration));
|
|
93
95
|
}
|
|
94
96
|
breaks({ call }) {
|
|
95
97
|
this.encounteredLoopBreaker = true;
|
|
96
|
-
const filtered = call.cds?.filter(c => c.id
|
|
98
|
+
const filtered = call.cds?.filter(c => this.withinLoop.has(c.id)) ?? [];
|
|
97
99
|
if (filtered.length > 0) {
|
|
98
100
|
this.loopCds = (this.loopCds ?? []).concat(filtered);
|
|
99
101
|
}
|