@eagleoutice/flowr 2.10.5 → 2.10.7

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 (113) hide show
  1. package/README.md +21 -21
  2. package/abstract-interpretation/absint-visitor.d.ts +1 -2
  3. package/abstract-interpretation/domains/state-domain-like.d.ts +2 -2
  4. package/config.d.ts +6 -0
  5. package/config.js +2 -0
  6. package/control-flow/basic-cfg-guided-visitor.d.ts +1 -1
  7. package/control-flow/semantic-cfg-guided-visitor.js +4 -0
  8. package/dataflow/environments/built-in-proc-name.d.ts +27 -19
  9. package/dataflow/environments/built-in-proc-name.js +27 -19
  10. package/dataflow/environments/built-in.d.ts +24 -18
  11. package/dataflow/environments/built-in.js +6 -0
  12. package/dataflow/environments/default-builtin-config.d.ts +53 -1
  13. package/dataflow/environments/default-builtin-config.js +13 -3
  14. package/dataflow/environments/identifier.d.ts +19 -0
  15. package/dataflow/environments/reference-to-maybe.js +32 -6
  16. package/dataflow/eval/resolve/alias-tracking.js +5 -0
  17. package/dataflow/graph/graph.js +51 -30
  18. package/dataflow/graph/vertex.d.ts +18 -11
  19. package/dataflow/internal/process/functions/call/built-in/built-in-access.js +16 -0
  20. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +6 -0
  21. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +145 -11
  22. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +15 -0
  23. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +54 -0
  24. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.d.ts +75 -0
  25. package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +196 -0
  26. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +22 -8
  27. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +57 -1
  28. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +5 -0
  29. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +27 -13
  30. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +14 -4
  31. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.d.ts +27 -0
  32. package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +97 -0
  33. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +7 -7
  34. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +23 -0
  35. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +90 -0
  36. package/documentation/doc-util/doc-types.d.ts +11 -2
  37. package/documentation/doc-util/doc-types.js +31 -9
  38. package/documentation/wiki-absint.d.ts +16 -0
  39. package/documentation/wiki-absint.js +50 -15
  40. package/documentation/wiki-interface.js +1 -0
  41. package/documentation/wiki-mk/doc-context.d.ts +14 -1
  42. package/documentation/wiki-mk/doc-context.js +6 -0
  43. package/documentation/wiki-normalized-ast.d.ts +0 -9
  44. package/documentation/wiki-normalized-ast.js +9 -60
  45. package/linter/linter-format.d.ts +4 -0
  46. package/linter/linter-rules.d.ts +7 -6
  47. package/linter/rules/absolute-path.d.ts +0 -2
  48. package/linter/rules/dataframe-access-validation.d.ts +4 -7
  49. package/linter/rules/dataframe-access-validation.js +3 -3
  50. package/linter/rules/dead-code.d.ts +4 -7
  51. package/linter/rules/file-path-validity.d.ts +0 -2
  52. package/linter/rules/function-finder-util.d.ts +1 -3
  53. package/linter/rules/function-finder-util.js +2 -2
  54. package/linter/rules/naming-convention.d.ts +0 -2
  55. package/linter/rules/network-functions.js +4 -1
  56. package/linter/rules/problematic-inputs.d.ts +9 -6
  57. package/linter/rules/problematic-inputs.js +108 -58
  58. package/linter/rules/roxygen-arguments.d.ts +0 -2
  59. package/linter/rules/seeded-randomness.d.ts +0 -2
  60. package/linter/rules/stop-with-call-arg.d.ts +3 -6
  61. package/linter/rules/unused-definition.d.ts +0 -2
  62. package/linter/rules/useless-loop.d.ts +0 -2
  63. package/package.json +4 -4
  64. package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -2
  65. package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
  66. package/queries/catalog/dependencies-query/function-info/read-functions.js +2 -0
  67. package/queries/catalog/dependencies-query/function-info/source-functions.js +1 -1
  68. package/queries/catalog/dependencies-query/function-info/write-functions.js +1 -0
  69. package/queries/catalog/input-sources-query/input-source-functions.d.ts +1 -0
  70. package/queries/catalog/input-sources-query/input-source-functions.js +7 -1
  71. package/queries/catalog/input-sources-query/input-sources-query-format.js +3 -1
  72. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +3 -1
  73. package/queries/catalog/input-sources-query/simple-input-classifier.js +3 -1
  74. package/r-bridge/data/data.d.ts +28 -2
  75. package/r-bridge/data/data.js +34 -2
  76. package/r-bridge/lang-4.x/ast/model/model.d.ts +1 -2
  77. package/r-bridge/lang-4.x/ast/model/model.js +0 -1
  78. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -3
  79. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -3
  80. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -3
  81. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -3
  82. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -3
  83. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -3
  84. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -3
  85. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
  86. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -3
  87. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -3
  88. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -3
  89. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -3
  90. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -3
  91. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -3
  92. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -3
  93. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -3
  94. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -3
  95. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -3
  96. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -3
  97. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -3
  98. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -3
  99. package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +1 -1
  100. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +16 -16
  101. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
  102. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +8 -0
  103. package/search/flowr-search-builder.d.ts +16 -2
  104. package/search/flowr-search-builder.js +10 -1
  105. package/search/flowr-search.d.ts +9 -0
  106. package/search/search-executor/search-generators.d.ts +1 -1
  107. package/search/search-executor/search-generators.js +28 -2
  108. package/slicing/static/static-slicer.js +2 -2
  109. package/util/range.d.ts +13 -1
  110. package/util/range.js +32 -2
  111. package/util/version.js +1 -1
  112. package/abstract-interpretation/normalized-ast-fold.d.ts +0 -119
  113. package/abstract-interpretation/normalized-ast-fold.js +0 -181
