@eagleoutice/flowr 2.17.0 → 2.17.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 (134) hide show
  1. package/README.md +8 -8
  2. package/config.d.ts +32 -0
  3. package/config.js +22 -2
  4. package/control-flow/semantic-cfg-guided-visitor.js +2 -0
  5. package/dataflow/environments/ambient-state-name.d.ts +4 -0
  6. package/dataflow/environments/ambient-state-name.js +4 -0
  7. package/dataflow/environments/built-in-proc-name.d.ts +4 -0
  8. package/dataflow/environments/built-in-proc-name.js +4 -0
  9. package/dataflow/environments/built-in-props.d.ts +18 -2
  10. package/dataflow/environments/built-in-props.js +26 -4
  11. package/dataflow/environments/built-in.d.ts +16 -6
  12. package/dataflow/environments/built-in.js +58 -7
  13. package/dataflow/environments/default-builtin-config.d.ts +1245 -159
  14. package/dataflow/environments/default-builtin-config.js +191 -38
  15. package/dataflow/environments/environment.d.ts +19 -2
  16. package/dataflow/environments/environment.js +90 -19
  17. package/dataflow/environments/identifier.d.ts +25 -1
  18. package/dataflow/environments/query-fn-props.js +4 -3
  19. package/dataflow/environments/resolve-by-name.js +5 -3
  20. package/dataflow/eval/resolve/node-value.d.ts +1 -1
  21. package/dataflow/eval/resolve/node-value.js +2 -2
  22. package/dataflow/eval/resolve/resolve-argument.js +1 -1
  23. package/dataflow/extractor.js +68 -17
  24. package/dataflow/fn/function-semantics.d.ts +1 -0
  25. package/dataflow/graph/df-helper.d.ts +34 -1
  26. package/dataflow/graph/df-helper.js +60 -0
  27. package/dataflow/info.d.ts +2 -0
  28. package/dataflow/info.js +4 -0
  29. package/dataflow/internal/linker.js +21 -5
  30. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +4 -0
  31. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +3 -0
  32. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +18 -2
  33. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +144 -30
  34. package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +1 -1
  35. package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +2 -1
  36. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +1 -1
  37. package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -0
  38. package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +8 -4
  39. package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +43 -8
  40. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.d.ts +1 -1
  41. package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +5 -4
  42. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +67 -3
  43. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +4 -2
  44. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +27 -3
  45. package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
  46. package/dataflow/internal/process/functions/call/built-in/built-in-get.js +2 -14
  47. package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +1 -7
  48. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +28 -10
  49. package/dataflow/internal/process/functions/call/built-in/built-in-library.js +134 -88
  50. package/dataflow/internal/process/functions/call/built-in/built-in-load.d.ts +1 -1
  51. package/dataflow/internal/process/functions/call/built-in/built-in-load.js +87 -10
  52. package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +8 -0
  53. package/dataflow/internal/process/functions/call/built-in/built-in-local.js +23 -12
  54. package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +7 -1
  55. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +28 -10
  56. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -1
  57. package/dataflow/internal/process/functions/call/built-in/built-in-with.js +7 -5
  58. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +2 -2
  59. package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +18 -15
  60. package/dataflow/internal/process/functions/call/named-call-handling.js +8 -4
  61. package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
  62. package/dataflow/internal/process/functions/call/quoted.js +8 -7
  63. package/documentation/wiki-dataflow-graph.js +20 -1
  64. package/linter/rules/network-functions.js +10 -2
  65. package/linter/rules/undefined-symbol.js +2 -2
  66. package/linter/rules/unused-import.js +11 -1
  67. package/package.json +1 -1
  68. package/project/attached-packages.d.ts +11 -6
  69. package/project/attached-packages.js +37 -9
  70. package/project/cache/flowr-analyzer-cache.d.ts +4 -0
  71. package/project/cache/flowr-analyzer-cache.js +11 -0
  72. package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -0
  73. package/project/context/flowr-analyzer-dependencies-context.js +6 -0
  74. package/project/context/flowr-file.d.ts +2 -2
  75. package/project/context/flowr-file.js +2 -2
  76. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +39 -4
  77. package/project/plugins/file-plugins/files/flowr-manifest-files.js +134 -30
  78. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
  79. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +7 -0
  80. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +14 -1
  81. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
  82. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
  83. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +18 -5
  84. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +43 -15
  85. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +12 -0
  86. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -2
  87. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +58 -0
  88. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +237 -0
  89. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +8 -0
  90. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +8 -0
  91. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +7 -0
  92. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +24 -18
  93. package/project/plugins/plugin-registry.d.ts +5 -4
  94. package/project/plugins/plugin-registry.js +6 -0
  95. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
  96. package/project/sigdb/decode.js +13 -3
  97. package/project/sigdb/memory-source.d.ts +6 -4
  98. package/project/sigdb/memory-source.js +6 -5
  99. package/project/sigdb/on-demand/fetch.d.ts +18 -0
  100. package/project/sigdb/on-demand/fetch.js +127 -0
  101. package/project/sigdb/on-demand/package-sources.d.ts +40 -0
  102. package/project/sigdb/on-demand/package-sources.js +263 -0
  103. package/project/sigdb/on-demand/recoverer.d.ts +40 -0
  104. package/project/sigdb/on-demand/recoverer.js +169 -0
  105. package/project/sigdb/on-demand/remote-sources.d.ts +72 -0
  106. package/project/sigdb/on-demand/remote-sources.js +132 -0
  107. package/project/sigdb/on-demand/tar.d.ts +19 -0
  108. package/project/sigdb/on-demand/tar.js +119 -0
  109. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +5 -0
  110. package/queries/catalog/dependencies-query/function-info/derived-functions.js +17 -1
  111. package/queries/catalog/dependencies-query/function-info/read-functions.js +3 -1
  112. package/queries/catalog/dependencies-query/function-info/write-functions.js +11 -1
  113. package/queries/catalog/signature-query/signature-query-executor.js +15 -1
  114. package/queries/catalog/signature-query/signature-query-format.d.ts +3 -2
  115. package/r-bridge/data/data.d.ts +31 -2
  116. package/r-bridge/data/data.js +25 -2
  117. package/r-bridge/lang-4.x/ast/model/model.d.ts +2 -0
  118. package/r-bridge/lang-4.x/ast/model/model.js +6 -1
  119. package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -1
  120. package/r-bridge/lang-4.x/ast/model/processing/node-id.js +12 -1
  121. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +4 -0
  122. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +8 -0
  123. package/reconstruct/reconstruct.js +2 -5
  124. package/search/search-executor/search-enrichers.js +17 -2
  125. package/search/search-executor/search-generators.js +6 -2
  126. package/slicing/static/slice-call.d.ts +16 -0
  127. package/slicing/static/slice-call.js +42 -0
  128. package/slicing/static/static-slicer.js +6 -0
  129. package/taint-analysis/predefined/secret-analysis.js +7 -2
  130. package/taint-analysis/taint-mapping.d.ts +5 -2
  131. package/taint-analysis/taint-mapping.js +17 -6
  132. package/util/flowr-version.d.ts +1 -1
  133. package/util/flowr-version.js +2 -2
  134. package/util/r-version.js +4 -2
