@eagleoutice/flowr 2.15.10 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/cli/flowr-main-options.d.ts +15 -0
- package/cli/flowr-main-options.js +18 -0
- package/cli/flowr.d.ts +18 -0
- package/cli/flowr.js +13 -2
- package/cli/repl/commands/repl-clipboard.js +2 -1
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-main.d.ts +5 -0
- package/cli/repl/commands/repl-signature.js +2 -0
- package/cli/repl/core.d.ts +7 -1
- package/cli/repl/core.js +17 -8
- package/cli/repl/execute.js +2 -0
- package/cli/repl/server/connection.js +2 -1
- package/cli/repl/server/net.d.ts +10 -0
- package/cli/repl/server/net.js +34 -1
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +12 -2
- package/config.js +91 -14
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +185 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +64 -42
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +42 -4
- package/dataflow/internal/control-flow.js +76 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +60 -58
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/doc-capabilities.js +4 -1
- package/documentation/wiki-interface.js +4 -0
- package/documentation/wiki-setup.js +23 -0
- package/engines.js +11 -3
- package/linter/linter-executor.js +19 -1
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +117 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +130 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
- package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
- package/project/sigdb/decompress.js +3 -1
- package/project/sigdb/sigdb-download.js +9 -6
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +9 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell-executor.js +2 -0
- package/r-bridge/shell.js +8 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +120 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +6 -0
- package/util/files.js +12 -0
- package/util/parallel.js +2 -0
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/secure-mode.d.ts +42 -0
- package/util/secure-mode.js +70 -0
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -10,10 +10,15 @@ const visiting_queue_1 = require("./visiting-queue");
|
|
|
10
10
|
const slice_call_1 = require("./slice-call");
|
|
11
11
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
12
12
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
13
|
+
const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
|
|
14
|
+
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
13
15
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
14
16
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
15
17
|
const slice_direction_1 = require("../../util/slice-direction");
|
|
16
18
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
19
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
20
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
21
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
17
22
|
exports.slicerLogger = log_1.log.getSubLogger({ name: 'slicer' });
|
|
18
23
|
/**
|
|
19
24
|
* Computes the node ids to include in a static slice, starting from the given seed ids.
|
|
@@ -23,53 +28,54 @@ function staticSlice(options) {
|
|
|
23
28
|
const { ctx, info, ids, cache, sliceGraph } = options;
|
|
24
29
|
const { idMap } = options.ast;
|
|
25
30
|
const direction = options.direction ?? slice_direction_1.SliceDirection.Backward;
|
|
26
|
-
const threshold = options.threshold ?? 75;
|
|
27
31
|
(0, assert_1.guard)(ids.length > 0, 'must have at least one seed id to calculate slice');
|
|
28
32
|
// includeCallees only makes sense on the original (non-reduced) graph, backward
|
|
29
33
|
const trackCallees = (options.includeCallees ?? false) && direction === slice_direction_1.SliceDirection.Backward && sliceGraph === undefined;
|
|
30
34
|
// enclosing function definitions whose callees still need to be considered, mapped to the env to enqueue them in
|
|
31
35
|
const pendingCalleeBoundaries = new Map();
|
|
32
36
|
const resolvedCalleeBoundaries = new Set();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
graph = info.graph;
|
|
39
|
-
if (direction === slice_direction_1.SliceDirection.Forward) {
|
|
40
|
-
graph = df_helper_1.Dataflow.invertGraph(graph, ctx.env.makeCleanEnv());
|
|
37
|
+
/* a body entered through a call gets its arguments from that call, so only bodies the slice starts in open their callers */
|
|
38
|
+
const openedBodies = new Set();
|
|
39
|
+
const openBodiesAround = (from) => {
|
|
40
|
+
for (let fn = model_1.RNode.findEnclosing(from, idMap, r_function_definition_1.RFunctionDefinition.is); fn !== undefined; fn = model_1.RNode.strictlyEnclosingFunction(fn, idMap)) {
|
|
41
|
+
openedBodies.add(fn);
|
|
41
42
|
}
|
|
42
|
-
}
|
|
43
|
-
const
|
|
43
|
+
};
|
|
44
|
+
const graph = sliceGraph ?? (direction === slice_direction_1.SliceDirection.Forward ? df_helper_1.Dataflow.invertGraph(info.graph, ctx.env.makeCleanEnv()) : info.graph);
|
|
45
|
+
const emptyEnv = ctx.env.makeCleanEnv();
|
|
46
|
+
const basePrint = ctx.env.getCleanEnvFingerprint();
|
|
47
|
+
const queue = new visiting_queue_1.VisitingQueue(options.threshold ?? 75, cache, graph, ctx.gas.scope(options.gas), [emptyEnv, basePrint]);
|
|
48
|
+
const enclosingHandled = new Set();
|
|
49
|
+
const enqueue = (id, env, print) => {
|
|
50
|
+
if (!queue.hasId(id)) {
|
|
51
|
+
queue.add(id, env, print, true);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
44
54
|
let minNesting = Number.MAX_SAFE_INTEGER;
|
|
45
55
|
const sliceSeedIds = new Set();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*/
|
|
59
|
-
for (const id of graph.unknownSideEffects) {
|
|
60
|
-
if (typeof id !== 'object') {
|
|
61
|
-
/* otherwise, their target is just missing */
|
|
62
|
-
queue.add(id, emptyEnv, basePrint, true);
|
|
63
|
-
}
|
|
56
|
+
for (const startId of ids) {
|
|
57
|
+
queue.add(startId, emptyEnv, basePrint, false);
|
|
58
|
+
// retrieve the minimum nesting of all nodes to only add control dependencies if they are "part" of the current execution
|
|
59
|
+
minNesting = Math.min(minNesting, idMap.get(startId)?.info.nest ?? minNesting);
|
|
60
|
+
sliceSeedIds.add(startId);
|
|
61
|
+
openBodiesAround(startId);
|
|
62
|
+
}
|
|
63
|
+
/* include all the implicit side effects that we have to consider as we are unable to narrow them down */
|
|
64
|
+
for (const id of graph.unknownSideEffects) {
|
|
65
|
+
/* a linked side effect is no vertex of its own, its target is just missing */
|
|
66
|
+
if (typeof id !== 'object') {
|
|
67
|
+
queue.add(id, emptyEnv, basePrint, true);
|
|
64
68
|
}
|
|
65
69
|
}
|
|
70
|
+
/* a call asked about does what the functions it runs do, which includes what they print */
|
|
71
|
+
for (const id of outputWithinCallees(ids, graph)) {
|
|
72
|
+
queue.add(id, emptyEnv, basePrint, false);
|
|
73
|
+
}
|
|
74
|
+
/* a drained queue completes the body slice, only then can a boundary decide whether its callers matter */
|
|
66
75
|
do {
|
|
67
76
|
while (queue.nonEmpty()) {
|
|
68
77
|
processNode();
|
|
69
78
|
}
|
|
70
|
-
// the queue drained: only now do we know the full body slice, so decide per boundary whether the callers
|
|
71
|
-
// can actually influence the result (i.e., the slice reaches a parameter or a captured scope variable).
|
|
72
|
-
// resolving a boundary may enqueue new nodes, hence the surrounding do-while re-enters the traversal.
|
|
73
79
|
resolveCalleeBoundaries();
|
|
74
80
|
} while (queue.nonEmpty());
|
|
75
81
|
function processNode() {
|
|
@@ -81,31 +87,43 @@ function staticSlice(options) {
|
|
|
81
87
|
return;
|
|
82
88
|
}
|
|
83
89
|
const [currentVertex, currentEdges] = currentInfo;
|
|
90
|
+
const strictlyEnclosing = model_1.RNode.strictlyEnclosingFunction(id, idMap);
|
|
91
|
+
if (!enclosingHandled.has(strictlyEnclosing)) {
|
|
92
|
+
enclosingHandled.add(strictlyEnclosing);
|
|
93
|
+
definitionWithHolders(strictlyEnclosing, idMap, graph, trackCallees ? undefined : openedBodies).forEach(outer => enqueue(outer, emptyEnv, basePrint));
|
|
94
|
+
}
|
|
84
95
|
// includeCallees: note the enclosing function definition (if any) so its callees can be considered once the body slice is complete
|
|
85
96
|
if (trackCallees) {
|
|
86
|
-
const enclosingFnDef = (
|
|
87
|
-
if (enclosingFnDef !== undefined && !resolvedCalleeBoundaries.has(enclosingFnDef) && !pendingCalleeBoundaries.has(enclosingFnDef)) {
|
|
97
|
+
const enclosingFnDef = r_function_definition_1.RFunctionDefinition.is(idMap.get(id)) ? id : strictlyEnclosing;
|
|
98
|
+
if (enclosingFnDef !== undefined && openedBodies.has(enclosingFnDef) && !resolvedCalleeBoundaries.has(enclosingFnDef) && !pendingCalleeBoundaries.has(enclosingFnDef)) {
|
|
88
99
|
pendingCalleeBoundaries.set(enclosingFnDef, [baseEnvironment, baseEnvFingerprint]);
|
|
89
100
|
}
|
|
90
101
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
/* control dependencies count only in a different call or at least at the nesting of the seeds; a read or a constant
|
|
103
|
+
is the same value whether or not its promise is forced, only what runs within one depends on its call */
|
|
104
|
+
const topLevel = graph.isRoot(id) || sliceSeedIds.has(id);
|
|
105
|
+
const plain = vertex_1.DfgVertex.isUse(currentVertex) || vertex_1.DfgVertex.isValue(currentVertex);
|
|
106
|
+
for (const cd of currentVertex.cds?.filter(cd => !(plain && cd.byPromise) && !queue.hasId(cd.id)) ?? []) {
|
|
107
|
+
if (!topLevel || (idMap.get(cd.id)?.info.nest ?? 0) >= minNesting) {
|
|
108
|
+
queue.add(cd.id, baseEnvironment, baseEnvFingerprint, false);
|
|
98
109
|
}
|
|
99
110
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
111
|
+
/* a call or a definition within a promise runs only when the promise is forced, within captured code only when it is evaluated */
|
|
112
|
+
if (vertex_1.DfgVertex.isFunctionCall(currentVertex) || vertex_1.DfgVertex.isVariableDefinition(currentVertex)) {
|
|
113
|
+
const dependencies = function_semantics_1.FunctionSemantics.promiseDependencies(id, graph);
|
|
114
|
+
if (graph.isQuoted(id)) {
|
|
115
|
+
dependencies.push(...function_semantics_1.FunctionSemantics.call.quoted.evaluationDependencies(graph, id));
|
|
103
116
|
}
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
return;
|
|
117
|
+
for (const dep of dependencies) {
|
|
118
|
+
enqueue(dep, baseEnvironment, baseEnvFingerprint);
|
|
107
119
|
}
|
|
108
120
|
}
|
|
121
|
+
if (vertex_1.DfgVertex.isFunctionCall(currentVertex)) {
|
|
122
|
+
(0, slice_call_1.sliceForCall)(current, currentVertex, info, queue, ctx);
|
|
123
|
+
}
|
|
124
|
+
if (!onlyForSideEffects && (0, slice_call_1.handleReturns)(id, queue, currentEdges, baseEnvFingerprint, baseEnvironment)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
109
127
|
for (const [target, e] of currentEdges) {
|
|
110
128
|
const t = (0, edge_1.shouldTraverseEdge)(e);
|
|
111
129
|
switch (t) {
|
|
@@ -126,16 +144,13 @@ function staticSlice(options) {
|
|
|
126
144
|
}
|
|
127
145
|
}
|
|
128
146
|
function resolveCalleeBoundaries() {
|
|
129
|
-
if (pendingCalleeBoundaries.size === 0) {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
147
|
const boundaries = [...pendingCalleeBoundaries];
|
|
133
148
|
pendingCalleeBoundaries.clear();
|
|
134
149
|
for (const [fnDefId, [env, fingerprint]] of boundaries) {
|
|
135
150
|
resolvedCalleeBoundaries.add(fnDefId);
|
|
136
151
|
// only continue past the boundary if the callers can actually influence the sliced result
|
|
137
152
|
if ((0, slice_call_1.sliceReachesFunctionInterface)(fnDefId, info.graph, queue, idMap, ctx)) {
|
|
138
|
-
(0, slice_call_1.includeCalleesOfDefinition)(fnDefId, info.graph, queue, env, fingerprint);
|
|
153
|
+
(0, slice_call_1.includeCalleesOfDefinition)(fnDefId, info.graph, queue, env, fingerprint).forEach(openBodiesAround);
|
|
139
154
|
}
|
|
140
155
|
}
|
|
141
156
|
}
|
|
@@ -143,6 +158,51 @@ function staticSlice(options) {
|
|
|
143
158
|
const result = ctx.config.solver.slicer?.autoExtend ? extendSlices(status.result, idMap) : status.result;
|
|
144
159
|
return { ...status, slicedFor: ids, result, freeNames: freeNamesOf(result, info.graph) };
|
|
145
160
|
}
|
|
161
|
+
/** The calls writing output (`cat`, `print`, ...: a side effect linked to `sink`) within the functions the call `seeds` run, transitively. */
|
|
162
|
+
function outputWithinCallees(seeds, graph) {
|
|
163
|
+
const writers = new Set();
|
|
164
|
+
for (const effect of graph.unknownSideEffects) {
|
|
165
|
+
if (typeof effect === 'object') {
|
|
166
|
+
writers.add(effect.id);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (writers.size === 0) {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
const found = [];
|
|
173
|
+
const seen = new Set();
|
|
174
|
+
const calls = [...seeds].filter(id => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(id)));
|
|
175
|
+
while (calls.length > 0) {
|
|
176
|
+
for (const target of (0, frame_reflection_1.calledDefinitions)(graph, calls.pop()).filter(t => !seen.has(t))) {
|
|
177
|
+
seen.add(target);
|
|
178
|
+
const callee = graph.getVertex(target);
|
|
179
|
+
found.push(...[...callee.subflow.graph].filter(inner => writers.has(inner)));
|
|
180
|
+
calls.push(...[...(0, frame_reflection_1.callsIn)(callee, graph)].map(([inner]) => inner));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return found;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* The function `definition` and what holds it, up to its statement, as a body only runs as part of its definition.
|
|
187
|
+
* The `opened` bodies the slice starts in stop at an argument holding them or handed to a call of them: that call is a caller.
|
|
188
|
+
*/
|
|
189
|
+
function definitionWithHolders(definition, idMap, graph, opened) {
|
|
190
|
+
const definitionNode = definition === undefined ? undefined : idMap.get(definition);
|
|
191
|
+
if (definitionNode === undefined) {
|
|
192
|
+
return [];
|
|
193
|
+
}
|
|
194
|
+
const outer = [definitionNode.info.id];
|
|
195
|
+
for (const node of model_1.RNode.iterateParents(definitionNode, idMap)) {
|
|
196
|
+
if (r_function_definition_1.RFunctionDefinition.is(node) || (r_expression_list_1.RExpressionList.is(node) && node.grouping?.[0].lexeme !== '(')
|
|
197
|
+
|| (opened !== undefined && r_argument_1.RArgument.is(node) && (opened.has(definitionNode.info.id) || (0, frame_reflection_1.edgeTargets)(graph, node.info.parent ?? '', edge_1.EdgeType.Calls).some(fn => opened.has(fn))))) {
|
|
198
|
+
break;
|
|
199
|
+
}
|
|
200
|
+
if (graph.hasVertex(node.info.id)) {
|
|
201
|
+
outer.push(node.info.id);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return outer;
|
|
205
|
+
}
|
|
146
206
|
/**
|
|
147
207
|
* The names the slice reads without defining them: a use whose definitions all stayed outside meets that name
|
|
148
208
|
* undefined, and so does one that reads nothing at all (a name the program never defines). Reading a built-in
|
|
@@ -154,13 +214,7 @@ function freeNamesOf(slice, graph) {
|
|
|
154
214
|
if (!vertex_1.DfgVertex.isUse(graph.getVertex(id))) {
|
|
155
215
|
continue;
|
|
156
216
|
}
|
|
157
|
-
|
|
158
|
-
for (const [target, edge] of graph.edgesFrom(id)) {
|
|
159
|
-
if (edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && (slice.has(target) || node_id_1.NodeId.isBuiltIn(target))) {
|
|
160
|
-
defined = true;
|
|
161
|
-
break;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
217
|
+
const defined = (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads).some(t => slice.has(t) || node_id_1.NodeId.isBuiltIn(t));
|
|
164
218
|
const name = defined ? undefined : node_id_1.NodeId.recoverName(id, graph.idMap);
|
|
165
219
|
if (name !== undefined) {
|
|
166
220
|
free.add(name);
|
|
@@ -180,18 +234,12 @@ function staticDice(ctx, info, ast, startIds, endIds, threshold = 75, includeCal
|
|
|
180
234
|
(0, assert_1.guard)(startIds.length > 0 && endIds.length > 0, 'must have at least one start and one end id for dicing');
|
|
181
235
|
const backward = staticSlice({ ctx, info, ast, ids: endIds, direction: slice_direction_1.SliceDirection.Backward, threshold, includeCallees, gas });
|
|
182
236
|
// reduce to backward result and invert edges in one pass; original info kept for sliceForCall
|
|
183
|
-
const
|
|
184
|
-
const forward = staticSlice({ ctx, info, ast, ids: startIds, direction: slice_direction_1.SliceDirection.Backward, threshold, sliceGraph
|
|
185
|
-
// explicit intersection handles seed nodes that landed outside the reduced graph
|
|
186
|
-
const result = new Set();
|
|
187
|
-
for (const id of forward.result) {
|
|
188
|
-
if (backward.result.has(id)) {
|
|
189
|
-
result.add(id);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
237
|
+
const sliceGraph = df_helper_1.Dataflow.reduceAndInvertGraph(info.graph, backward.result, ctx.env.makeCleanEnv());
|
|
238
|
+
const forward = staticSlice({ ctx, info, ast, ids: startIds, direction: slice_direction_1.SliceDirection.Backward, threshold, sliceGraph, gas });
|
|
192
239
|
return {
|
|
193
240
|
timesHitThreshold: forward.timesHitThreshold + backward.timesHitThreshold,
|
|
194
|
-
|
|
241
|
+
// explicit intersection handles seed nodes that landed outside the reduced graph
|
|
242
|
+
result: new Set([...forward.result].filter(id => backward.result.has(id))),
|
|
195
243
|
slicedFor: [...startIds, ...endIds],
|
|
196
244
|
...(forward.stoppedEarly || backward.stoppedEarly ? {
|
|
197
245
|
stoppedEarly: true,
|
|
@@ -203,18 +251,11 @@ function staticDice(ctx, info, ast, startIds, endIds, threshold = 75, includeCal
|
|
|
203
251
|
};
|
|
204
252
|
}
|
|
205
253
|
function extendSlices(results, ast) {
|
|
206
|
-
const res = new Set();
|
|
254
|
+
const res = new Set(results);
|
|
207
255
|
for (const id of results) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
parent = parent.info.parent ? ast.get(parent.info.parent) : undefined;
|
|
212
|
-
}
|
|
213
|
-
if (!parent) {
|
|
214
|
-
continue; // no parent, no need to extend
|
|
215
|
-
}
|
|
216
|
-
for (const id of model_1.RNode.collectAllIds(parent)) {
|
|
217
|
-
res.add(id);
|
|
256
|
+
const statement = model_1.RNode.findEnclosing(id, ast, n => n.info.role === "root" /* RoleInParent.Root */ || n.info.role === "el-c" /* RoleInParent.ExpressionListChild */);
|
|
257
|
+
for (const inner of statement === undefined ? [] : model_1.RNode.collectAllIds(ast.get(statement))) {
|
|
258
|
+
res.add(inner);
|
|
218
259
|
}
|
|
219
260
|
}
|
|
220
261
|
return res;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Fingerprint } from './fingerprint';
|
|
2
2
|
import type { NodeToSlice, SliceResult } from './slicer-types';
|
|
3
3
|
import type { REnvironmentInformation } from '../../dataflow/environments/environment';
|
|
4
|
+
import type { DataflowGraph } from '../../dataflow/graph/graph';
|
|
4
5
|
import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
5
|
-
import type { DataflowGraphVertexInfo } from '../../dataflow/graph/vertex';
|
|
6
6
|
import type { ReadOnlyFlowrAnalyzerGasContext } from '../../project/context/flowr-analyzer-gas-context';
|
|
7
7
|
export declare class VisitingQueue {
|
|
8
8
|
private readonly threshold;
|
|
@@ -13,9 +13,8 @@ export declare class VisitingQueue {
|
|
|
13
13
|
private readonly queue;
|
|
14
14
|
private readonly cache?;
|
|
15
15
|
potentialAdditions: Map<NodeId, [NodeId, NodeToSlice]>;
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
private readonly isGraphVertex?;
|
|
16
|
+
private readonly graph?;
|
|
17
|
+
private readonly global?;
|
|
19
18
|
private readonly gas?;
|
|
20
19
|
private stoppedEarly;
|
|
21
20
|
/** how many nodes pass between two gas checks, see {@link ReadOnlyFlowrAnalyzerGasContext#checkEvery} */
|
|
@@ -23,7 +22,7 @@ export declare class VisitingQueue {
|
|
|
23
22
|
private untilGasCheck;
|
|
24
23
|
/** entries dequeued, see {@link SliceProgress} */
|
|
25
24
|
private visited;
|
|
26
|
-
constructor(threshold: number, cache?: Map<Fingerprint, Set<NodeId>>,
|
|
25
|
+
constructor(threshold: number, cache?: Map<Fingerprint, Set<NodeId>>, graph?: Pick<DataflowGraph, 'hasVertex' | 'isRoot'>, gas?: ReadOnlyFlowrAnalyzerGasContext, global?: readonly [REnvironmentInformation, Fingerprint]);
|
|
27
26
|
/**
|
|
28
27
|
* Adds a node to the queue if it has not been seen before.
|
|
29
28
|
* @param target - the node to add
|
|
@@ -41,6 +40,5 @@ export declare class VisitingQueue {
|
|
|
41
40
|
*/
|
|
42
41
|
private outOfGas;
|
|
43
42
|
hasId(id: NodeId): boolean;
|
|
44
|
-
memoizeCallTargets(id: NodeId, targets: () => Set<DataflowGraphVertexInfo>): Set<DataflowGraphVertexInfo>;
|
|
45
43
|
status(): Readonly<Pick<SliceResult, 'timesHitThreshold' | 'result' | 'stoppedEarly' | 'progress'>>;
|
|
46
44
|
}
|
|
@@ -16,9 +16,8 @@ class VisitingQueue {
|
|
|
16
16
|
// the set of potential additions holds nodes which may be added if a second edge deems them relevant (e.g., found with the `defined-by-on-call` edge)
|
|
17
17
|
// additionally it holds which node id added the addition so we can separate their inclusion on the structure
|
|
18
18
|
potentialAdditions = new Map();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
isGraphVertex;
|
|
19
|
+
graph;
|
|
20
|
+
global;
|
|
22
21
|
gas;
|
|
23
22
|
stoppedEarly = false;
|
|
24
23
|
/** how many nodes pass between two gas checks, see {@link ReadOnlyFlowrAnalyzerGasContext#checkEvery} */
|
|
@@ -26,10 +25,11 @@ class VisitingQueue {
|
|
|
26
25
|
untilGasCheck = 0;
|
|
27
26
|
/** entries dequeued, see {@link SliceProgress} */
|
|
28
27
|
visited = 0;
|
|
29
|
-
constructor(threshold, cache,
|
|
28
|
+
constructor(threshold, cache, graph, gas, global) {
|
|
30
29
|
this.threshold = threshold;
|
|
31
30
|
this.cache = cache;
|
|
32
|
-
this.
|
|
31
|
+
this.graph = graph;
|
|
32
|
+
this.global = global;
|
|
33
33
|
this.gas = gas;
|
|
34
34
|
this.gasCheckEvery = gas?.checkEvery() ?? 0;
|
|
35
35
|
}
|
|
@@ -43,9 +43,12 @@ class VisitingQueue {
|
|
|
43
43
|
add(target, env, envFingerprint, onlyForSideEffects) {
|
|
44
44
|
/* a built-in without a vertex is R's own definition (`x <- 1` reads `built-in:<-`), a dead end the traversal
|
|
45
45
|
* would drop right back out of, so it only ever widened the result */
|
|
46
|
-
if (node_id_1.NodeId.isBuiltIn(target) && this.
|
|
46
|
+
if (node_id_1.NodeId.isBuiltIn(target) && this.graph?.hasVertex(target) === false) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
|
+
if (this.global !== undefined && this.graph?.isRoot(target)) {
|
|
50
|
+
[env, envFingerprint] = this.global;
|
|
51
|
+
}
|
|
49
52
|
const idCounter = this.idThreshold.get(target) ?? 0;
|
|
50
53
|
if (idCounter > this.threshold) {
|
|
51
54
|
this.timesHitThreshold++;
|
|
@@ -101,13 +104,6 @@ class VisitingQueue {
|
|
|
101
104
|
hasId(id) {
|
|
102
105
|
return this.idThreshold.has(id);
|
|
103
106
|
}
|
|
104
|
-
memoizeCallTargets(id, targets) {
|
|
105
|
-
let known = this.cachedCallTargets.get(id);
|
|
106
|
-
if (known === undefined) {
|
|
107
|
-
this.cachedCallTargets.set(id, known = targets());
|
|
108
|
-
}
|
|
109
|
-
return known;
|
|
110
|
-
}
|
|
111
107
|
status() {
|
|
112
108
|
return {
|
|
113
109
|
timesHitThreshold: this.timesHitThreshold,
|
package/util/files.d.ts
CHANGED
|
@@ -47,6 +47,12 @@ export declare function readLineByLine(filePath: string, onLine: (line: Buffer,
|
|
|
47
47
|
* See {@link readLineByLine} for an asynchronous version.
|
|
48
48
|
*/
|
|
49
49
|
export declare function readLineByLineSync(filePath: string, onLine: (line: Buffer, lineNumber: number) => void, maxLines?: number): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Joins `base` with a single path segment taken from an untrusted source (e.g., a file name, release tag, or hash read
|
|
52
|
+
* from a downloaded or project-supplied file), refusing every segment that could name anything outside `base`.
|
|
53
|
+
* @throws if the segment is empty, `.` or `..`, or contains a path separator or NUL
|
|
54
|
+
*/
|
|
55
|
+
export declare function joinUntrustedSegment(base: string, segment: string): string;
|
|
50
56
|
/**
|
|
51
57
|
* Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
|
|
52
58
|
* If an absolute path is passed, the returned path is also absolute.
|
package/util/files.js
CHANGED
|
@@ -42,6 +42,7 @@ exports.getAllFilesSync = getAllFilesSync;
|
|
|
42
42
|
exports.allRFiles = allRFiles;
|
|
43
43
|
exports.readLineByLine = readLineByLine;
|
|
44
44
|
exports.readLineByLineSync = readLineByLineSync;
|
|
45
|
+
exports.joinUntrustedSegment = joinUntrustedSegment;
|
|
45
46
|
exports.getParentDirectory = getParentDirectory;
|
|
46
47
|
exports.commonDirectory = commonDirectory;
|
|
47
48
|
exports.relativeTo = relativeTo;
|
|
@@ -190,6 +191,17 @@ function readLineByLineSync(filePath, onLine, maxLines = Infinity) {
|
|
|
190
191
|
}
|
|
191
192
|
return true;
|
|
192
193
|
}
|
|
194
|
+
/**
|
|
195
|
+
* Joins `base` with a single path segment taken from an untrusted source (e.g., a file name, release tag, or hash read
|
|
196
|
+
* from a downloaded or project-supplied file), refusing every segment that could name anything outside `base`.
|
|
197
|
+
* @throws if the segment is empty, `.` or `..`, or contains a path separator or NUL
|
|
198
|
+
*/
|
|
199
|
+
function joinUntrustedSegment(base, segment) {
|
|
200
|
+
if (segment === '' || segment === '.' || segment === '..' || /[/\\\0]/.test(segment) || path_1.default.isAbsolute(segment)) {
|
|
201
|
+
throw new Error(`Refusing the untrusted path segment ${JSON.stringify(segment)}`);
|
|
202
|
+
}
|
|
203
|
+
return path_1.default.join(base, segment);
|
|
204
|
+
}
|
|
193
205
|
/**
|
|
194
206
|
* Chops off the last part of the given directory path after a path separator, essentially returning the path's parent directory.
|
|
195
207
|
* If an absolute path is passed, the returned path is also absolute.
|
package/util/parallel.js
CHANGED
|
@@ -43,6 +43,7 @@ const cp = __importStar(require("child_process"));
|
|
|
43
43
|
const log_1 = require("./log");
|
|
44
44
|
const assert_1 = require("./assert");
|
|
45
45
|
const json_1 = require("./json");
|
|
46
|
+
const secure_mode_1 = require("./secure-mode");
|
|
46
47
|
/**
|
|
47
48
|
* This is not really generic but written especially for the benchmarking script.
|
|
48
49
|
* It offers a work stealing thread pool executor.
|
|
@@ -93,6 +94,7 @@ class LimitedThreadPool {
|
|
|
93
94
|
(0, assert_1.guard)(args !== undefined, () => `arguments should not be undefined in ${JSON.stringify(this.workingQueue)}`);
|
|
94
95
|
this.currentlyRunning.add(args);
|
|
95
96
|
console.log(`[${this.counter}/${this.limit}] Running next, currently running: ${this.currentlyRunning.size}, queue: ${this.workingQueue.length} [args: ${args.join(' ')}]`);
|
|
97
|
+
secure_mode_1.SecureMode.guard('starting a process', this.module);
|
|
96
98
|
const child = cp.fork(this.module, args);
|
|
97
99
|
child.on('exit', this.onChildExit(args));
|
|
98
100
|
let timeout;
|
package/util/proc.js
CHANGED
|
@@ -15,6 +15,7 @@ function exitSafe(code = 0) {
|
|
|
15
15
|
};
|
|
16
16
|
process.stdout.write('', done);
|
|
17
17
|
process.stderr.write('', done);
|
|
18
|
-
|
|
18
|
+
/* a browser's timer is a plain number that cannot be unreferenced */
|
|
19
|
+
setTimeout(() => process.exit(code), 60_000).unref?.();
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=proc.js.map
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* for the version-aware view, as a release cannot attach a package it did not ship.
|
|
8
8
|
*/
|
|
9
9
|
export declare const AttachedBasePackages: readonly string[];
|
|
10
|
+
/** The data sets of `datasets` (R 4.6), always in scope as lazy data, which its namespace does not export. */
|
|
11
|
+
export declare const BaseDatasets: ReadonlySet<string>;
|
|
10
12
|
/** {@link AttachedBasePackages} for membership tests, which happen far more often than iteration. */
|
|
11
13
|
export declare const AttachedBasePackageSet: ReadonlySet<string>;
|
|
12
14
|
/**
|
package/util/r-base-packages.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AttachedBasePackageSet = exports.AttachedBasePackages = void 0;
|
|
3
|
+
exports.AttachedBasePackageSet = exports.BaseDatasets = exports.AttachedBasePackages = void 0;
|
|
4
4
|
exports.baseRPackages = baseRPackages;
|
|
5
5
|
exports.attachedBasePackages = attachedBasePackages;
|
|
6
6
|
exports.baseRExportOwner = baseRExportOwner;
|
|
@@ -8,6 +8,7 @@ exports.isBaseRPackage = isBaseRPackage;
|
|
|
8
8
|
const r_base_packages_generated_1 = require("../data/r-base-packages.generated");
|
|
9
9
|
const r_base_primitives_generated_1 = require("../data/r-base-primitives.generated");
|
|
10
10
|
const r_version_1 = require("./r-version");
|
|
11
|
+
const defaultmap_1 = require("./collections/defaultmap");
|
|
11
12
|
/**
|
|
12
13
|
* The base packages R attaches to the search path on startup, so their exports are usable without a `library` call.
|
|
13
14
|
*
|
|
@@ -17,14 +18,32 @@ const r_version_1 = require("./r-version");
|
|
|
17
18
|
* for the version-aware view, as a release cannot attach a package it did not ship.
|
|
18
19
|
*/
|
|
19
20
|
exports.AttachedBasePackages = ['base', 'stats', 'graphics', 'grDevices', 'utils', 'datasets', 'methods'];
|
|
21
|
+
/** The data sets of `datasets` (R 4.6), always in scope as lazy data, which its namespace does not export. */
|
|
22
|
+
exports.BaseDatasets = new Set([
|
|
23
|
+
'ability.cov', 'airmiles', 'AirPassengers', 'airquality', 'anscombe', 'attenu', 'attitude', 'austres', 'beaver1', 'beaver2', 'BJsales',
|
|
24
|
+
'BJsales.lead', 'BOD', 'cars', 'ChickWeight', 'chickwts', 'co2', 'CO2', 'crimtab', 'discoveries', 'DNase', 'esoph', 'euro', 'euro.cross',
|
|
25
|
+
'eurodist', 'EuStockMarkets', 'faithful', 'fdeaths', 'Formaldehyde', 'freeny', 'freeny.x', 'freeny.y', 'gait', 'HairEyeColor',
|
|
26
|
+
'Harman23.cor', 'Harman74.cor', 'Indometh', 'infert', 'InsectSprays', 'iris', 'iris3', 'islands', 'JohnsonJohnson', 'LakeHuron', 'ldeaths',
|
|
27
|
+
'lh', 'LifeCycleSavings', 'Loblolly', 'longley', 'lynx', 'mdeaths', 'morley', 'mtcars', 'nhtemp', 'Nile', 'nottem', 'npk',
|
|
28
|
+
'occupationalStatus', 'Orange', 'OrchardSprays', 'penguins', 'penguins_raw', 'PlantGrowth', 'precip', 'presidents', 'pressure', 'Puromycin',
|
|
29
|
+
'quakes', 'randu', 'rivers', 'rock', 'Seatbelts', 'sleep', 'stack.loss', 'stack.x', 'stackloss', 'state.abb', 'state.area', 'state.center',
|
|
30
|
+
'state.division', 'state.name', 'state.region', 'state.x77', 'sunspot.m2014', 'sunspot.month', 'sunspot.year', 'sunspots', 'swiss',
|
|
31
|
+
'Theoph', 'Titanic', 'ToothGrowth', 'treering', 'trees', 'UCBAdmissions', 'UKDriverDeaths', 'UKgas', 'USAccDeaths', 'USArrests',
|
|
32
|
+
'UScitiesD', 'USJudgeRatings', 'USPersonalExpenditure', 'uspop', 'VADeaths', 'volcano', 'warpbreaks', 'women', 'WorldPhones', 'WWWusage'
|
|
33
|
+
]);
|
|
20
34
|
/** {@link AttachedBasePackages} for membership tests, which happen far more often than iteration. */
|
|
21
35
|
exports.AttachedBasePackageSet = new Set(exports.AttachedBasePackages);
|
|
22
36
|
/** clamp `rVersion` to the newest R release the store knows about (so a future R version stays answerable) */
|
|
23
37
|
function effective(rVersion) {
|
|
24
38
|
return r_version_1.RVersion.compare(rVersion, r_base_packages_generated_1.RBasePackageStore.newestRVersion) > 0 ? r_base_packages_generated_1.RBasePackageStore.newestRVersion : rVersion;
|
|
25
39
|
}
|
|
26
|
-
/** memoized
|
|
27
|
-
const
|
|
40
|
+
/** memoized per assumed R version, so the list is computed at most once per version (never per lookup) */
|
|
41
|
+
const basePackagesAt = (0, defaultmap_1.memoize)((rVersion) => {
|
|
42
|
+
const eff = effective(rVersion);
|
|
43
|
+
return Object.entries(r_base_packages_generated_1.RBasePackageStore.packages)
|
|
44
|
+
.filter(([, [first, last]]) => r_version_1.RVersion.compare(first, eff) <= 0 && r_version_1.RVersion.compare(last, eff) >= 0)
|
|
45
|
+
.map(([name]) => name);
|
|
46
|
+
});
|
|
28
47
|
/**
|
|
29
48
|
* The base packages available at the assumed R version (all of them if omitted). A package counts as
|
|
30
49
|
* available when that R release lies within the range it was part of core; e.g. `parallel` (added in R
|
|
@@ -38,16 +57,7 @@ function baseRPackages(rVersion) {
|
|
|
38
57
|
if (rVersion === undefined || rVersion === r_base_packages_generated_1.RBasePackageStore.newestRVersion || r_version_1.RVersion.compare(rVersion, r_base_packages_generated_1.RBasePackageStore.newestRVersion) >= 0) {
|
|
39
58
|
return r_base_packages_generated_1.RBasePackageStore.current; // the current base set, precomputed at bundle time
|
|
40
59
|
}
|
|
41
|
-
|
|
42
|
-
if (cached !== undefined) {
|
|
43
|
-
return cached;
|
|
44
|
-
}
|
|
45
|
-
const eff = effective(rVersion);
|
|
46
|
-
const result = Object.entries(r_base_packages_generated_1.RBasePackageStore.packages)
|
|
47
|
-
.filter(([, [first, last]]) => r_version_1.RVersion.compare(first, eff) <= 0 && r_version_1.RVersion.compare(last, eff) >= 0)
|
|
48
|
-
.map(([name]) => name);
|
|
49
|
-
cache.set(rVersion, result);
|
|
50
|
-
return result;
|
|
60
|
+
return basePackagesAt(rVersion);
|
|
51
61
|
}
|
|
52
62
|
/**
|
|
53
63
|
* The base packages attached at the assumed R version: {@link AttachedBasePackages} without the ones that
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* flowR's secure mode, for analyzing untrusted code (e.g., on a server that accepts arbitrary projects).
|
|
3
|
+
*
|
|
4
|
+
* Once enabled, it stays enabled for the lifetime of the process: there is deliberately no way to disable it.
|
|
5
|
+
* Instead of trying to find every path that may lead to a dangerous operation, the operations themselves
|
|
6
|
+
* (starting R or any other process, accessing the network, using the clipboard) check {@link SecureMode.guard}, so
|
|
7
|
+
* code added later is covered as well. Configuration is restricted on top (see {@link FlowrConfig.fromFile}).
|
|
8
|
+
*
|
|
9
|
+
* Enable it with `--secure` on the command line, the environment variable {@link SecureMode.EnvVar}, or {@link SecureMode.enable}.
|
|
10
|
+
*/
|
|
11
|
+
/** What the secure mode forbids, named in the error it throws. */
|
|
12
|
+
export type SecureModeOperation = 'starting R' | 'starting a process' | 'network access' | 'clipboard access';
|
|
13
|
+
/** Thrown by {@link SecureMode.guard} if a forbidden operation is attempted in secure mode. */
|
|
14
|
+
export declare class SecureModeError extends Error {
|
|
15
|
+
readonly operation: SecureModeOperation;
|
|
16
|
+
constructor(operation: SecureModeOperation, detail?: string);
|
|
17
|
+
}
|
|
18
|
+
/** Whether `value` (of an environment variable) switches something on. */
|
|
19
|
+
export declare function isTruthyEnvValue(value: string | undefined): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The process-wide secure mode, see the module documentation.
|
|
22
|
+
* @helper security
|
|
23
|
+
*/
|
|
24
|
+
export declare const SecureMode: {
|
|
25
|
+
readonly EnvVar: "FLOWR_SECURE_MODE";
|
|
26
|
+
/** Enables the secure mode for the rest of the process's lifetime (there is no way back). */
|
|
27
|
+
readonly enable: (this: void) => void;
|
|
28
|
+
/**
|
|
29
|
+
* In secure mode, decompressing a file of the analyzed project must not yield more than this many bytes,
|
|
30
|
+
* so a decompression bomb cannot exhaust the memory. Use {@link SecureMode.decompressionLimit}.
|
|
31
|
+
*/
|
|
32
|
+
readonly MaxDecompressedBytes: number;
|
|
33
|
+
/** The maximum number of bytes decompressing a project file may yield, `undefined` (no limit) outside the secure mode. */
|
|
34
|
+
readonly decompressionLimit: (this: void) => number | undefined;
|
|
35
|
+
/** Whether the secure mode is enabled. */
|
|
36
|
+
readonly isEnabled: (this: void) => boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Call this right before performing the given operation.
|
|
39
|
+
* @throws a {@link SecureModeError} if the secure mode is enabled
|
|
40
|
+
*/
|
|
41
|
+
readonly guard: (this: void, operation: SecureModeOperation, detail?: string) => void;
|
|
42
|
+
};
|