@eagleoutice/flowr 2.16.0 → 2.16.2

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.
Files changed (80) hide show
  1. package/README.md +9 -9
  2. package/cli/flowr-main-options.d.ts +15 -0
  3. package/cli/flowr-main-options.js +18 -0
  4. package/cli/flowr.d.ts +18 -0
  5. package/cli/flowr.js +13 -2
  6. package/cli/repl/commands/repl-clipboard.js +2 -1
  7. package/cli/repl/commands/repl-commands.js +2 -0
  8. package/cli/repl/commands/repl-main.d.ts +5 -0
  9. package/cli/repl/commands/repl-signature.js +2 -0
  10. package/cli/repl/core.d.ts +7 -1
  11. package/cli/repl/core.js +17 -8
  12. package/cli/repl/execute.js +2 -0
  13. package/cli/repl/server/connection.js +2 -1
  14. package/cli/repl/server/net.d.ts +10 -0
  15. package/cli/repl/server/net.js +34 -1
  16. package/cli/slicer-app.js +2 -1
  17. package/config.d.ts +12 -2
  18. package/config.js +91 -14
  19. package/dataflow/environments/built-in-props.d.ts +5 -2
  20. package/dataflow/environments/built-in-props.js +6 -3
  21. package/dataflow/environments/default-builtin-config.d.ts +197 -11
  22. package/dataflow/environments/default-builtin-config.js +62 -42
  23. package/dataflow/environments/identifier.d.ts +1 -0
  24. package/dataflow/environments/query-fn-props.d.ts +3 -0
  25. package/dataflow/environments/query-fn-props.js +8 -0
  26. package/dataflow/environments/resolve-by-name.js +11 -4
  27. package/dataflow/eval/resolve/resolve-argument.js +5 -1
  28. package/dataflow/extractor.js +14 -5
  29. package/dataflow/fn/frame-reflection.js +14 -2
  30. package/dataflow/graph/graph.js +12 -0
  31. package/dataflow/internal/control-flow.d.ts +11 -0
  32. package/dataflow/internal/control-flow.js +15 -0
  33. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +4 -10
  34. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +1 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +9 -0
  36. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +8 -7
  37. package/dataflow/internal/process/functions/call/deferred.js +6 -1
  38. package/dataflow/internal/process/functions/call/named-call-handling.js +70 -9
  39. package/documentation/doc-capabilities.js +4 -1
  40. package/documentation/wiki-interface.js +4 -0
  41. package/engines.js +11 -3
  42. package/linter/linter-executor.js +19 -1
  43. package/linter/linter-rules.d.ts +8 -3
  44. package/linter/rules/file-path-validity.js +4 -1
  45. package/linter/rules/function-finder-util.d.ts +1 -1
  46. package/linter/rules/function-finder-util.js +1 -3
  47. package/linter/rules/network-functions.d.ts +4 -3
  48. package/linter/rules/network-functions.js +14 -12
  49. package/linter/rules/no-leaked-credentials.d.ts +8 -3
  50. package/linter/rules/no-leaked-credentials.js +133 -35
  51. package/linter/rules/problematic-inputs.d.ts +1 -1
  52. package/linter/rules/problematic-inputs.js +20 -14
  53. package/linter/rules/seeded-randomness.js +3 -1
  54. package/linter/rules/unescaped-arguments.d.ts +13 -2
  55. package/linter/rules/unescaped-arguments.js +100 -12
  56. package/package.json +1 -1
  57. package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
  58. package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
  59. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +2 -1
  60. package/project/sigdb/decompress.js +3 -1
  61. package/project/sigdb/sigdb-download.js +9 -6
  62. package/queries/catalog/call-context-query/call-context-query-executor.js +2 -1
  63. package/queries/catalog/config-query/config-query-executor.js +9 -2
  64. package/queries/catalog/input-sources-query/input-source-functions.d.ts +6 -4
  65. package/queries/catalog/input-sources-query/input-source-functions.js +11 -6
  66. package/queries/catalog/input-sources-query/input-sources-query-executor.js +1 -1
  67. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -1
  68. package/queries/catalog/input-sources-query/input-sources-query-format.js +9 -2
  69. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +12 -4
  70. package/queries/catalog/input-sources-query/simple-input-classifier.js +227 -29
  71. package/r-bridge/shell-executor.js +2 -0
  72. package/r-bridge/shell.js +2 -0
  73. package/search/search-executor/search-enrichers.js +5 -3
  74. package/slicing/static/static-slicer.js +14 -9
  75. package/util/files.d.ts +6 -0
  76. package/util/files.js +12 -0
  77. package/util/parallel.js +2 -0
  78. package/util/secure-mode.d.ts +42 -0
  79. package/util/secure-mode.js +70 -0
  80. package/util/version.js +2 -2
@@ -11,7 +11,12 @@ const identify_link_to_last_call_relation_1 = require("../../queries/catalog/cal
11
11
  const input_source_functions_1 = require("../../queries/catalog/input-sources-query/input-source-functions");
12
12
  const simple_input_classifier_1 = require("../../queries/catalog/input-sources-query/simple-input-classifier");
13
13
  const edge_1 = require("../../dataflow/graph/edge");
14
+ const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
14
15
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
16
+ const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
17
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
18
+ const r_access_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-access");
19
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
15
20
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
16
21
  const parse_1 = require("../../slicing/criterion/parse");
17
22
  const assert_1 = require("../../util/assert");
@@ -40,7 +45,7 @@ const ParameterSearchLimit = 256;
40
45
  /** Maximum depth to descent to find unescaped part of argument */
41
46
  const MaxDescentDepth = 5;
42
47
  /** Input types that are considered to be safe */
43
- const AcceptedInputs = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
48
+ const AcceptedInputs = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant, simple_input_classifier_1.InputType.TempFile];
44
49
  /** Input types that may be critical (uncertain) */
45
50
  const UncertainInputs = [simple_input_classifier_1.InputType.Unknown, simple_input_classifier_1.InputType.Parameter, simple_input_classifier_1.InputType.Scope];
