@eagleoutice/flowr 2.15.10 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/README.md +23 -26
  2. package/abstract-interpretation/data-frame/arguments.js +11 -7
  3. package/control-flow/happens-before.d.ts +5 -0
  4. package/control-flow/happens-before.js +48 -34
  5. package/control-flow/useless-loop.d.ts +1 -1
  6. package/control-flow/useless-loop.js +29 -42
  7. package/dataflow/environments/built-in-props.d.ts +9 -0
  8. package/dataflow/environments/built-in-props.js +25 -19
  9. package/dataflow/environments/built-in.d.ts +2 -2
  10. package/dataflow/environments/built-in.js +41 -77
  11. package/dataflow/environments/default-builtin-config.d.ts +181 -29
  12. package/dataflow/environments/default-builtin-config.js +38 -24
  13. package/dataflow/environments/environment.d.ts +6 -4
  14. package/dataflow/environments/environment.js +54 -121
  15. package/dataflow/environments/identifier.d.ts +4 -2
  16. package/dataflow/environments/identifier.js +23 -69
  17. package/dataflow/environments/reference-to-maybe.d.ts +9 -0
  18. package/dataflow/environments/reference-to-maybe.js +23 -51
  19. package/dataflow/environments/resolve-by-name.js +37 -76
  20. package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
  21. package/dataflow/eval/resolve/resolve-argument.js +61 -64
  22. package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
  23. package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
  24. package/dataflow/eval/resolve/resolve.d.ts +4 -0
  25. package/dataflow/eval/resolve/resolve.js +23 -14
  26. package/dataflow/extractor.js +176 -59
  27. package/dataflow/fn/class-declaration.d.ts +8 -2
  28. package/dataflow/fn/class-declaration.js +96 -97
  29. package/dataflow/fn/exceptions-of-function.js +68 -37
  30. package/dataflow/fn/frame-reflection.d.ts +12 -4
  31. package/dataflow/fn/frame-reflection.js +51 -41
  32. package/dataflow/fn/function-props.js +15 -33
  33. package/dataflow/fn/function-semantics.d.ts +11 -3
  34. package/dataflow/fn/function-semantics.js +6 -0
  35. package/dataflow/fn/higher-order-function.js +13 -17
  36. package/dataflow/fn/strict-function.d.ts +13 -0
  37. package/dataflow/fn/strict-function.js +285 -122
  38. package/dataflow/graph/call-graph.d.ts +7 -6
  39. package/dataflow/graph/call-graph.js +35 -46
  40. package/dataflow/graph/graph.d.ts +6 -1
  41. package/dataflow/graph/graph.js +57 -66
  42. package/dataflow/info.d.ts +8 -1
  43. package/dataflow/info.js +24 -30
  44. package/dataflow/internal/control-flow.d.ts +31 -4
  45. package/dataflow/internal/control-flow.js +61 -39
  46. package/dataflow/internal/linker.d.ts +15 -9
  47. package/dataflow/internal/linker.js +253 -241
  48. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
  49. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
  50. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
  52. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
  53. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
  54. package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
  55. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
  56. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
  57. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
  58. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
  59. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  60. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
  61. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
  62. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
  63. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
  64. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
  65. package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
  66. package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
  67. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
  68. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
  69. package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
  70. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
  71. package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
  72. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
  73. package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
  74. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
  75. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
  76. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
  77. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
  78. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
  79. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
  80. package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
  81. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
  83. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
  84. package/dataflow/internal/process/functions/call/common.d.ts +1 -3
  85. package/dataflow/internal/process/functions/call/common.js +36 -76
  86. package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
  87. package/dataflow/internal/process/functions/call/deferred.js +54 -57
  88. package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
  89. package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
  90. package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
  91. package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
  92. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  93. package/dataflow/internal/process/functions/call/quoted.js +162 -172
  94. package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
  95. package/dataflow/internal/process/functions/process-parameter.js +25 -32
  96. package/dataflow/internal/process/process-symbol.js +3 -6
  97. package/dataflow/internal/program-order.d.ts +26 -0
  98. package/dataflow/internal/program-order.js +49 -0
  99. package/documentation/wiki-setup.js +23 -0
  100. package/linter/linter-rules.d.ts +17 -8
  101. package/linter/rules/absolute-path.js +63 -87
  102. package/linter/rules/file-path-validity.d.ts +4 -2
  103. package/linter/rules/file-path-validity.js +114 -80
  104. package/linter/rules/namespace-access.js +21 -33
  105. package/linter/rules/naming-convention.d.ts +1 -1
  106. package/linter/rules/naming-convention.js +60 -48
  107. package/linter/rules/network-functions.js +11 -7
  108. package/linter/rules/no-leaked-credentials.js +15 -18
  109. package/linter/rules/problematic-inputs.d.ts +2 -1
  110. package/linter/rules/problematic-inputs.js +39 -59
  111. package/linter/rules/roxygen-arguments.d.ts +9 -4
  112. package/linter/rules/roxygen-arguments.js +29 -48
  113. package/linter/rules/seeded-randomness.d.ts +7 -4
  114. package/linter/rules/seeded-randomness.js +128 -89
  115. package/linter/rules/stop-with-call-arg.d.ts +4 -2
  116. package/linter/rules/stop-with-call-arg.js +25 -22
  117. package/linter/rules/unclosed-connection.js +31 -24
  118. package/linter/rules/undefined-symbol.d.ts +4 -6
  119. package/linter/rules/undefined-symbol.js +58 -75
  120. package/linter/rules/unescaped-arguments.js +18 -44
  121. package/linter/rules/unused-definition.d.ts +6 -0
  122. package/linter/rules/unused-definition.js +105 -145
  123. package/linter/rules/unused-import.d.ts +3 -0
  124. package/linter/rules/unused-import.js +25 -43
  125. package/package.json +5 -2
  126. package/project/flowr-analyzer.js +6 -2
  127. package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
  128. package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
  129. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
  130. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
  131. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
  132. package/queries/base-query-format.js +1 -2
  133. package/queries/catalog/absint-query/absint-query-format.js +1 -1
  134. package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
  135. package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
  136. package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
  137. package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
  138. package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
  139. package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
  140. package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
  141. package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
  142. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
  143. package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
  144. package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
  145. package/r-bridge/lang-4.x/ast/model/model.js +19 -43
  146. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
  147. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
  148. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
  149. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
  150. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
  151. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
  152. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
  153. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
  154. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
  155. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
  156. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
  157. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
  158. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
  159. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
  160. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
  161. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
  162. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
  163. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
  164. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
  165. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
  166. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
  167. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
  168. package/r-bridge/roxygen2/roxygen-parse.js +28 -42
  169. package/r-bridge/shell.js +6 -0
  170. package/search/search-executor/search-enrichers.js +25 -37
  171. package/slicing/static/slice-call.d.ts +4 -3
  172. package/slicing/static/slice-call.js +56 -88
  173. package/slicing/static/static-slicer.js +115 -79
  174. package/slicing/static/visiting-queue.d.ts +4 -6
  175. package/slicing/static/visiting-queue.js +9 -13
  176. package/util/proc.js +2 -1
  177. package/util/r-base-packages.d.ts +2 -0
  178. package/util/r-base-packages.js +23 -13
  179. package/util/text/playground-link.d.ts +12 -3
  180. package/util/text/playground-link.js +18 -27
  181. package/util/version.js +4 -10
