@eagleoutice/flowr 2.16.8 → 2.17.1

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 (153) hide show
  1. package/README.md +16 -10
  2. package/abstract-interpretation/absint-inference.d.ts +17 -1
  3. package/abstract-interpretation/absint-inference.js +118 -3
  4. package/abstract-interpretation/data-frame/arguments.d.ts +11 -1
  5. package/abstract-interpretation/data-frame/arguments.js +12 -0
  6. package/abstract-interpretation/domains/lattice.d.ts +2 -0
  7. package/abstract-interpretation/domains/lattice.js +0 -6
  8. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +2 -1
  9. package/abstract-interpretation/domains/multi-value-state-domain.js +7 -3
  10. package/abstract-interpretation/domains/partial-product-domain.js +2 -1
  11. package/abstract-interpretation/domains/state-abstract-domain.d.ts +6 -3
  12. package/abstract-interpretation/domains/state-abstract-domain.js +13 -7
  13. package/abstract-interpretation/domains/state-domain.d.ts +4 -0
  14. package/config.d.ts +32 -0
  15. package/config.js +23 -3
  16. package/control-flow/useless-loop.js +10 -8
  17. package/data/r-primitives.generated.d.ts +1 -0
  18. package/data/r-primitives.generated.js +9 -0
  19. package/data/sigdb/sigdb.remote.json +110 -110
  20. package/dataflow/environments/built-in-props.d.ts +16 -2
  21. package/dataflow/environments/built-in-props.js +23 -3
  22. package/dataflow/environments/built-in.js +13 -3
  23. package/dataflow/environments/default-builtin-config.d.ts +268 -7
  24. package/dataflow/environments/default-builtin-config.js +72 -13
  25. package/dataflow/environments/identifier.d.ts +7 -1
  26. package/dataflow/environments/query-fn-props.d.ts +9 -3
  27. package/dataflow/environments/query-fn-props.js +13 -5
  28. package/dataflow/extractor.js +49 -14
  29. package/dataflow/fn/class-declaration.js +1 -8
  30. package/dataflow/fn/function-semantics.d.ts +1 -0
  31. package/dataflow/graph/df-helper.d.ts +2 -0
  32. package/dataflow/graph/df-helper.js +7 -0
  33. package/documentation/wiki-linter.js +29 -0
  34. package/documentation/wiki-query.js +20 -1
  35. package/linter/linter-executor.js +2 -1
  36. package/linter/linter-rules.d.ts +65 -0
  37. package/linter/linter-rules.js +5 -1
  38. package/linter/rules/cmd-check/global-environment-modification.d.ts +14 -1
  39. package/linter/rules/cmd-check/global-environment-modification.js +15 -7
  40. package/linter/rules/network-functions.js +10 -2
  41. package/linter/rules/no-leaked-credentials.d.ts +1 -0
  42. package/linter/rules/no-leaked-credentials.js +3 -3
  43. package/linter/rules/process-state-in-session.d.ts +71 -0
  44. package/linter/rules/process-state-in-session.js +267 -0
  45. package/linter/rules/secret-exfiltration.d.ts +80 -0
  46. package/linter/rules/secret-exfiltration.js +183 -0
  47. package/linter/rules/unused-import.js +11 -1
  48. package/package.json +1 -1
  49. package/project/cache/flowr-analyzer-cache.d.ts +4 -0
  50. package/project/cache/flowr-analyzer-cache.js +11 -0
  51. package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -0
  52. package/project/context/flowr-analyzer-dependencies-context.js +6 -0
  53. package/project/context/flowr-file.d.ts +2 -2
  54. package/project/context/flowr-file.js +2 -2
  55. package/project/flowr-analyzer.d.ts +6 -0
  56. package/project/flowr-analyzer.js +4 -0
  57. package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +39 -4
  58. package/project/plugins/file-plugins/files/flowr-manifest-files.js +134 -30
  59. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +2 -0
  60. package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -3
  61. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
  62. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +7 -0
  63. package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +14 -1
  64. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
  65. package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
  66. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +18 -5
  67. package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +43 -15
  68. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +12 -0
  69. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -2
  70. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +58 -0
  71. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +237 -0
  72. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +8 -0
  73. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +8 -0
  74. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +7 -0
  75. package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +24 -18
  76. package/project/plugins/plugin-registry.d.ts +5 -4
  77. package/project/plugins/plugin-registry.js +6 -0
  78. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
  79. package/project/sigdb/decode.js +13 -3
  80. package/project/sigdb/decompress.d.ts +4 -0
  81. package/project/sigdb/decompress.js +60 -25
  82. package/project/sigdb/manifest.d.ts +1 -1
  83. package/project/sigdb/manifest.js +2 -5
  84. package/project/sigdb/memory-source.d.ts +6 -4
  85. package/project/sigdb/memory-source.js +6 -5
  86. package/project/sigdb/on-demand/fetch.d.ts +18 -0
  87. package/project/sigdb/on-demand/fetch.js +127 -0
  88. package/project/sigdb/on-demand/package-sources.d.ts +40 -0
  89. package/project/sigdb/on-demand/package-sources.js +263 -0
  90. package/project/sigdb/on-demand/recoverer.d.ts +40 -0
  91. package/project/sigdb/on-demand/recoverer.js +169 -0
  92. package/project/sigdb/on-demand/remote-sources.d.ts +72 -0
  93. package/project/sigdb/on-demand/remote-sources.js +132 -0
  94. package/project/sigdb/on-demand/tar.d.ts +19 -0
  95. package/project/sigdb/on-demand/tar.js +119 -0
  96. package/project/sigdb/reader.js +15 -6
  97. package/project/sigdb/sigdb-download.d.ts +3 -7
  98. package/project/sigdb/sigdb-download.js +71 -72
  99. package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +5 -0
  100. package/queries/catalog/dependencies-query/function-info/derived-functions.js +17 -1
  101. package/queries/catalog/dependencies-query/function-info/read-functions.js +3 -1
  102. package/queries/catalog/dependencies-query/function-info/write-functions.js +11 -1
  103. package/queries/catalog/taint-query/taint-query-executor.d.ts +7 -0
  104. package/queries/catalog/taint-query/taint-query-executor.js +30 -0
  105. package/queries/catalog/taint-query/taint-query-format.d.ts +29 -0
  106. package/queries/catalog/taint-query/taint-query-format.js +124 -0
  107. package/queries/query.d.ts +12 -1
  108. package/queries/query.js +2 -0
  109. package/r-bridge/data/data.d.ts +29 -0
  110. package/r-bridge/data/data.js +23 -0
  111. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +4 -0
  112. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +8 -0
  113. package/taint-analysis/builder/domain.d.ts +14 -0
  114. package/taint-analysis/builder/domain.js +69 -0
  115. package/taint-analysis/builder/report-template.d.ts +50 -0
  116. package/taint-analysis/builder/report-template.js +46 -0
  117. package/taint-analysis/builder/taint-analysis-definition.d.ts +108 -0
  118. package/taint-analysis/builder/taint-analysis-definition.js +128 -0
  119. package/taint-analysis/builder/taint-analysis.d.ts +124 -0
  120. package/taint-analysis/builder/taint-analysis.js +93 -0
  121. package/taint-analysis/builtin-index-bridge.d.ts +20 -0
  122. package/taint-analysis/builtin-index-bridge.js +48 -0
  123. package/taint-analysis/eval/eval.d.ts +1 -0
  124. package/taint-analysis/eval/eval.js +124 -0
  125. package/taint-analysis/eval/instrumentation.d.ts +59 -0
  126. package/taint-analysis/eval/instrumentation.js +124 -0
  127. package/taint-analysis/finite-domain.d.ts +41 -0
  128. package/taint-analysis/finite-domain.js +118 -0
  129. package/taint-analysis/function-categories.d.ts +31 -0
  130. package/taint-analysis/function-categories.js +61 -0
  131. package/taint-analysis/logger.d.ts +1 -0
  132. package/taint-analysis/logger.js +6 -0
  133. package/taint-analysis/predefined/determinism.d.ts +6 -0
  134. package/taint-analysis/predefined/determinism.js +14 -0
  135. package/taint-analysis/predefined/normalization.d.ts +17 -0
  136. package/taint-analysis/predefined/normalization.js +150 -0
  137. package/taint-analysis/predefined/predefined.d.ts +12 -0
  138. package/taint-analysis/predefined/predefined.js +18 -0
  139. package/taint-analysis/predefined/randomness-analysis.d.ts +6 -0
  140. package/taint-analysis/predefined/randomness-analysis.js +124 -0
  141. package/taint-analysis/predefined/secret-analysis.d.ts +77 -0
  142. package/taint-analysis/predefined/secret-analysis.js +170 -0
  143. package/taint-analysis/predefined/security-analysis.d.ts +7 -0
  144. package/taint-analysis/predefined/security-analysis.js +91 -0
  145. package/taint-analysis/taint-mapping.d.ts +89 -0
  146. package/taint-analysis/taint-mapping.js +81 -0
  147. package/taint-analysis/taint-resolve.d.ts +26 -0
  148. package/taint-analysis/taint-resolve.js +86 -0
  149. package/taint-analysis/taint-visitor.d.ts +80 -0
  150. package/taint-analysis/taint-visitor.js +82 -0
  151. package/util/flowr-version.d.ts +1 -1
  152. package/util/flowr-version.js +2 -2
  153. package/util/r-version.js +4 -2