@@ -227,8 +227,8 @@ export declare const flowrCapabilities: {
227
227
  readonly name: "Dynamic Search Path";
228
228
  readonly id: "dynamic-search-path";
229
229
  readonly code: readonly ["search", "searchpaths"];
230
- readonly supported: "not";
231
- readonly description: "_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ None of this is modelled, and `search()` reads as an unknown call.";
230
+ readonly supported: "partially";
231
+ readonly description: "_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ `search()` and `searchpaths()` read every `library`, `attach`, and `detach` before them, and `detach`/`unloadNamespace` remove the entry they name, but `search()` itself is not computed as a value.";
232
232
  readonly example: string;
233
233
  readonly url: [{
234
234
  name: string;
@@ -1560,6 +1560,18 @@ export declare const flowrCapabilities: {
1560
1560
  readonly name: "uvr";
1561
1561
  readonly href: "https://github.com/nbafrank/uvr";
1562
1562
  }];
1563
+ }, {
1564
+ readonly name: "rig";
1565
+ readonly id: "version-manager-rig";
1566
+ readonly supported: "fully";
1567
+ readonly description: "_Read the configuration of [rig](https://rig.r-lib.org/proj-guide.html) projects and scripts._ Parses `rproj.toml`, the inline `# /// script` block a script declares its dependencies in, and the resolved `rproj.lock` or `<script>.R.lock`.";
1568
+ readonly url: [{
1569
+ name: string;
1570
+ href: string;
1571
+ }, {
1572
+ readonly name: "rig";
1573
+ readonly href: "https://rig.r-lib.org/scripts.html";
1574
+ }];
1563
1575
  }, {
1564
1576
  readonly name: "Installed Library";
1565
1577
  readonly id: "project-library";
@@ -1569,6 +1581,16 @@ export declare const flowrCapabilities: {
1569
1581
  name: string;
1570
1582
  href: string;
1571
1583
  }];
1584
+ }, {
1585
+ readonly name: "On-Demand Package Sources";
1586
+ readonly id: "project-on-demand-sources";
1587
+ readonly supported: "partially";
1588
+ readonly description: "_Fetch the source of a package no signature database knows when the code uses it, from CRAN, Bioconductor, or GitHub (`solver.sigdb.onDemand`)._ The repository comes from an `install_github`-style call, the `Remotes` of the `DESCRIPTION`, or the configuration. The exports come from the `NAMESPACE` (an `exportPattern` matched against the names the code defines) and the formals from the functions the `R/` files define at the top level, cached per package so a later analysis works offline. A fetched package counts as untrusted: its code is parsed, never run, only `https` to public hosts (or the configured mirrors) is used, what it states is cut down to names, formals, and a version, and it cannot take over a function that matters to security (`system`, `eval`, file and network calls), so those keep being found. Only a trusted configuration can switch this on. Function bodies are not analyzed, and a package loaded under a name only known at run time is not fetched.";
1589
+ readonly example: string;
1590
+ readonly url: [{
1591
+ name: string;
1592
+ href: string;
1593
+ }];
1572
1594
  }];
1573
1595
  }, {
1574
1596
  readonly name: "Startup and Discovery";
@@ -1648,6 +1670,13 @@ export declare const flowrCapabilities: {
1648
1670
  name: string;
1649
1671
  href: string;
1650
1672
  }];