@@ -7,6 +7,7 @@ const range_1 = require("../../util/range");
7
7
  const linter_tags_1 = require("../linter-tags");
8
8
  const vertex_1 = require("../../dataflow/graph/vertex");
9
9
  const edge_1 = require("../../dataflow/graph/edge");
10
+ const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
10
11
  const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
11
12
  const defaultCredentialNamePattern = '(?:password|passwd|pwd|secret|api[_.]?key|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential)';
12
13
  const defaultCredentialValuePattern = '^(?:AKIA|AIPA|ASIA|AROA)[A-Z0-9]{16}' + // AWS access key IDs (exact 20-char format)
@@ -32,27 +33,23 @@ exports.NO_LEAKED_CREDENTIALS = {
32
33
  let totalChecked = 0;
33
34
  const results = elements.getElements().flatMap(element => {
34
35
  totalChecked++;
35
- const name = element.node.lexeme ?? '';
36
- const vertex = dfg.getVertex(element.node.info.id);
37
- if (!vertex_1.DfgVertex.isVariableDefinition(vertex)) {
36
+ const id = element.node.info.id;
37
+ if (!vertex_1.DfgVertex.isVariableDefinition(dfg.getVertex(id))) {
38
38
  return [];
39
39
  }
40
+ const name = element.node.lexeme ?? '';
40
41
  const nameMatches = namePattern.test(name);
41
- for (const [targetId, edge] of dfg.edgesFrom(element.node.info.id)) {
42
- if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy)) {
43
- continue;
44
- }
45
- const targetNode = normalize.idMap.get(targetId);
46
- if (targetNode && r_string_1.RString.is(targetNode) && (nameMatches || valuePattern.test(targetNode.content.str))) {
47
- return [{
48
- certainty: linter_format_1.LintingResultCertainty.Uncertain,
49
- involvedId: element.node.info.id,
50
- variableName: name,
51
- loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid()
52
- }];
53
- }
54
- }
55
- return [];
42
+ /* a credential-like name only leaks a non-empty string, a credential-like value leaks under any name */
43
+ const leaks = (0, frame_reflection_1.edgeTargets)(dfg, id, edge_1.EdgeType.DefinedBy).some(target => {
44
+ const value = normalize.idMap.get(target);
45
+ return r_string_1.RString.is(value) && ((nameMatches && value.content.str !== '') || valuePattern.test(value.content.str));
46
+ });
47
+ return leaks ? [{
48
+ certainty: linter_format_1.LintingResultCertainty.Uncertain,
49
+ involvedId: id,
50
+ variableName: name,
51
+ loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid()
52
+ }] : [];
56
53
  });