@@ -219,6 +219,7 @@ export declare const enum PkgName {
219
219
  Utils = "utils",
220
220
  AnnotationHub = "AnnotationHub",
221
221
  Ape = "ape",
222
+ Archive = "archive",
222
223
  Arrow = "arrow",
223
224
  AssertThat = "assertthat",
224
225
  Audio = "audio",
@@ -243,6 +244,7 @@ export declare const enum PkgName {
243
244
  DoMc = "doMC",
244
245
  DoParallel = "doParallel",
245
246
  DoSnow = "doSNOW",
247
+ Downloader = "downloader",
246
248
  Dplyr = "dplyr",
247
249
  EbImage = "EBImage",
248
250
  Emmeans = "emmeans",
@@ -298,8 +300,10 @@ export declare const enum PkgName {
298
300
  NorTest = "nortest",
299
301
  OpenImageR = "OpenImageR",
300
302
  OpenXlsx = "openxlsx",
303
+ Osfr = "osfr",
301
304
  Parallelly = "parallelly",
302
305
  Patchwork = "patchwork",
306
+ Piggyback = "piggyback",
303
307
  PkgLoad = "pkgload",
304
308
  Plyr = "plyr",
305
309
  Png = "png",
@@ -378,7 +382,9 @@ export declare const enum PkgName {
378
382
  XlConnect = "XLConnect",
379
383
  Xlsx = "xlsx",
380
384
  Xml2 = "xml2",
381
- Yaml = "yaml"
385
+ Yaml = "yaml",
386
+ Zen4R = "zen4R",
387
+ Zip = "zip"
382
388
  }
383
389
  /**
384
390
  * Each reference has exactly one reference type, stored as the respective number.
@@ -141,13 +141,19 @@ export declare class BuiltInIndex {
141
141
  static ofEnvironment(builtIns: BuiltIns): BuiltInIndex;
142
142
  /** answers are keyed by what was asked, as every caller asks the same handful of questions over and over */
143
143
  private cached;
144
- /** Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls. */
145
- with(props: PropSelector): readonly Identifier[];
144
+ /**
145
+ * Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls.
146
+ * @param props - The built-in must satisfy at least one of these properties.
147
+ * @param excluding - Drop built-ins that also carry any of these properties.
148
+ */
149
+ with(props: PropSelector, excluding?: PropSelector): readonly Identifier[];
146
150
  /**
147
151
  * Every built-in carrying *every* property of `props`, for the questions a single one cannot answer,
148
152
  * like {@link FileInputProps} for the calls that read a file rather than only write one.
153
+ * @param props - The built-in must satisfy all of these properties.
154
+ * @param excluding - Drop built-ins that also carry any of these properties.
149
155
  */
150
- withAll(props: PropSelector): readonly Identifier[];
156
+ withAll(props: PropSelector, excluding?: PropSelector): readonly Identifier[];
151
157
  /**
152
158
  * Every built-in that states its props but carries none of `props`. With {@link InputProps} this yields
153
159
  * the calls that derive their result from their arguments alone.
@@ -380,16 +380,24 @@ class BuiltInIndex {
380
380
  }
381
381
  return found;
382
382
  }
383
- /** Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls. */
384
- with(props) {
385
- return this.cached(`with:${function_semantics_1.FunctionSemantics.call.props.key(props)}`, e => function_semantics_1.FunctionSemantics.call.props.hasAny(e, props));
383
+ /**
384
+ * Every built-in carrying at least one property of `props`, like {@link SemanticCallTag.File} for the file calls.
385
+ * @param props - The built-in must satisfy at least one of these properties.
386
+ * @param excluding - Drop built-ins that also carry any of these properties.
387
+ */
388
+ with(props, excluding) {
389
+ const key = `with:${built_in_props_1.CallProps.key(props)}${excluding === undefined ? '' : `!${built_in_props_1.CallProps.key(excluding)}`}`;
390
+ return this.cached(key, e => built_in_props_1.CallProps.hasAny(e, props) && (excluding === undefined || !built_in_props_1.CallProps.hasAny(e, excluding)));
386
391
  }
387
392
  /**
388
393
  * Every built-in carrying *every* property of `props`, for the questions a single one cannot answer,
389
394
  * like {@link FileInputProps} for the calls that read a file rather than only write one.
395
+ * @param props - The built-in must satisfy all of these properties.
396
+ * @param excluding - Drop built-ins that also carry any of these properties.
390
397
  */
391
- withAll(props) {
392
- return this.cached(`all:${function_semantics_1.FunctionSemantics.call.props.key(props)}`, e => function_semantics_1.FunctionSemantics.call.props.hasAny(e) && function_semantics_1.FunctionSemantics.call.props.hasAll(e, props));
398
+ withAll(props, excluding) {
399
+ const key = `all:${built_in_props_1.CallProps.key(props)}${excluding === undefined ? '' : `!${built_in_props_1.CallProps.key(excluding)}`}`;
400
+ return this.cached(key, e => built_in_props_1.CallProps.hasAny(e) && built_in_props_1.CallProps.hasAll(e, props) && (excluding === undefined || !built_in_props_1.CallProps.hasAny(e, excluding)));
393
401
  }
394
402
  /**
395
403
  * Every built-in that states its props but carries none of `props`. With {@link InputProps} this yields
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.processors = void 0;
4
7
  exports.produceDataFlowGraph = produceDataFlowGraph;
8
+ const path_1 = __importDefault(require("path"));
5
9
  const applied_arguments_1 = require("./graph/applied-arguments");
6
10
  const function_semantics_1 = require("./fn/function-semantics");
7
11
  const processor_1 = require("./processor");
@@ -266,6 +270,30 @@ function readFramesThroughEnvironment(graph) {
266
270
  function argsWithProp(vertex, info, prop) {
267
271
  return info?.sig === undefined ? [] : match_args_1.MatchArgs.findWithProps(vertex.args, info.sig, prop);
268
272
  }
273
+ /** the path with `/` separators, without `./` steps or a trailing `/` */
274
+ function normalizedPath(p) {
275
+ return path_1.default.posix.normalize(p.replaceAll('\\', '/')).replace(/(?<=.)\/$/, '');
276
+ }
277
+ /**
278
+ * Whether the paths may name one file, as they do when one of them is a directory holding the other:
279
+ * `unzip(zipfile, exdir = "data")` and `file.copy(from, to = "out")` write into one, `list.files("data")` reads one. The working
280
+ * directory holds every relative path.
281
+ */
282
+ function sharesFile(a, b) {
283
+ const [x, y] = [normalizedPath(a), normalizedPath(b)];
284
+ return x === y || holds(x, y) || holds(y, x);
285
+ }
286
+ function holds(directory, file) {
287
+ return directory === '.' ? !path_1.default.posix.isAbsolute(file) && file !== '..' && !file.startsWith('../') : file.startsWith(directory.endsWith('/') ? directory : `${directory}/`);
288
+ }
289
+ /** whether the call tells the files it reads from the ones it writes, see {@link FnSig.resources} */
290
+ function splitsResources(info) {
291
+ return info?.sig !== undefined && built_in_props_1.FnSig.resources(info.sig, true) !== info.sig;
292
+ }
293
+ /** The {@link ArgProp.Resource} arguments naming what the call writes (`writes`) or reads, see {@link FnSig.resources}. */
294
+ function resourceArgs(vertex, info, writes) {
295
+ return info?.sig === undefined ? [] : match_args_1.MatchArgs.findWithProps(vertex.args, built_in_props_1.FnSig.resources(info.sig, writes), built_in_props_1.ArgProp.Resource);
296
+ }
269
297
  function definitionsReachedBy(node, graph) {
270
298
  return df_helper_1.Dataflow.reachable(graph, node, {
271
299
  follow: edge_1.EdgeType.Reads,
@@ -302,10 +330,16 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
302
330
  if (!reads && !writes) {
303
331
  continue;
304
332
  }
305
- const resource = argsWithProp((0, applied_arguments_1.appliedArguments)(graph, vertex), info, built_in_props_1.ArgProp.Resource)[0];
333
+ const applied = (0, applied_arguments_1.appliedArguments)(graph, vertex);
334
+ /* a call stating both without saying which files it writes (`file(path, open)`) counts as a reader */
335
+ const read = reads ? resourceArgs(applied, info, false)[0] : undefined;
336
+ const written = writes && (!reads || splitsResources(info)) ? resourceArgs(applied, info, true)[0] : undefined;
306
337
  /* writing to the console names no file, and neither does a reader we cannot pin down */
307
- if (resource !== undefined) {
308
- (reads ? readers : writers).push({ id, resource });
338
+ if (read !== undefined) {
339
+ readers.push({ id, resource: read });
340
+ }
341
+ if (written !== undefined) {
342
+ writers.push({ id, resource: written });
309
343
  }
310
344
  }
311
345
  if (readers.length === 0 || writers.length === 0) {
@@ -321,7 +355,7 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
321
355
  /* a path we cannot resolve may name the other one */
322
356
  const path = pathOf(a);
323
357
  const other = pathOf(b);
324
- return path === undefined || other === undefined || path === other;
358
+ return path === undefined || other === undefined || sharesFile(path, other);
325
359
  };
326
360
  /* each added edge clears the graph's cached call names, but none of these edges changes what a call targets */
327
361
  const prints = (0, defaultmap_1.memoize)((id) => function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(id, { graph, environment }), [built_in_props_1.SemanticCallTag.Prints]));
@@ -343,13 +377,13 @@ function linkResourceReadersToWriters(graph, environment, ctx) {
343
377
  }
344
378
  }
345
379
  }
346
- /** The paths the {@link ArgProp.Resource} arguments of the file accessing call `id` name, `undefined` unless every one resolves to strings. */
347
- function pathsOf(id, graph, environment, ctx, callContext) {
380
+ /** The paths the file accessing call `id` writes (`writes`) or reads, `undefined` unless every one resolves to strings. */
381
+ function pathsOf(id, writes, graph, environment, ctx, callContext) {
348
382
  const vertex = graph.getVertex(id);
349
383
  if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
350
384
  return undefined;
351
385
  }
352
- const resources = argsWithProp((0, applied_arguments_1.appliedArguments)(graph, vertex), (0, query_fn_props_1.callFnProps)(id, { graph, environment }), built_in_props_1.ArgProp.Resource);
386
+ const resources = resourceArgs((0, applied_arguments_1.appliedArguments)(graph, vertex), (0, query_fn_props_1.callFnProps)(id, { graph, environment }), writes);
353
387
  const paths = new Set();
354
388
  for (const resource of resources) {
355
389
  const strings = node_value_1.NodeValue.stringsOf(r_argument_1.RArgument.valueOf(graph.idMap?.get(resource)) ?? resource, resolve_helper_1.Resolve.info(graph, ctx), { callContext });
@@ -407,20 +441,21 @@ function separateFileWritesPerCall(graph, environment, ctx) {
407
441
  }
408
442
  const fileAccess = (0, defaultmap_1.memoize)((id) => {
409
443
  const info = (0, query_fn_props_1.callFnProps)(id, { graph, environment });
410
- return function_semantics_1.FunctionSemantics.call.props.hasAll(info, [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes]) ? 'write'
411
- : function_semantics_1.FunctionSemantics.call.props.hasAll(info, [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads]) ? 'read' : undefined;
444
+ const writes = function_semantics_1.FunctionSemantics.call.props.hasAll(info, [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes]);
445
+ const reads = function_semantics_1.FunctionSemantics.call.props.hasAll(info, [built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads]) && (!writes || splitsResources(info));
446
+ return { reads, writes };
412
447
  });
413
- const readPaths = (0, defaultmap_1.memoize)((id) => fileAccess(id) === 'read' ? pathsOf(id, graph, environment, ctx) : undefined);
448
+ const readPaths = (0, defaultmap_1.memoize)((id) => fileAccess(id).reads ? pathsOf(id, false, graph, environment, ctx) : undefined);
414
449
  /* writing to the console (`cat(x)`) names no file, and has no call to tell apart */
415
450
  const namesFile = (id) => {
416
451
  const vertex = graph.getVertex(id);
417
- return argsWithProp((0, applied_arguments_1.appliedArguments)(graph, vertex), (0, query_fn_props_1.callFnProps)(id, { graph, environment }), built_in_props_1.ArgProp.Resource).length > 0;
452
+ return resourceArgs((0, applied_arguments_1.appliedArguments)(graph, vertex), (0, query_fn_props_1.callFnProps)(id, { graph, environment }), true).length > 0;
418
453
  };
419
454
  const writers = [...graph.verticesOfType(vertex_1.VertexType.FunctionCall)].map(([id]) => id)
420
- .filter(id => graph.edgesFrom(id).values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.SideEffectOnCall)) && !graph.unknownSideEffects.has(id) && fileAccess(id) === 'write' && namesFile(id));
455
+ .filter(id => graph.edgesFrom(id).values().some(e => edge_1.DfEdge.includesType(e, edge_1.EdgeType.SideEffectOnCall)) && !graph.unknownSideEffects.has(id) && fileAccess(id).writes && namesFile(id));
421
456
  const separated = new Set();
422
457
  for (const writer of writers) {
423
- const levels = fileWriteLevels(writer, graph, idMap, callContext => pathsOf(writer, graph, environment, ctx, callContext));
458
+ const levels = fileWriteLevels(writer, graph, idMap, callContext => pathsOf(writer, true, graph, environment, ctx, callContext));
424
459
  if (levels !== undefined) {
425
460
  separated.add(writer);
426
461
  }
@@ -432,7 +467,7 @@ function separateFileWritesPerCall(graph, environment, ctx) {
432
467
  for (const { call, paths } of calls) {
433
468
  for (const reader of readers) {
434
469
  const read = readPaths(reader);
435
- if (read === undefined || paths === undefined || !read.isDisjointFrom(paths)) {
470
+ if (read === undefined || paths === undefined || read.values().some(r => paths.values().some(w => sharesFile(r, w)))) {
436
471
  graph.addEdge(reader, call, edge_1.EdgeType.Reads);
437
472
  }
438
473
  }
@@ -20,7 +20,6 @@ const edge_1 = require("../graph/edge");
20
20
  const assert_1 = require("../../util/assert");
21
21
  const objects_1 = require("../../util/objects");
22
22
  const vertex_1 = require("../graph/vertex");
23
- const built_in_proc_name_1 = require("../environments/built-in-proc-name");
24
23
  const node_value_1 = require("../eval/resolve/node-value");
25
24
  const string_constants_1 = require("../eval/values/string/string-constants");
26
25
  const r_value_1 = require("../eval/values/r-value");
@@ -253,18 +252,12 @@ function s3ClassOfValue(id, info) {
253
252
  }
254
253
  return undefined;
255
254
  }
256
- /** The value a plain assignment binds to the definition `def`, `undefined` for any other kind of definition (`class(x) <- `, `assign`, a parameter, ...). */
257
- function assignedValueOf(def, graph) {
258
- const vertex = graph.getVertex(def);
259
- const byAssignment = df_helper_1.Dataflow.targetsOf(graph, def, edge_1.EdgeType.DefinedBy).some(t => vertex_1.DfgVertex.hasOrigin(graph.getVertex(t), built_in_proc_name_1.BuiltInProcName.Assignment));
260
- return vertex_1.DfgVertex.isVariableDefinition(vertex) && byAssignment && vertex.source?.length === 1 ? vertex.source[0] : undefined;
261
- }
262
255
  /** The class vectors S3 dispatch may see for the argument at `id`, one per reaching definition, `undefined` unless all are known. */
263
256
  function s3DispatchClassesOf(id, info) {
264
257
  const { graph } = info;
265
258
  const value = r_argument_1.RArgument.valueOf(info.idMap.get(id))?.info.id;
266
259
  const isRead = value !== undefined && vertex_1.DfgVertex.isUse(graph.getVertex(value));
267
- const values = isRead ? df_helper_1.Dataflow.targetsOf(graph, value, edge_1.EdgeType.Reads).map(def => assignedValueOf(def, graph)) : [value];
260
+ const values = isRead ? df_helper_1.Dataflow.targetsOf(graph, value, edge_1.EdgeType.Reads).map(def => df_helper_1.Dataflow.assignedValueOf(def, graph)) : [value];
268
261
  const classes = values.map(v => v === undefined ? undefined : s3ClassOfValue(v, info));
269
262
  return classes.length > 0 && classes.every(assert_1.isNotUndefined) ? classes : undefined;
270
263
  }
@@ -75,6 +75,7 @@ export declare const FunctionSemantics: {
75
75
  readonly forcing: (this: void, sig: FnSig | undefined, count: number) => readonly import("../../util/logic").Ternary[] | undefined;
76
76
  readonly every: FnSig;
77
77
  readonly only: (this: void, index: number, name: string) => FnSig;
78
+ readonly resources: (sig: FnSig, writes: boolean) => FnSig;
78
79
  };
79
80
  /** The same as {@link FunctionSemantics.call.props}, for one argument. */
80
81
  readonly argument: {
@@ -133,6 +133,8 @@ export declare const Dataflow: {
133
133
  * @see {@link Dataflow.calleeIdsOf} - for what a single call calls
134
134
  */
135
135
  readonly callsIn: (this: void, definition: DataflowGraphVertexFunctionDefinition, graph: DataflowGraph) => Generator<[NodeId, DataflowGraphVertexFunctionCall]>;
136
+ /** The value a plain assignment binds to the definition `def`, `undefined` for any other kind of definition (`class(x) <- `, `assign`, a parameter, ...). */
137
+ readonly assignedValueOf: (this: void, def: NodeId, graph: DataflowGraph) => NodeId | undefined;
136
138
  /** Every variable definition of the graph by its unquoted name, in a single pass. */
137
139
  readonly definitionsByName: (this: void, graph: DataflowGraph) => DefaultMap<string, NodeId[]>;
138
140
  /**
@@ -10,6 +10,7 @@ const transitive_side_effects_1 = require("../internal/process/functions/call/bu
10
10
  const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
11
11
  const vertex_1 = require("./vertex");
12
12
  const identifier_1 = require("../environments/identifier");
13
+ const built_in_proc_name_1 = require("../environments/built-in-proc-name");
13
14
  const r_base_packages_1 = require("../../util/r-base-packages");
14
15
  const defaultmap_1 = require("../../util/collections/defaultmap");
15
16
  const linker_1 = require("../internal/linker");
@@ -204,6 +205,12 @@ exports.Dataflow = {
204
205
  }
205
206
  }
206
207
  },
208
+ /** The value a plain assignment binds to the definition `def`, `undefined` for any other kind of definition (`class(x) <- `, `assign`, a parameter, ...). */
209
+ assignedValueOf(def, graph) {
210
+ const vertex = graph.getVertex(def);
211
+ const byAssignment = exports.Dataflow.targetsOf(graph, def, edge_1.EdgeType.DefinedBy).some(t => vertex_1.DfgVertex.hasOrigin(graph.getVertex(t), built_in_proc_name_1.BuiltInProcName.Assignment));
212
+ return vertex_1.DfgVertex.isVariableDefinition(vertex) && byAssignment && vertex.source?.length === 1 ? vertex.source[0] : undefined;
213
+ },
207
214
  /** Every variable definition of the graph by its unquoted name, in a single pass. */
208
215
  definitionsByName(graph) {
209
216
  const byName = new defaultmap_1.DefaultMap(() => []);
@@ -252,6 +252,35 @@ function(x) {
252
252
  'package-runtime': {
253
253
  configType: 'PackageRuntimeConfig', ruleType: 'PACKAGE_RUNTIME', testfile: 'cmd-check/lint-package-runtime',
254
254
  example: { code: 'f <- function() 1', files: { DESCRIPTION: ExampleDescription, 'NAMESPACE': 'export(f)\nexport(g)\nexportPattern("^api_")\n' } }
255
+ },
256
+ 'secret-exfiltration': {
257
+ configType: 'SecretExfiltrationConfig', ruleType: 'SECRET_EXFILTRATION', testfile: 'lint-secret-exfiltration',
258
+ example: `
259
+ key <- Sys.getenv("API_KEY")
260
+ server <- function(input, output, session) {
261
+ httr2::request("https://api.example.org") |>
262
+ httr2::req_auth_bearer_token(key)
263
+ httr::GET(input$url, httr::add_headers(Authorization = key))
264
+ output$debug <- renderPrint(Sys.getenv())
265
+ message("calling with ", key)
266
+ message("key set: ", nzchar(key))
267
+ httr::GET(paste0("https://api.example.org/?key=", key))
268
+ }
269
+ `,
270
+ config: { optIn: ['url'] }
271
+ },
272
+ 'process-state-in-session': {
273
+ configType: 'ProcessStateInSessionConfig', ruleType: 'PROCESS_STATE_IN_SESSION', testfile: 'lint-process-state-in-session',
274
+ example: `
275
+ counter <- reactiveVal(0)
276
+ addResourcePath("data", "/srv/data")
277
+ server <- function(input, output, session) {
278
+ user <<- input$name
279
+ options(digits = input$digits)
280
+ counter(counter() + 1)
281
+ output$plot <- renderPlot(plot(load_for(session$user, input$n))) |> bindCache(input$n)
282
+ }
283
+ `
255
284
  }
256
285
  };
257
286
  /** the kinds of issue a rule finds, each rule carries at most one */
@@ -382,7 +382,7 @@ enables quick statistics after each REPL command. Likewise, ${ctx.linkConfig('re
382
382
  const inference = 'df-shape';
383
383
  const exampleCode = 'df <- data.frame(id = 1:3) |>\n filter(df, FALSE)';
384
384
  return `
385
- This query infers all shapes of dataframes within the code using abstract interpretaion. For example, you can use:
385
+ This query infers all shapes of dataframes within the code using abstract interpretation. For example, you can use:
386
386
  ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'absint', inference: inference }], { showCode: true, collapseQuery: true, ctx })}
387
387
 
388
388
  The query optionally also accepts slice criteria to narrow the results to specific nodes. For example:
@@ -390,6 +390,25 @@ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{ type: 'absint', infere
390
390
  `;
391
391
  }
392
392
  });
393
+ (0, doc_query_1.registerQueryDocumentation)('taint', {
394
+ type: 'active',
395
+ shortDescription: 'Returns the taint values inferred for every expression.',
396
+ buildExplanation: async (shell, ctx) => {
397
+ const defs = ['normalization-constant'];
398
+ const exampleCode = `
399
+ x <- c(1 , 2 , 3 , 4 , 5)\n
400
+ y <- scale(x)\n
401
+ z <- mean(y)`;
402
+ return `
403
+ This query infers all taints for one or multiple analysis definitions within the code using taint analysis.
404
+ For example, you can use the following query to get the results of the normalization analysis:
405
+ ${await (0, doc_query_1.showQuery)(shell, exampleCode, [{
406
+ type: 'taint',
407
+ defs: defs
408
+ }], { showCode: true, collapseQuery: true, ctx })}
409
+ `;
410
+ }
411
+ });
393
412
  (0, doc_query_1.registerQueryDocumentation)('compound', {
394
413
  name: 'Compound Query',
395
414
  type: 'virtual',
@@ -12,7 +12,8 @@ const secure_mode_1 = require("../util/secure-mode");
12
12
  const RegexRuleOptions = {
13
13
  'absolute-file-paths': ['absolutePathRegex'],
14
14
  'problematic-inputs': ['consider', 'pipeCommandFunctions'],
15
- 'no-leaked-credentials': ['credentialNamePattern', 'credentialValuePattern']
15
+ 'no-leaked-credentials': ['credentialNamePattern', 'credentialValuePattern', 'credentialCallPattern'],
16
+ 'secret-exfiltration': ['credentialNamePattern', 'credentialValuePattern', 'secretFiles', 'trustedFiles']
16
17
  };
17
18
  /** The given rule config without the {@link RegexRuleOptions} if the secure mode is enabled. */
18
19
  function withoutUntrustedRegexes(ruleName, config) {
@@ -1122,6 +1122,71 @@ export declare const LintingRules: {
1122
1122
  };
1123
1123
  };
1124
1124
  };
1125
+ readonly 'secret-exfiltration': {
1126
+ readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"from", [], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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>[]>>;
1127
+ 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: import("./rules/secret-exfiltration").SecretExfiltrationConfig, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
1128
+ results: import("./rules/secret-exfiltration").SecretExfiltrationResult[];
1129
+ '.meta': {
1130
+ secretSinkCalls: number;
1131
+ };
1132
+ }>;
1133
+ readonly prettyPrint: {
1134
+ readonly query: (r: import("./rules/secret-exfiltration").SecretExfiltrationResult, metadata: unknown) => string;
1135
+ readonly full: (r: import("./rules/secret-exfiltration").SecretExfiltrationResult, metadata: unknown) => string;
1136
+ };
1137
+ readonly info: {
1138
+ readonly name: "Secret Exfiltration";
1139
+ readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Security, import("./linter-tags").LintingRuleTag.Shiny];
1140
+ readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
1141
+ readonly description: "Finds secrets (environment, keyrings, config, credential files) sent to untrusted hosts, the browser, or logs, and optionally into urls, files, other processes, or language models.";
1142
+ readonly defaultConfig: () => {
1143
+ credentialNamePattern: string;
1144
+ credentialValuePattern: string;
1145
+ sources: never[];
1146
+ declassifiers: never[];
1147
+ sinks: readonly import("../taint-analysis/predefined/secret-analysis").SecretSink[];
1148
+ optIn: never[];
1149
+ controlledInputs: (import("../queries/catalog/input-sources-query/input-types").InputType.Parameter | import("../queries/catalog/input-sources-query/input-types").InputType.File | import("../queries/catalog/input-sources-query/input-types").InputType.Network | import("../queries/catalog/input-sources-query/input-types").InputType.CommandLine | import("../queries/catalog/input-sources-query/input-types").InputType.User)[];
1150
+ fileTrust: import("../taint-analysis/predefined/secret-analysis").FileTrust.None;
1151
+ secretFiles: string;
1152
+ trustedFiles: string;
1153
+ };
1154
+ };
1155
+ };
1156
+ readonly 'process-state-in-session': {
1157
+ readonly createSearch: () => import("../search/flowr-search-builder").FlowrSearchBuilder<"from", [], import("../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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>[]>>;
1158
+ 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: import("./rules/process-state-in-session").ProcessStateInSessionConfig, data: import("..").ReadonlyFlowrAnalysisProvider<import("..").KnownParser>) => Promise<{
1159
+ results: import("./rules/process-state-in-session").ProcessStateInSessionResult[];
1160
+ '.meta': {
1161
+ sessionFunctions: number;
1162
+ };
1163
+ }>;
1164
+ readonly prettyPrint: {
1165
+ readonly query: (r: import("./rules/process-state-in-session").ProcessStateInSessionResult, metadata: unknown) => string;
1166
+ readonly full: (r: import("./rules/process-state-in-session").ProcessStateInSessionResult, metadata: unknown) => string;
1167
+ };
1168
+ readonly info: {
1169
+ readonly name: "Process State in Session";
1170
+ readonly tags: readonly [import("./linter-tags").LintingRuleTag.Bug, import("./linter-tags").LintingRuleTag.Security, import("./linter-tags").LintingRuleTag.Shiny];
1171
+ readonly certainty: import("./linter-format").LintingRuleCertainty.BestEffort;
1172
+ readonly description: "Finds per-session Shiny code changing state all sessions share: globals, options, environment variables, the working directory, namespaces, top-level reactive values, shared caches (memoise, bindCache, cachem) whose key misses session values, and resource paths.";
1173
+ readonly defaultConfig: () => {
1174
+ sessionSignatures: string[][];
1175
+ settings: {
1176
+ options: string;
1177
+ 'Sys.setenv': string;
1178
+ 'Sys.unsetenv': string;
1179
+ setwd: string;
1180
+ 'Sys.setlocale': string;
1181
+ 'set.seed': string;
1182
+ 'Sys.umask': string;
1183
+ };
1184
+ sharedState: string[];
1185
+ caches: string[];
1186
+ memoisers: string[];
1187
+ };
1188
+ };
1189
+ };
1125
1190
  };
1126
1191
  export type LintingRuleNames = keyof typeof LintingRules;
1127
1192
  export type LintingRuleMetadata<Name extends LintingRuleNames> = typeof LintingRules[Name] extends LintingRule<infer _Result, infer Metadata, infer _Config, infer _Info, infer _Elements> ? Metadata : never;
@@ -43,6 +43,8 @@ const package_metafiles_1 = require("./rules/cmd-check/package-metafiles");
43
43
  const rd_files_1 = require("./rules/cmd-check/rd-files");
44
44
  const package_data_1 = require("./rules/cmd-check/package-data");
45
45
  const package_runtime_1 = require("./rules/cmd-check/package-runtime");
46
+ const secret_exfiltration_1 = require("./rules/secret-exfiltration");
47
+ const process_state_in_session_1 = require("./rules/process-state-in-session");
46
48
  /**
47
49
  * The registry of currently supported linting rules.
48
50
  * A linting rule can be executed on a dataflow pipeline result using {@link executeLintingRule}.
@@ -89,6 +91,8 @@ exports.LintingRules = {
89
91
  'package-metafiles': package_metafiles_1.PACKAGE_METAFILES,
90
92
  'rd-files': rd_files_1.RD_FILES,
91
93
  'package-data': package_data_1.PACKAGE_DATA,
92
- 'package-runtime': package_runtime_1.PACKAGE_RUNTIME
94
+ 'package-runtime': package_runtime_1.PACKAGE_RUNTIME,
95
+ 'secret-exfiltration': secret_exfiltration_1.SECRET_EXFILTRATION,
96
+ 'process-state-in-session': process_state_in_session_1.PROCESS_STATE_IN_SESSION
93
97
  };
94
98
  //# sourceMappingURL=linter-rules.js.map
@@ -1,8 +1,13 @@
1
+ import type { DataflowGraphVertexFunctionCall } from '../../../dataflow/graph/vertex';
1
2
  import { LintingRuleCertainty } from '../../linter-format';
2
3
  import type { MergeableRecord } from '../../../util/objects';
3
4
  import { LintingRuleTag } from '../../linter-tags';
4
- import type { ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
+ import { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
+ import type { AstIdMap, ParentInformation } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
7
+ import type { DataflowInformation } from '../../../dataflow/info';
8
+ import type { ReadOnlyFlowrAnalyzerContext } from '../../../project/context/flowr-analyzer-context';
5
9
  import { type CmdCheckResult } from './cmd-check-util';
10
+ import { RNode } from '../../../r-bridge/lang-4.x/ast/model/model';
6
11
  /** how the code changes the global environment or the search path */
7
12
  export type GlobalEnvironmentModificationKind =
8
13
  /** `assign(..., envir = globalenv())` */
@@ -30,6 +35,14 @@ export interface GlobalEnvironmentModificationMetadata extends MergeableRecord {
30
35
  /** calls of `assign`, `data` and `attach` inspected */
31
36
  readonly consideredCalls: number;
32
37
  }
38
+ /** the variable an `assign` into the global environment writes (`undefined` if not constant) */
39
+ export declare function globalAssignment(call: DataflowGraphVertexFunctionCall, df: DataflowInformation, idMap: AstIdMap, ctx: ReadOnlyFlowrAnalyzerContext): {
40
+ variable?: string;
41
+ } | undefined;
42
+ /** the variable an assignment target writes, looking through replacement calls and accesses (`names(x)`, `x$a`, `x[[1]]`) */
43
+ export declare function targetVariable(lhs: RNode<ParentInformation>): string | undefined;
44
+ /** what a `<<-` in a package function writes: a binding of an enclosing scope, the package namespace, or the global environment */
45
+ export declare function superAssignmentTarget(op: RNode<ParentInformation>, name: string, idMap: AstIdMap, topLevel: ReadonlySet<string>, memo: Map<NodeId, ReadonlySet<string>>): 'enclosing' | 'namespace' | 'global' | 'top-level';
33
46
  /**
34
47
  * Port of the `R CMD check` notes on code that changes the global environment
35
48
  * (`checking R code for possible problems`): `tools:::.check_package_code_assign_to_globalenv`,
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GLOBAL_ENVIRONMENT_MODIFICATION = void 0;
4
+ exports.globalAssignment = globalAssignment;
5
+ exports.targetVariable = targetVariable;
6
+ exports.superAssignmentTarget = superAssignmentTarget;
4
7
  const linter_format_1 = require("../../linter-format");
5
8
  const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
6
9
  const r_number_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-number");
@@ -53,6 +56,15 @@ function denotesGlobalEnv(node, environment, df, idMap, ctx, depth = 0) {
53
56
  return value !== undefined && denotesGlobalEnv(value, df.graph.getVertex(d)?.environment ?? environment, df, idMap, ctx, depth + 1);
54
57
  });
55
58
  }
59
+ /** the variable an `assign` into the global environment writes (`undefined` if not constant) */
60
+ function globalAssignment(call, df, idMap, ctx) {
61
+ const args = function_semantics_1.FunctionSemantics.call.match.toSpec(call.args, EnvironmentWriters.assign);
62
+ const arg = (formal) => r_argument_1.RArgument.valueOf(args.get(formal)?.length === 1 ? idMap.get(args.get(formal)?.[0] ?? '') : undefined);
63
+ const env = call.environment ?? df.environment;
64
+ const target = arg('x');
65
+ const global = denotesGlobalEnv(arg('envir'), env, df, idMap, ctx) || denotesGlobalPos(arg('pos')) || denotesGlobalEnv(arg('pos'), env, df, idMap, ctx);
66
+ return global ? { variable: r_string_1.RString.is(target) ? target.content.str : undefined } : undefined;
67
+ }
56
68
  /** whether a `pos` argument names the global environment, which is the first entry of the search path */
57
69
  function denotesGlobalPos(node) {
58
70
  return (r_number_1.RNumber.is(node) && node.content.num === 1) || (r_string_1.RString.is(node) && node.content.str === '.GlobalEnv');
@@ -181,13 +193,9 @@ exports.GLOBAL_ENVIRONMENT_MODIFICATION = {
181
193
  add(node, 'attach', 'attach() puts an object on the search path, where it masks and is masked by others; access it directly or use with() instead');
182
194
  break;
183
195
  case 'assign': {
184
- const target = valueOf(arg('x'));
185
- const variable = r_string_1.RString.is(target) ? target.content.str : undefined;
186
- if (variable !== undefined && allowed.has(variable)) {
187
- break;
188
- }
189
- if (denotesGlobalEnv(valueOf(arg('envir')), env, df, idMap, ctx) || denotesGlobalPos(valueOf(arg('pos'))) || denotesGlobalEnv(valueOf(arg('pos')), env, df, idMap, ctx)) {
190
- add(node, 'assign', `assign() writes ${variable === undefined ? 'a variable' : `'${variable}'`} into the global environment, which belongs to the user`, variable);
196
+ const global = globalAssignment(call, df, idMap, ctx);
197
+ if (global !== undefined && (global.variable === undefined || !allowed.has(global.variable))) {
198
+ add(node, 'assign', `assign() writes ${global.variable === undefined ? 'a variable' : `'${global.variable}'`} into the global environment, which belongs to the user`, global.variable);
191
199
  }
192
200
  break;
193
201
  }
@@ -36,13 +36,19 @@ function addressParam(params) {
36
36
  */
37
37
  function networkFunctions(index) {
38
38
  const resources = new Map();
39
+ /* the calls with a destination they save to, like the `destfile` of a download, which is a path rather than an address */
40
+ const saving = new Set();
39
41
  for (const param of index.params(built_in_props_1.ArgProp.Resource)) {
42
+ const key = identifier_1.Identifier.toString(param.call);
40
43
  /* R opens a path it writes to as a local file (or a `|` pipe), never as a url, and a command is no address either */
41
44
  const tags = index.get(param.call)?.tags;
45
+ if ((param.props & built_in_props_1.ArgProp.Written) !== 0) {
46
+ saving.add(key);
47
+ continue;
48
+ }
42
49
  if ((tags?.includes(built_in_props_1.SemanticCallTag.Writes) && !tags.includes(built_in_props_1.SemanticCallTag.Reads)) || tags?.includes(built_in_props_1.SemanticCallTag.Process)) {
43
50
  continue;
44
51
  }
45
- const key = identifier_1.Identifier.toString(param.call);
46
52
  resources.set(key, [...resources.get(key) ?? [], param]);
47
53
  }
48
54
  const names = new Map(index.with(built_in_props_1.SemanticCallTag.Network).map(call => [identifier_1.Identifier.toString(call), call]));
@@ -55,10 +61,12 @@ function networkFunctions(index) {
55
61
  const params = resources.get(key);
56
62
  const address = params === undefined ? undefined : addressParam(params);
57
63
  const tags = index.get(name)?.tags;
64
+ /* a call touching files only to save what it fetched, like `req_perform(req, path)`, opens no local file in place of the network */
65
+ const mayOpenLocal = tags?.includes(built_in_props_1.SemanticCallTag.File) && !(saving.has(key) && address === undefined);
58
66
  return {
59
67
  name,
60
68
  ...(address === undefined ? {} : { info: { argIdx: address.index, argName: address.name, resolveValue: true } }),
61
- ...(tags?.includes(built_in_props_1.SemanticCallTag.Network) && !tags.includes(built_in_props_1.SemanticCallTag.File) ? {} : { onlyTriggerWithArgument: UrlPattern })
69
+ ...(tags?.includes(built_in_props_1.SemanticCallTag.Network) && !mayOpenLocal ? {} : { onlyTriggerWithArgument: UrlPattern })
62
70
  };
63
71
  });
64
72
  }
@@ -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 { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
5
+ export declare const defaultCredentialValuePattern: string;
5
6
  export interface NoLeakedCredentialsResult extends LintingResult {
6
7
  readonly variableName: string;
7
8
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NO_LEAKED_CREDENTIALS = void 0;
3
+ exports.NO_LEAKED_CREDENTIALS = exports.defaultCredentialValuePattern = void 0;
4
4
  const linter_format_1 = require("../linter-format");
5
5
  const flowr_search_builder_1 = require("../../search/flowr-search-builder");
6
6
  const range_1 = require("../../util/range");
@@ -17,7 +17,7 @@ const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
17
17
  const df_helper_1 = require("../../dataflow/graph/df-helper");
18
18
  const defaultCredentialNamePattern = '(?:passw(?:or)?d|authorization|passphrase|(?:^|[_.])pass(?:$|[_.])|pwd|secret|api[_.]?key|access[_.]?key|(?:^|[_.])token$|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential|(?:^|[_.])pat$)';
19
19
  const defaultCredentialCallPattern = '(?:auth|login|signin|credential|password|secret|token|key_?set)';
20
- const defaultCredentialValuePattern = '(?:(?<![A-Za-z0-9_])|(?<=\\\\[nrt]))(?:' +
20
+ exports.defaultCredentialValuePattern = '(?:(?<![A-Za-z0-9_])|(?<=\\\\[nrt]))(?:' +
21
21
  '(?:AKIA|AIPA|ASIA|AROA)[A-Z0-9]{16}' + // AWS access key IDs (exact 20-char format)
22
22
  '|gh[psoar]_[A-Za-z0-9_]{10,}' + // GitHub Classic/App/OAuth/Actions tokens
23
23
  '|github_pat_[A-Za-z0-9_]{10,}' + // GitHub fine-grained PATs
@@ -158,7 +158,7 @@ exports.NO_LEAKED_CREDENTIALS = {
158
158
  certainty: linter_format_1.LintingRuleCertainty.BestEffort,
159
159
  defaultConfig: () => ({
160
160
  credentialNamePattern: defaultCredentialNamePattern,
161
- credentialValuePattern: defaultCredentialValuePattern,
161
+ credentialValuePattern: exports.defaultCredentialValuePattern,
162
162
  credentialCallPattern: defaultCredentialCallPattern
163
163
  })
164
164
  }