46
51
  const UnescapedArgumentCategories = record_1.Record.values(UnescapedArgumentCategory);
@@ -58,17 +63,33 @@ function getCriticalTargets(elements, graph, config, builtIns) {
58
63
  const criticalCalls = Map.groupBy(getEnabledCriticalCalls(config, builtIns), call => identifier_1.Identifier.getName(call.name));
59
64
  const targets = [];
60
65
  const seen = new Set();
61
- for (const { node } of elements) {
62
- const call = graph.getVertex(node.info.id);
66
+ const ids = new Set(elements.map(({ node }) => node.info.id));
67
+ /* calls of an alias (`s <- system; s(x)`) link to the built-in they resolve to */
68
+ const aliases = new Map(graph.verticesOfType(vertex_1.VertexType.FunctionCall).map(([id]) => [id, new Set([...linkedBuiltIns(graph, id, edge_1.EdgeType.Calls), ...wrappedBuiltIns(graph, id)])]));
69
+ for (const [id, names] of aliases) {
70
+ if (names.values().some(name => criticalCalls.has(name))) {
71
+ ids.add(id);
72
+ }
73
+ }
74
+ const locate = (arg) => {
75
+ const node = graph.idMap?.get(arg);
76
+ const range = model_1.RNode.span(node);
77
+ return range === undefined || node === undefined ? undefined : range_1.SourceLocation.from(range, node.info.file);
78
+ };
79
+ for (const id of ids) {
80
+ const call = graph.getVertex(id);
63
81
  if (!vertex_1.DfgVertex.isFunctionCall(call)) {
64
82
  continue;
65
83
  }
66
- for (const { category, name, signature } of criticalCalls.get(identifier_1.Identifier.getName(call.name)) ?? []) {
67
- if (!identifier_1.Identifier.matches(name, call.name) && !identifier_1.Identifier.matches(call.name, name)) {
84
+ const aliased = aliases.get(id) ?? new Set();
85
+ for (const { category, name, signature } of [identifier_1.Identifier.getName(call.name), ...aliased].flatMap(n => criticalCalls.get(n) ?? [])) {
86
+ const viaAlias = !identifier_1.Identifier.matches(name, call.name) && !identifier_1.Identifier.matches(call.name, name);
87
+ /* a function handed on (`purrr::map(x, system)`) is called where it lands, not here */
88
+ if (viaAlias && (!aliased.has(identifier_1.Identifier.getName(name)) || call.args.some(a => linkedBuiltIns(graph, graph_1.FunctionArgument.getReference(a) ?? '', edge_1.EdgeType.Reads).includes(identifier_1.Identifier.getName(name))))) {
68
89
  continue;
69
90
  }
70
91
  for (const arg of function_semantics_1.FunctionSemantics.call.match.findWithProps(call.args, signature, config.categories[category].criticalArgs)) {
71
- const location = range_1.SourceLocation.fromNode(graph.idMap?.get(arg));
92
+ const location = locate(arg);
72
93
  const key = `${category}-${call.id}-${arg}`;
73
94
  if (location !== undefined && !seen.has(key)) {
74
95
  seen.add(key);
@@ -77,8 +98,66 @@ function getCriticalTargets(elements, graph, config, builtIns) {
77
98
  }
78
99
  }
79
100
  }
101
+ for (const category of UnescapedArgumentCategories.filter(c => !config.disabledCategories.includes(c))) {
102
+ for (const { call, callee } of methodCalls(graph, config.categories[category].methods ?? [])) {
103
+ for (const arg of call.args.filter(a => graph_1.FunctionArgument.getName(a) === undefined).map(graph_1.FunctionArgument.getReference).filter(assert_1.isNotUndefined)) {
104
+ const location = locate(arg);
105
+ if (location !== undefined) {
106
+ targets.push({ category, call, callee, signature: [], arg, location });
107
+ }
108
+ }
109
+ }
110
+ }
80
111
  return targets;
81
112
  }
113
+ /** the calls `obj$method(...)` of the given methods, on the named object or on one its constructor returned */
114
+ function methodCalls(graph, methods) {
115
+ if (methods.length === 0) {
116
+ return [];
117
+ }
118
+ /* a value made by the constructor, also through a branch or block (`if(a) V8::v8() else ...`) or another alias */
119
+ const holds = (v, receiver, depth) => {
120
+ const made = graph.getVertex(v);
121
+ const value = graph.idMap?.get(v);
122
+ if (vertex_1.DfgVertex.isVariableDefinition(made) || vertex_1.DfgVertex.hasOrigin(made, built_in_proc_name_1.BuiltInProcName.Assignment)) {
123
+ return false;
124
+ }
125
+ else if (r_symbol_1.RSymbol.is(value) && !vertex_1.DfgVertex.isFunctionCall(made)) {
126
+ return means(value, receiver, depth - 1);
127
+ }
128
+ return vertex_1.DfgVertex.isFunctionCall(made) && (identifier_1.Identifier.matches(made.name, receiver)
129
+ || (depth > 0 && (0, frame_reflection_1.edgeTargets)(graph, v, edge_1.EdgeType.Returns).some(r => holds(r, receiver, depth - 1))));
130
+ };
131
+ /* the named object where no binding of the program surely shadows it, otherwise what a binding holds */
132
+ const means = (symbol, receiver, depth = 4) => {
133
+ const defs = (0, frame_reflection_1.edgeTargets)(graph, symbol.info.id, edge_1.EdgeType.Reads).filter(d => !node_id_1.NodeId.isBuiltIn(d));
134
+ return (defs.every(d => graph.getVertex(d)?.cds?.length) && identifier_1.Identifier.matches(symbol.content, receiver))
135
+ || (depth > 0 && defs.some(def => (0, frame_reflection_1.edgeTargets)(graph, def, edge_1.EdgeType.DefinedBy).some(v => holds(v, receiver, depth))));
136
+ };
137
+ return graph.verticesOfType(vertex_1.VertexType.FunctionCall).flatMap(([id, call]) => {
138
+ const node = graph.idMap?.get(id);
139
+ const access = r_function_call_1.RFunctionCall.isUnnamed(node) ? node.calledFunction : undefined;
140
+ if (!r_access_1.RAccess.isNamed(access) || !r_symbol_1.RSymbol.is(access.accessed) || !vertex_1.DfgVertex.isFunctionCall(call)) {
141
+ return [];
142
+ }
143
+ const field = model_1.RNode.lexeme(access.access[0].value);
144
+ const accessed = access.accessed;
145
+ return methods.some(m => m.method === field && means(accessed, m.receiver)) ? [{ call, callee: model_1.RNode.lexeme(access) ?? field ?? '' }] : [];
146
+ }).toArray();
147
+ }
148
+ /** The names of the built-ins `id` links to with an edge of the given type, none if it may link to anything else (a closure checked where its body calls them) */
149
+ function linkedBuiltIns(graph, id, type) {
150
+ const linked = graph.outgoingEdges(id)?.entries().filter(([, edge]) => edge_1.DfEdge.includesType(edge, type)).map(([to]) => to).toArray() ?? [];
151
+ return linked.every(node_id_1.NodeId.isBuiltIn) ? linked.map(node_id_1.NodeId.fromBuiltIn) : [];
152
+ }
153
+ /** the built-ins handed to the call a called variable holds the result of, as `p` holds `purrr::partial(system)` */
154
+ function wrappedBuiltIns(graph, id) {
155
+ return (0, frame_reflection_1.edgeTargets)(graph, id, edge_1.EdgeType.Reads).flatMap(v => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(v)) ? (0, frame_reflection_1.edgeTargets)(graph, v, edge_1.EdgeType.DefinedBy) : [])
156
+ .flatMap(w => {
157
+ const wrapper = graph.getVertex(w);
158
+ return vertex_1.DfgVertex.isFunctionCall(wrapper) ? wrapper.args.flatMap(a => linkedBuiltIns(graph, graph_1.FunctionArgument.getReference(a) ?? '', edge_1.EdgeType.Reads)) : [];
159
+ });
160
+ }
82
161
  function mapInputSourceToArgs(call, sources) {
83
162
  const args = call.args.map(graph_1.FunctionArgument.getReference).filter(assert_1.isNotUndefined);
84
163
  return args.flatMap((arg, i) => {
@@ -128,8 +207,9 @@ function isCertainlyCritical(source, config) {
128
207
  async function getUnescapedSources(category, targets, config, data, graph) {
129
208
  const sanitizers = config.categories[category].sanitizers ?? [];
130
209
  const sanitizerNames = new Set(sanitizers.map(call => identifier_1.Identifier.getName(call)));
131
- const narrowing = [...(0, input_source_functions_1.narrowingFunctions)(data.inspectContext().env.builtInIndex), ...sanitizers.map(call => ({ call }))];
132
- const queryConfig = { narrowing };
210
+ const builtIns = data.inspectContext().env.builtInIndex;
211
+ /* a count or a logical carries nothing that could be injected, even when it depends on the input */
212
+ const queryConfig = { narrowing: (0, input_source_functions_1.narrowingFunctions)(builtIns), sanitizers: [...(0, input_source_functions_1.contentFreeFunctions)(builtIns), ...sanitizers] };
133
213
  const found = new Map();
134
214
  let entries = targets.map(target => ({ target, call: target.call.id, only: new Set([target.arg]), depth: 0 }));
135
215
  while (entries.length > 0) {
@@ -197,7 +277,7 @@ function createResult(target, sources, config, idMap) {
197
277
  involvedId: [target.call.id, target.arg],
198
278
  loc: target.location,
199
279
  category: target.category,
200
- function: identifier_1.Identifier.toString(target.call.name),
280
+ function: target.callee ?? identifier_1.Identifier.toString(target.call.name),
201
281
  sources,
202
282
  input: [...new Set(sources.flatMap(source => source.types).filter(type => !config.acceptedInputs.includes(type)))],
203
283
  ...(quickFix.length > 0 ? { quickFix } : {})
@@ -223,7 +303,11 @@ exports.UNESCAPED_ARGUMENTS = {
223
303
  const unescaped = await getUnescapedSources(category, categoryTargets, config, data, graph);
224
304
  for (const target of categoryTargets) {
225
305
  const sources = unescaped.get(target);
226
- if (sources === undefined) {
306
+ /* `eval(parse_expr(x))` is reported where the inner call is handed `x` */
307
+ if (sources?.every(s => categoryTargets.some(t => t.call.id === s.id && unescaped.has(t)))) {
308
+ continue;
309
+ }
310
+ else if (sources === undefined) {
227
311
  escaped++;
228
312
  }
229
313
  else {
@@ -254,7 +338,7 @@ exports.UNESCAPED_ARGUMENTS = {
254
338
  quickFix: { call: 'shQuote' }
255
339
  },
256
340
  [UnescapedArgumentCategory.Eval]: {
257
- criticalCalls: built_in_props_1.SemanticCallTag.Eval,
341
+ criticalCalls: [built_in_props_1.SemanticCallTag.Eval, built_in_props_1.CallProp.Lang],
258
342
  criticalArgs: built_in_props_1.ArgProp.Injectable,
259
343
  sanitizers: [
260
344
  identifier_1.Identifier.from(['match.arg', "base" /* PkgName.Base */]),
@@ -294,7 +378,11 @@ exports.UNESCAPED_ARGUMENTS = {
294
378
  identifier_1.Identifier.from(['toJSON', 'RJSONIO']),
295
379
  identifier_1.Identifier.from(['toJSON', 'rjson'])
296
380
  ],
297
- quickFix: { call: identifier_1.Identifier.from(['toJSON', "jsonlite" /* PkgName.Jsonlite */]), partsOnly: true }
381
+ quickFix: { call: identifier_1.Identifier.from(['toJSON', "jsonlite" /* PkgName.Jsonlite */]), partsOnly: true },
382
+ methods: [
383
+ ...['eval', 'call', 'source'].flatMap(method => identifier_1.Identifier.fromAll('V8', ['v8', 'new_context']).map(receiver => ({ receiver, method }))),
384
+ ...identifier_1.Identifier.fromAllIn(["htmltools" /* PkgName.HtmlTools */, "shiny" /* PkgName.Shiny */], ['tags']).map(receiver => ({ receiver, method: 'script' }))
385
+ ]
298
386
  }
299
387
  },
300
388
  disabledCategories: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.16.0",
3
+ "version": "2.16.2",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "engines": {
6
6
  "node": ">=22"
@@ -165,6 +165,15 @@ export declare enum SerializationFormat {
165
165
  Ascii = "ASCII",
166
166
  Binary = "BINARY"
167
167
  }
168
+ /** The parts of the (untyped) `bzip2` package we use. */
169
+ export interface Bzip2 {
170
+ array(bytes: Uint8Array): unknown;
171
+ header(bits: unknown): number;
172
+ /** decompresses the next block (stopping after `len` bytes), `-1` after the last one */
173
+ decompress(bits: unknown, size: number, len?: number): Uint8Array | -1;
174
+ }
175
+ /** Decompresses a bzip2 stream block by block, throwing a `RangeError` if it would yield more than `limit` bytes. */
176
+ export declare function bunzip(bzip2: Bzip2, content: Buffer, limit?: number): Buffer;
168
177
  /**
169
178
  * Parser for RDA files.
170
179
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c | R source: serialize.c}
@@ -176,7 +185,6 @@ export declare class RDAParser {
176
185
  private buffer;
177
186
  private currentDepth;
178
187
  private static readonly INITIAL_DEPTH;
179
- private lastName;
180
188
  private offset;
181
189
  private static readonly R_CODE_SET_MAX;
182
190
  private RWeakRefs;
@@ -250,15 +258,16 @@ export declare class RDAParser {
250
258
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2117-L2121 | R source: ReadItem}
251
259
  */
252
260
  readItem(): RObject;
253
- /** Runs `code` in R and answers an `EnvSxp`, `value` set to {@link RValues.GlobalEnv} when the result names it. Shared by {@link R_FindNamespace} and {@link R_FindNamespace1}. */
254
- private runNamespaceLookup;
255
261
  /**
256
- * Resolves a namespace reference by name via `getNamespace()` in R. Simpler variant of {@link R_FindNamespace1}.
262
+ * Resolves a namespace reference by name. Simpler variant of {@link R_FindNamespace1}.
263
+ * R would load the namespace (`getNamespace()`), but flowR analyzes R code and data without running it: the name comes
264
+ * from the (untrusted) file, and loading a namespace runs the package's code. Hence, this answers an `EnvSxp` standing
265
+ * for the (unknown) namespace environment without consulting R.
257
266
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3795-L3804 | R source: R_FindNamespace}
258
267
  */
259
268
  R_FindNamespace(info: RObjectData): RObjectData;
260
269
  /**
261
- * Resolves a serialized namespace reference by executing R at runtime. See {@link R_FindNamespace} for the result shape.
270
+ * Resolves a serialized namespace reference, see {@link R_FindNamespace} for why this does not ask R.
262
271
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1785-L1796 | R source: R_FindNamespace1}
263
272
  */
264
273
  R_FindNamespace1(info: RObjectData): RObjectData;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.RDAParser = exports.SerializationFormat = exports.SexpType = exports.SerializationTypeTag = exports.CompressionType = exports.FlowrRDAFile = void 0;
7
+ exports.bunzip = bunzip;
7
8
  exports.attributeOf = attributeOf;
8
9
  exports.stringsOf = stringsOf;
9
10
  exports.namesOf = namesOf;
@@ -12,8 +13,8 @@ const flowr_file_1 = require("../../../context/flowr-file");
12
13
  const fs_1 = __importDefault(require("fs"));
13
14
  const assert_1 = require("../../../../util/assert");
14
15
  const r_fun_tab_1 = require("./r-fun-tab");
15
- const shell_executor_1 = require("../../../../r-bridge/shell-executor");
16
16
  const log_1 = require("../../../../util/log");
17
+ const secure_mode_1 = require("../../../../util/secure-mode");
17
18
  const rdaLog = log_1.log.getSubLogger({ name: 'flowr-rda-file' });
18
19
  /**
19
20
  * This decorates a text file and provides access to its content in the format of an {@link RObjectData}.
@@ -227,6 +228,21 @@ const SpecialValueSxps = new Map([
227
228
  [SexpType.MissingArgSxp, { value: RValues.MissingArg, type: SexpType.EnvSxp }],
228
229
  [SexpType.BaseNamespaceSxp, { value: RValues.BaseNamespace, type: SexpType.EnvSxp }],
229
230
  ]);
231
+ /** Decompresses a bzip2 stream block by block, throwing a `RangeError` if it would yield more than `limit` bytes. */
232
+ function bunzip(bzip2, content, limit = Infinity) {
233
+ const bits = bzip2.array(content);
234
+ const size = bzip2.header(bits);
235
+ const chunks = [];
236
+ let total = 0;
237
+ for (let chunk = bzip2.decompress(bits, size, limit - total + 1); chunk !== -1; chunk = bzip2.decompress(bits, size, limit - total + 1)) {
238
+ total += chunk.byteLength;
239
+ if (total > limit) {
240
+ throw new RangeError(`Refusing to decompress more than ${limit} bytes`);
241
+ }
242
+ chunks.push(chunk);
243
+ }
244
+ return Buffer.concat(chunks);
245
+ }
230
246
  /**
231
247
  * Parser for RDA files.
232
248
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c | R source: serialize.c}
@@ -238,7 +254,6 @@ class RDAParser {
238
254
  buffer;
239
255
  currentDepth = 0;
240
256
  static INITIAL_DEPTH = 1;
241
- lastName = undefined;
242
257
  offset = 0;
243
258
  static R_CODE_SET_MAX = 2 ** 6 - 1;
244
259
  RWeakRefs = null;
@@ -290,27 +305,29 @@ class RDAParser {
290
305
  /** Decompresses `fileContent` per the {@link detectCompression} result `compressionType`. Throws error for unsupported compression types. */
291
306
  decompress(fileContent, compressionType) {
292
307
  let buffer;
308
+ // the file belongs to the (possibly hostile) project, so the secure mode bounds what it may decompress to
309
+ const limit = secure_mode_1.SecureMode.decompressionLimit();
293
310
  switch (compressionType) {
294
311
  case CompressionType.CompGz: {
295
312
  // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
296
313
  const zlib = require('zlib');
297
314
  try {
298
315
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
299
- buffer = zlib.gunzipSync(fileContent);
316
+ buffer = zlib.gunzipSync(fileContent, { maxOutputLength: limit });
300
317
  }
301
- catch {
318
+ catch (e) {
319
+ if (e.code === 'ERR_BUFFER_TOO_LARGE') {
320
+ throw e;
321
+ }
302
322
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
303
- buffer = zlib.inflateSync(fileContent);
323
+ buffer = zlib.inflateSync(fileContent, { maxOutputLength: limit });
304
324
  }
305
325
  break;
306
326
  }
307
327
  case CompressionType.CompBz: {
308
- // eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
328
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
309
329
  const bzip2 = require('bzip2');
310
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
311
- const decompressed = bzip2.simple(bzip2.array(fileContent));
312
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
313
- buffer = Buffer.from(decompressed);
330
+ buffer = bunzip(bzip2, fileContent, limit);
314
331
  break;
315
332
  }
316
333
  case CompressionType.CompXz:
@@ -614,26 +631,23 @@ class RDAParser {
614
631
  const flags = this.assertInteger(this.inInteger());
615
632
  return this.readItemRecursive(flags);
616
633
  }
617
- /** Runs `code` in R and answers an `EnvSxp`, `value` set to {@link RValues.GlobalEnv} when the result names it. Shared by {@link R_FindNamespace} and {@link R_FindNamespace1}. */
618
- runNamespaceLookup(code) {
619
- const shell = new shell_executor_1.RShellExecutor();
620
- const result = shell.run(code);
621
- shell.close();
622
- return result === '<environment: R_GlobalEnv>' ? { type: SexpType.EnvSxp, value: RValues.GlobalEnv } : { type: SexpType.EnvSxp };
623
- }
624
634
  /**
625
- * Resolves a namespace reference by name via `getNamespace()` in R. Simpler variant of {@link R_FindNamespace1}.
635
+ * Resolves a namespace reference by name. Simpler variant of {@link R_FindNamespace1}.
636
+ * R would load the namespace (`getNamespace()`), but flowR analyzes R code and data without running it: the name comes
637
+ * from the (untrusted) file, and loading a namespace runs the package's code. Hence, this answers an `EnvSxp` standing
638
+ * for the (unknown) namespace environment without consulting R.
626
639
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3795-L3804 | R source: R_FindNamespace}
627
640
  */
628
641
  R_FindNamespace(info) {
629
- return this.runNamespaceLookup(`getNamespace("${info.value.name}")`);
642
+ rdaLog.trace(`Not loading namespace ${JSON.stringify(info.value?.name)} of a serialized object`);
643
+ return { type: SexpType.EnvSxp };
630
644
  }
631
645
  /**
632
- * Resolves a serialized namespace reference by executing R at runtime. See {@link R_FindNamespace} for the result shape.
646
+ * Resolves a serialized namespace reference, see {@link R_FindNamespace} for why this does not ask R.
633
647
  * @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1785-L1796 | R source: R_FindNamespace1}
634
648
  */
635
649
  R_FindNamespace1(info) {
636
- return this.runNamespaceLookup(`..getNamespace("${info.value[0].name}", "${this.lastName}")`);
650
+ return this.R_FindNamespace({ ...info, value: info.value?.[0] });
637
651
  }
638
652
  /**
639
653
  * Deserializes a single SEXP node, dispatching on its encoded {@link SexpType}.
@@ -1076,9 +1090,6 @@ class RDAParser {
1076
1090
  this.currentDepth++;
1077
1091
  s.attributes = hasAttr ? [this.shortcut ? this.skipItem() : this.assertRObjectData(this.readItem())] : undefined;
1078
1092
  s.tag = hasTag ? this.readItem() : RValues.NilValue;
1079
- if (hasTag && this.currentDepth == RDAParser.INITIAL_DEPTH && typeof s.tag === 'object') {
1080
- this.lastName = s.tag.name;
1081
- }
1082
1093
  s.car = this.shortcut ? this.skipItem() : this.readItem();
1083
1094
  this.currentDepth--;
1084
1095
  if (sFirst === null) {
@@ -55,6 +55,7 @@ const r_version_1 = require("../../../util/r-version");
55
55
  const r_base_packages_1 = require("../../../util/r-base-packages");
56
56
  const defaultmap_1 = require("../../../util/collections/defaultmap");
57
57
  const arrays_1 = require("../../../util/collections/arrays");
58
+ const secure_mode_1 = require("../../../util/secure-mode");
58
59
  /** the plugin's instance name (pass to `unregisterPlugins` to disable the default sigdb resolver) */
59
60
  exports.SigDbPluginName = 'flowr-analyzer-package-versions-sigdb-plugin';
60
61
  /** a resolved source's compressed extension as a codec name for display, a file without one is `plain` */
@@ -171,7 +172,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
171
172
  if (ctx.config.solver.sigdb.warmInBackground) {
172
173
  this.startBackgroundWarm();
173
174
  }
174
- if (ctx.config.solver.sigdb.autoSync) {
175
+ if (ctx.config.solver.sigdb.autoSync && !secure_mode_1.SecureMode.isEnabled()) {
175
176
  this.startBackgroundSync(ctx);
176
177
  }
177
178
  if (ctx.config.solver.sigdb.versionSelection === config_1.VersionSelection.System) {
@@ -27,6 +27,7 @@ const schema_1 = require("./schema");
27
27
  const index_format_1 = require("./index-format");
28
28
  const hash_1 = require("../../util/hash");
29
29
  const codec_1 = require("./codec");
30
+ const files_1 = require("../../util/files");
30
31
  /** whether a bundle path is a compressed (`.br`/`.zst`/`.gz`) source that must be decompressed to be seekable */
31
32
  const isCompressed = (f) => (0, codec_1.isCompressedExt)(f);
32
33
  exports.isCompressed = isCompressed;
@@ -117,7 +118,8 @@ async function readHeaderOf(source) {
117
118
  }
118
119
  }
119
120
  function cachePaths(hash, cacheDir) {
120
- const plain = path_1.default.join(sigDbCacheDir(cacheDir), `sigdb-${hash}${schema_1.SigDbExt}`);
121
+ // the hash may come from the header of a project-supplied bundle
122
+ const plain = (0, files_1.joinUntrustedSegment)(sigDbCacheDir(cacheDir), `sigdb-${hash}${schema_1.SigDbExt}`);
121
123
  return { plain, idx: `${plain}.idx` };
122
124
  }
123
125
  /** whether a compressed source with the given content hash has already been unpacked into its decompressed cache */
@@ -18,6 +18,8 @@ const crypto_1 = __importDefault(require("crypto"));
18
18
  const decompress_1 = require("./decompress");
19
19
  const codec_1 = require("./codec");
20
20
  const version_1 = require("../../util/version");
21
+ const files_1 = require("../../util/files");
22
+ const secure_mode_1 = require("../../util/secure-mode");
21
23
  /** the GitHub `owner/repo` the full-history bundle is published to (see `scripts/publish-sigdb.mjs`) */
22
24
  const DefaultRepo = 'flowr-analysis/flowr';
23
25
  /** GitHub request headers; the token (used only for the API's rate limit and private repos) is attached only when `withAuth` */
@@ -39,6 +41,7 @@ class HttpError extends Error {
39
41
  }
40
42
  /** GET following redirects (GitHub asset URLs redirect to a storage host); resolves the final response for streaming */
41
43
  function httpGet(url, accept, redirects = 5, withAuth = true) {
44
+ secure_mode_1.SecureMode.guard('network access', url);
42
45
  return new Promise((resolve, reject) => {
43
46
  const req = (url.startsWith('http:') ? http_1.default : https_1.default).get(url, { headers: ghHeaders(accept, withAuth) }, res => {
44
47
  const status = res.statusCode ?? 0;
@@ -143,9 +146,8 @@ function findRemotePointer() {
143
146
  return fs_1.default.existsSync(override) ? override : undefined;
144
147
  }
145
148
  const candidates = [
146
- path_1.default.join(__dirname, '../../data/sigdb', exports.SigDbRemoteFileName), // src/ and dist/src/ layouts (same depth)
147
- path_1.default.join(process.cwd(), 'src/data/sigdb', exports.SigDbRemoteFileName),
148
- path_1.default.join(process.cwd(), 'dist/src/data/sigdb', exports.SigDbRemoteFileName),
149
+ // src/ and dist/src/ layouts (same depth); never the working directory, which may be the analyzed (untrusted) project
150
+ path_1.default.join(__dirname, '../../data/sigdb', exports.SigDbRemoteFileName),
149
151
  ];
150
152
  return candidates.find(p => {
151
153
  try {
@@ -238,10 +240,11 @@ function isCached(dest, file) {
238
240
  async function syncFiles(tag, repo, planned, opts) {
239
241
  const progress = opts.onProgress ?? (() => { });
240
242
  const start = Date.now();
241
- const dir = path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', tag);
243
+ // tag and file names come from the (remote) pointer and release listing
244
+ const dir = (0, files_1.joinUntrustedSegment)(path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles'), tag);
242
245
  fs_1.default.mkdirSync(dir, { recursive: true });
243
246
  const ordered = [...planned.filter(p => !(0, exports.isManifestFile)(p.name)), ...planned.filter(p => (0, exports.isManifestFile)(p.name))];
244
- const missing = ordered.filter(p => opts.force || !isCached(path_1.default.join(dir, p.name), p));
247
+ const missing = ordered.filter(p => opts.force || !isCached((0, files_1.joinUntrustedSegment)(dir, p.name), p));
245
248
  const toFetch = missing.reduce((sum, p) => sum + (p.expected?.bytes ?? p.size ?? 0), 0);
246
249
  progress(`signature database ${tag} from ${repo}: ${ordered.length} file(s), ${ordered.length - missing.length} up to date, ${missing.length} to fetch (${mb(toFetch)}) into ${dir}`);
247
250
  const files = [];
@@ -249,7 +252,7 @@ async function syncFiles(tag, repo, planned, opts) {
249
252
  const failed = [];
250
253
  let bytes = 0;
251
254
  for (const file of ordered) {
252
- const dest = path_1.default.join(dir, file.name);
255
+ const dest = (0, files_1.joinUntrustedSegment)(dir, file.name);
253
256
  if (!missing.includes(file)) {
254
257
  files.push(dest);
255
258
  continue;
@@ -12,6 +12,7 @@ const identify_link_to_last_call_relation_1 = require("./identify-link-to-last-c
12
12
  const identify_link_to_relation_1 = require("./identify-link-to-relation");
13
13
  const identifier_1 = require("../../../dataflow/environments/identifier");
14
14
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
15
+ const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
15
16
  const queue_1 = require("../../../util/collections/queue");
16
17
  const r_base_packages_1 = require("../../../util/r-base-packages");
17
18
  function makeReport(collector) {
@@ -310,7 +311,7 @@ async function executeCallContextQueries({ analyzer }, queries) {
310
311
  continue;
311
312
  }
312
313
  }
313
- if (df_helper_1.Dataflow.isQuoted(nodeId, dataflow.graph)) {
314
+ if (df_helper_1.Dataflow.isQuoted(nodeId, dataflow.graph) && !(0, query_fn_props_1.quotedForWorker)(nodeId, dataflow.graph, analyzer.inspectContext().env.builtInIndex)) {
314
315
  /* if the call is quoted, we do not want to link to it */
315
316
  continue;
316
317
  }
@@ -4,6 +4,7 @@ exports.executeConfigQuery = executeConfigQuery;
4
4
  const log_1 = require("../../../util/log");
5
5
  const config_query_format_1 = require("./config-query-format");
6
6
  const assert_1 = require("../../../util/assert");
7
+ const config_1 = require("../../../config");
7
8
  /**
8
9
  * Executes the given configuration queries using the provided analyzer.
9
10
  */
@@ -17,12 +18,18 @@ function executeConfigQuery({ analyzer }, queries) {
17
18
  }
18
19
  // validate here too (not only in the repl parser), so a programmatic / JSON-API update cannot merge an unknown
19
20
  // key or a wrong-typed value; the update then lands via `updateConfig`, which invalidates the analysis cache
20
- for (const update of updates) {
21
- const err = (0, config_query_format_1.validateConfigUpdate)(update);
21
+ for (const given of updates) {
22
+ const err = (0, config_query_format_1.validateConfigUpdate)(given);
22
23
  if (err !== undefined) {
23
24
  log_1.log.warn(`ignoring invalid config update: ${err}`);
24
25
  continue;
25
26
  }
27
+ // queries may come from clients of the server, so they must not choose what flowR executes, loads, or downloads
28
+ const update = structuredClone(given);
29
+ const dropped = config_1.FlowrConfig.dropUntrusted(update);
30
+ if (dropped.length > 0) {
31
+ log_1.log.warn(`ignoring untrusted options in config update: ${dropped.join(', ')}`);
32
+ }
26
33
  analyzer.updateConfig(update);
27
34
  }
28
35
  const specialization = analyzer.inspectContext().configSpecialization();
@@ -1,3 +1,4 @@
1
+ import { Identifier } from '../../../dataflow/environments/identifier';
1
2
  import type { LinkedInputEntryPoint, LinkedInputObject, NarrowingFunction } from './simple-input-classifier';
2
3
  import type { BuiltInIndex } from '../../../dataflow/environments/query-fn-props';
3
4
  /**
@@ -8,12 +9,13 @@ import type { BuiltInIndex } from '../../../dataflow/environments/query-fn-props
8
9
  */
9
10
  export declare const LinkedInputObjects: readonly LinkedInputObject[];
10
11
  /**
11
- * The functions whose result is bounded no matter what flows in, read back from the {@link SemanticCallTag.Narrows}
12
- * built-ins: with an {@link ArgProp.Bounds} parameter the result is one of that argument's values (`match.arg`
13
- * and its `choices`), without one it is a count, an index, or a logical of the call's own making. Label a
14
- * built-in `Narrows` (in the {@link DefaultBuiltinConfig} or your own definitions) and it shows up here.
12
+ * The {@link SemanticCallTag.Narrows} built-ins with an {@link ArgProp.Bounds} parameter, whose result is one of
13
+ * that argument's values (`match.arg` and its `choices`). Label a built-in `Narrows` with such a parameter
14
+ * (in the {@link DefaultBuiltinConfig} or your own definitions) and it shows up here.
15
15
  */
16
16
  export declare function narrowingFunctions(index: BuiltInIndex): readonly NarrowingFunction[];
17
+ /** The {@link SemanticCallTag.Narrows} built-ins without an {@link ArgProp.Bounds} parameter: counts and logicals free of their arguments' content. */
18
+ export declare function contentFreeFunctions(index: BuiltInIndex): readonly Identifier[];
17
19
  /**
18
20
  * Calls that hand a function to a framework which binds its parameters by position.
19
21
  * @see {@link LinkedInputEntryPoint}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LinkedInputEntryPoints = exports.LinkedInputObjects = void 0;
4
4
  exports.narrowingFunctions = narrowingFunctions;
5
+ exports.contentFreeFunctions = contentFreeFunctions;
5
6
  const identifier_1 = require("../../../dataflow/environments/identifier");
6
7
  const simple_input_classifier_1 = require("./simple-input-classifier");
7
8
  const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
@@ -28,18 +29,22 @@ exports.LinkedInputObjects = [
28
29
  { name: 'session', type: simple_input_classifier_1.InputType.User, withParams: ['input', 'output'], requires: 'shiny', fields: ['clientData', 'request'] }
29
30
  ];
30
31
  /**
31
- * The functions whose result is bounded no matter what flows in, read back from the {@link SemanticCallTag.Narrows}
32
- * built-ins: with an {@link ArgProp.Bounds} parameter the result is one of that argument's values (`match.arg`
33
- * and its `choices`), without one it is a count, an index, or a logical of the call's own making. Label a
34
- * built-in `Narrows` (in the {@link DefaultBuiltinConfig} or your own definitions) and it shows up here.
32
+ * The {@link SemanticCallTag.Narrows} built-ins with an {@link ArgProp.Bounds} parameter, whose result is one of
33
+ * that argument's values (`match.arg` and its `choices`). Label a built-in `Narrows` with such a parameter
34
+ * (in the {@link DefaultBuiltinConfig} or your own definitions) and it shows up here.
35
35
  */
36
36
  function narrowingFunctions(index) {
37
37
  const bounds = new Map(index.params(built_in_props_1.ArgProp.Bounds).map(p => [identifier_1.Identifier.getName(p.call), p]));
38
- return index.with(built_in_props_1.SemanticCallTag.Narrows).map(call => {
38
+ return index.with(built_in_props_1.SemanticCallTag.Narrows).flatMap(call => {
39
39
  const bound = bounds.get(identifier_1.Identifier.getName(call));
40
- return bound === undefined ? { call } : { call, argName: bound.name, argIdx: bound.index };
40
+ return bound === undefined ? [] : [{ call, argName: bound.name, argIdx: bound.index }];
41
41
  });
42
42
  }
43
+ /** The {@link SemanticCallTag.Narrows} built-ins without an {@link ArgProp.Bounds} parameter: counts and logicals free of their arguments' content. */
44
+ function contentFreeFunctions(index) {
45
+ const bounded = new Set(index.params(built_in_props_1.ArgProp.Bounds).map(p => identifier_1.Identifier.getName(p.call)));
46
+ return index.with(built_in_props_1.SemanticCallTag.Narrows).filter(call => !bounded.has(identifier_1.Identifier.getName(call)));
47
+ }
43
48
  /** shiny binds `input`, `output`, and `session` positionally, so their names are up to whoever writes the server */
44
49
  const ShinyServerParams = ['input', undefined, 'session'];
45
50
  /**
@@ -70,7 +70,7 @@ function addAll(base, extra) {
70
70
  return result;
71
71
  }
72
72
  /** Config fields that hold structured values (not function searches) and are carried over verbatim. */
73
- const StructuredConfigKeys = ['linkedObjects', 'linkedEntryPoints', 'narrowing'];
73
+ const StructuredConfigKeys = ['linkedObjects', 'linkedEntryPoints', 'narrowing', 'templates'];
74
74
  function isStructuredConfigKey(key) {
75
75
  return StructuredConfigKeys.includes(key);
76
76
  }
@@ -23,7 +23,7 @@ export interface InputSourcesQuery extends BaseQueryFormat {
23
23
  /**
24
24
  * Which functions belong to which input type is stated with the functions themselves, in the built-in configuration
25
25
  * the analyzer registered (see {@link ReadOnlyFlowrAnalyzerEnvironmentContext#builtInDefinitions}):
26
- * a function that states its props and carries none of the {@link InputProps} derives its result from its arguments, the others bring in data of their own, and a {@link SemanticCallTag.Narrows} one bounds its result no matter what flows in. Add a function there (or override its props with your own built-in definitions) and it shows up here.
26
+ * a function that states its props and carries none of the {@link InputProps} derives its result from its arguments, the others bring in data of their own, and a {@link SemanticCallTag.Narrows} one with an {@link ArgProp.Bounds} parameter is classified by that argument alone. Add a function there (or override its props with your own built-in definitions) and it shows up here.
27
27
  */
28
28
  export declare const defaultInputClassifierConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => InputClassifierConfig;
29
29
  export interface InputSourcesQueryResult extends BaseQueryResult {
@@ -21,7 +21,7 @@ const built_in_props_1 = require("../../../dataflow/environments/built-in-props"
21
21
  /**
22
22
  * Which functions belong to which input type is stated with the functions themselves, in the built-in configuration
23
23
  * the analyzer registered (see {@link ReadOnlyFlowrAnalyzerEnvironmentContext#builtInDefinitions}):
24
- * a function that states its props and carries none of the {@link InputProps} derives its result from its arguments, the others bring in data of their own, and a {@link SemanticCallTag.Narrows} one bounds its result no matter what flows in. Add a function there (or override its props with your own built-in definitions) and it shows up here.
24
+ * a function that states its props and carries none of the {@link InputProps} derives its result from its arguments, the others bring in data of their own, and a {@link SemanticCallTag.Narrows} one with an {@link ArgProp.Bounds} parameter is classified by that argument alone. Add a function there (or override its props with your own built-in definitions) and it shows up here.
25
25
  */
26
26
  const defaultInputClassifierConfig = (ctx) => ctx.env.derive(inputClassifierConfigOf);
27
27
  exports.defaultInputClassifierConfig = defaultInputClassifierConfig;
@@ -37,9 +37,13 @@ const inputClassifierConfigOf = (env) => {
37
37
  [simple_input_classifier_1.InputType.System]: builtIns.with(built_in_props_1.SemanticCallTag.Process),
38
38
  [simple_input_classifier_1.InputType.Ffi]: builtIns.with(built_in_props_1.CallProp.Ffi),
39
39
  [simple_input_classifier_1.InputType.Lang]: builtIns.with(built_in_props_1.CallProp.Lang),
40
- [simple_input_classifier_1.InputType.Options]: builtIns.with(built_in_props_1.CallProp.Ambient),
40
+ [simple_input_classifier_1.InputType.Options]: builtIns.with([built_in_props_1.CallProp.Ambient, built_in_props_1.SemanticCallTag.LoadsPackage, built_in_props_1.SemanticCallTag.ChecksPackage]),
41
41
  [simple_input_classifier_1.InputType.CommandLine]: builtIns.with(built_in_props_1.SemanticCallTag.CommandLine),
42
42
  [simple_input_classifier_1.InputType.User]: builtIns.with(built_in_props_1.SemanticCallTag.User),
43
+ [simple_input_classifier_1.InputType.Unknown]: builtIns.with(built_in_props_1.CallProp.NonDet),
44
+ evaluating: builtIns.with(built_in_props_1.SemanticCallTag.Eval),
45
+ editing: builtIns.with(built_in_props_1.SemanticCallTag.Edits),
46
+ templates: builtIns.params(built_in_props_1.ArgProp.Injectable).map(p => ({ call: p.call, argName: p.name, argIdx: p.index })),
43
47
  linkedObjects: input_source_functions_1.LinkedInputObjects,
44
48
  linkedEntryPoints: input_source_functions_1.LinkedInputEntryPoints,
45
49
  narrowing: (0, input_source_functions_1.narrowingFunctions)(builtIns)
@@ -87,6 +91,9 @@ exports.InputSourcesDefinition = {
87
91
  [simple_input_classifier_1.InputType.Options]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
88
92
  [simple_input_classifier_1.InputType.CommandLine]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that hand back what the program was invoked with (e.g., commandArgs).'),
89
93
  [simple_input_classifier_1.InputType.User]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read interactive user input (e.g., file.choose, readline, menu, askYesNo).'),
94
+ sanitizers: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions whose result counts as a derived constant whatever flows in (e.g., an escaping function).'),
95
+ evaluating: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that evaluate code or look up names at run time, whose result is unknown (e.g., eval, do.call, exists).'),
96
+ editing: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that cut or replace parts of a string, undoing what a sanitizer escaped (e.g., gsub, substr).'),
90
97
  linkedObjects: joi_1.default.array().items(joi_1.default.object({
91
98
  name: joi_1.default.string().required().description('Name of the object, e.g. input.'),
92
99
  type: joi_1.default.string().valid(...record_1.Record.values(simple_input_classifier_1.InputType)).required().description('How reads of the object (or of its fields) are classified.'),