1673
+ }, {
1674
+ readonly name: "File Dependencies";
1675
+ readonly id: "file-dependencies";
1676
+ readonly code: readonly ["file.copy", "unzip", "untar", "zip", "archive::archive_extract", "R.utils::gunzip"];
1677
+ readonly supported: "partially";
1678
+ readonly description: "_A file read after a call that wrote it, also when the call copies, moves, packs, or unpacks it._ A read of a file links to the earlier writes of a file of the same name, and calls like `file.copy(from, to)` or `unzip(zipfile, exdir)` read the files of some arguments and write those of others, so `read.csv(\"data/b.csv\")` after `unzip(\"a.zip\", exdir = \"data\")` keeps the `unzip` and whatever wrote `a.zip`. What an archive holds is unknown, so unpacking one counts as writing any file, and a read of a file nothing named before reads every such write. Paths are compared by name, not against the working directory.";
1679
+ readonly example: string;
1651
1680
  }, {
1652
1681
  readonly name: "Foreign Function Interface";
1653
1682
  readonly id: "foreign-function-interface";
@@ -217,8 +217,8 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
217
217
  name: 'Dynamic Search Path',
218
218
  id: 'dynamic-search-path',
219
219
  code: ['search', 'searchpaths'],
220
- supported: 'not',
221
- description: '_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ None of this is modelled, and `search()` reads as an unknown call.',
220
+ supported: 'partially',
221
+ description: '_Programmatically inspecting or mutating the search path with `search()`, `searchpaths()`, or detaching by position._ `search()` and `searchpaths()` read every `library`, `attach`, and `detach` before them, and `detach`/`unloadNamespace` remove the entry they name, but `search()` itself is not computed as a value.',
222
222
  example: (0, doc_code_1.codeBlock)('r', 'library(stats)\nn <- search()\nprint(n[2])'),
223
223
  url: [RLang('Search path')]
224
224
  },
@@ -1362,12 +1362,27 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
1362
1362
  description: '_Read the configuration of [uvr](https://github.com/nbafrank/uvr), an R project manager modelled on uv._ Parses `uvr.toml` and the `uvr.lock` beside it.',
1363
1363
  url: [Plugin('src/project/plugins/file-plugins/files/flowr-manifest-files.ts'), { name: 'uvr', href: 'https://github.com/nbafrank/uvr' }]
1364
1364
  },
1365
+ {
1366
+ name: 'rig',
1367
+ id: 'version-manager-rig',
1368
+ supported: 'fully',
1369
+ description: '_Read the configuration of [rig](https://rig.r-lib.org/proj-guide.html) projects and scripts._ Parses `rproj.toml`, the inline `# /// script` block a script declares its dependencies in, and the resolved `rproj.lock` or `<script>.R.lock`.',
1370
+ url: [Plugin('src/project/plugins/file-plugins/files/flowr-manifest-files.ts'), { name: 'rig', href: 'https://rig.r-lib.org/scripts.html' }]
1371
+ },
1365
1372
  {
1366
1373
  name: 'Installed Library',
1367
1374
  id: 'project-library',
1368
1375
  supported: 'partially',
1369
1376
  description: '_Read the package library a project installs into (`renv/library`, `packrat/lib`, or the platform library)._ Their code is not read.',
1370
1377
  url: [Plugin('src/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.ts')]
1378
+ },
1379
+ {
1380
+ name: 'On-Demand Package Sources',
1381
+ id: 'project-on-demand-sources',
1382
+ supported: 'partially',
1383
+ description: '_Fetch the source of a package no signature database knows when the code uses it, from CRAN, Bioconductor, or GitHub (`solver.sigdb.onDemand`)._ The repository comes from an `install_github`-style call, the `Remotes` of the `DESCRIPTION`, or the configuration. The exports come from the `NAMESPACE` (an `exportPattern` matched against the names the code defines) and the formals from the functions the `R/` files define at the top level, cached per package so a later analysis works offline. A fetched package counts as untrusted: its code is parsed, never run, only `https` to public hosts (or the configured mirrors) is used, what it states is cut down to names, formals, and a version, and it cannot take over a function that matters to security (`system`, `eval`, file and network calls), so those keep being found. Only a trusted configuration can switch this on. Function bodies are not analyzed, and a package loaded under a name only known at run time is not fetched.',
1384
+ example: (0, doc_code_1.codeBlock)('r', 'remotes::install_github("masurp/ggmirt")\nlibrary(ggmirt)\ntracePlot(fit, theta_range = c(-3, 3))'),
1385
+ url: [Plugin('src/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.ts')]
1371
1386
  }
1372
1387
  ]
1373
1388
  },
@@ -1446,6 +1461,14 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
1446
1461
  example: (0, doc_code_1.codeBlock)('r', 'd <- read.csv("in.csv")\nwrite.csv(d, "out.csv")'),
1447
1462
  url: [RLang('Operating system access')]
1448
1463
  },