57
54
  return { results, '.meta': { totalChecked } };
58
55
  },
@@ -2,6 +2,7 @@ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
3
  import { LintingRuleTag } from '../linter-tags';
4
4
  import type { InputClassifierConfig, InputSources } from '../../queries/catalog/input-sources-query/simple-input-classifier';
5
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
5
6
  export interface PipeCommandFunctionSpec {
6
7
  pattern: string;
7
8
  argIdx: number;
@@ -31,7 +32,7 @@ export declare const PROBLEMATIC_INPUTS: {
31
32
  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.";
32
33
  readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Smell, LintingRuleTag.Readability, LintingRuleTag.Performance];
33
34
  readonly certainty: LintingRuleCertainty.BestEffort;
34
- readonly defaultConfig: (ctx: import("../../project/context/flowr-analyzer-context").ReadOnlyFlowrAnalyzerContext) => {
35
+ readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
35
36
  consider: readonly string[];
36
37
  pipeCommandFunctions: readonly PipeCommandFunctionSpec[];
37
38
  };
@@ -9,8 +9,10 @@ const linter_tags_1 = require("../linter-tags");
9
9
  const simple_input_classifier_1 = require("../../queries/catalog/input-sources-query/simple-input-classifier");
10
10
  const parse_1 = require("../../slicing/criterion/parse");
11
11
  const graph_1 = require("../../dataflow/graph/graph");
12
+ const vertex_1 = require("../../dataflow/graph/vertex");
12
13
  const built_in_props_1 = require("../../dataflow/environments/built-in-props");
13
14
  const identifier_1 = require("../../dataflow/environments/identifier");
15
+ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
14
16
  function defaultConsider(index) {
15
17
  return ['^eval$', ...index.with(built_in_props_1.SemanticCallTag.Process).map(n => `^${identifier_1.Identifier.quote(identifier_1.Identifier.getName(n))}$`)];
16
18
  }
@@ -25,20 +27,16 @@ function normalizePipeSpecs(cfg) {
25
27
  const raw = cfg === undefined ? defaultPipeCommandFunctions
26
28
  : (0, arrays_1.isArray)(cfg) ? (cfg.length === 0 ? defaultPipeCommandFunctions : cfg)
27
29
  : [cfg];
28
- return raw.map(s => ({ pattern: new RegExp(s.pattern), argIdx: s.argIdx, argName: s.argName }));
30
+ return raw.map(s => ({ ...s, pattern: new RegExp(s.pattern) }));
29
31
  }
30
- function formatInputSources(inputs, inline = true) {
31
- if (!inputs || inputs.length === 0) {
32
- return inline ? '' : [];
33
- }
34
- const fmt = (s) => {
32
+ function formatInputSources(inputs, inline) {
33
+ return inputs.map(s => {
35
34
  const t = '[' + s.types.join(',') + ']';
36
35
  const c = s.cds ? ', cds: [' + s.cds.join(',') + ']' : '';
37
36
  return inline
38
37
  ? `${s.id} (type: ${t}, trace: ${s.trace}${c})`
39
38
  : `- ${s.id}: type=${t}, trace=${s.trace}${c}`;
40
- };
41
- return inline ? inputs.map(fmt).join('; ') : inputs.map(fmt);
39
+ });
42
40
  }
43
41
  function hasUnknownSource(sources) {
44
42
  return sources.some(s => s.types.includes(simple_input_classifier_1.InputType.Unknown));
@@ -46,6 +44,7 @@ function hasUnknownSource(sources) {
46
44
  function isProblematicForAllowed(sources, allowed) {
47
45
  return sources.some(s => s.types.some(t => !allowed.includes(t)));
48
46
  }
47
+ /** A path starting with `|` runs a command, so anything but a constant path, user input included, may start one. */
49
48
  function getPipeCommandValue(sources) {
50
49
  for (const s of sources) {
51
50
  if (typeof s.value === 'string' && s.value.startsWith('|')) {
@@ -54,37 +53,19 @@ function getPipeCommandValue(sources) {
54
53
  }
55
54
  return undefined;
56
55
  }
57
- function resolveFileArgId(vertex, argIdx, argName) {
58
- const args = vertex?.args;
59
- if (!args) {
60
- return undefined;
61
- }
62
- let idx = args.findIndex(a => graph_1.FunctionArgument.isNamed(a) && a.name === argName);
63
- if (idx < 0) {
64
- idx = argIdx;
65
- }
66
- if (idx >= args.length) {
56
+ function resolveFileArgId(graph, vertex, argIdx, argName, ctx) {
57
+ if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
67
58
  return undefined;
68
59
  }
69
- const arg = args[idx];
70
- return graph_1.FunctionArgument.isEmpty(arg) ? undefined : graph_1.FunctionArgument.getReference(arg);
71
- }
72
- function checkPipeInjection(nid, loc, name, sources) {
73
- const pipeCmd = getPipeCommandValue(sources);
74
- if (pipeCmd !== undefined) {
75
- return { involvedId: nid, certainty: linter_format_1.LintingResultCertainty.Certain, loc, name, sources, pipeCommand: pipeCmd };
76
- }
77
- if (hasUnknownSource(sources)) {
78
- return { involvedId: nid, certainty: linter_format_1.LintingResultCertainty.Uncertain, loc, name, sources };
79
- }
80
- return undefined;
60
+ const arg = vertex.args[(0, resolve_argument_1.boundArgumentIndex)(graph, vertex, argIdx, argName, ctx)];
61
+ return arg === undefined ? undefined : graph_1.FunctionArgument.getReference(arg);
81
62
  }
82
63
  exports.PROBLEMATIC_INPUTS = {
83
- createSearch: (config) => {
64
+ createSearch: config => {
84
65
  const toQ = (name, subkind) => ({ type: 'call-context', callName: name, callNameExact: false, subkind });
85
66
  return flowr_search_builder_1.Q.fromQuery([
86
67
  ...normalizePatternList(config.consider).map((n, i) => toQ(n, `fn-${i}`)),
87
- ...normalizePipeSpecs(config?.pipeCommandFunctions).map((s, i) => toQ(s.pattern, `pipe-${i}`))
68
+ ...normalizePipeSpecs(config.pipeCommandFunctions).map((s, i) => toQ(s.pattern, `pipe-${i}`))
88
69
  ]);
89
70
  },
90
71
  processSearchResult: async (elements, config, data) => {
@@ -93,7 +74,7 @@ exports.PROBLEMATIC_INPUTS = {
93
74
  const seen = new Set();
94
75
  const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
95
76
  const considerPats = normalizePatternList(config.consider);
96
- const pipePats = normalizePipeSpecs(config?.pipeCommandFunctions);
77
+ const pipePats = normalizePipeSpecs(config.pipeCommandFunctions);
97
78
  for (const element of elements.getElements()) {
98
79
  const nid = element.node.info.id;
99
80
  if (seen.has(nid)) {
@@ -101,33 +82,32 @@ exports.PROBLEMATIC_INPUTS = {
101
82
  }
102
83
  const name = element.node.lexeme ?? '';
103
84
  const pipeSpec = pipePats.find(s => s.pattern.test(name));
104
- const isConsider = pipeSpec === undefined && considerPats.some(p => p.test(name));
105
- if (pipeSpec === undefined && !isConsider) {
106
- continue;
107
- }
108
- const loc = range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid();
85
+ /* a pipe spec checks the file argument of the call, a considered call the call itself */
86
+ let target;
109
87
  if (pipeSpec !== undefined) {
110
- const vertex = df.graph.getVertex(nid);
111
- const fileArgId = resolveFileArgId(vertex, pipeSpec.argIdx, pipeSpec.argName);
112
- if (fileArgId !== undefined) {
113
- const criterion = parse_1.SlicingCriterion.fromId(fileArgId);
114
- const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
115
- const sources = all['input-sources']?.results?.[criterion] ?? [];
116
- const r = checkPipeInjection(nid, loc, name, sources);
117
- if (r !== undefined) {
118
- seen.add(nid);
119
- results.push(r);
120
- }
121
- }
88
+ target = resolveFileArgId(df.graph, df.graph.getVertex(nid), pipeSpec.argIdx, pipeSpec.argName, data.inspectContext());
89
+ }
90
+ else if (considerPats.some(p => p.test(name))) {
91
+ target = nid;
92
+ }
93
+ if (target === undefined) {
94
+ continue;
122
95
  }
123
- else {
124
- const criterion = parse_1.SlicingCriterion.fromId(nid);
125
- const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
126
- const sources = all['input-sources']?.results?.[criterion] ?? [];
127
- if (isProblematicForAllowed(sources, defaultAccept)) {
128
- seen.add(nid);
129
- results.push({ involvedId: nid, certainty: hasUnknownSource(sources) ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain, loc, name, sources });
130
- }
96
+ const criterion = parse_1.SlicingCriterion.fromId(target);
97
+ const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
98
+ const sources = all['input-sources']?.results?.[criterion] ?? [];
99
+ const pipeCommand = pipeSpec === undefined ? undefined : getPipeCommandValue(sources);
100
+ if (pipeCommand !== undefined || isProblematicForAllowed(sources, defaultAccept)) {
101
+ seen.add(nid);
102
+ const uncertain = pipeCommand === undefined && hasUnknownSource(sources);
103
+ results.push({
104
+ involvedId: nid,
105
+ certainty: uncertain ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain,
106
+ loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
107
+ name,
108
+ sources,
109
+ ...(pipeCommand === undefined ? {} : { pipeCommand })
110
+ });
131
111
  }
132
112
  }
133
113
  return { results };
@@ -137,7 +117,7 @@ exports.PROBLEMATIC_INPUTS = {
137
117
  if (result.pipeCommand !== undefined) {
138
118
  return `Pipe command injection via '${result.pipeCommand}' in call to ${result.name} at ${range_1.SourceLocation.format(result.loc)}`;
139
119
  }
140
- const src = formatInputSources(result.sources ?? [], true);
120
+ const src = formatInputSources(result.sources ?? [], true).join('; ');
141
121
  return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + (src ? '; inputs: ' + src : '');
142
122
  },
143
123
  [linter_format_1.LintingPrettyPrintContext.Full]: result => {
@@ -1,7 +1,6 @@
1
- import { type LintingResult, LintingRuleCertainty } from '../linter-format';
1
+ import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
2
2
  import type { MergeableRecord } from '../../util/objects';
3
3
  import { LintingRuleTag } from '../linter-tags';
4
- import type { Writable } from 'ts-essentials';
5
4
  export interface RoxygenArgsResult extends LintingResult {
6
5
  readonly overDocumented?: string[];
7
6
  readonly underDocumented?: string[];
@@ -10,8 +9,14 @@ export type RoxygenArgsConfig = MergeableRecord;
10
9
  export type RoxygenArgsMetadata = MergeableRecord;
11
10
  export declare const ROXYGEN_ARGS: {
12
11
  readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
13
- readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, _config: MergeableRecord) => {
14
- results: Writable<RoxygenArgsResult>[];
12
+ readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>) => {
13
+ results: {
14
+ certainty: LintingResultCertainty.Uncertain;
15
+ involvedId: import("../..").NodeId;
16
+ loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
17
+ underDocumented: string[];
18
+ overDocumented: string[];
19
+ }[];
15
20
  '.meta': {};
16
21
  };
17
22
  readonly prettyPrint: {
@@ -5,27 +5,22 @@ const linter_format_1 = require("../linter-format");
5
5
  const range_1 = require("../../util/range");
6
6
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
7
7
  const linter_tags_1 = require("../linter-tags");
8
- const assert_1 = require("../../util/assert");
9
8
  const vertex_1 = require("../../dataflow/graph/vertex");
10
9
  const roxygen_ast_1 = require("../../r-bridge/roxygen2/roxygen-ast");
11
10
  const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
12
11
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
12
+ const identifier_1 = require("../../dataflow/environments/identifier");
13
13
  function calculateArgumentDiff(inheritedParams, functionParam, roxygenParam) {
14
14
  //match documented against existing params
15
- let underDocumented = new Set(functionParam);
16
- const notOverDocumented = underDocumented.has('...');
17
- let overDocumented = new Set(roxygenParam);
18
- const commonParams = underDocumented.intersection(overDocumented);
19
- underDocumented = underDocumented.difference(commonParams);
20
- overDocumented = overDocumented.difference(commonParams);
15
+ const underDocumented = new Set(functionParam).difference(new Set(roxygenParam));
16
+ let overDocumented = new Set(roxygenParam).difference(new Set(functionParam));
21
17
  //case: '...', overdocumentation not possible
22
- if (notOverDocumented) {
18
+ if (functionParam.includes('...')) {
23
19
  //if still remaining overdocumented parameters, "..." doesn't need to be documented
24
20
  if (overDocumented.size > 0) {
25
21
  underDocumented.delete('...');
26
22
  }
27
- //can't be overdocumented
28
- overDocumented.clear();
23
+ overDocumented = new Set();
29
24
  }
30
25
  //inherited params removed from list of overdocumented params
31
26
  overDocumented = overDocumented.difference(new Set(inheritedParams));
@@ -35,44 +30,30 @@ exports.ROXYGEN_ARGS = {
35
30
  createSearch: () => flowr_search_builder_1.Q.all()
36
31
  .filter(vertex_1.VertexType.FunctionDefinition)
37
32
  .with(search_enrichers_1.Enrichment.Roxygen),
38
- processSearchResult: (elements, _config) => {
39
- return {
40
- results: elements.getElements()
41
- .map(element => ({
42
- element,
43
- underDocumented: [],
44
- overDocumented: []
45
- }))
46
- .filter(({ element, underDocumented, overDocumented }) => {
47
- const roxygen = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.Roxygen);
48
- if (!roxygen.documentation.length) {
49
- return false;
50
- }
51
- //get parameter names
52
- const params = roxygen.tags[roxygen_ast_1.KnownRoxygenTags.Param] ?? [];
53
- const functionParamNames = getParameters(element.node).map(p => p.name.content.toString());
54
- const documented = (tag) => tag.value.name.split(',').map(n => n.trim()).filter(n => n.length > 0);
55
- const inheritedParams = params.filter(tag => tag.inherited).flatMap(documented);
56
- const roxygenParamNames = params.flatMap(documented);
57
- const result = calculateArgumentDiff(inheritedParams ?? [], functionParamNames, roxygenParamNames);
58
- if (result === false) {
59
- return false;
60
- }
61
- underDocumented.push(...result.under);
62
- overDocumented.push(...result.over);
63
- return true;
64
- })
65
- .map(({ element, overDocumented, underDocumented }) => ({
66
- certainty: linter_format_1.LintingResultCertainty.Uncertain,
67
- involvedId: element.node.info.id,
68
- loc: range_1.SourceLocation.fromNode(element.node),
69
- underDocumented: underDocumented,
70
- overDocumented: overDocumented
71
- }))
72
- .filter(element => (0, assert_1.isNotUndefined)(element.loc)),
73
- '.meta': {}
74
- };
75
- },
33
+ processSearchResult: elements => ({
34
+ results: elements.getElements().flatMap(element => {
35
+ const node = element.node;
36
+ const roxygen = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.Roxygen);
37
+ if (!roxygen.documentation.length) {
38
+ return [];
39
+ }
40
+ const params = roxygen.tags[roxygen_ast_1.KnownRoxygenTags.Param] ?? [];
41
+ const functionParamNames = getParameters(node).map(p => identifier_1.Identifier.make(identifier_1.Identifier.getName(p.name.content)).toString());
42
+ /* one `@param a,b` documents several parameters */
43
+ const documented = (tag) => tag.value.name.split(',').map(n => n.trim()).filter(n => n.length > 0);
44
+ const inheritedParams = params.filter(tag => tag.inherited).flatMap(documented);
45
+ const diff = calculateArgumentDiff(inheritedParams, functionParamNames, params.flatMap(documented));
46
+ const loc = range_1.SourceLocation.fromNode(node);
47
+ return diff === false || loc === undefined ? [] : [{
48
+ certainty: linter_format_1.LintingResultCertainty.Uncertain,
49
+ involvedId: node.info.id,
50
+ loc,
51
+ underDocumented: diff.under,
52
+ overDocumented: diff.over
53
+ }];
54
+ }),
55
+ '.meta': {}
56
+ }),
76
57
  prettyPrint: {
77
58
  [linter_format_1.LintingPrettyPrintContext.Query]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`,
78
59
  [linter_format_1.LintingPrettyPrintContext.Full]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`
@@ -30,7 +30,7 @@ export interface SeededRandomnessMeta extends MergeableRecord {
30
30
  callsWithOtherBranchProducers: number;
31
31
  }
32
32
  export declare const SEEDED_RANDOMNESS: {
33
- readonly createSearch: (config: SeededRandomnessConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
33
+ readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
34
34
  readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
35
35
  results: {
36
36
  involvedId: NodeId;
@@ -42,10 +42,13 @@ export declare const SEEDED_RANDOMNESS: {
42
42
  }>;
43
43
  readonly info: {
44
44
  readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
45
- randomnessProducers: {
46
- type: "function" | "assignment";
45
+ randomnessProducers: ({
46
+ readonly type: "function";
47
+ readonly name: string;
48
+ } | {
49
+ type: "assignment";
47
50
  name: string;
48
- }[];
51
+ })[];
49
52
  randomnessConsumers: string[];
50
53
  };
51
54
  readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility];