@eagleoutice/flowr 2.17.11 → 2.17.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/abstract-interpretation/branch-paths-interpreter.js +12 -1
- package/benchmark/slicer.js +3 -1
- package/config.d.ts +1 -0
- package/config.js +4 -2
- package/dataflow/environments/default-builtin-config/base-functions.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/base-functions.js +2 -0
- package/dataflow/environments/default-builtin-config/database-access.d.ts +1 -1
- package/dataflow/environments/default-builtin-config/database-access.js +3 -0
- package/dataflow/environments/default-builtin-config/guards.js +3 -1
- package/dataflow/environments/default-builtin-config/index.d.ts +1 -1
- package/dataflow/extractor.js +66 -4
- package/dataflow/fn/guards/built-in-guards.js +4 -4
- package/dataflow/fn/guards/call-contracts.js +8 -8
- package/dataflow/fn/guards/condition-grouping.js +4 -3
- package/dataflow/fn/guards/function-guards.js +103 -97
- package/dataflow/fn/guards/group-method-guards.js +22 -12
- package/dataflow/fn/guards/guard-claims.js +152 -128
- package/dataflow/fn/guards/guard-knowledge.js +19 -18
- package/dataflow/fn/guards/guard-term-syntax.js +13 -12
- package/dataflow/fn/guards/guard-term.d.ts +71 -0
- package/dataflow/fn/guards/guard-term.js +183 -75
- package/dataflow/graph/graph.d.ts +9 -0
- package/dataflow/graph/graph.js +19 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +6 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +9 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +135 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +35 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +2 -1
- package/dataflow/internal/program-order.d.ts +9 -0
- package/dataflow/internal/program-order.js +38 -2
- package/documentation/wiki-interface.js +1 -0
- package/linter/linter-rules.d.ts +1 -0
- package/linter/rules/problematic-inputs.d.ts +3 -0
- package/linter/rules/problematic-inputs.js +12 -9
- package/linter/rules/undefined-symbol.js +3 -2
- package/package.json +5 -2
- package/project/sigdb/export-keys.d.ts +9 -0
- package/project/sigdb/export-keys.js +121 -0
- package/project/sigdb/reader.d.ts +7 -9
- package/project/sigdb/reader.js +24 -42
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +0 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +136 -38
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/mermaid/mermaid.js +1 -1
|
@@ -23,6 +23,7 @@ const r_function_call_1 = require("../../../../../../r-bridge/lang-4.x/ast/model
|
|
|
23
23
|
const node_id_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
24
24
|
const model_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/model");
|
|
25
25
|
const program_order_1 = require("../../../../program-order");
|
|
26
|
+
const ambient_access_1 = require("../../../../../graph/ambient-access");
|
|
26
27
|
const graph_1 = require("../../../../../graph/graph");
|
|
27
28
|
const identifier_1 = require("../../../../../environments/identifier");
|
|
28
29
|
const vertex_1 = require("../../../../../graph/vertex");
|
|
@@ -43,6 +44,7 @@ const ambient_state_name_1 = require("../../../../../environments/ambient-state-
|
|
|
43
44
|
const r_argument_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
44
45
|
const r_function_definition_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
45
46
|
const r_expression_list_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
47
|
+
const r_binary_op_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
|
|
46
48
|
const r_parameter_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-parameter");
|
|
47
49
|
const r_string_1 = require("../../../../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
48
50
|
const query_fn_props_1 = require("../../../../../environments/query-fn-props");
|
|
@@ -342,7 +344,13 @@ function updateNestedFunctionClosures(graph, outEnvironment, openReads) {
|
|
|
342
344
|
}
|
|
343
345
|
// track *all* function definitions, including those nested within, resolving their 'in' via the lowest scope (popped after this definition)
|
|
344
346
|
for (const [fn, { subflow }] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
345
|
-
|
|
347
|
+
const calls = callsWithinBody(fn, graph);
|
|
348
|
+
subflow.in = resolveIngoingRefs(subflow.in, outEnvironment, (ingoing, found) => {
|
|
349
|
+
/* a binding the body makes only after every call of the closure is not one any call sees */
|
|
350
|
+
const resolved = calls === undefined ? found : found.filter(ref => !calls.every(call => program_order_1.ProgramOrder.boundLaterInBody(ref.nodeId, call, graph)));
|
|
351
|
+
if (resolved.length === 0) {
|
|
352
|
+
return true;
|
|
353
|
+
}
|
|
346
354
|
const writes = superWrites.get(ingoing.name);
|
|
347
355
|
for (const ref of resolved) {
|
|
348
356
|
graph.addEdge(ingoing.nodeId, ref.nodeId, edge_1.EdgeType.Reads);
|
|
@@ -383,6 +391,21 @@ function updateNestedFunctionClosures(graph, outEnvironment, openReads) {
|
|
|
383
391
|
openReads.push(...kept);
|
|
384
392
|
}
|
|
385
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* The calls of the closure defined at `fn` if the body around it can call it nowhere else: it is bound by a statement of the body (that is not the
|
|
396
|
+
* value the body returns) and every read of that binding calls it, `undefined` if the closure may escape or the body may reach it in ways flowR does not see.
|
|
397
|
+
*/
|
|
398
|
+
function callsWithinBody(fn, graph) {
|
|
399
|
+
const idMap = graph.idMap;
|
|
400
|
+
const assignment = idMap?.get(idMap.get(fn)?.info.parent ?? '');
|
|
401
|
+
const block = assignment?.info.parent === undefined ? undefined : idMap?.get(assignment.info.parent);
|
|
402
|
+
if (idMap === undefined || graph.unknownSideEffects.size > 0 || !r_binary_op_1.RBinaryOp.is(assignment) || assignment.rhs.info.id !== fn || !r_expression_list_1.RExpressionList.is(block)
|
|
403
|
+
|| block.children.at(-1) === assignment || !vertex_1.DfgVertex.hasOrigin(graph.getVertex(assignment.info.id), built_in_proc_name_1.BuiltInProcName.Assignment)) {
|
|
404
|
+
return undefined;
|
|
405
|
+
}
|
|
406
|
+
const readers = df_helper_1.Dataflow.sourcesOf(graph, assignment.lhs.info.id, edge_1.EdgeType.Reads);
|
|
407
|
+
return readers.length > 0 && readers.every(r => vertex_1.DfgVertex.isFunctionCall(graph.getVertex(r)) && df_helper_1.Dataflow.hasEdge(graph, r, fn, edge_1.EdgeType.Calls)) ? readers : undefined;
|
|
408
|
+
}
|
|
386
409
|
/** Whether an enclosing scope binds the name of a call within a closure before the closure exists, see {@link boundBeforeClosure}: then the call reaches only what its reads do, and never looks further out, whatever the end of the script binds there. */
|
|
387
410
|
function callBoundInScope(call, graph) {
|
|
388
411
|
return !graph.isRoot(call) && nameReadsOf(call, graph).some(r => boundBeforeClosure(r, call, graph));
|
|
@@ -713,6 +736,8 @@ function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
713
736
|
const fn = enclosingOf(at);
|
|
714
737
|
return fn === undefined || graph.edgesTo(fn).values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.Calls));
|
|
715
738
|
});
|
|
739
|
+
/* the calls that may run a method bound by a name we cannot tell */
|
|
740
|
+
const runsUnknownMethod = new Set();
|
|
716
741
|
/* per function, the `NextMethod` calls of its body */
|
|
717
742
|
const namedNextCalls = new Map();
|
|
718
743
|
for (const [id, vertex] of calls) {
|
|
@@ -757,9 +782,9 @@ function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
757
782
|
}
|
|
758
783
|
continue;
|
|
759
784
|
}
|
|
760
|
-
/* a method the code binds by a name we cannot tell may be one the call dispatches to */
|
|
761
|
-
if (unknownMethodsAt.some(at => !program_order_1.ProgramOrder.definedLater(at,
|
|
762
|
-
|
|
785
|
+
/* a method the code binds by a name we cannot tell may be one the call dispatches to, a function nothing resolves is just one we cannot see */
|
|
786
|
+
if (unknownMethodsAt.some(at => !program_order_1.ProgramOrder.definedLater(at, program_order_1.ProgramOrder.runsWithin(id, graph), graph)) && ((handsObjects(vertex, graph.idMap) && runWithin(name).length > 0) || built_in_props_1.CallProps.hasAny(fnPropsOf(name, environmentAt(id), databaseInfoOf), built_in_props_1.CallProp.Generic))) {
|
|
787
|
+
runsUnknownMethod.add(id);
|
|
763
788
|
}
|
|
764
789
|
/* the code writes a `<name>.<class>`, so a built-in `name` that dispatches may reach it */
|
|
765
790
|
const mayDispatch = (0, group_generics_1.s3MethodPrefixesOf)(name).some(p => generics.has(p));
|
|
@@ -771,7 +796,7 @@ function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
771
796
|
}
|
|
772
797
|
const effectiveEnvironment = environmentAt(id);
|
|
773
798
|
/* a call the program runs once, at the top and outside any loop, cannot see what is defined after it */
|
|
774
|
-
const definedLater = (definition) => program_order_1.ProgramOrder.definedLater(definition, runsOnceAt(id), graph);
|
|
799
|
+
const definedLater = (definition) => program_order_1.ProgramOrder.definedLater(definition, runsOnceAt(id), graph) || program_order_1.ProgramOrder.boundLaterInBody(definition, id, graph);
|
|
775
800
|
/* the dispatch is decided anew, from every method the name may reach */
|
|
776
801
|
delete vertex.ruledOut;
|
|
777
802
|
delete vertex.ruledOutAt;
|
|
@@ -970,7 +995,9 @@ function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
970
995
|
function_semantics_1.FunctionSemantics.call.match.onCallAndLink(args, parameters, graph);
|
|
971
996
|
}
|
|
972
997
|
function_semantics_1.FunctionSemantics.call.match.unforceUnreadDots(graph);
|
|
973
|
-
|
|
998
|
+
const topLevelCallsOf = topLevelCallsRunning(graph, enclosingOf);
|
|
999
|
+
linkLiftedReads(graph, lifted, topLevelCallsOf, environmentAt, runsOnceAt);
|
|
1000
|
+
linkStateReadsToUnknownMethods(graph, runsUnknownMethod, unknownMethodsAt, enclosingOf, topLevelCallsOf);
|
|
974
1001
|
/* a method only a next-method call reaches is linked by no call that resolves what it reads */
|
|
975
1002
|
const called = new Set(graph.verticesOfType(vertex_1.VertexType.FunctionCall).filter(([, v]) => !vertex_1.DfgVertex.hasOrigin(v, built_in_proc_name_1.BuiltInProcName.S3DispatchNext)).flatMap(([id]) => df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Calls)));
|
|
976
1003
|
for (const [id, vertex] of graph.verticesOfType(vertex_1.VertexType.FunctionDefinition)) {
|
|
@@ -987,10 +1014,105 @@ function linkNestedFunctionCalls(graph, outEnvironment, ctx) {
|
|
|
987
1014
|
}, { fn: id, graph });
|
|
988
1015
|
}
|
|
989
1016
|
}
|
|
990
|
-
/**
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
1017
|
+
/**
|
|
1018
|
+
* A method we cannot see may read and change the session state (`options(digits = 3)`), so a read of that state reads each call
|
|
1019
|
+
* that may dispatch to such a method and may run before it. The calls stay out of the slices that read no state.
|
|
1020
|
+
* To keep this linear, each call reads the one running before it and a read reads only the last call that may run before it.
|
|
1021
|
+
* A call in a function runs where the top-level calls running the function do, so these take its place in the order and it reads
|
|
1022
|
+
* what runs up to the last of them. A call in a function nothing calls runs, if at all, once the code is done (as does the `<<-` of
|
|
1023
|
+
* such a function), and a call we cannot place reads all of them and is read by all of them.
|
|
1024
|
+
* A read that runs before every binding we cannot tell sees no such method at all.
|
|
1025
|
+
*/
|
|
1026
|
+
function linkStateReadsToUnknownMethods(graph, calls, unknownMethodsAt, enclosingOf, topLevelCallsOf) {
|
|
1027
|
+
/* quoted code runs only where it is evaluated, which is a call of its own */
|
|
1028
|
+
const runs = calls.values().filter(c => !graph.isQuoted(c)).toArray();
|
|
1029
|
+
if (runs.length === 0) {
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
const before = (a, b) => program_order_1.ProgramOrder.runsBefore(a, b, graph);
|
|
1033
|
+
const inOrder = (a, b) => before(a, b) ? -1 : before(b, a) ? 1 : 0;
|
|
1034
|
+
const placed = (c) => program_order_1.ProgramOrder.runsWithin(c, graph) !== undefined;
|
|
1035
|
+
/* the top-level calls `id` runs at in program order, `undefined` if we cannot place one of them */
|
|
1036
|
+
const sitesOf = (id) => {
|
|
1037
|
+
if (placed(id)) {
|
|
1038
|
+
return [id];
|
|
1039
|
+
}
|
|
1040
|
+
const fn = enclosingOf(id);
|
|
1041
|
+
/* a call the dataflow adds for a function handed to another (`sapply(l, function(x) f(x))`) runs where that one runs */
|
|
1042
|
+
const sites = fn === undefined ? [] : [...topLevelCallsOf(fn)].flatMap(s => graph.idMap?.has(s) === false ? df_helper_1.Dataflow.sourcesOf(graph, s, edge_1.EdgeType.Calls).flatMap(handing => {
|
|
1043
|
+
const outer = graph.isRoot(handing) ? undefined : enclosingOf(handing);
|
|
1044
|
+
return outer === undefined ? [handing] : [...topLevelCallsOf(outer)];
|
|
1045
|
+
}) : [s]);
|
|
1046
|
+
return fn !== undefined && sites.every(placed) ? sites.sort(inOrder) : undefined;
|
|
1047
|
+
};
|
|
1048
|
+
/* before every binding we cannot tell, there is no method we cannot see */
|
|
1049
|
+
const afterUnknown = (site) => unknownMethodsAt.some(at => !before(site, at));
|
|
1050
|
+
/* the top-level calls in program order, each running a call that may dispatch or a function holding one */
|
|
1051
|
+
const chain = new Set();
|
|
1052
|
+
const inFunctions = [];
|
|
1053
|
+
const atEnd = [];
|
|
1054
|
+
const floating = [];
|
|
1055
|
+
for (const id of runs) {
|
|
1056
|
+
const sites = sitesOf(id);
|
|
1057
|
+
if (sites === undefined) {
|
|
1058
|
+
floating.push(id);
|
|
1059
|
+
}
|
|
1060
|
+
else if (sites.length === 0) {
|
|
1061
|
+
atEnd.push(id);
|
|
1062
|
+
}
|
|
1063
|
+
else if (sites.some(afterUnknown)) {
|
|
1064
|
+
const later = sites.filter(afterUnknown);
|
|
1065
|
+
later.forEach(s => chain.add(s));
|
|
1066
|
+
if (later[0] !== id) {
|
|
1067
|
+
inFunctions.push([id, later]);
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
const ordered = [...chain].sort(inOrder);
|
|
1072
|
+
/* the last call of the chain that does not run after `site` */
|
|
1073
|
+
const upTo = (site) => {
|
|
1074
|
+
let last = ordered.length - 1;
|
|
1075
|
+
while (last >= 0 && before(site, ordered[last])) {
|
|
1076
|
+
last--;
|
|
1077
|
+
}
|
|
1078
|
+
return ordered[last];
|
|
1079
|
+
};
|
|
1080
|
+
const link = (from, to) => {
|
|
1081
|
+
if (to !== undefined && from !== to) {
|
|
1082
|
+
graph.addEdge(from, to, edge_1.EdgeType.Reads);
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
ordered.forEach((c, i) => link(c, i === 0 ? floating[0] : ordered[i - 1]));
|
|
1086
|
+
/* the call that runs the function runs what it runs, which sees what ran before the last of these calls */
|
|
1087
|
+
for (const [id, sites] of inFunctions) {
|
|
1088
|
+
sites.forEach(s => link(s, id));
|
|
1089
|
+
link(id, upTo(sites[sites.length - 1]));
|
|
1090
|
+
}
|
|
1091
|
+
const end = ordered.at(-1) ?? floating[0];
|
|
1092
|
+
floating.forEach((c, i) => link(c, i + 1 < floating.length ? floating[i + 1] : end));
|
|
1093
|
+
atEnd.forEach((c, i) => link(c, i === 0 ? end : atEnd[i - 1]));
|
|
1094
|
+
for (const reader of graph.ambientAccessIds()) {
|
|
1095
|
+
if (graph.isQuoted(reader) || (graph.ambientAccessOf(reader)?.[ambient_access_1.AmbientAccessKind.Read].size ?? 0) === 0) {
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
const site = sitesOf(reader)?.at(-1);
|
|
1099
|
+
if (site === undefined) {
|
|
1100
|
+
link(reader, atEnd.at(-1) ?? end);
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
/* every later call runs only after the read */
|
|
1104
|
+
const last = upTo(site);
|
|
1105
|
+
if (last !== undefined) {
|
|
1106
|
+
link(reader, last);
|
|
1107
|
+
}
|
|
1108
|
+
else if (unknownMethodsAt.some(at => at !== site && !before(site, at))) {
|
|
1109
|
+
link(reader, floating[0]);
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
/** The top-level calls that run a definition, through the calls of the functions that enclose its calls. */
|
|
1114
|
+
function topLevelCallsRunning(graph, enclosingOf) {
|
|
1115
|
+
return (0, defaultmap_1.memoize)((start) => {
|
|
994
1116
|
const calls = new Set();
|
|
995
1117
|
const definitions = new Set([start]);
|
|
996
1118
|
for (const definition of definitions) {
|
|
@@ -1009,6 +1131,9 @@ function linkLiftedReads(graph, lifted, enclosingOf, environmentAt, runsOnceAt)
|
|
|
1009
1131
|
}
|
|
1010
1132
|
return calls;
|
|
1011
1133
|
});
|
|
1134
|
+
}
|
|
1135
|
+
/** Resolves each global read of a nested call where the enclosing function is called. */
|
|
1136
|
+
function linkLiftedReads(graph, lifted, topLevelCallsOf, environmentAt, runsOnceAt) {
|
|
1012
1137
|
/* a call reads several states under its own id (`#wd`, `#file:f`), so a read is told apart by its name as well */
|
|
1013
1138
|
const seen = new defaultmap_1.DefaultMap(() => new defaultmap_1.DefaultMap(() => new Set()));
|
|
1014
1139
|
for (let next = lifted.pop(); next !== undefined; next = lifted.pop()) {
|
|
@@ -78,7 +78,7 @@ function processLocal(name, args, rootId, data, config) {
|
|
|
78
78
|
out: dfExpr.out.concat(dfEnv.out),
|
|
79
79
|
unknownReferences: []
|
|
80
80
|
};
|
|
81
|
-
(0, built_in_envir_utils_1.unknownIfAmbiguous)(envirRouting, baseResult, rootId);
|
|
81
|
+
(0, built_in_envir_utils_1.unknownIfAmbiguous)(envirRouting, baseResult, rootId, env?.info.id);
|
|
82
82
|
return baseResult;
|
|
83
83
|
}
|
|
84
84
|
/** Evaluates `expr` in the environment `envir` pins down, or in a fresh frame on top of the current one, as `local` and `eval(expr, envir)` do. */
|
|
@@ -115,7 +115,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
115
115
|
if (sourceFileArgument === undefined) {
|
|
116
116
|
logger_1.dataflowLogger.warn('Expected a file argument for source, skipping');
|
|
117
117
|
const unknown = (0, known_call_handling_1.processKnownFunctionCall)({ name, args, rootId, data, origin: 'default' }).information;
|
|
118
|
-
(
|
|
118
|
+
bindsUnseen(unknown, rootId, data);
|
|
119
119
|
return unknown;
|
|
120
120
|
}
|
|
121
121
|
const localArg = bound.get(config.envIn ?? 'local');
|
|
@@ -130,7 +130,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
130
130
|
const withAmbient = () => config.ambient === undefined ? information : (0, built_in_ambient_state_1.applyAmbientEffects)(information, args, rootId, data, config.ambient);
|
|
131
131
|
if (!config.forceFollow && data.ctx.config.ignoreSourceCalls) {
|
|
132
132
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source call ${JSON.stringify(sourceFileArgument)} (disabled in config file)`);
|
|
133
|
-
(
|
|
133
|
+
bindsUnseen(information, rootId, data);
|
|
134
134
|
return withAmbient();
|
|
135
135
|
}
|
|
136
136
|
let sourceFile;
|
|
@@ -143,7 +143,7 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
143
143
|
const path = sourceFile?.length === 1 ? r_string_1.RString.unquote(sourceFile[0]) : undefined;
|
|
144
144
|
const filepath = path ? findSource(data.ctx.config.solver.resolveSource, path, data) : undefined;
|
|
145
145
|
if (localArg !== undefined && !r_logical_1.RLogical.is(localArg.value) && resolution === undefined) {
|
|
146
|
-
(
|
|
146
|
+
bindsUnseen(information, rootId, data);
|
|
147
147
|
return withAmbient();
|
|
148
148
|
}
|
|
149
149
|
if (filepath !== undefined && filepath.length > 0) {
|
|
@@ -183,9 +183,18 @@ function processSourceCall(name, args, rootId, data, config) {
|
|
|
183
183
|
return routed;
|
|
184
184
|
}
|
|
185
185
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Non-constant argument ${JSON.stringify(sourceFile)} for source is currently not supported, skipping`);
|
|
186
|
-
(
|
|
186
|
+
bindsUnseen(information, rootId, data);
|
|
187
187
|
return withAmbient();
|
|
188
188
|
}
|
|
189
|
+
/** Code we cannot see has an unknown side effect, and binds methods only if `solver.resolveSource.unseenMethods` is set. */
|
|
190
|
+
function bindsUnseen(information, rootId, data) {
|
|
191
|
+
if (data.ctx.config.solver.resolveSource?.unseenMethods) {
|
|
192
|
+
(0, built_in_expression_list_1.bindsUnknownNames)(information.graph, information.environment, rootId);
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, rootId);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
189
198
|
/** The reads of code evaluated in the global environment, which no frame of the function running it binds; the `call`'s own reads stay as they are. */
|
|
190
199
|
function readGlobally(result, call) {
|
|
191
200
|
const own = new Set([...call.in, ...call.unknownReferences]);
|
|
@@ -207,20 +216,20 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
207
216
|
const textRequest = data.ctx.files.resolveRequest(request);
|
|
208
217
|
if (textRequest === undefined && request.request === 'file') {
|
|
209
218
|
logger_1.dataflowLogger.warn(`Failed to analyze sourced file ${JSON.stringify(request)}: file does not exist`);
|
|
210
|
-
(
|
|
219
|
+
bindsUnseen(information, rootId, data);
|
|
211
220
|
return information;
|
|
212
221
|
}
|
|
213
222
|
(0, assert_1.guard)(textRequest !== undefined, `Expected text request to be defined for sourced file ${JSON.stringify(request)}`);
|
|
214
223
|
const ext = textRequest.path ? /\.[^.]*$/.exec(textRequest.path)?.[0].toLowerCase() : undefined;
|
|
215
224
|
if (ext !== undefined && ext !== '.r') {
|
|
216
225
|
(0, log_1.expensiveTrace)(logger_1.dataflowLogger, () => `Skipping source of non-R file ${JSON.stringify(textRequest.path)}`);
|
|
217
|
-
(
|
|
226
|
+
bindsUnseen(information, rootId, data);
|
|
218
227
|
return information;
|
|
219
228
|
}
|
|
220
229
|
const gasLevel = data.ctx.gas.checkGas(gas_1.GasFeatureKey.Source);
|
|
221
230
|
if (gasLevel >= 2 /* GasLevel.Critical */) {
|
|
222
231
|
logger_1.dataflowLogger.warn(`Skipping source of ${JSON.stringify(request)} due to resource pressure (gas: critical). See ${gas_1.GasWikiRef}`);
|
|
223
|
-
(
|
|
232
|
+
bindsUnseen(information, rootId, data);
|
|
224
233
|
return information;
|
|
225
234
|
}
|
|
226
235
|
else if (gasLevel >= 1 /* GasLevel.Problematic */) {
|
|
@@ -257,7 +266,7 @@ function sourceRequest(rootId, request, data, information, makeMaybe, getId, eva
|
|
|
257
266
|
catch (e) {
|
|
258
267
|
logger_1.dataflowLogger.error(`Failed to analyze sourced file ${JSON.stringify(request)}, skipping: ${e.message}`);
|
|
259
268
|
logger_1.dataflowLogger.error(e.stack);
|
|
260
|
-
(
|
|
269
|
+
bindsUnseen(information, rootId, data);
|
|
261
270
|
return information;
|
|
262
271
|
}
|
|
263
272
|
// take the entry point as well as all the written references, and give them a control dependency to the source call to show that they are conditional
|
|
@@ -304,10 +313,11 @@ function standaloneSourceFile(idx, file, data, information) {
|
|
|
304
313
|
(0, unknown_side_effect_1.handleUnknownSideEffect)(information.graph, information.environment, file.root.info.id);
|
|
305
314
|
return information;
|
|
306
315
|
}
|
|
316
|
+
/* `sourceRequest` appends the file itself, so it runs at the top level just like the first file (e.g., auto-printing) */
|
|
307
317
|
return sourceRequest('file-' + idx, file, {
|
|
308
318
|
...data,
|
|
309
319
|
environment: information.environment,
|
|
310
|
-
referenceChain: [
|
|
320
|
+
referenceChain: []
|
|
311
321
|
}, information, false, undefined, false, false);
|
|
312
322
|
}
|
|
313
323
|
/** Folds the results of analyzing sourced code back into the information of the call that asked for it, which `eval` and the string templates both need: the code contributes everything it reads, writes, and leaves open. */
|
|
@@ -68,11 +68,35 @@ function processWithEnv(name, args, rootId, data) {
|
|
|
68
68
|
const envirResolution = (0, built_in_envir_utils_1.envirOf)(envirRouting);
|
|
69
69
|
if (!envirResolution) {
|
|
70
70
|
const fallback = markAsMaskedFallback(name, args, rootId, data, exprArg.value);
|
|
71
|
+
const isWithin = identifier_1.Identifier.getName(name.content) === 'within';
|
|
72
|
+
if (isWithin) {
|
|
73
|
+
/* the copy `within` returns carries every variable `expr` defines, so the call needs all of these definitions, not just the last */
|
|
74
|
+
for (const [defId] of fallback.graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
|
|
75
|
+
fallback.graph.addEdge(rootId, defId, edge_1.EdgeType.Reads);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/*
|
|
79
|
+
* `within` only has methods for lists and data frames and works on a copy of them, so what `expr` writes into a value
|
|
80
|
+
* the program defines (but we cannot track as an environment) never reaches the caller; a parameter is left alone,
|
|
81
|
+
* as the caller may hand in anything
|
|
82
|
+
*/
|
|
83
|
+
if (isWithin && envirRouting === 'ambiguous' && !mayBeParameter(dataArg.value, data)) {
|
|
84
|
+
return fallback;
|
|
85
|
+
}
|
|
86
|
+
const defines = !fallback.graph.verticesOfType(vertex_1.VertexType.VariableDefinition).next().done;
|
|
71
87
|
/* only a definition or a call we cannot see into (a closure of `data`) can write to a `data` we cannot pin down */
|
|
72
|
-
if (
|
|
73
|
-
return
|
|
88
|
+
if (!defines && !callsOpaque(fallback.graph, rootId)) {
|
|
89
|
+
return fallback;
|
|
74
90
|
}
|
|
75
|
-
|
|
91
|
+
/*
|
|
92
|
+
* a definition in `expr` lands in `data` if it is an environment, which may be the global one, so only a definition
|
|
93
|
+
* makes the call an unknown side effect; a call we cannot see into is no more opaque than the same call outside of `with`,
|
|
94
|
+
* it can at most change `data`, which `mayWriteInto` covers
|
|
95
|
+
*/
|
|
96
|
+
if (defines && (0, built_in_envir_utils_1.unknownIfAmbiguous)(envirRouting, fallback, rootId, dataArg.value.info.id)) {
|
|
97
|
+
return fallback;
|
|
98
|
+
}
|
|
99
|
+
return mayWriteInto(dataArg.value, fallback, rootId, data);
|
|
76
100
|
}
|
|
77
101
|
const pipedData = (0, common_1.isPipedArgument)(dataArg, rootId, data);
|
|
78
102
|
const dfDataArg = pipedData ? info_1.DataflowInformation.initialize(rootId, data) : (0, processor_1.processDataflowFor)(dataArg.value, data);
|
|
@@ -192,6 +216,14 @@ function processWithLiteralList(name, rootId, data, dataNode, expr, elements) {
|
|
|
192
216
|
function callsOpaque(graph, rootId) {
|
|
193
217
|
return graph.verticesOfType(vertex_1.VertexType.FunctionCall).some(([id, vertex]) => id !== rootId && !vertex.onlyBuiltin);
|
|
194
218
|
}
|
|
219
|
+
/** whether `dataNode` is not a symbol, or a symbol of which some definition is a parameter of the enclosing function */
|
|
220
|
+
function mayBeParameter(dataNode, data) {
|
|
221
|
+
if (!r_symbol_1.RSymbol.is(dataNode)) {
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
const defs = resolve_helper_1.Resolve.byNameAndType(dataNode.content, data.environment, identifier_1.ReferenceType.Variable);
|
|
225
|
+
return defs === undefined || defs.some(d => (d.type & identifier_1.ReferenceType.Parameter) !== 0);
|
|
226
|
+
}
|
|
195
227
|
/** `data` may be an untracked environment `expr` writes into, so later reads of its variable see the call as a maybe redefinition. */
|
|
196
228
|
function mayWriteInto(dataNode, result, rootId, data) {
|
|
197
229
|
keepCallFor(result.out, result.graph, rootId);
|
|
@@ -528,7 +528,8 @@ function keptPromisesOfPackageCall(graph, call, signatureOf) {
|
|
|
528
528
|
if (signature === false) {
|
|
529
529
|
return false;
|
|
530
530
|
}
|
|
531
|
-
|
|
531
|
+
/* a replacement (`x$f <- v`) gets the value already evaluated, whatever function it calls */
|
|
532
|
+
if (vertex_1.DfgVertex.hasOrigin(call, built_in_proc_name_1.BuiltInProcName.Replacement) || !handsBackCalledValue(graph, call.id)) {
|
|
532
533
|
return new Set();
|
|
533
534
|
}
|
|
534
535
|
const layout = signature.sig === undefined ? undefined : built_in_props_1.FnSig.layout(signature.sig);
|
|
@@ -10,10 +10,19 @@ export declare const ProgramOrder: {
|
|
|
10
10
|
readonly name: "ProgramOrder";
|
|
11
11
|
/** The top-level statement holding `id` if the program runs it once, in program order, `undefined` otherwise. */
|
|
12
12
|
readonly runsOnceAt: (this: void, id: NodeId, graph: DataflowGraph) => RNode<ParentInformation> | undefined;
|
|
13
|
+
/** The top-level statement holding `id` if it is top-level code outside quotes, also within a loop, whose every round ends before the next statement runs, `undefined` otherwise. */
|
|
14
|
+
readonly runsWithin: (this: void, id: NodeId, graph: DataflowGraph) => RNode<ParentInformation> | undefined;
|
|
15
|
+
/** Whether all of `id` is done before `later` starts: both are top-level code (see {@link ProgramOrder.runsWithin}), `later` in a later statement. */
|
|
16
|
+
readonly runsBefore: (this: void, id: NodeId, later: NodeId, graph: DataflowGraph) => boolean;
|
|
13
17
|
/** How many top-level statements of the same file after `statement` the top-level definition at `definition` is made, `0` for any other. */
|
|
14
18
|
readonly offset: (this: void, definition: NodeId, statement: RNode<ParentInformation> | undefined, graph: DataflowGraph) => number;
|
|
15
19
|
/** Whether the definition at `definition` is made only after `statement` ran: it sits in a later top-level statement, which holds a nested one too, as the function it is nested in does not exist before. */
|
|
16
20
|
readonly definedLater: (this: void, definition: NodeId, statement: RNode<ParentInformation> | undefined, graph: DataflowGraph) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the definition at `definition` is made only after `id` ran as the body of a function runs: both are directly in that body, the definition in a later statement of it,
|
|
23
|
+
* and each run of the function has a frame of its own. What a promise or an exit hook defers runs later.
|
|
24
|
+
*/
|
|
25
|
+
readonly boundLaterInBody: (this: void, definition: NodeId, id: NodeId, graph: DataflowGraph) => boolean;
|
|
17
26
|
/** For code the program runs once after `statement`, which surely makes the definition `write`: what that code reads no longer sees the definitions made before `statement`. */
|
|
18
27
|
readonly replaceEarlier: (this: void, write: NodeId, statement: RNode<ParentInformation>, graph: DataflowGraph, readsEarlier: boolean) => void;
|
|
19
28
|
};
|
|
@@ -4,6 +4,10 @@ exports.ProgramOrder = void 0;
|
|
|
4
4
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
5
5
|
const info_1 = require("../info");
|
|
6
6
|
const edge_1 = require("../graph/edge");
|
|
7
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
8
|
+
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
9
|
+
const vertex_1 = require("../graph/vertex");
|
|
10
|
+
const built_in_proc_name_1 = require("../environments/built-in-proc-name");
|
|
7
11
|
/**
|
|
8
12
|
* Program order of top-level code outside loops and quotes: it runs once, so its definitions are not there yet for the statements before.
|
|
9
13
|
* @helper dataflow
|
|
@@ -12,14 +16,22 @@ exports.ProgramOrder = {
|
|
|
12
16
|
name: 'ProgramOrder',
|
|
13
17
|
/** The top-level statement holding `id` if the program runs it once, in program order, `undefined` otherwise. */
|
|
14
18
|
runsOnceAt(id, graph) {
|
|
19
|
+
return graph.getVertex(id)?.cds?.some(cd => info_1.ControlDependency.isIterated(cd, graph.idMap)) ? undefined : exports.ProgramOrder.runsWithin(id, graph);
|
|
20
|
+
},
|
|
21
|
+
/** The top-level statement holding `id` if it is top-level code outside quotes, also within a loop, whose every round ends before the next statement runs, `undefined` otherwise. */
|
|
22
|
+
runsWithin(id, graph) {
|
|
15
23
|
const idMap = graph.idMap;
|
|
16
24
|
const node = idMap?.get(id);
|
|
17
|
-
if (idMap === undefined || node === undefined || !graph.isRoot(id)
|
|
18
|
-
|| graph.getVertex(id)?.cds?.some(cd => info_1.ControlDependency.isIterated(cd, idMap)) || graph.isQuoted(id)) {
|
|
25
|
+
if (idMap === undefined || node === undefined || !graph.isRoot(id) || graph.isQuoted(id)) {
|
|
19
26
|
return undefined;
|
|
20
27
|
}
|
|
21
28
|
return model_1.RNode.topLevelStatement(node, idMap);
|
|
22
29
|
},
|
|
30
|
+
/** Whether all of `id` is done before `later` starts: both are top-level code (see {@link ProgramOrder.runsWithin}), `later` in a later statement. */
|
|
31
|
+
runsBefore(id, later, graph) {
|
|
32
|
+
const at = exports.ProgramOrder.runsWithin(id, graph);
|
|
33
|
+
return at !== undefined && exports.ProgramOrder.runsWithin(later, graph) !== undefined && statementsAfter(later, at, graph) > 0;
|
|
34
|
+
},
|
|
23
35
|
/** How many top-level statements of the same file after `statement` the top-level definition at `definition` is made, `0` for any other. */
|
|
24
36
|
offset(definition, statement, graph) {
|
|
25
37
|
return graph.isRoot(definition) ? statementsAfter(definition, statement, graph) : 0;
|
|
@@ -28,6 +40,30 @@ exports.ProgramOrder = {
|
|
|
28
40
|
definedLater(definition, statement, graph) {
|
|
29
41
|
return statementsAfter(definition, statement, graph) > 0;
|
|
30
42
|
},
|
|
43
|
+
/**
|
|
44
|
+
* Whether the definition at `definition` is made only after `id` ran as the body of a function runs: both are directly in that body, the definition in a later statement of it,
|
|
45
|
+
* and each run of the function has a frame of its own. What a promise or an exit hook defers runs later.
|
|
46
|
+
*/
|
|
47
|
+
boundLaterInBody(definition, id, graph) {
|
|
48
|
+
const idMap = graph.idMap;
|
|
49
|
+
const fn = idMap === undefined ? undefined : model_1.RNode.strictlyEnclosingFunction(id, idMap);
|
|
50
|
+
const body = fn === undefined ? undefined : idMap?.get(fn);
|
|
51
|
+
if (idMap === undefined || !r_function_definition_1.RFunctionDefinition.is(body) || !r_expression_list_1.RExpressionList.is(body.body) || model_1.RNode.strictlyEnclosingFunction(definition, idMap) !== fn
|
|
52
|
+
|| graph.isQuoted(id) || graph.getVertex(id)?.cds?.some(cd => cd.byPromise)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
const statementOf = (node) => {
|
|
56
|
+
for (; node !== undefined && node.info.parent !== body.body.info.id; node = node.info.parent === undefined ? undefined : idMap.get(node.info.parent)) {
|
|
57
|
+
if (vertex_1.DfgVertex.hasOrigin(graph.getVertex(node.info.id), built_in_proc_name_1.BuiltInProcName.RegisterHook)) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return node;
|
|
62
|
+
};
|
|
63
|
+
const at = statementOf(idMap.get(id));
|
|
64
|
+
const made = statementOf(idMap.get(definition));
|
|
65
|
+
return at !== undefined && made !== undefined && made.info.index > at.info.index;
|
|
66
|
+
},
|
|
31
67
|
/** For code the program runs once after `statement`, which surely makes the definition `write`: what that code reads no longer sees the definitions made before `statement`. */
|
|
32
68
|
replaceEarlier(write, statement, graph, readsEarlier) {
|
|
33
69
|
const before = (id) => exports.ProgramOrder.runsOnceAt(id, graph) !== undefined && exports.ProgramOrder.offset(id, statement, graph) < 0;
|
|
@@ -229,6 +229,7 @@ The schema below documents every option; the ones you most likely want are:
|
|
|
229
229
|
- ${ctx.linkConfig('semantics.environment.overwriteBuiltIns')}: overwrite _flowR_'s handling of built-in functions, or clear the preset definitions entirely.
|
|
230
230
|
See [Configure BuiltIn Semantics](#configure-builtin-semantics) for more information.
|
|
231
231
|
- ${ctx.linkConfig('semantics.ambient.drawingWritesDevice')}: whether calls drawing on a graphics device (e.g., \`plot\`) count as writing the device in the ambient state queries.
|
|
232
|
+
- ${ctx.linkConfig('solver.resolveSource.unseenMethods')}: whether a sourced file _flowR_ cannot read may bind S3/S4 methods that later calls dispatch to (sound, but chains every such call, off by default).
|
|
232
233
|
- ${ctx.linkConfig('solver.variables')}: how to resolve variables and their values (${Object.values(config_1.VariableResolve).map(v => `\`${v}\``).join(', ')}).
|
|
233
234
|
- ${ctx.linkConfig('engines')} and ${ctx.linkConfig('defaultEngine')}: the engines used to interact with R code, see the ${ctx.linkPage('wiki/Engines', 'Engines wiki page')}.
|
|
234
235
|
- ${ctx.linkConfig('project.implicitSources')}: the files a framework loads without any \`source()\` call, in the order in which they are
|
package/linter/linter-rules.d.ts
CHANGED
|
@@ -264,6 +264,7 @@ export declare const LintingRules: {
|
|
|
264
264
|
readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
|
|
265
265
|
readonly defaultConfig: (ctx: import("../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext) => {
|
|
266
266
|
consider: readonly import("./rules/problematic-inputs").ConsiderSpec[];
|
|
267
|
+
reportConstantCommands: false;
|
|
267
268
|
pipeCommandFunctions: readonly import("./rules/problematic-inputs").PipeCommandFunctionSpec[];
|
|
268
269
|
};
|
|
269
270
|
};
|
|
@@ -25,6 +25,8 @@ export interface ProblematicInputsResult extends LintingResult {
|
|
|
25
25
|
}
|
|
26
26
|
export interface ProblematicInputsConfig extends MergeableRecord {
|
|
27
27
|
consider?: string | string[] | ConsiderSpec | ConsiderSpec[];
|
|
28
|
+
/** report a considered call without {@link ConsiderSpec.allowedInputTypes} even if it only receives constants (`system("ls")`), off by default */
|
|
29
|
+
reportConstantCommands?: boolean;
|
|
28
30
|
inputFns?: InputClassifierConfig;
|
|
29
31
|
pipeCommandFunctions?: PipeCommandFunctionSpec | PipeCommandFunctionSpec[];
|
|
30
32
|
}
|
|
@@ -44,6 +46,7 @@ export declare const PROBLEMATIC_INPUTS: {
|
|
|
44
46
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
45
47
|
readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
|
|
46
48
|
consider: readonly ConsiderSpec[];
|
|
49
|
+
reportConstantCommands: false;
|
|
47
50
|
pipeCommandFunctions: readonly PipeCommandFunctionSpec[];
|
|
48
51
|
};
|
|
49
52
|
};
|
|
@@ -16,6 +16,8 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
16
16
|
const strings_1 = require("../../util/text/strings");
|
|
17
17
|
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
18
18
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
19
|
+
const node_value_1 = require("../../dataflow/eval/resolve/node-value");
|
|
20
|
+
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
19
21
|
/** what runs a command, and what evaluates code beyond looking up a name (`get`) or calling a function it is handed (`do.call`) */
|
|
20
22
|
function defaultConsider(index) {
|
|
21
23
|
const evaluates = index.with(built_in_props_1.SemanticCallTag.Eval).filter(n => ((index.propsOf(n) ?? 0) & built_in_props_1.CallProp.Pure) === 0 && !index.get(n)?.sig?.some(([, p]) => (p & built_in_props_1.ArgProp.Callee) !== 0));
|
|
@@ -82,18 +84,18 @@ function isProblematicForAllowed(sources, evalValues, allowedTypes, allowedValue
|
|
|
82
84
|
return false;
|
|
83
85
|
}
|
|
84
86
|
/** A path starting with `|` runs a command, so anything but a constant path, user input included, may start one. */
|
|
85
|
-
function getPipeCommandValue(
|
|
86
|
-
for (const
|
|
87
|
-
if (typeof
|
|
87
|
+
function getPipeCommandValue(values, allowedValues, disallowedValues) {
|
|
88
|
+
for (const value of values) {
|
|
89
|
+
if (typeof value !== 'string' || !value.startsWith('|')) {
|
|
88
90
|
continue;
|
|
89
91
|
}
|
|
90
|
-
if (allowedValues !== undefined && allowedValues.test(
|
|
92
|
+
if (allowedValues !== undefined && allowedValues.test(value)) {
|
|
91
93
|
continue;
|
|
92
94
|
}
|
|
93
|
-
if (disallowedValues !== undefined && !disallowedValues.test(
|
|
95
|
+
if (disallowedValues !== undefined && !disallowedValues.test(value)) {
|
|
94
96
|
continue;
|
|
95
97
|
}
|
|
96
|
-
return
|
|
98
|
+
return value;
|
|
97
99
|
}
|
|
98
100
|
return undefined;
|
|
99
101
|
}
|
|
@@ -141,7 +143,8 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
141
143
|
const own = res[criterion] ?? [];
|
|
142
144
|
/* a file argument that is an input itself (`pdf(readline())`) only shows as a source of the call */
|
|
143
145
|
const sources = target === nid || own.some(s => s.id === target) ? own : own.concat((res[call] ?? []).filter(s => s.id === target));
|
|
144
|
-
|
|
146
|
+
/* a constant path is one of the values it may hold (`if(a) "|lpr" else "a.pdf"`), not only the one all of them agree on */
|
|
147
|
+
const pipeCommand = pipeSpec === undefined ? undefined : getPipeCommandValue([...sources.map(s => s.value), ...node_value_1.NodeValue.knownStringsOf(target, resolve_helper_1.Resolve.info(df.graph, data.inspectContext()))], pipeSpec.allowedValues, pipeSpec.disallowedValues);
|
|
145
148
|
const evalValues = [];
|
|
146
149
|
if (consider?.resolveSourceArgs) {
|
|
147
150
|
for (const source of sources) {
|
|
@@ -151,7 +154,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
151
154
|
}
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
|
-
if (pipeCommand !== undefined || isProblematicForAllowed(sources, evalValues, consider?.allowedInputTypes ?? (pipeSpec !== undefined || sources.some(s => s.types.includes(simple_input_classifier_1.InputType.TempFile)) ? tempFileAccept : []), consider?.allowedValues, consider?.disallowedValues)) {
|
|
157
|
+
if (pipeCommand !== undefined || isProblematicForAllowed(sources, evalValues, consider?.allowedInputTypes ?? (!config.reportConstantCommands || pipeSpec !== undefined || sources.some(s => s.types.includes(simple_input_classifier_1.InputType.TempFile)) ? tempFileAccept : []), consider?.allowedValues, consider?.disallowedValues)) {
|
|
155
158
|
seen.add(nid);
|
|
156
159
|
const uncertain = pipeCommand === undefined && hasUnknownSource(sources);
|
|
157
160
|
results.push({
|
|
@@ -184,7 +187,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
184
187
|
description: 'Finds dynamic calls (e.g. eval, system) with non-constant inputs, and graphics-device calls (pdf, postscript) where a filename starts with \'|\' indicating a pipe command injection.',
|
|
185
188
|
tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Readability, linter_tags_1.LintingRuleTag.Performance],
|
|
186
189
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
187
|
-
defaultConfig: ctx => ({ consider: ctx.env.deriveFromIndex(defaultConsider), pipeCommandFunctions: defaultPipeCommandFunctions })
|
|
190
|
+
defaultConfig: ctx => ({ consider: ctx.env.deriveFromIndex(defaultConsider), reportConstantCommands: false, pipeCommandFunctions: defaultPipeCommandFunctions })
|
|
188
191
|
}
|
|
189
192
|
};
|
|
190
193
|
//# sourceMappingURL=problematic-inputs.js.map
|
|
@@ -133,7 +133,7 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
133
133
|
const isExportedByLoadedPackage = (0, defaultmap_1.memoize)((name) => loadedPackages.some(p => p.has(name)) || isDatasetOfLoadedPackage(name) || [...importedByLoaded].some(p => exportsOf(p).has(name)));
|
|
134
134
|
// hint an unloaded package that exports `name` (e.g. `ggplot` -> `ggplot2`), from the package database
|
|
135
135
|
const attached = new Set(r_base_packages_1.AttachedBasePackages);
|
|
136
|
-
const hintPackagesFor = (name) => deps.packagesExporting(name).filter(p => !attached.has(p)).slice(0, MaxHintPackages);
|
|
136
|
+
const hintPackagesFor = (0, defaultmap_1.memoize)((name) => deps.packagesExporting(name).filter(p => !attached.has(p)).slice(0, MaxHintPackages));
|
|
137
137
|
/** shared resolution logic for a name used either as a function call or a variable */
|
|
138
138
|
function check(node, name, namespace, kind) {
|
|
139
139
|
const id = node.info.id;
|
|
@@ -177,7 +177,8 @@ exports.UNDEFINED_SYMBOL = {
|
|
|
177
177
|
if (loc === undefined) {
|
|
178
178
|
return undefined;
|
|
179
179
|
}
|
|
180
|
-
|
|
180
|
+
/* the database records no data sets, so only a called name has packages worth hinting at */
|
|
181
|
+
const availableInPackages = namespace === undefined && kind === 'function' ? hintPackagesFor(name) : [];
|
|
181
182
|
return { certainty: linter_format_1.LintingResultCertainty.Uncertain, name, kind, involvedId: id, loc, ...(availableInPackages.length > 0 ? { availableInPackages } : {}) };
|
|
182
183
|
}
|
|
183
184
|
/** the symbol to check if the config asks for it: a called function, or a plain symbol read */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eagleoutice/flowr",
|
|
3
|
-
"version": "2.17.
|
|
3
|
+
"version": "2.17.13",
|
|
4
4
|
"description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22"
|
|
@@ -34,7 +34,10 @@
|
|
|
34
34
|
"undici": "^7.30.1"
|
|
35
35
|
},
|
|
36
36
|
"glob": "^14.0.2",
|
|
37
|
-
"minimatch": "^11.0.1"
|
|
37
|
+
"minimatch": "^11.0.1",
|
|
38
|
+
"typedoc": {
|
|
39
|
+
"minimatch": "^10.2.5"
|
|
40
|
+
}
|
|
38
41
|
},
|
|
39
42
|
"dependencies": {
|
|
40
43
|
"@davisvaughan/tree-sitter-r": "^1.2.0",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ExportKeys {
|
|
2
|
+
/** the ordinals of the packages exporting the name with dictionary id `id`, ascending */
|
|
3
|
+
ordinalsOf(id: number): number[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The export index of a bundle of `packages` packages: the one persisted for `bundleFile` when there is one, otherwise
|
|
7
|
+
* derived from `pairs` (computed on demand) and persisted for the next process. Without a file, kept in memory only.
|
|
8
|
+
*/
|
|
9
|
+
export declare function exportKeysFor(bundleFile: string | undefined, packages: number, pairs: () => Iterable<readonly [id: number, ordinal: number]>): ExportKeys;
|