1464
+ {
1465
+ name: 'File Dependencies',
1466
+ id: 'file-dependencies',
1467
+ code: ['file.copy', 'unzip', 'untar', 'zip', 'archive::archive_extract', 'R.utils::gunzip'],
1468
+ supported: 'partially',
1469
+ description: '_A file read after a call that wrote it, also when the call copies, moves, packs, or unpacks it._ A read of a file links to the earlier writes of a file of the same name, and calls like `file.copy(from, to)` or `unzip(zipfile, exdir)` read the files of some arguments and write those of others, so `read.csv("data/b.csv")` after `unzip("a.zip", exdir = "data")` keeps the `unzip` and whatever wrote `a.zip`. What an archive holds is unknown, so unpacking one counts as writing any file, and a read of a file nothing named before reads every such write. Paths are compared by name, not against the working directory.',
1470
+ example: (0, doc_code_1.codeBlock)('r', 'download.file("https://example.org/a.zip", "a.zip")\nunzip("a.zip", exdir = "data")\nd <- read.csv("data/b.csv")')
1471
+ },
1449
1472
  {
1450
1473
  name: 'Foreign Function Interface',
1451
1474
  id: 'foreign-function-interface',
@@ -161,6 +161,8 @@ export declare const RLoopConstructs: {
161
161
  * A set of all types of loop constructs in the normalized AST, i.e. for, repeat and while loops.
162
162
  */
163
163
  readonly loopConstructTypes: ReadonlySet<RType>;
164
+ /** Whether `id` may run again in the same frame, as part of a loop not left through a function definition. */
165
+ readonly encloses: <OtherInfo>(this: void, id: NodeId, idMap: AstIdMap<OtherInfo & ParentInformation>) => boolean;
164
166
  };
165
167
  /**
166
168
  * As an extension to {@link RLoopConstructs}, this subtype of {@link RNode} includes
@@ -61,7 +61,12 @@ exports.RLoopConstructs = {
61
61
  /**
62
62
  * A set of all types of loop constructs in the normalized AST, i.e. for, repeat and while loops.
63
63
  */
64
- loopConstructTypes: new Set([type_1.RType.ForLoop, type_1.RType.RepeatLoop, type_1.RType.WhileLoop])
64
+ loopConstructTypes: new Set([type_1.RType.ForLoop, type_1.RType.RepeatLoop, type_1.RType.WhileLoop]),
65
+ /** Whether `id` may run again in the same frame, as part of a loop not left through a function definition. */
66
+ encloses(id, idMap) {
67
+ const enclosing = exports.RNode.findEnclosing(id, idMap, n => r_function_definition_1.RFunctionDefinition.is(n) || exports.RLoopConstructs.is(n));
68
+ return enclosing !== undefined && !r_function_definition_1.RFunctionDefinition.is(idMap.get(enclosing));
69
+ }
65
70
  };
66
71
  /**
67
72
  * Helper for working with {@link RConstructs} AST nodes.
@@ -1,5 +1,6 @@
1
- import type { AstIdMap } from './decorate';
1
+ import type { AstIdMap, ParentInformation } from './decorate';
2
2
  import type { DataflowGraph } from '../../../../../dataflow/graph/graph';
3
+ import { RNode } from '../model';
3
4
  import type { BuiltInProcName } from '../../../../../dataflow/environments/built-in-proc-name';
4
5
  /**
5
6
  * The type of the id assigned to each node. Branded to avoid problematic usages with other string or numeric types.
@@ -85,6 +86,10 @@ export declare const NodeId: {
85
86
  * @see {@link NodeId.recoverContent} - for what a call or a use stands for rather than how it is written
86
87
  */
87
88
  readonly recoverName: (this: void, id: NodeId, idMap?: AstIdMap) => string | undefined;
89
+ /** The id of the call the dataflow graph makes up for an anonymous function a call runs (`lapply(x, function(v) v)`, a `tryCatch` handler). */
90
+ readonly anonymousCall: (this: void, functionId: NodeId) => NodeId;
91
+ /** The node `id` belongs to; for a made-up {@link NodeId.anonymousCall} the anonymous function it calls. */
92
+ readonly nodeOf: <Info>(this: void, id: NodeId, idMap: AstIdMap<Info> | undefined) => RNode<Info & ParentInformation> | undefined;
88
93
  /**
89
94
  * The name the {@link RNode|node} the id belongs to binds or reads, without the backticks or quotes R lets it be
90
95
  * written in (`"x"` and `x` in backticks both name `x`), which is how the environments know it.
@@ -11,6 +11,8 @@ function startsNumeric(id) {
11
11
  const c = id.charCodeAt(0);
12
12
  return c >= 48 && c <= 57 /* 0-9 */ || c === 45 /* - */ || c === 43 /* + */ || c === 46;
13
13
  }
14
+ /** see {@link NodeId.anonymousCall} */
15
+ const AnonymousCallPrefix = 'anon-';
14
16
  /**
15
17
  * What a {@link NodeId} is: the identity of a node within one analysis, plus the built-in and `pkg::fn`
16
18
  * names encoded as one, and the ways to read a name back out of it.
@@ -116,7 +118,16 @@ exports.NodeId = {
116
118
  * @see {@link NodeId.recoverContent} - for what a call or a use stands for rather than how it is written
117
119
  */
118
120
  recoverName(id, idMap) {
119
- return idMap?.get(id)?.lexeme;
121
+ return exports.NodeId.nodeOf(id, idMap)?.lexeme;
122
+ },
123
+ /** The id of the call the dataflow graph makes up for an anonymous function a call runs (`lapply(x, function(v) v)`, a `tryCatch` handler). */
124
+ anonymousCall(functionId) {
125
+ return AnonymousCallPrefix + String(functionId);
126
+ },
127
+ /** The node `id` belongs to; for a made-up {@link NodeId.anonymousCall} the anonymous function it calls. */
128
+ nodeOf(id, idMap) {
129
+ const node = idMap?.get(id);
130
+ return node !== undefined || typeof id !== 'string' || !id.startsWith(AnonymousCallPrefix) ? node : idMap?.get(exports.NodeId.normalize(id.slice(AnonymousCallPrefix.length)));
120
131
  },
121
132
  /**
122
133
  * The name the {@link RNode|node} the id belongs to binds or reads, without the backticks or quotes R lets it be
@@ -29,6 +29,10 @@ export declare class TreeSitterExecutor implements SyncParser<Parser.Tree> {
29
29
  parse(request: RParseRequest & {
30
30
  filePath?: string;
31
31
  }, ctx: FlowrAnalyzerContext): Parser.Tree;
32
+ /** Parses code that belongs to no analysis, like the sources of a package, without incremental reparsing. */
33
+ parseCode(code: string): Parser.Tree;
34
+ /** Whether {@link initTreeSitter} has loaded the R grammar, which every parser needs. */
35
+ static isInitialized(): boolean;
32
36
  createQuery(source: string): Query;