@@ -61,7 +61,7 @@ exports.functionFinderUtil = {
61
61
  };
62
62
  },
63
63
  requireArgumentValue(element, pool, data, requireValue) {
64
- const info = pool.find(f => f.name === element.node.lexeme);
64
+ const info = pool.get(element.node.lexeme ?? '');
65
65
  /* if we have no additional info, we assume they always access the network */
66
66
  if (info === undefined) {
67
67
  return logic_1.Ternary.Always;
@@ -70,7 +70,7 @@ exports.functionFinderUtil = {
70
70
  if ((0, vertex_1.isFunctionCallVertex)(vert)) {
71
71
  const args = (0, resolve_argument_1.getArgumentStringValue)(data.analyzer.flowrConfig.solver.variables, data.dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, data.analyzer.inspectContext());
72
72
  // we obtain all values, at least one of them has to trigger for the request
73
- const argValues = args ? args.values().flatMap(v => [...v]).filter(assert_1.isNotUndefined).toArray() : [];
73
+ const argValues = args ? args.values().flatMap(s => Array.from(s)).filter(assert_1.isNotUndefined).toArray() : [];
74
74
  if (argValues.length === 0) {
75
75
  return logic_1.Ternary.Maybe;
76
76
  }
@@ -1,7 +1,6 @@
1
1
  import type { DataflowGraph } from '../../dataflow/graph/graph';
2
2
  import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
3
3
  import type { MergeableRecord } from '../../util/objects';
4
- import { SourceLocation } from '../../util/range';
5
4
  import { type LintingResult, type LintQuickFixReplacement, LintingRuleCertainty } from '../linter-format';
6
5
  import { LintingRuleTag } from '../linter-tags';
7
6
  export declare enum CasingConvention {
@@ -16,7 +15,6 @@ export declare enum CasingConvention {
16
15
  export interface NamingConventionResult extends LintingResult {
17
16
  name: string;
18
17
  detectedCasing: CasingConvention;
19
- loc: SourceLocation;
20
18
  }
21
19
  /**
22
20
  * It is planned to have a config like ESLint
@@ -6,12 +6,15 @@ const function_finder_util_1 = require("./function-finder-util");
6
6
  const linter_tags_1 = require("../linter-tags");
7
7
  const read_functions_1 = require("../../queries/catalog/dependencies-query/function-info/read-functions");
8
8
  const logic_1 = require("../../util/logic");
9
+ const source_functions_1 = require("../../queries/catalog/dependencies-query/function-info/source-functions");
10
+ const write_functions_1 = require("../../queries/catalog/dependencies-query/function-info/write-functions");
11
+ const FnPool = new Map(read_functions_1.ReadFunctions.concat(source_functions_1.SourceFunctions, write_functions_1.WriteFunctions).map(f => [f.name, f]));
9
12
  exports.NETWORK_FUNCTIONS = {
10
13
  createSearch: (config) => function_finder_util_1.functionFinderUtil.createSearch(config.fns),
11
14
  processSearchResult: (e, c, d) => function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, es => {
12
15
  const res = [];
13
16
  for (const e of es) {
14
- const val = function_finder_util_1.functionFinderUtil.requireArgumentValue(e, read_functions_1.ReadFunctions, d, c.onlyTriggerWithArgument);
17
+ const val = function_finder_util_1.functionFinderUtil.requireArgumentValue(e, FnPool, d, c.onlyTriggerWithArgument);
15
18
  if (val === logic_1.Ternary.Never) {
16
19
  continue;
17
20
  }
@@ -1,19 +1,21 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
- import { SourceLocation } from '../../util/range';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { InputClassifierConfig, InputSources } from '../../queries/catalog/input-sources-query/simple-input-classifier';
6
- /**
7
- * Describes a linting result for a problematic eval usage, including the location of the eval call and the computed input sources that lead to it.
8
- */
5
+ export interface PipeCommandFunctionSpec {
6
+ pattern: string;
7
+ argIdx: number;
8
+ argName: string;
9
+ }
9
10
  export interface ProblematicInputsResult extends LintingResult {
10
11
  name: string;
11
- loc: SourceLocation;
12
12
  sources: InputSources;
13
+ pipeCommand?: string;
13
14
  }
14
15
  export interface ProblematicInputsConfig extends MergeableRecord {
15
16
  consider?: string | string[];
16
17
  inputFns?: InputClassifierConfig;
18
+ pipeCommandFunctions?: PipeCommandFunctionSpec | PipeCommandFunctionSpec[];
17
19
  }
18
20
  export type ProblematicInputsMetadata = MergeableRecord;
19
21
  export declare const PROBLEMATIC_INPUTS: {
@@ -33,11 +35,12 @@ export declare const PROBLEMATIC_INPUTS: {
33
35
  };
34
36
  readonly info: {
35
37
  readonly name: "Problematic inputs";
36
- readonly description: "Detects uses of configured dynamic calls (e.g. eval, system) whose inputs are not statically constant. Prints the computed input-sources for the call and flags usages that depend on non-constant/trusted inputs.";
38
+ readonly description: "Detects uses of 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.";
37
39
  readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Smell, LintingRuleTag.Readability, LintingRuleTag.Performance];
38
40
  readonly certainty: LintingRuleCertainty.BestEffort;
39
41
  readonly defaultConfig: {
40
42
  readonly consider: readonly ["^eval$", "^system$", "^system2$", "^shell$"];
43
+ readonly pipeCommandFunctions: readonly PipeCommandFunctionSpec[];
41
44
  };
42
45
  };
43
46
  };
@@ -7,103 +7,153 @@ const range_1 = require("../../util/range");
7
7
  const linter_tags_1 = require("../linter-tags");
8
8
  const simple_input_classifier_1 = require("../../queries/catalog/input-sources-query/simple-input-classifier");
9
9
  const parse_1 = require("../../slicing/criterion/parse");
10
+ const graph_1 = require("../../dataflow/graph/graph");
10
11
  const defaultConsider = ['^eval$', '^system$', '^system2$', '^shell$'];
11
- function normalizeConsider(cfg) {
12
- if (cfg?.consider === undefined) {
13
- return Array.from(defaultConsider, s => new RegExp(s));
12
+ const defaultPipeCommandFunctions = [
13
+ { pattern: '^pdf$', argIdx: 0, argName: 'file' },
14
+ { pattern: '^postscript$', argIdx: 0, argName: 'file' }
15
+ ];
16
+ function normalizePatternList(cfg, defaults) {
17
+ if (cfg === undefined) {
18
+ return Array.from(defaults, s => new RegExp(s));
14
19
  }
15
- if (Array.isArray(cfg.consider)) {
16
- const arr = cfg.consider.length === 0 ? Array.from(defaultConsider) : cfg.consider;
17
- // deduplicate while preserving order
20
+ if (Array.isArray(cfg)) {
21
+ const arr = cfg.length === 0 ? Array.from(defaults) : cfg;
18
22
  return Array.from(new Set(arr), s => new RegExp(s));
19
23
  }
20
- return [new RegExp(cfg.consider)];
24
+ return [new RegExp(cfg)];
25
+ }
26
+ function normalizePipeSpecs(cfg) {
27
+ const raw = cfg === undefined ? defaultPipeCommandFunctions
28
+ : Array.isArray(cfg) ? (cfg.length === 0 ? defaultPipeCommandFunctions : cfg)
29
+ : [cfg];
30
+ return raw.map(s => ({ pattern: new RegExp(s.pattern), argIdx: s.argIdx, argName: s.argName }));
21
31
  }
22
- /**
23
- * Format a list of input sources either as a single-line string (inline) or a block.
24
- * - inline: returns a semicolon-separated single-line summary
25
- * - block: returns an array of lines (to be joined with newlines by the caller)
26
- */
27
32
  function formatInputSources(inputs, inline = true) {
28
33
  if (!inputs || inputs.length === 0) {
29
34
  return inline ? '' : [];
30
35
  }
31
- const formatOne = (s, inlineMode) => {
32
- const typeStr = '[' + s.types.join(',') + ']';
33
- const cdsStr = s.cds ? ', cds: [' + s.cds.join(',') + ']' : '';
34
- return inlineMode
35
- ? `${s.id} (type: ${typeStr}, trace: ${s.trace}${cdsStr})`
36
- : `- ${s.id}: type=${typeStr}, trace=${s.trace}${cdsStr}`;
36
+ const fmt = (s) => {
37
+ const t = '[' + s.types.join(',') + ']';
38
+ const c = s.cds ? ', cds: [' + s.cds.join(',') + ']' : '';
39
+ return inline
40
+ ? `${s.id} (type: ${t}, trace: ${s.trace}${c})`
41
+ : `- ${s.id}: type=${t}, trace=${s.trace}${c}`;
37
42
  };
38
- if (inline) {
39
- return inputs.map(s => formatOne(s, true)).join('; ');
40
- }
41
- return inputs.map(s => formatOne(s, false));
43
+ return inline ? inputs.map(fmt).join('; ') : inputs.map(fmt);
42
44
  }
43
- // small helpers to keep checks readable
44
45
  function hasUnknownSource(sources) {
45
46
  return sources.some(s => s.types.includes(simple_input_classifier_1.InputType.Unknown));
46
47
  }
47
48
  function isProblematicForAllowed(sources, allowed) {
48
49
  return sources.some(s => s.types.some(t => !allowed.includes(t)));
49
50
  }
51
+ function getPipeCommandValue(sources) {
52
+ for (const s of sources) {
53
+ if (typeof s.value === 'string' && s.value.startsWith('|')) {
54
+ return s.value;
55
+ }
56
+ }
57
+ return undefined;
58
+ }
59
+ function resolveFileArgId(vertex, argIdx, argName) {
60
+ const args = vertex?.args;
61
+ if (!args) {
62
+ return undefined;
63
+ }
64
+ let idx = args.findIndex(a => graph_1.FunctionArgument.isNamed(a) && a.name === argName);
65
+ if (idx < 0) {
66
+ idx = argIdx;
67
+ }
68
+ if (idx >= args.length) {
69
+ return undefined;
70
+ }
71
+ const arg = args[idx];
72
+ return graph_1.FunctionArgument.isEmpty(arg) ? undefined : graph_1.FunctionArgument.getReference(arg);
73
+ }
74
+ function checkPipeInjection(nid, loc, name, sources) {
75
+ const pipeCmd = getPipeCommandValue(sources);
76
+ if (pipeCmd !== undefined) {
77
+ return { involvedId: nid, certainty: linter_format_1.LintingResultCertainty.Certain, loc, name, sources, pipeCommand: pipeCmd };
78
+ }
79
+ if (hasUnknownSource(sources)) {
80
+ return { involvedId: nid, certainty: linter_format_1.LintingResultCertainty.Uncertain, loc, name, sources };
81
+ }
82
+ return undefined;
83
+ }
50
84
  exports.PROBLEMATIC_INPUTS = {
51
85
  createSearch: config => {
52
- const considerArr = normalizeConsider(config);
53
- const queries = considerArr.map((name, i) => ({
54
- type: 'call-context',
55
- callName: name,
56
- callNameExact: false,
57
- subkind: `fn-${i}`
58
- }));
59
- return flowr_search_builder_1.Q.fromQuery(...queries);
86
+ const toQ = (name, subkind) => ({ type: 'call-context', callName: name, callNameExact: false, subkind });
87
+ return flowr_search_builder_1.Q.fromQuery(...normalizePatternList(config?.consider, defaultConsider).map((n, i) => toQ(n, `fn-${i}`)), ...normalizePipeSpecs(config?.pipeCommandFunctions).map((s, i) => toQ(s.pattern, `pipe-${i}`)));
60
88
  },
61
89
  processSearchResult: async (elements, config, data) => {
62
90
  const results = [];
91
+ const seen = new Set();
63
92
  const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
93
+ const considerPats = normalizePatternList(config?.consider, defaultConsider);
94
+ const pipePats = normalizePipeSpecs(config?.pipeCommandFunctions);
64
95
  for (const element of elements.getElements()) {
65
96
  const nid = element.node.info.id;
66
- const criterion = parse_1.SlicingCriterion.fromId(nid);
67
- const q = { type: 'input-sources', criterion, config: config.inputFns };
68
- const all = await data.analyzer.query([q]);
69
- const inputSourcesResult = all['input-sources'];
70
- const sources = inputSourcesResult?.results?.[criterion] ?? [];
71
- if (isProblematicForAllowed(sources, defaultAccept)) {
72
- const certainty = hasUnknownSource(sources) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain;
73
- results.push({
74
- involvedId: nid,
75
- certainty,
76
- loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
77
- name: element.node.lexeme ?? '',
78
- sources
79
- });
97
+ if (seen.has(nid)) {
98
+ continue;
99
+ }
100
+ const name = element.node.lexeme ?? '';
101
+ const pipeSpec = pipePats.find(s => s.pattern.test(name));
102
+ const isConsider = pipeSpec === undefined && considerPats.some(p => p.test(name));
103
+ if (pipeSpec === undefined && !isConsider) {
104
+ continue;
105
+ }
106
+ const loc = range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid();
107
+ if (pipeSpec !== undefined) {
108
+ const vertex = data.dataflow.graph.getVertex(nid);
109
+ const fileArgId = resolveFileArgId(vertex, pipeSpec.argIdx, pipeSpec.argName);
110
+ if (fileArgId !== undefined) {
111
+ const criterion = parse_1.SlicingCriterion.fromId(fileArgId);
112
+ const all = await data.analyzer.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
113
+ const sources = all['input-sources']?.results?.[criterion] ?? [];
114
+ const r = checkPipeInjection(nid, loc, name, sources);
115
+ if (r !== undefined) {
116
+ seen.add(nid);
117
+ results.push(r);
118
+ }
119
+ }
120
+ }
121
+ else {
122
+ const criterion = parse_1.SlicingCriterion.fromId(nid);
123
+ const all = await data.analyzer.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
124
+ const sources = all['input-sources']?.results?.[criterion] ?? [];
125
+ if (isProblematicForAllowed(sources, defaultAccept)) {
126
+ seen.add(nid);
127
+ results.push({ involvedId: nid, certainty: hasUnknownSource(sources) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain, loc, name, sources });
128
+ }
80
129
  }
81
130
  }
82
- return {
83
- results,
84
- '.meta': {}
85
- };
131
+ return { results, '.meta': {} };
86
132
  },
87
- /* helper to format input sources for pretty printing */
88
133
  prettyPrint: {
89
134
  [linter_format_1.LintingPrettyPrintContext.Query]: result => {
90
- const inputs = result.sources ?? [];
91
- const srcStr = formatInputSources(inputs, true);
92
- return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + (srcStr ? '; inputs: ' + srcStr : '');
135
+ if (result.pipeCommand !== undefined) {
136
+ return `Pipe command injection via '${result.pipeCommand}' in call to ${result.name} at ${range_1.SourceLocation.format(result.loc)}`;
137
+ }
138
+ const src = formatInputSources(result.sources ?? [], true);
139
+ return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + (src ? '; inputs: ' + src : '');
93
140
  },
94
141
  [linter_format_1.LintingPrettyPrintContext.Full]: result => {
95
- const inputs = result.sources ?? [];
96
- const srcLines = formatInputSources(inputs, false);
97
- return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + ' is potentially problematic' + (srcLines.length ? '\nInputs:\n' + srcLines.join('\n') : '');
142
+ const lines = formatInputSources(result.sources ?? [], false);
143
+ const tail = lines.length ? '\nInputs:\n' + lines.join('\n') : '';
144
+ return result.pipeCommand !== undefined
145
+ ? `Pipe command injection: '${result.pipeCommand}' passed as filename to ${result.name} at ${range_1.SourceLocation.format(result.loc)}${tail}`
146
+ : 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + ' is potentially problematic' + tail;
98
147
  }
99
148
  },
100
149
  info: {
101
150
  name: 'Problematic inputs',
102
- description: 'Detects uses of configured dynamic calls (e.g. eval, system) whose inputs are not statically constant. Prints the computed input-sources for the call and flags usages that depend on non-constant/trusted inputs.',
151
+ description: 'Detects uses of 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.',
103
152
  tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Readability, linter_tags_1.LintingRuleTag.Performance],
104
153
  certainty: linter_format_1.LintingRuleCertainty.BestEffort,
105
154
  defaultConfig: {
106
- consider: defaultConsider
155
+ consider: defaultConsider,
156
+ pipeCommandFunctions: defaultPipeCommandFunctions
107
157
  }
108
158
  }
109
159
  };
@@ -1,10 +1,8 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
- import { SourceLocation } from '../../util/range';
3
2
  import type { MergeableRecord } from '../../util/objects';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { Writable } from 'ts-essentials';
6
5
  export interface RoxygenArgsResult extends LintingResult {
7
- readonly loc: SourceLocation;
8
6
  readonly overDocumented?: string[];
9
7
  readonly underDocumented?: string[];
10
8
  }
@@ -1,11 +1,9 @@
1
1
  import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
2
- import { SourceLocation } from '../../util/range';
3
2
  import type { MergeableRecord } from '../../util/objects';
4
3
  import type { BrandedIdentifier } from '../../dataflow/environments/identifier';
5
4
  import { LintingRuleTag } from '../linter-tags';
6
5
  export interface SeededRandomnessResult extends LintingResult {
7
6
  function: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  export interface SeededRandomnessConfig extends MergeableRecord {
11
9
  /**
@@ -1,11 +1,8 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
- import { SourceLocation } from '../../util/range';
3
2
  import type { MergeableRecord } from '../../util/objects';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { Writable } from 'ts-essentials';
6
- export interface StopWithCallResult extends LintingResult {
7
- readonly loc: SourceLocation;
8
- }
5
+ export type StopWithCallResult = LintingResult;
9
6
  export type StopWithCallConfig = MergeableRecord;
10
7
  export interface StopWithCallMetadata extends MergeableRecord {
11
8
  consideredNodes: number;
@@ -22,8 +19,8 @@ export declare const STOP_WITH_CALL_ARG: {
22
19
  '.meta': StopWithCallMetadata;
23
20
  };
24
21
  readonly prettyPrint: {
25
- readonly query: (result: StopWithCallResult) => string;
26
- readonly full: (result: StopWithCallResult) => string;
22
+ readonly query: (result: LintingResult) => string;
23
+ readonly full: (result: LintingResult) => string;
27
24
  };
28
25
  readonly info: {
29
26
  readonly name: "Stop without call.=False argument";
@@ -1,11 +1,9 @@
1
1
  import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
- import { SourceLocation } from '../../util/range';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
6
5
  export interface UnusedDefinitionResult extends LintingResult {
7
6
  variableName?: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  export interface UnusedDefinitionConfig extends MergeableRecord {
11
9
  /**
@@ -1,11 +1,9 @@
1
1
  import type { MergeableRecord } from '../../util/objects';
2
- import { SourceLocation } from '../../util/range';
3
2
  import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
4
3
  import { LintingRuleTag } from '../linter-tags';
5
4
  import type { BuiltInProcName } from '../../dataflow/environments/built-in-proc-name';
6
5
  export interface UselessLoopResult extends LintingResult {
7
6
  name: string;
8
- loc: SourceLocation;
9
7
  }
10
8
  export interface UselessLoopConfig extends MergeableRecord {
11
9
  /** Function origins that are considered loops */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eagleoutice/flowr",
3
- "version": "2.10.5",
3
+ "version": "2.10.7",
4
4
  "description": "Static Dataflow Analyzer and Program Slicer for the R Programming Language",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "repository": {
@@ -35,7 +35,7 @@
35
35
  "build:copy-wasm": "mkdir -p dist/node_modules/@davisvaughan/tree-sitter-r/ && mkdir -p dist/node_modules/web-tree-sitter && cp node_modules/@davisvaughan/tree-sitter-r/tree-sitter-r.wasm dist/node_modules/@davisvaughan/tree-sitter-r/ && cp node_modules/web-tree-sitter/tree-sitter.wasm dist/node_modules/web-tree-sitter/",
36
36
  "lint-local": "npx eslint --version && npx eslint src/ test/ --rule \"no-warning-comments: off\"",
37
37
  "lint": "npm run license-compat -- --summary && npx eslint --version && npx eslint src/ test/",
38
- "license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD'",
38
+ "license-compat": "license-checker-rseidelsohn --onlyAllow 'MIT;MPL-2.0;MIT OR X11;GPLv2;LGPL;GNUGPL;ISC;Apache-2.0;FreeBSD;BSD-2-Clause;clearbsd;ModifiedBSD;BSD-3-Clause;Python-2.0;Unlicense;WTFPL;BlueOak-1.0.0;CC-BY-4.0;CC-BY-3.0;CC0-1.0;0BSD'",
39
39
  "doc": "typedoc",
40
40
  "test": "vitest --exclude \"test/system-tests/**\" --config test/vitest.config.mts",
41
41
  "test:system": "vitest --dir test/system-tests --config test/system-tests/vitest.config.mts",
@@ -183,7 +183,7 @@
183
183
  "@types/tmp": "^0.2.6",
184
184
  "@types/ws": "^8.18.1",
185
185
  "@typescript-eslint/eslint-plugin": "^8.40.0",
186
- "@vitest/coverage-v8": "^3.2.4",
186
+ "@vitest/coverage-v8": "^4.1.8",
187
187
  "esbuild": "^0.27.2",
188
188
  "eslint": "^9.39.2",
189
189
  "license-checker-rseidelsohn": "^4.4.2",
@@ -195,7 +195,7 @@
195
195
  "typedoc-theme-hierarchy": "^6.0.0",
196
196
  "typedoc-umlclass": "^0.10.2",
197
197
  "typescript": "^5.9.3",
198
- "vitest": "^3.2.4"
198
+ "vitest": "^4.1.8"
199
199
  },
200
200
  "dependencies": {
201
201
  "@davisvaughan/tree-sitter-r": "^1.2.0",
@@ -162,13 +162,17 @@ function getResults(queries, { dataflow, config, normalize }, results, kind, fun
162
162
  }
163
163
  for (const [arg, values] of foundValues.entries()) {
164
164
  for (const value of values) {
165
- const dep = value ? d.getDependency(value) ?? undefined : undefined;
165
+ let resolvedValue = value;
166
+ if (info.stringReplacements && resolvedValue !== undefined && Object.hasOwn(info.stringReplacements, resolvedValue)) {
167
+ resolvedValue = info.stringReplacements[resolvedValue];
168
+ }
169
+ const dep = resolvedValue ? d.getDependency(resolvedValue) ?? undefined : undefined;
166
170
  finalResults.push((0, objects_1.compactRecord)({
167
171
  nodeId: id,
168
172
  functionName: vertex.name,
169
173
  lexemeOfArgument: getLexeme(value, arg),
170
174
  linkedIds: linked?.length ? linked : undefined,
171
- value: value ?? info.defaultValue ?? defaultValue,
175
+ value: resolvedValue ?? info.defaultValue ?? defaultValue,
172
176
  versionConstraints: dep?.versionConstraints,
173
177
  derivedVersion: dep?.derivedVersion,
174
178
  namespaceInfo: dep?.namespaceInfo
@@ -32,4 +32,6 @@ export interface FunctionInfo extends FunctionArgInfo {
32
32
  ignoreIf?: 'arg-missing' | 'mode-only-read' | 'mode-only-write' | 'arg-true' | 'arg-false';
33
33
  /** additional info on arguments - e.g. for the mode flag */
34
34
  additionalArgs?: Record<string, FunctionArgInfo>;
35
+ /** string replacements to apply to resolved values, e.g. `{ '': 'stdin' }` */
36
+ stringReplacements?: Record<string, string>;
35
37
  }
@@ -114,5 +114,7 @@ exports.ReadFunctions = [
114
114
  { package: 'openxlsx', name: 'loadWorkbook', argIdx: 0, argName: 'file', resolveValue: true },
115
115
  { package: 'readODS', name: 'read_ods', argIdx: 0, argName: 'path', resolveValue: true },
116
116
  { package: 'vroom', name: 'vroom', argIdx: 0, argName: 'file', resolveValue: true },
117
+ { package: 'compiler', name: 'loadcmp', argIdx: 0, argName: 'file', resolveValue: true },
118
+ { package: 'compiler', name: 'cmpfile', argIdx: 0, argName: 'infile', resolveValue: true }
117
119
  ];
118
120
  //# sourceMappingURL=read-functions.js.map
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SourceFunctions = void 0;
4
4
  // these lists are originally based on https://github.com/duncantl/CodeDepends/blob/7fd96dfee16b252e5f642c77a7ababf48e9326f8/R/codeTypes.R
5
5
  exports.SourceFunctions = [
6
- { package: 'base', name: 'source', argIdx: 0, argName: 'file', resolveValue: true },
6
+ { package: 'base', name: 'source', argIdx: 0, argName: 'file', resolveValue: true, stringReplacements: { '': 'stdin' } },
7
7
  { package: 'base', name: 'sys.source', argIdx: 0, argName: 'file', resolveValue: true },
8
8
  { package: 'devtools', name: 'source_url', argIdx: 0, argName: 'url', resolveValue: true },
9
9
  { package: 'devtools', name: 'source_gist', argIdx: 0, argName: 'id', resolveValue: true }
@@ -123,5 +123,6 @@ exports.WriteFunctions = [
123
123
  { package: 'rio', name: 'export', argIdx: 1, argName: 'file', resolveValue: true },
124
124
  { package: 'rio', name: 'export_list', argIdx: 1, argName: 'file', resolveValue: true },
125
125
  { package: 'magick', name: 'image_write', argIdx: 1, argName: 'path', resolveValue: true, ignoreIf: 'arg-missing' },
126
+ { package: 'compiler', name: 'cmpfile', argIdx: 1, argName: 'outfile', resolveValue: true }
126
127
  ];
127
128
  //# sourceMappingURL=write-functions.js.map
@@ -4,3 +4,4 @@ export declare const SystemFunctions: Identifier[];
4
4
  export declare const FfiFunctions: Identifier[];
5
5
  export declare const LangFunctions: Identifier[];
6
6
  export declare const OptionsFunctions: Identifier[];
7
+ export declare const UserFunctions: Identifier[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = void 0;
3
+ exports.UserFunctions = exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = void 0;
4
4
  exports.PureFunctions = [
5
5
  'paste', 'paste0', 'parse', '+', '-', '*',
6
6
  '/', '^', '%%', '%/%', '&', '|', '!', '&&', '||',
@@ -47,4 +47,10 @@ exports.LangFunctions = [
47
47
  'sym', 'syms', 'ensym', 'ensyms'
48
48
  ];
49
49
  exports.OptionsFunctions = ['options', 'getOption', 'Sys.getenv'];
50
+ exports.UserFunctions = [
51
+ 'readline', 'scan', 'askYesNo',
52
+ 'file.choose', 'choose.files', 'choose.dir', 'menu', 'select.list', 'winDialogString', 'winDialog',
53
+ 'showPrompt', 'askForPassword', 'selectDirectory', 'selectFile',
54
+ 'dlgInput', 'dlgOpen',
55
+ ];
50
56
  //# sourceMappingURL=input-source-functions.js.map
@@ -22,7 +22,8 @@ exports.DefaultInputClassifierConfig = {
22
22
  [simple_input_classifier_1.InputType.System]: input_source_functions_1.SystemFunctions,
23
23
  [simple_input_classifier_1.InputType.Ffi]: input_source_functions_1.FfiFunctions,
24
24
  [simple_input_classifier_1.InputType.Lang]: input_source_functions_1.LangFunctions,
25
- [simple_input_classifier_1.InputType.Options]: input_source_functions_1.OptionsFunctions
25
+ [simple_input_classifier_1.InputType.Options]: input_source_functions_1.OptionsFunctions,
26
+ [simple_input_classifier_1.InputType.User]: input_source_functions_1.UserFunctions
26
27
  };
27
28
  function inputSourcesQueryLineParser(output, line, _config) {
28
29
  const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
@@ -65,6 +66,7 @@ exports.InputSourcesDefinition = {
65
66
  [simple_input_classifier_1.InputType.Ffi]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that call native code via the R FFI (.C, .Call, .Fortran, .External, dyn.load).'),
66
67
  [simple_input_classifier_1.InputType.Lang]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
67
68
  [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).'),
69
+ [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).'),
68
70
  }).optional()
69
71
  }).description('Input Sources query definition'),
70
72
  flattenInvolvedNodes: (queryResults) => {
@@ -11,7 +11,7 @@ import type { FlowrSearchLike } from '../../../search/flowr-search-builder';
11
11
  *```
12
12
  * [ Unknown ]
13
13
  * |
14
- * [Param] [File] [Net], ...
14
+ * [Param] [File] [Net] [User], ...
15
15
  * |
16
16
  * [ DerivedConstant ]
17
17
  * |
@@ -32,6 +32,8 @@ export declare enum InputType {
32
32
  Lang = "lang",
33
33
  /** Global options / option accessors (options, getOption) */
34
34
  Options = "options",
35
+ /** Interactive user input (file choosers, prompts, dialogs, menu selections) */
36
+ User = "user",
35
37
  Constant = "const",
36
38
  /** Read from environment/call scope */
37
39
  Scope = "scope",
@@ -310,7 +310,7 @@ class InputClassifier {
310
310
  *```
311
311
  * [ Unknown ]
312
312
  * |
313
- * [Param] [File] [Net], ...
313
+ * [Param] [File] [Net] [User], ...
314
314
  * |
315
315
  * [ DerivedConstant ]
316
316
  * |
@@ -332,6 +332,8 @@ var InputType;
332
332
  InputType["Lang"] = "lang";
333
333
  /** Global options / option accessors (options, getOption) */
334
334
  InputType["Options"] = "options";
335
+ /** Interactive user input (file choosers, prompts, dialogs, menu selections) */
336
+ InputType["User"] = "user";
335
337
  InputType["Constant"] = "const";
336
338
  /** Read from environment/call scope */
337
339
  InputType["Scope"] = "scope";
@@ -71,8 +71,34 @@ export declare const flowrCapabilities: {
71
71
  }, {
72
72
  readonly name: "Dynamic Environment Resolution";
73
73
  readonly id: "dynamic-environment-resolution";
74
- readonly supported: "not";
75
- readonly description: "_For example, using `new.env` and friends_";
74
+ readonly supported: "partially";
75
+ readonly description: "_For example, using `new.env` and friends. Supports `new.env`/`new.environment`/`rlang::new_environment`, `assign`/`get`/`local` with `envir=`, dollar-sign access (`e$x`), `attach`, `with`/`within`, and env-variable aliasing (`alias <- e`). Static parent-argument resolution (`parent = e`, `parent = emptyenv()`) is supported._";
76
+ readonly capabilities: readonly [{
77
+ readonly name: "Environment in Conditionals";
78
+ readonly id: "environment-in-conditionals";
79
+ readonly supported: "partially";
80
+ readonly description: "_Tracking environment assignments and reads across if-then-else branches. flowR propagates envState through branch merging, but cross-branch name resolution inside the env is not guaranteed._";
81
+ }, {
82
+ readonly name: "Environment in Loops";
83
+ readonly id: "environment-in-loops";
84
+ readonly supported: "partially";
85
+ readonly description: "_Tracking environment assignments inside loop constructs (for, while, repeat). The env variable is correctly attributed in each iteration body, but dynamic key generation (e.g., `paste0`) prevents static name resolution._";
86
+ }, {
87
+ readonly name: "Environment Parent";
88
+ readonly id: "environment-parent";
89
+ readonly supported: "partially";
90
+ readonly description: "_Specifying a parent for a newly-created environment (`new.env(parent = e)`, `new.env(parent = emptyenv())`). Tracked-env-variable parents and `emptyenv()`/`NULL` are resolved statically; dynamic or unknown parents fall back to the default (`parent.frame()`)._";
91
+ }, {
92
+ readonly name: "Environment Alias";
93
+ readonly id: "environment-alias";
94
+ readonly supported: "partially";
95
+ readonly description: "_Aliasing a tracked environment variable (`alias <- e`). The `envState` snapshot at assignment time is propagated, so assigns made BEFORE the alias are visible through it. Assigns made AFTER the alias to the original variable are not reflected._";
96
+ }, {
97
+ readonly name: "With / Within";
98
+ readonly id: "environment-with";
99
+ readonly supported: "partially";
100
+ readonly description: "_Evaluating an expression inside a named environment with `with(data, expr)` or `within(data, expr)`. When `data` is a tracked env variable, reads of names defined in that env resolve correctly. Writes inside `expr` are ephemeral (not persisted back to the env)._";
101
+ }];
76
102
  }, {
77
103
  readonly name: "Environment Sharing";
78
104
  readonly id: "environment-sharing";