33
37
  query(source: Query | string, ...tree: readonly Parser.Tree[]): QueryCapture[];
34
38
  close(): void;
@@ -98,6 +98,14 @@ class TreeSitterExecutor {
98
98
  previousTree.edit(reparseInfo.editRegion);
99
99
  return this.parser.parse(sourceCode, previousTree);
100
100
  }
101
+ /** Parses code that belongs to no analysis, like the sources of a package, without incremental reparsing. */
102
+ parseCode(code) {
103
+ return this.parser.parse(code);
104
+ }
105
+ /** Whether {@link initTreeSitter} has loaded the R grammar, which every parser needs. */
106
+ static isInitialized() {
107
+ return TreeSitterExecutor.language !== undefined;
108
+ }
101
109
  createQuery(source) {
102
110
  return this.parser.getLanguage().query(source);
103
111
  }
@@ -402,11 +402,8 @@ function reconstructFunctionCall(call, functionName, args, configuration) {
402
402
  }
403
403
  if (!selected) {
404
404
  const f = args.filter(a => a !== r_function_call_1.EmptyArgument && a.length !== 0);
405
- if (f.length === 0) {
406
- return [];
407
- }
408
- else if (f.length === 1) {
409
- return f[0];
405
+ if (f.length <= 1 || (call.infixSpecial !== true && functionName.length === 0)) {
406
+ return f.flat();
410
407
  }
411
408
  }
412
409
  if (call.infixSpecial === true) {
@@ -13,6 +13,11 @@ const identify_link_to_last_call_relation_1 = require("../../queries/catalog/cal
13
13
  const identifier_1 = require("../../dataflow/environments/identifier");
14
14
  const df_helper_1 = require("../../dataflow/graph/df-helper");
15
15
  const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
16
+ /** The search element of the node `id` belongs to (see {@link NodeId.nodeOf}), `undefined` if there is none. */
17
+ function elementOf(id, idMap) {
18
+ const node = node_id_1.NodeId.nodeOf(id, idMap);
19
+ return node === undefined ? undefined : { node };
20
+ }
16
21
  /**
17
22
  * An enumeration that stores the names of the available enrichments that can be applied to a set of search elements.
18
23
  * See {@link FlowrSearchBuilder.with} for more information on how to apply enrichments.
@@ -44,6 +49,13 @@ function collectAliveNodes(ast, reachable) {
44
49
  alive.add(node.info.id);
45
50
  }
46
51
  }
52
+ /* a node the analysis made up for a call (the variables `load` restores) is no code of its own, it runs with the call */
53
+ for (const [id, node] of ast.idMap) {
54
+ const parent = node.info.parent === undefined || !alive.has(node.info.parent) ? undefined : ast.idMap.get(node.info.parent);
55
+ if (parent !== undefined && !alive.has(id) && !model_1.RNode.directChildren(parent).includes(node)) {
56
+ alive.add(id);
57
+ }
58
+ }
47
59
  return alive;
48
60
  }
49
61
  /**
@@ -132,7 +144,7 @@ exports.Enrichments = {
132
144
  // user-code node, so surface it as a built-in identifier (see `onlyBuiltin` above)
133
145
  return qualifyIdentifier([o], node_id_1.NodeId.recoverName(o.id, n.idMap)) ?? String(o.id);
134
146
  }
135
- return { node: n.idMap.get(o.id) };
147
+ return elementOf(o.id, n.idMap);
136
148
  case 3 /* OriginType.BuiltInFunctionOrigin */: {
137
149
  /* an alias (`s <- system; s()`) calls the built-in it is linked to rather than its own name */
138
150
  const linked = node_id_1.NodeId.isBuiltIn(o.proc) ? node_id_1.NodeId.toPkgFn(o.proc)?.[1] ?? node_id_1.NodeId.fromBuiltIn(o.proc) : undefined;
@@ -177,7 +189,10 @@ exports.Enrichments = {
177
189
  type: 'link-to-last-call',
178
190
  });
179
191
  for (const lastCall of lastCalls) {
180
- content.linkedIds.push({ node: n.idMap.get(lastCall) });
192
+ const linked = elementOf(lastCall, n.idMap);
193
+ if (linked !== undefined) {
194
+ content.linkedIds.push(linked);
195
+ }
181
196
  }
182
197
  }
183
198
  }
@@ -4,6 +4,7 @@ exports.generators = exports.searchLogger = void 0;
4
4
  exports.getGenerator = getGenerator;
5
5
  const flowr_search_1 = require("../flowr-search");
6
6
  const parse_1 = require("../../slicing/criterion/parse");
7
+ const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
7
8
  const assert_1 = require("../../util/assert");
8
9
  const range_1 = require("../../util/range");
9
10
  const query_1 = require("../../queries/query");
@@ -90,8 +91,11 @@ async function generateFromQuery(input, args) {
90
91
  }
91
92
  const nodes = new Set();
92
93
  const queryDef = query_1.SupportedQueries[query];
93
- for (const node of (queryDef.flattenInvolvedNodes?.(content, args.from, args.certainty) ?? [])) {
94
- nodes.add({ node: idMap.get(node) });
94
+ for (const id of (queryDef.flattenInvolvedNodes?.(content, args.from, args.certainty) ?? [])) {
95
+ const node = node_id_1.NodeId.nodeOf(id, idMap);
96
+ if (node !== undefined) {
97
+ nodes.add({ node });
98
+ }
95
99
  }
96
100
  nodesByQuery.set(query, nodes);
97
101
  }
@@ -8,6 +8,7 @@ import { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
8
8
  import type { DataflowInformation } from '../../dataflow/info';
9
9
  import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
10
10
  import type { AstIdMap } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
11
+ import { FnSig } from '../../dataflow/environments/built-in-props';
11
12
  /**
12
13
  * Returns the function call targets (definitions) by the given caller
13
14
  */
@@ -33,3 +34,18 @@ export declare function sliceReachesFunctionInterface(fnDefId: NodeId, graph: Da
33
34
  export declare function includeCalleesOfDefinition(fnDefId: NodeId, graph: DataflowGraph, queue: VisitingQueue, baseEnvironment: REnvironmentInformation, baseEnvFingerprint: Fingerprint): NodeId[];
34
35
  /** Returns true if we found at least one return edge */
35
36
  export declare function handleReturns(from: NodeId, queue: VisitingQueue, currentEdges: ReadonlyOutgoingEdges, baseEnvFingerprint: Fingerprint, baseEnvironment: REnvironmentInformation): boolean;
37
+ /** What decides whether a call runs code elsewhere: the role of each argument, and whether it evaluates code (`eval`) at all. */
38
+ interface DeferringInfo {
39
+ readonly sig?: FnSig;
40
+ readonly evaluates: boolean;
41
+ }
42
+ /**
43
+ * The built-in call that decides when, where or whether the code at `id` runs: the closest call it is an argument
44
+ * of that quotes it or calls it (`on.exit(expr)`, `do.call("f", args)`, `delayedAssign(x, expr)`), up to the
45
+ * function it is defined in. Without that call, the code would run in the order of the caller. A call capturing
46
+ * its argument for another call to evaluate is left to the evaluation of captured code, as that one drops it
47
+ * where the captured code is run in place.
48
+ * @param sigs - the signatures of the calls met on the way, filled as they are asked for
49
+ */
50
+ export declare function deferringCall(id: NodeId, info: DataflowInformation, idMap: AstIdMap, sigs: Map<NodeId, DeferringInfo>): NodeId | undefined;
51
+ export {};
@@ -5,6 +5,7 @@ exports.sliceForCall = sliceForCall;
5
5
  exports.sliceReachesFunctionInterface = sliceReachesFunctionInterface;
6
6
  exports.includeCalleesOfDefinition = includeCalleesOfDefinition;
7
7
  exports.handleReturns = handleReturns;
8
+ exports.deferringCall = deferringCall;
8
9
  const assert_1 = require("../../util/assert");
9
10
  const fingerprint_1 = require("./fingerprint");
10
11
  const linker_1 = require("../../dataflow/internal/linker");
@@ -19,6 +20,11 @@ const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
19
20
  const vertex_1 = require("../../dataflow/graph/vertex");
20
21
  const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
21
22
  const df_helper_1 = require("../../dataflow/graph/df-helper");
23
+ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
24
+ const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
25
+ const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
26
+ const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
27
+ const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
22
28
  const NoCallTargets = new Set();
23
29
  const linkedByGraph = new WeakMap();
24
30
  function linkedFunctionsOf(defs, graph) {
@@ -163,4 +169,40 @@ function handleReturns(from, queue, currentEdges, baseEnvFingerprint, baseEnviro
163
169
  }
164
170
  return true;
165
171
  }
172
+ /** What a call states of an argument it does not evaluate where and when it stands: quoted, or called as a function. */
173
+ const RunsElsewhere = built_in_props_1.ArgProp.Nse | built_in_props_1.ArgProp.Callee;
174
+ /** A promise the call does not force may run any number of times, or never, as with `replicate(n, expr)`. */
175
+ function runsElsewhere(prop) {
176
+ return (prop & RunsElsewhere) !== 0 || (prop & (built_in_props_1.ArgProp.Value | built_in_props_1.ArgProp.Forced)) === built_in_props_1.ArgProp.Value;
177
+ }
178
+ /**
179
+ * The built-in call that decides when, where or whether the code at `id` runs: the closest call it is an argument
180
+ * of that quotes it or calls it (`on.exit(expr)`, `do.call("f", args)`, `delayedAssign(x, expr)`), up to the
181
+ * function it is defined in. Without that call, the code would run in the order of the caller. A call capturing
182
+ * its argument for another call to evaluate is left to the evaluation of captured code, as that one drops it
183
+ * where the captured code is run in place.
184
+ * @param sigs - the signatures of the calls met on the way, filled as they are asked for
185
+ */
186
+ function deferringCall(id, info, idMap, sigs) {
187
+ for (let child = idMap.get(id), parent = child && model_1.RNode.directParent(child, idMap); child !== undefined && parent !== undefined && !r_function_definition_1.RFunctionDefinition.is(parent); child = parent, parent = model_1.RNode.directParent(parent, idMap)) {
188
+ if (!r_argument_1.RArgument.is(child) || !r_function_call_1.RFunctionCall.is(parent)) {
189
+ continue;
190
+ }
191
+ const call = parent.info.id;
192
+ let known = sigs.get(call);
193
+ if (known === undefined) {
194
+ const props = (0, query_fn_props_1.callFnProps)(call, info);
195
+ known = { sig: props?.sig, evaluates: props?.tags?.includes(built_in_props_1.SemanticCallTag.Eval) === true };
196
+ sigs.set(call, known);
197
+ }
198
+ /* quoted code the dataflow evaluates in place needs neither the quote nor the evaluating call */
199
+ if (vertex_1.DfgVertex.hasOrigin(info.graph.getVertex(call), built_in_proc_name_1.BuiltInProcName.Quote)) {
200
+ return undefined;
201
+ }
202
+ if (known.evaluates || (known.sig !== undefined && runsElsewhere(built_in_props_1.FnSig.propAt(built_in_props_1.FnSig.layout(known.sig), parent.arguments.indexOf(child))))) {
203
+ return call;
204
+ }
205
+ }
206
+ return undefined;
207
+ }
166
208
  //# sourceMappingURL=slice-call.js.map
@@ -45,6 +45,7 @@ function staticSlice(options) {
45
45
  const basePrint = ctx.env.getCleanEnvFingerprint();
46
46
  const queue = new visiting_queue_1.VisitingQueue(options.threshold ?? 75, cache, graph, ctx.gas.scope(options.gas), [emptyEnv, basePrint]);
47
47
  const enclosingHandled = new Set();
48
+ const callSigs = new Map();
48
49
  /* the unknown side effects every slice keeps are seeds as well, so what they reach is not cut off as running too late */
49
50
  const effects = [...graph.unknownSideEffects].filter((id) => typeof id !== 'object');
50
51
  const missesSeeds = sliceGraph === undefined ? outsideSeedRun([...ids, ...effects], idMap, direction, graph) : undefined;
@@ -119,6 +120,11 @@ function staticSlice(options) {
119
120
  queue.add(cd.id, baseEnvironment, baseEnvFingerprint, false);
120
121
  }
121
122
  }
123
+ /* code a call quotes or calls runs where and when that call says, so the call stays with it */
124
+ const deferring = (0, slice_call_1.deferringCall)(id, info, idMap, callSigs);
125
+ if (deferring !== undefined) {
126
+ enqueue(deferring, baseEnvironment, baseEnvFingerprint);
127
+ }
122
128
  /* a call or a definition within a promise runs only when the promise is forced, within captured code only when it is evaluated */
123
129
  if (vertex_1.DfgVertex.isFunctionCall(currentVertex) || vertex_1.DfgVertex.isVariableDefinition(currentVertex)) {
124
130
  const dependencies = function_semantics_1.FunctionSemantics.promiseDependencies(id, graph);
@@ -49,6 +49,8 @@ var SecretSinkClass;
49
49
  SecretSinkClass["Llm"] = "llm";
50
50
  })(SecretSinkClass || (exports.SecretSinkClass = SecretSinkClass = {}));
51
51
  const index = query_fn_props_1.BuiltInIndex.default();
52
+ /** the calls fetching from the network into a file, like `download.file` */
53
+ const downloads = new Set(index.withAll([built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.Reads, built_in_props_1.SemanticCallTag.Writes]).map(f => identifier_1.Identifier.toString(f)));
52
54
  /** functions by package, as `pkg: f g; other: h`, with `$` for methods */
53
55
  const fns = (spec) => spec.split(';').flatMap(group => {
54
56
  const [pkg, names] = group.split(':').map(p => p.trim());
@@ -78,7 +80,8 @@ exports.DefaultSecretSinks = [
78
80
  ...identifier_1.Identifier.fromAll('futile.logger', logLevels.map(l => `flog.${l}`)),
79
81
  ...fns('base: stop packageStartupMessage; rlang: inform abort; cli: cli_alert cli_alert_info cli_alert_success cli_alert_warning cli_alert_danger cli_inform cli_warn cli_abort cli_text; clipr: write_clip')
80
82
  ] },
81
- { class: SecretSinkClass.Files, fns: [...index.withAll([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes]), ...fns('utils: write.csv write.csv2 write.table; base: writeBin; DBI: dbWriteTable dbAppendTable; pins: pin_write; googlesheets4: sheet_write write_sheet sheet_append; aws.s3: s3saveRDS put_object')] },
83
+ /* a download writes what it fetched rather than its arguments, which reach the network (a sink of their own) */
84
+ { class: SecretSinkClass.Files, fns: [...index.withAll([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes]).filter(f => !downloads.has(identifier_1.Identifier.toString(f))), ...fns('utils: write.csv write.csv2 write.table; base: writeBin; DBI: dbWriteTable dbAppendTable; pins: pin_write; googlesheets4: sheet_write write_sheet sheet_append; aws.s3: s3saveRDS put_object')] },
82
85
  { class: SecretSinkClass.Process, fns: [...index.with(built_in_props_1.SemanticCallTag.Process), ...fns('utils: browseURL')] },
83
86
  { class: SecretSinkClass.Llm, fns: fns('ellmer: chat chat_openai chat_anthropic chat_claude chat_gemini chat_google_gemini chat_ollama chat_mistral chat_groq chat_azure_openai chat_bedrock; openai: create_chat_completion create_completion; $: chat stream chat_async stream_async chat_structured set_system_prompt') }
84
87
  ];
@@ -122,7 +125,9 @@ function createSecretAnalysis({ credentialNamePattern = exports.CredentialNamePa
122
125
  ...sources
123
126
  ],
124
127
  taint: exports.Secret
125
- }, ...(0, builtin_index_bridge_1.argValueMappingFromBuiltInIndex)(built_in_props_1.FileInputProps, built_in_props_1.ArgProp.Resource, fileTaint))
128
+ },
129
+ /* a call that also writes (a copy, an unpack, a download) moves the content and returns a status or paths */
130
+ ...(0, builtin_index_bridge_1.argValueMappingFromBuiltInIndex)(built_in_props_1.FileInputProps, built_in_props_1.ArgProp.Resource, fileTaint, built_in_props_1.SemanticCallTag.Writes))
126
131
  .through({
127
132
  identifier: [
128
133
  ...fns('digest: digest sha1 hmac; openssl: sha1 sha256 sha512 md5 sha2; sodium: password_store hash sha256; base: nzchar is.na is.null nchar identical == != isTRUE isFALSE'),
@@ -3,8 +3,11 @@ import type { FunctionParameterLocation } from '../abstract-interpretation/data-
3
3
  import type { ArgProps, FnSig } from '../dataflow/environments/built-in-props';
4
4
  import { Identifier } from '../dataflow/environments/identifier';
5
5
  export declare class TaintMapper<Domain extends AnyAbstractDomain> {
6
- mapper: TaintMappingInternal<Domain>[];
7
- constructor(mapper?: TaintMappingInternal<Domain>[]);
6
+ readonly mapper: TaintMappingInternal<Domain>[];
7
+ /** the mappings by the name they map, in the order they were added; a mapping only ever applies to a call of its name */
8
+ private readonly byName;
9
+ constructor(mapper?: readonly TaintMappingInternal<Domain>[]);
10
+ private add;
8
11
  /**
9
12
  * Add one or more taint mapping rules to the mapper
10
13
  */
@@ -4,16 +4,27 @@ exports.TaintRole = exports.TaintMapper = void 0;
4
4
  const identifier_1 = require("../dataflow/environments/identifier");
5
5
  class TaintMapper {
6
6
  mapper = [];
7
+ /** the mappings by the name they map, in the order they were added; a mapping only ever applies to a call of its name */
8
+ byName = new Map();
7
9
  constructor(mapper) {
8
- if (mapper) {
9
- this.mapper = mapper;
10
+ mapper?.forEach(m => this.add(m));
11
+ }
12
+ add(mapping) {
13
+ this.mapper.push(mapping);
14
+ const name = identifier_1.Identifier.getName(mapping.identifier);
15
+ const named = this.byName.get(name);
16
+ if (named === undefined) {
17
+ this.byName.set(name, [mapping]);
18
+ }
19
+ else {
20
+ named.push(mapping);
10
21
  }
11
22
  }
12
23
  /**
13
24
  * Add one or more taint mapping rules to the mapper
14
25
  */
15
26
  pushMapping(mappings) {
16
- this.mapper.push(...this.mapRulesToInternal(mappings));
27
+ this.mapRulesToInternal(mappings).forEach(m => this.add(m));
17
28
  }
18
29
  /**
19
30
  * Add one or more taint mapping rules to the mapper.
@@ -25,14 +36,14 @@ class TaintMapper {
25
36
  if (this.hasMappingForRole(rule)) {
26
37
  continue;
27
38
  }
28
- this.mapper.push(rule);
39
+ this.add(rule);
29
40
  }
30
41
  }
31
42
  /**
32
43
  * Get all mappings belonging to the given identifier
33
44
  */
34
45
  getMappings(identifier) {
35
- return this.mapper.filter(m => TaintMapper.matches(m.identifier, identifier));
46
+ return this.byName.get(identifier_1.Identifier.getName(identifier))?.filter(m => TaintMapper.matches(m.identifier, identifier)) ?? [];
36
47
  }
37
48
  /** Whether a mapped identifier applies to a call of `called`, which matches any namespace when it names none */
38
49
  static matches(mapped, called) {
@@ -42,7 +53,7 @@ class TaintMapper {
42
53
  * Create a new, independent mapper containing the same taint mappings
43
54
  */
44
55
  clone() {
45
- return new TaintMapper([...this.mapper]);
56
+ return new TaintMapper(this.mapper);
46
57
  }
47
58
  hasMappingForRole(rule) {
48
59
  return this.getMappings(rule.identifier).some(i => i.role === rule.role);
@@ -3,7 +3,7 @@
3
3
  * @module
4
4
  */
5
5
  import { SemVer } from 'semver';
6
- export declare const versionDate = "2026-11-03T08:51:21Z";
6
+ export declare const versionDate = "2026-11-05T14:04:12Z";
7
7
  /**
8
8
  * Retrieves the current flowR version as a new {@link SemVer} object.
9
9
  */
@@ -8,9 +8,9 @@ exports.flowrVersion = flowrVersion;
8
8
  */
9
9
  const semver_1 = require("semver");
10
10
  // this is automatically replaced with the current version by release-it
11
- const version = '2.17.0';
11
+ const version = '2.17.2';
12
12
  // this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
13
- exports.versionDate = '2026-11-03T08:51:21Z';
13
+ exports.versionDate = '2026-11-05T14:04:12Z';
14
14
  /**
15
15
  * Retrieves the current flowR version as a new {@link SemVer} object.
16
16
  */
package/util/r-version.js CHANGED
@@ -65,7 +65,8 @@ function normalizeVersions(versions) {
65
65
  parts.push(prefix);
66
66
  }
67
67
  const versionPart = match[1];
68
- parts.push(normalizeVersion(versionPart));
68
+ // keep what separated it from the previous part, else `>= 1.0 < 2.0` would run together
69
+ parts.push(/^\s*/.exec(versionPart)?.[0] + normalizeVersion(versionPart));
69
70
  index = match.index + versionPart.length;
70
71
  }
71
72
  if (index < versions.length) {
@@ -181,7 +182,8 @@ exports.RRange = {
181
182
  }
182
183
  catch { /* try to normalize R range to SemVer */ }
183
184
  try {
184
- return makeRange(normalizeVersions(range), range);
185
+ // a comma joins requirements as semver's space does (`>= 1.0, < 2.0`, as rig and cargo write them)
186
+ return makeRange(normalizeVersions(range.replaceAll(/\s*,\s*/g, ' ')), range);
185
187
  }
186
188
  catch { /* unparseable even after normalization -> report as "no constraint" */ }
187
189
  return undefined;