@eagleoutice/flowr 2.10.8 → 2.10.10

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 (260) hide show
  1. package/README.md +106 -36
  2. package/abstract-interpretation/absint-visitor.js +6 -3
  3. package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
  4. package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
  5. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  6. package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
  7. package/abstract-interpretation/domains/interval-domain.js +1 -1
  8. package/abstract-interpretation/domains/lattice.d.ts +1 -1
  9. package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
  10. package/abstract-interpretation/domains/partial-product-domain.js +2 -2
  11. package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
  12. package/abstract-interpretation/domains/set-range-domain.js +1 -1
  13. package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
  14. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  15. package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
  16. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  17. package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
  18. package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
  19. package/abstract-interpretation/unsupported-functions.d.ts +3 -2
  20. package/abstract-interpretation/unsupported-functions.js +38 -28
  21. package/cli/benchmark-app.js +2 -1
  22. package/cli/common/script.js +3 -2
  23. package/cli/flowr.js +47 -10
  24. package/cli/repl/commands/repl-cfg.js +9 -9
  25. package/cli/repl/commands/repl-commands.js +5 -0
  26. package/cli/repl/commands/repl-dataflow.js +31 -24
  27. package/cli/repl/commands/repl-main.d.ts +6 -0
  28. package/cli/repl/commands/repl-normalize.js +15 -12
  29. package/cli/repl/commands/repl-parse.js +1 -1
  30. package/cli/repl/commands/repl-query.js +4 -5
  31. package/cli/repl/commands/repl-quit.js +2 -1
  32. package/cli/repl/core.d.ts +11 -0
  33. package/cli/repl/core.js +101 -3
  34. package/cli/repl/execute.js +3 -2
  35. package/cli/repl/parser/slice-query-parser.d.ts +16 -0
  36. package/cli/repl/parser/slice-query-parser.js +52 -0
  37. package/cli/repl/server/connection.d.ts +1 -0
  38. package/cli/repl/server/connection.js +25 -0
  39. package/cli/repl/server/messages/message-analysis.d.ts +10 -0
  40. package/cli/repl/server/messages/message-analysis.js +6 -2
  41. package/cli/repl/server/messages/message-slice.d.ts +1 -1
  42. package/cli/script-core/statistics-core.js +2 -1
  43. package/cli/script-core/statistics-helper-core.js +2 -1
  44. package/cli/wiki.d.ts +2 -1
  45. package/cli/wiki.js +4 -1
  46. package/config.d.ts +9 -0
  47. package/config.js +23 -1
  48. package/control-flow/diff-cfg.d.ts +1 -1
  49. package/control-flow/diff-cfg.js +1 -1
  50. package/control-flow/extract-cfg.js +9 -3
  51. package/control-flow/semantic-cfg-guided-visitor.js +1 -0
  52. package/control-flow/simple-visitor.js +6 -5
  53. package/control-flow/useless-loop.js +2 -2
  54. package/core/print/dataflow-printer.d.ts +2 -2
  55. package/core/print/dataflow-printer.js +2 -2
  56. package/core/steps/all/static-slicing/00-slice.js +1 -1
  57. package/core/steps/pipeline/default-pipelines.d.ts +146 -146
  58. package/dataflow/environments/append.d.ts +2 -1
  59. package/dataflow/environments/append.js +2 -1
  60. package/dataflow/environments/built-in-proc-name.d.ts +2 -0
  61. package/dataflow/environments/built-in-proc-name.js +2 -0
  62. package/dataflow/environments/built-in.d.ts +2 -0
  63. package/dataflow/environments/built-in.js +2 -0
  64. package/dataflow/environments/default-builtin-config.d.ts +122 -66
  65. package/dataflow/environments/default-builtin-config.js +324 -145
  66. package/dataflow/environments/environment.d.ts +2 -1
  67. package/dataflow/environments/environment.js +13 -9
  68. package/dataflow/environments/identifier.d.ts +55 -2
  69. package/dataflow/environments/identifier.js +14 -2
  70. package/dataflow/environments/reference-to-maybe.d.ts +2 -0
  71. package/dataflow/environments/reference-to-maybe.js +56 -11
  72. package/dataflow/environments/resolve-by-name.js +13 -7
  73. package/dataflow/eval/values/general.js +4 -0
  74. package/dataflow/extractor.js +22 -3
  75. package/dataflow/graph/df-helper.d.ts +6 -0
  76. package/dataflow/graph/df-helper.js +33 -0
  77. package/dataflow/graph/graph.js +7 -3
  78. package/dataflow/info.d.ts +1 -1
  79. package/dataflow/info.js +3 -1
  80. package/dataflow/internal/linker.d.ts +5 -1
  81. package/dataflow/internal/linker.js +34 -9
  82. package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -1
  83. package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
  84. package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
  85. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
  86. package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
  87. package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
  88. package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
  89. package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
  90. package/dataflow/internal/process/functions/call/built-in/built-in-source.js +19 -0
  91. package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
  92. package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
  93. package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
  94. package/dataflow/origin/dfg-get-origin.d.ts +1 -1
  95. package/dataflow/origin/dfg-get-origin.js +1 -1
  96. package/dataflow/processor.d.ts +6 -0
  97. package/documentation/data/faq/faqs.d.ts +2 -1
  98. package/documentation/data/faq/faqs.js +75 -57
  99. package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
  100. package/documentation/data/server/doc-data-server-messages.js +15 -7
  101. package/documentation/doc-readme.js +15 -15
  102. package/documentation/doc-util/doc-cfg.d.ts +3 -1
  103. package/documentation/doc-util/doc-cfg.js +3 -3
  104. package/documentation/doc-util/doc-dfg.d.ts +3 -1
  105. package/documentation/doc-util/doc-dfg.js +3 -3
  106. package/documentation/doc-util/doc-files.d.ts +3 -1
  107. package/documentation/doc-util/doc-files.js +9 -6
  108. package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
  109. package/documentation/doc-util/doc-normalized-ast.js +2 -2
  110. package/documentation/doc-util/doc-query.d.ts +2 -1
  111. package/documentation/doc-util/doc-query.js +2 -2
  112. package/documentation/doc-util/doc-repl.js +1 -0
  113. package/documentation/doc-util/doc-types.d.ts +6 -6
  114. package/documentation/doc-util/doc-types.js +11 -9
  115. package/documentation/issue-linting-rule.js +1 -2
  116. package/documentation/wiki-analyzer.js +9 -9
  117. package/documentation/wiki-cfg.js +40 -41
  118. package/documentation/wiki-core.js +119 -31
  119. package/documentation/wiki-create-linting-rules.d.ts +6 -0
  120. package/documentation/wiki-create-linting-rules.js +95 -0
  121. package/documentation/wiki-dataflow-graph.js +77 -76
  122. package/documentation/wiki-engine.js +1 -2
  123. package/documentation/wiki-faq.d.ts +2 -1
  124. package/documentation/wiki-faq.js +4 -4
  125. package/documentation/wiki-interface.js +19 -6
  126. package/documentation/wiki-linter.d.ts +1 -1
  127. package/documentation/wiki-linter.js +14 -6
  128. package/documentation/wiki-linting-and-testing.js +2 -2
  129. package/documentation/wiki-mk/doc-context.d.ts +3 -3
  130. package/documentation/wiki-mk/doc-maker.d.ts +2 -0
  131. package/documentation/wiki-mk/doc-maker.js +7 -1
  132. package/documentation/wiki-normalized-ast.js +5 -5
  133. package/documentation/wiki-onboarding.d.ts +2 -1
  134. package/documentation/wiki-onboarding.js +5 -5
  135. package/documentation/wiki-overview.js +3 -3
  136. package/documentation/wiki-query.js +85 -84
  137. package/documentation/wiki-search.js +4 -5
  138. package/documentation/wiki-setup.js +6 -7
  139. package/gas.d.ts +74 -0
  140. package/gas.js +18 -0
  141. package/linter/linter-executor.js +2 -8
  142. package/linter/linter-format.d.ts +4 -11
  143. package/linter/linter-rules.d.ts +88 -86
  144. package/linter/linter-rules.js +7 -1
  145. package/linter/rules/absolute-path.d.ts +2 -7
  146. package/linter/rules/absolute-path.js +6 -4
  147. package/linter/rules/dataframe-access-validation.d.ts +1 -6
  148. package/linter/rules/dataframe-access-validation.js +8 -6
  149. package/linter/rules/dead-code.d.ts +2 -11
  150. package/linter/rules/dead-code.js +16 -11
  151. package/linter/rules/deprecated-functions.d.ts +3 -3
  152. package/linter/rules/file-path-validity.d.ts +1 -6
  153. package/linter/rules/file-path-validity.js +5 -5
  154. package/linter/rules/function-finder-util.d.ts +7 -11
  155. package/linter/rules/function-finder-util.js +9 -6
  156. package/linter/rules/naming-convention.d.ts +2 -7
  157. package/linter/rules/naming-convention.js +3 -2
  158. package/linter/rules/network-functions.d.ts +2 -7
  159. package/linter/rules/network-functions.js +14 -12
  160. package/linter/rules/no-leaked-credentials.d.ts +36 -0
  161. package/linter/rules/no-leaked-credentials.js +75 -0
  162. package/linter/rules/problematic-inputs.d.ts +1 -8
  163. package/linter/rules/problematic-inputs.js +5 -4
  164. package/linter/rules/roxygen-arguments.d.ts +2 -7
  165. package/linter/rules/roxygen-arguments.js +13 -20
  166. package/linter/rules/seeded-randomness.d.ts +2 -7
  167. package/linter/rules/seeded-randomness.js +7 -4
  168. package/linter/rules/software-has-license.d.ts +31 -0
  169. package/linter/rules/software-has-license.js +46 -0
  170. package/linter/rules/software-has-tests.d.ts +38 -0
  171. package/linter/rules/software-has-tests.js +48 -0
  172. package/linter/rules/stop-with-call-arg.d.ts +2 -7
  173. package/linter/rules/stop-with-call-arg.js +3 -2
  174. package/linter/rules/unused-definition.d.ts +3 -8
  175. package/linter/rules/unused-definition.js +7 -5
  176. package/linter/rules/useless-loop.d.ts +2 -7
  177. package/linter/rules/useless-loop.js +5 -2
  178. package/package.json +3 -2
  179. package/project/context/flowr-analyzer-context.d.ts +13 -14
  180. package/project/context/flowr-analyzer-context.js +4 -0
  181. package/project/context/flowr-analyzer-files-context.d.ts +12 -0
  182. package/project/context/flowr-analyzer-files-context.js +12 -2
  183. package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
  184. package/project/context/flowr-analyzer-gas-context.js +101 -0
  185. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
  186. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
  187. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
  188. package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
  189. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
  190. package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
  191. package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
  192. package/project/plugins/flowr-analyzer-plugin.js +14 -7
  193. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
  194. package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
  195. package/project/plugins/plugin-registry.d.ts +2 -1
  196. package/project/plugins/plugin-registry.js +3 -1
  197. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
  198. package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
  199. package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
  200. package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
  201. package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
  202. package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
  203. package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
  204. package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
  205. package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
  206. package/queries/catalog/dice-query/dice-query-executor.js +52 -0
  207. package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
  208. package/queries/catalog/dice-query/dice-query-format.js +102 -0
  209. package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
  210. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
  211. package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
  212. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
  213. package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
  214. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
  215. package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
  216. package/queries/catalog/linter-query/linter-query-executor.js +7 -0
  217. package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
  218. package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
  219. package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
  220. package/queries/catalog/origin-query/origin-query-format.js +1 -0
  221. package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
  222. package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
  223. package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
  224. package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
  225. package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
  226. package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
  227. package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
  228. package/queries/query.d.ts +18 -1
  229. package/queries/query.js +3 -1
  230. package/r-bridge/data/data.d.ts +5 -0
  231. package/r-bridge/data/data.js +6 -0
  232. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
  233. package/r-bridge/lang-4.x/ast/model/processing/decorate.js +10 -1
  234. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
  235. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
  236. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
  237. package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
  238. package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +63 -44
  239. package/r-bridge/parser.js +2 -9
  240. package/r-bridge/shell.d.ts +8 -1
  241. package/r-bridge/shell.js +26 -7
  242. package/search/flowr-search-builder.d.ts +2 -2
  243. package/search/flowr-search-builder.js +1 -1
  244. package/search/flowr-search-filters.d.ts +30 -9
  245. package/search/flowr-search-filters.js +26 -21
  246. package/search/search-executor/search-enrichers.d.ts +600 -0
  247. package/search/search-executor/search-enrichers.js +23 -2
  248. package/slicing/static/static-slicer.d.ts +39 -11
  249. package/slicing/static/static-slicer.js +44 -14
  250. package/util/collections/queue.d.ts +16 -0
  251. package/util/collections/queue.js +38 -0
  252. package/util/log.d.ts +1 -1
  253. package/util/log.js +1 -1
  254. package/util/mermaid/dfg.d.ts +2 -2
  255. package/util/mermaid/dfg.js +2 -2
  256. package/util/objects.d.ts +9 -0
  257. package/util/objects.js +57 -1
  258. package/util/proc.d.ts +6 -0
  259. package/util/proc.js +20 -0
  260. package/util/version.js +1 -1
@@ -35,15 +35,10 @@ export interface AbsoluteFilePathMetadata extends MergeableRecord {
35
35
  }
36
36
  export declare const ABSOLUTE_PATH: {
37
37
  readonly createSearch: (config: AbsoluteFilePathConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["unique"], 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>[]>>;
38
- 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: AbsoluteFilePathConfig, data: {
39
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
40
- dataflow: import("../../dataflow/info").DataflowInformation;
41
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
42
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
43
- }) => {
38
+ 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: AbsoluteFilePathConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
44
39
  results: AbsoluteFilePathResult[];
45
40
  ".meta": AbsoluteFilePathMetadata;
46
- };
41
+ }>;
47
42
  readonly prettyPrint: {
48
43
  readonly query: (result: AbsoluteFilePathResult) => string;
49
44
  readonly full: (result: AbsoluteFilePathResult) => string;
@@ -103,13 +103,15 @@ exports.ABSOLUTE_PATH = {
103
103
  }
104
104
  return q.unique();
105
105
  },
106
- processSearchResult: (elements, config, data) => {
106
+ processSearchResult: async (elements, config, data) => {
107
107
  const metadata = {
108
108
  totalConsidered: 0,
109
109
  totalUnknown: 0
110
110
  };
111
111
  const queryResults = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData)?.queries;
112
112
  const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
113
+ const normalize = await data.normalize();
114
+ const dataflow = await data.dataflow();
113
115
  return {
114
116
  results: elements.getElements().flatMap(element => {
115
117
  metadata.totalConsidered++;
@@ -139,7 +141,7 @@ exports.ABSOLUTE_PATH = {
139
141
  if (resolved === undefined || !(0, strings_1.isAbsolutePath)(resolved, regex)) {
140
142
  return [];
141
143
  }
142
- const elem = data.normalize.idMap.get(r.nodeId);
144
+ const elem = normalize.idMap.get(r.nodeId);
143
145
  return [{
144
146
  certainty: linter_format_1.LintingResultCertainty.Certain,
145
147
  filePath: resolved,
@@ -156,10 +158,10 @@ exports.ABSOLUTE_PATH = {
156
158
  }
157
159
  }
158
160
  else {
159
- const dfNode = data.dataflow.graph.getVertex(node.info.id);
161
+ const dfNode = dataflow.graph.getVertex(node.info.id);
160
162
  if ((0, vertex_1.isFunctionCallVertex)(dfNode)) {
161
163
  const handler = dfNode.name ? PathFunctions.get(dfNode.name) : undefined;
162
- const strings = handler ? handler(data.dataflow.graph, dfNode, data.analyzer.inspectContext()) : [];
164
+ const strings = handler ? handler(dataflow.graph, dfNode, data.inspectContext()) : [];
163
165
  if (strings) {
164
166
  return strings.flatMap(s => {
165
167
  const resolved = resolvePathForAbsoluteCheck(s, config.ignoreUrls);
@@ -27,12 +27,7 @@ export interface DataFrameAccessValidationMetadata extends MergeableRecord {
27
27
  }
28
28
  export declare const DATA_FRAME_ACCESS_VALIDATION: {
29
29
  readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", [], ParentInformation, FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
30
- readonly processSearchResult: (elements: FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: DataFrameAccessValidationConfig, data: {
31
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
32
- dataflow: import("../../dataflow/info").DataflowInformation;
33
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
34
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
35
- }) => Promise<{
30
+ readonly processSearchResult: (elements: FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: DataFrameAccessValidationConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
36
31
  results: DataFrameAccessValidationResult[];
37
32
  '.meta': DataFrameAccessValidationMetadata;
38
33
  }>;
@@ -15,18 +15,20 @@ const linter_tags_1 = require("../linter-tags");
15
15
  exports.DATA_FRAME_ACCESS_VALIDATION = {
16
16
  createSearch: () => flowr_search_builder_1.Q.all(),
17
17
  processSearchResult: async (elements, config, data) => {
18
- let ctx = data.analyzer.inspectContext();
18
+ const normalize = await data.normalize();
19
+ const dataflow = await data.dataflow();
20
+ let ctx = data.inspectContext();
19
21
  ctx = {
20
22
  ...ctx,
21
- config: config_1.FlowrConfig.amend(data.analyzer.flowrConfig, flowrConfig => {
23
+ config: config_1.FlowrConfig.amend(data.flowrConfig, flowrConfig => {
22
24
  if (config.readLoadedData !== undefined) {
23
25
  flowrConfig.abstractInterpretation.dataFrame.readLoadedData.readExternalFiles = config.readLoadedData;
24
26
  }
25
27
  return flowrConfig;
26
28
  })
27
29
  };
28
- const cfg = await data.analyzer.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
29
- const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg: data.dataflow.graph, normalizedAst: data.normalize, ctx });
30
+ const cfg = await data.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
31
+ const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg: dataflow.graph, normalizedAst: normalize, ctx });
30
32
  inference.start();
31
33
  const accessOperations = getAccessOperations(elements, inference);
32
34
  const accesses = [];
@@ -59,8 +61,8 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
59
61
  .map(accessed => ({ nodeId: access.nodeId, operand: access.operand, ...accessed })))
60
62
  .map(({ nodeId, operand, ...accessed }) => ({
61
63
  ...accessed,
62
- node: data.normalize.idMap.get(nodeId),
63
- operand: operand === undefined ? undefined : data.normalize.idMap.get(operand),
64
+ node: normalize.idMap.get(nodeId),
65
+ operand: operand === undefined ? undefined : normalize.idMap.get(operand),
64
66
  }))
65
67
  .map(({ node, operand, ...accessed }) => ({
66
68
  ...accessed,
@@ -10,19 +10,10 @@ export interface DeadCodeConfig extends MergeableRecord {
10
10
  */
11
11
  simplificationPasses?: CfgSimplificationPassName[];
12
12
  }
13
- export interface DeadCodeMetadata extends MergeableRecord {
14
- consideredNodes: number;
15
- }
16
13
  export declare const DEAD_CODE: {
17
- readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
18
- 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: DeadCodeConfig, _data: {
19
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
20
- dataflow: import("../../dataflow/info").DataflowInformation;
21
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
22
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
23
- }) => {
14
+ readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
15
+ 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: DeadCodeConfig, _data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => {
24
16
  results: LintingResult[];
25
- '.meta': DeadCodeMetadata;
26
17
  };
27
18
  readonly prettyPrint: {
28
19
  readonly query: (result: LintingResult) => string;
@@ -8,29 +8,34 @@ const linter_tags_1 = require("../linter-tags");
8
8
  const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
9
9
  const assert_1 = require("../../util/assert");
10
10
  const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
11
+ const flowr_search_filters_1 = require("../../search/flowr-search-filters");
11
12
  exports.DEAD_CODE = {
12
13
  createSearch: (config) => flowr_search_builder_1.Q.all().with(search_enrichers_1.Enrichment.CfgInformation, {
13
14
  checkReachable: true,
14
15
  simplificationPasses: config.simplificationPasses ?? [...cfg_simplification_1.DefaultCfgSimplificationOrder, 'analyze-dead-code']
15
- }),
16
+ }).filter(flowr_search_filters_1.F.not(flowr_search_filters_1.F.or({
17
+ name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
18
+ args: {
19
+ enrichment: search_enrichers_1.Enrichment.CfgInformation,
20
+ test: {
21
+ isReachable: true
22
+ }
23
+ }
24
+ }, {
25
+ name: flowr_search_filters_1.FlowrFilter.RoleInParent,
26
+ args: {
27
+ roleInParent: "el-g" /* RoleInParent.ExpressionListGrouping */
28
+ }
29
+ }))),
16
30
  processSearchResult: (elements, _config, _data) => {
17
- const meta = {
18
- consideredNodes: 0
19
- };
20
31
  return {
21
32
  results: combineResults(elements.getElements()
22
- .filter(element => {
23
- meta.consideredNodes++;
24
- const cfgInformation = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CfgInformation);
25
- return element.node.info.role !== "el-g" /* RoleInParent.ExpressionListGrouping */ && !cfgInformation.isReachable;
26
- })
27
33
  .map(element => ({
28
34
  certainty: linter_format_1.LintingResultCertainty.Certain,
29
35
  involvedId: element.node.info.id,
30
36
  loc: range_1.SourceLocation.fromNode(element.node)
31
37
  }))
32
- .filter(element => (0, assert_1.isNotUndefined)(element.loc))),
33
- '.meta': meta
38
+ .filter(element => (0, assert_1.isNotUndefined)(element.loc)))
34
39
  };
35
40
  },
36
41
  prettyPrint: {
@@ -3,12 +3,12 @@ import { LintingRuleTag } from '../linter-tags';
3
3
  import { type FunctionsMetadata, type FunctionsResult, type FunctionsToDetectConfig } from './function-finder-util';
4
4
  export declare const DEPRECATED_FUNCTIONS: {
5
5
  readonly createSearch: (config: FunctionsToDetectConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
6
- readonly processSearchResult: <T extends import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>(elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => (T[number] & {
6
+ readonly processSearchResult: <T extends import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>(this: void, elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => import("ts-essentials").AsyncOrSync<(T[number] & {
7
7
  certainty?: import("../linter-format").LintingResultCertainty;
8
- })[]) => {
8
+ })[]>) => Promise<{
9
9
  results: FunctionsResult[];
10
10
  '.meta': FunctionsMetadata;
11
- };
11
+ }>;
12
12
  readonly prettyPrint: {
13
13
  query: (result: FunctionsResult) => string;
14
14
  full: (result: FunctionsResult) => string;
@@ -35,12 +35,7 @@ export interface FilePathValidityMetadata extends MergeableRecord {
35
35
  }
36
36
  export declare const FILE_PATH_VALIDITY: {
37
37
  readonly createSearch: (config: FilePathValidityConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
38
- 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: FilePathValidityConfig, data: {
39
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
40
- dataflow: import("../../dataflow/info").DataflowInformation;
41
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
42
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
43
- }) => Promise<{
38
+ 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: FilePathValidityConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
44
39
  results: FilePathValidityResult[];
45
40
  ".meta": FilePathValidityMetadata;
46
41
  }>;
@@ -64,9 +64,9 @@ exports.FILE_PATH_VALIDITY = {
64
64
  // file:// URIs are local paths; resolve and check existence directly
65
65
  const localFromFileUrl = (0, strings_1.fileUrlToPath)(matchingRead.value);
66
66
  if (localFromFileUrl !== undefined) {
67
- const paths = (0, built_in_source_1.findSource)(data.analyzer.flowrConfig.solver.resolveSource, localFromFileUrl, {
67
+ const paths = (0, built_in_source_1.findSource)(data.flowrConfig.solver.resolveSource, localFromFileUrl, {
68
68
  referenceChain: element.node.info.file ? [element.node.info.file] : [],
69
- ctx: data.analyzer.inspectContext()
69
+ ctx: data.inspectContext()
70
70
  });
71
71
  if (paths && paths.length) {
72
72
  metadata.totalValid++;
@@ -97,16 +97,16 @@ exports.FILE_PATH_VALIDITY = {
97
97
  }];
98
98
  }
99
99
  // check if any write to the same file happens before the read, and exclude this case if so
100
- const writesToFile = results.write.filter(r => samePath(r.value, matchingRead.value, data.analyzer.flowrConfig.solver.resolveSource?.ignoreCapitalization));
100
+ const writesToFile = results.write.filter(r => samePath(r.value, matchingRead.value, data.flowrConfig.solver.resolveSource?.ignoreCapitalization));
101
101
  const writesBefore = writesToFile.map(w => (0, happens_before_1.happensBefore)(cfg, w.nodeId, element.node.info.id));
102
102
  if (writesBefore.some(w => w === logic_1.Ternary.Always)) {
103
103
  metadata.totalWritesBeforeAlways++;
104
104
  return [];
105
105
  }
106
106
  // check if the file exists!
107
- const paths = (0, built_in_source_1.findSource)(data.analyzer.flowrConfig.solver.resolveSource, matchingRead.value, {
107
+ const paths = (0, built_in_source_1.findSource)(data.flowrConfig.solver.resolveSource, matchingRead.value, {
108
108
  referenceChain: element.node.info.file ? [element.node.info.file] : [],
109
- ctx: data.analyzer.inspectContext()
109
+ ctx: data.inspectContext()
110
110
  });
111
111
  if (paths && paths.length) {
112
112
  metadata.totalValid++;
@@ -1,11 +1,11 @@
1
1
  import { type LintingResult, LintingResultCertainty } from '../linter-format';
2
2
  import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr-search';
3
- import type { NormalizedAst, ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
3
+ import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
4
4
  import type { MergeableRecord } from '../../util/objects';
5
- import type { DataflowInformation } from '../../dataflow/info';
6
5
  import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
7
- import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
8
6
  import { Ternary } from '../../util/logic';
7
+ import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
8
+ import type { AsyncOrSync } from 'ts-essentials';
9
9
  export interface FunctionsResult extends LintingResult {
10
10
  function: string;
11
11
  }
@@ -24,19 +24,15 @@ export interface FunctionsToDetectConfig extends MergeableRecord {
24
24
  */
25
25
  export declare const functionFinderUtil: {
26
26
  createSearch: (functions: readonly string[]) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], ParentInformation, Promise<FlowrSearchElements<ParentInformation, [] | FlowrSearchElement<ParentInformation>[]>>>;
27
- processSearchResult: <T extends FlowrSearchElement<ParentInformation>[]>(elements: FlowrSearchElements<ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => (T[number] & {
27
+ processSearchResult<T extends FlowrSearchElement<ParentInformation>[]>(this: void, elements: FlowrSearchElements<ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => AsyncOrSync<(T[number] & {
28
28
  certainty?: LintingResultCertainty;
29
- })[]) => {
29
+ })[]>): Promise<{
30
30
  results: FunctionsResult[];
31
31
  '.meta': FunctionsMetadata;
32
- };
32
+ }>;
33
33
  prettyPrint: (functionType: string) => {
34
34
  query: (result: FunctionsResult) => string;
35
35
  full: (result: FunctionsResult) => string;
36
36
  };
37
- requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, data: {
38
- normalize: NormalizedAst;
39
- dataflow: DataflowInformation;
40
- analyzer: ReadonlyFlowrAnalysisProvider;
41
- }, requireValue: RegExp | string | undefined): Ternary;
37
+ requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, analyzer: ReadonlyFlowrAnalysisProvider, requireValue: RegExp | string | undefined): Promise<Ternary>;
42
38
  };
@@ -22,16 +22,18 @@ exports.functionFinderUtil = {
22
22
  name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
23
23
  args: {
24
24
  enrichment: search_enrichers_1.Enrichment.CallTargets,
25
- test: (0, flowr_search_filters_1.testFunctionsIgnoringPackage)(functions)
25
+ test: {
26
+ targets: (0, flowr_search_filters_1.testFunctionsIgnoringPackage)(functions)
27
+ }
26
28
  }
27
29
  }));
28
30
  },
29
- processSearchResult: (elements, _config, _data, refineSearch = e => e) => {
31
+ async processSearchResult(elements, _config, _data, refineSearch = e => e) {
30
32
  const metadata = {
31
33
  totalCalls: 0,
32
34
  totalFunctionDefinitions: 0
33
35
  };
34
- const results = refineSearch(elements.getElements())
36
+ const results = (await refineSearch(elements.getElements()))
35
37
  .flatMap(element => {
36
38
  metadata.totalCalls++;
37
39
  return (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CallTargets).targets.map(target => {
@@ -60,15 +62,16 @@ exports.functionFinderUtil = {
60
62
  [linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Function \`${result.function}\` called at ${range_1.SourceLocation.format(result.loc)} is related to ${functionType}`
61
63
  };
62
64
  },
63
- requireArgumentValue(element, pool, data, requireValue) {
65
+ async requireArgumentValue(element, pool, analyzer, requireValue) {
64
66
  const info = pool.get(element.node.lexeme ?? '');
65
67
  /* if we have no additional info, we assume they always access the network */
66
68
  if (info === undefined) {
67
69
  return logic_1.Ternary.Always;
68
70
  }
69
- const vert = data.dataflow.graph.getVertex(element.node.info.id);
71
+ const dataflow = await analyzer.dataflow();
72
+ const vert = dataflow.graph.getVertex(element.node.info.id);
70
73
  if ((0, vertex_1.isFunctionCallVertex)(vert)) {
71
- const args = (0, resolve_argument_1.getArgumentStringValue)(data.analyzer.flowrConfig.solver.variables, data.dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, data.analyzer.inspectContext());
74
+ const args = (0, resolve_argument_1.getArgumentStringValue)(analyzer.flowrConfig.solver.variables, dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, analyzer.inspectContext());
72
75
  // we obtain all values, at least one of them has to trigger for the request
73
76
  const argValues = args ? args.values().flatMap(s => Array.from(s)).filter(assert_1.isNotUndefined).toArray() : [];
74
77
  if (argValues.length === 0) {
@@ -58,18 +58,13 @@ export declare function fixCasing(identifier: string, convention: CasingConventi
58
58
  export declare function createNamingConventionQuickFixes(graph: DataflowGraph, nodeId: NodeId, replacement: string, conv: CasingConvention): LintQuickFixReplacement[] | undefined;
59
59
  export declare const NAMING_CONVENTION: {
60
60
  readonly createSearch: (_config: NamingConventionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
61
- 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: NamingConventionConfig, data: {
62
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
63
- dataflow: import("../../dataflow/info").DataflowInformation;
64
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
65
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
66
- }) => {
61
+ 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: NamingConventionConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
67
62
  results: NamingConventionResult[];
68
63
  '.meta': {
69
64
  numMatches: number;
70
65
  numBreak: number;
71
66
  };
72
- };
67
+ }>;
73
68
  readonly prettyPrint: {
74
69
  readonly query: (result: NamingConventionResult) => string;
75
70
  readonly full: (result: NamingConventionResult) => string;
@@ -158,7 +158,8 @@ function createNamingConventionQuickFixes(graph, nodeId, replacement, conv) {
158
158
  }
159
159
  exports.NAMING_CONVENTION = {
160
160
  createSearch: (_config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.VariableDefinition),
161
- processSearchResult: (elements, config, data) => {
161
+ processSearchResult: async (elements, config, data) => {
162
+ const dataflow = await data.dataflow();
162
163
  const symbols = elements.getElements()
163
164
  .map(m => ({
164
165
  certainty: linter_format_1.LintingResultCertainty.Certain,
@@ -175,7 +176,7 @@ exports.NAMING_CONVENTION = {
175
176
  return {
176
177
  ...m,
177
178
  involvedId: id,
178
- quickFix: fix ? createNamingConventionQuickFixes(data.dataflow.graph, id, fix, casing) : undefined
179
+ quickFix: fix ? createNamingConventionQuickFixes(dataflow.graph, id, fix, casing) : undefined
179
180
  };
180
181
  });
181
182
  return {
@@ -12,15 +12,10 @@ export interface NetworkFunctionsConfig extends MergeableRecord {
12
12
  }
13
13
  export declare const NETWORK_FUNCTIONS: {
14
14
  readonly createSearch: (config: NetworkFunctionsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | FlowrSearchElement<ParentInformation>[]>>>;
15
- readonly processSearchResult: (e: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, c: NetworkFunctionsConfig, d: {
16
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
17
- dataflow: import("../../dataflow/info").DataflowInformation;
18
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
19
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
20
- }) => {
15
+ readonly processSearchResult: (e: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, c: NetworkFunctionsConfig, d: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
21
16
  results: FunctionsResult[];
22
17
  '.meta': FunctionsMetadata;
23
- };
18
+ }>;
24
19
  readonly prettyPrint: {
25
20
  query: (result: FunctionsResult) => string;
26
21
  full: (result: FunctionsResult) => string;
@@ -11,19 +11,21 @@ const write_functions_1 = require("../../queries/catalog/dependencies-query/func
11
11
  const FnPool = new Map(read_functions_1.ReadFunctions.concat(source_functions_1.SourceFunctions, write_functions_1.WriteFunctions).map(f => [f.name, f]));
12
12
  exports.NETWORK_FUNCTIONS = {
13
13
  createSearch: (config) => function_finder_util_1.functionFinderUtil.createSearch(config.fns),
14
- processSearchResult: (e, c, d) => function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, es => {
15
- const res = [];
16
- for (const e of es) {
17
- const val = function_finder_util_1.functionFinderUtil.requireArgumentValue(e, FnPool, d, c.onlyTriggerWithArgument);
18
- if (val === logic_1.Ternary.Never) {
19
- continue;
14
+ processSearchResult: (e, c, d) => {
15
+ return function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, async (es) => {
16
+ const res = [];
17
+ for (const e of es) {
18
+ const val = await function_finder_util_1.functionFinderUtil.requireArgumentValue(e, FnPool, d, c.onlyTriggerWithArgument);
19
+ if (val === logic_1.Ternary.Never) {
20
+ continue;
21
+ }
22
+ const x = e;
23
+ x.certainty = val === logic_1.Ternary.Always ? linter_format_1.LintingResultCertainty.Certain : linter_format_1.LintingResultCertainty.Uncertain;
24
+ res.push(x);
20
25
  }
21
- const x = e;
22
- x.certainty = val === logic_1.Ternary.Always ? linter_format_1.LintingResultCertainty.Certain : linter_format_1.LintingResultCertainty.Uncertain;
23
- res.push(x);
24
- }
25
- return res;
26
- }),
26
+ return res;
27
+ });
28
+ },
27
29
  prettyPrint: function_finder_util_1.functionFinderUtil.prettyPrint('network operations'),
28
30
  info: {
29
31
  name: 'Network Functions',
@@ -0,0 +1,36 @@
1
+ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
2
+ import type { MergeableRecord } from '../../util/objects';
3
+ import { LintingRuleTag } from '../linter-tags';
4
+ export interface NoLeakedCredentialsResult extends LintingResult {
5
+ readonly variableName: string;
6
+ }
7
+ export interface NoLeakedCredentialsConfig extends MergeableRecord {
8
+ /** Pattern matched (case-insensitively) against variable names to identify potential credential assignments */
9
+ readonly credentialNamePattern: string;
10
+ /** Pattern matched against string literal values to detect known credential formats (e.g., AWS access key IDs, GitHub tokens) */
11
+ readonly credentialValuePattern: string;
12
+ }
13
+ export interface NoLeakedCredentialsMetadata extends MergeableRecord {
14
+ readonly totalChecked: number;
15
+ }
16
+ export declare const NO_LEAKED_CREDENTIALS: {
17
+ readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
18
+ 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: NoLeakedCredentialsConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
19
+ results: NoLeakedCredentialsResult[];
20
+ ".meta": NoLeakedCredentialsMetadata;
21
+ }>;
22
+ readonly prettyPrint: {
23
+ readonly query: (result: NoLeakedCredentialsResult) => string;
24
+ readonly full: (result: NoLeakedCredentialsResult) => string;
25
+ };
26
+ readonly info: {
27
+ readonly name: "No Leaked Credentials";
28
+ readonly description: "Detects hardcoded credentials assigned to variables whose names suggest they hold passwords, tokens, or API keys, or whose values match known credential formats (AWS, GitHub, Slack, Stripe, SSH).";
29
+ readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Experimental, LintingRuleTag.Smell];
30
+ readonly certainty: LintingRuleCertainty.BestEffort;
31
+ readonly defaultConfig: {
32
+ readonly credentialNamePattern: "(?:password|passwd|pwd|secret|api[_.]?key|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential)";
33
+ readonly credentialValuePattern: string;
34
+ };
35
+ };
36
+ };
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NO_LEAKED_CREDENTIALS = void 0;
4
+ const linter_format_1 = require("../linter-format");
5
+ const flowr_search_builder_1 = require("../../search/flowr-search-builder");
6
+ const range_1 = require("../../util/range");
7
+ const linter_tags_1 = require("../linter-tags");
8
+ const assert_1 = require("../../util/assert");
9
+ const vertex_1 = require("../../dataflow/graph/vertex");
10
+ const edge_1 = require("../../dataflow/graph/edge");
11
+ const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
12
+ const defaultCredentialNamePattern = '(?:password|passwd|pwd|secret|api[_.]?key|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential)';
13
+ const defaultCredentialValuePattern = '^(?:AKIA|AIPA|ASIA|AROA)[A-Z0-9]{16}' + // AWS access key IDs (exact 20-char format)
14
+ '|^gh[psoar]_[A-Za-z0-9_]{10,}' + // GitHub Classic/App/OAuth/Actions tokens
15
+ '|^github_pat_[A-Za-z0-9_]{10,}' + // GitHub fine-grained PATs
16
+ '|^glpat-[A-Za-z0-9_-]{20}' + // GitLab Personal Access Tokens (fixed length)
17
+ '|^xox[baprs]-[0-9A-Za-z]{10,}' + // Slack tokens (xoxb-, xoxp-, xoxa-, xoxr-, xoxs-)
18
+ '|^sk_(?:live|test)_[A-Za-z0-9]{24}' + // Stripe secret/test keys (length-anchored)
19
+ '|^rk_live_[A-Za-z0-9]{24}' + // Stripe restricted keys (length-anchored)
20
+ '|^npm_[A-Za-z0-9]{36}' + // npm access tokens (fixed length)
21
+ '|^shp(?:at|ss|pa|ca)_[A-Za-z0-9]{32}' + // Shopify Admin/Shared/Private/Custom tokens
22
+ '|^sk-ant-[A-Za-z0-9_-]{10,}' + // Anthropic API keys
23
+ '|^sk-proj-[A-Za-z0-9_-]{10,}' + // OpenAI project API keys
24
+ '|^SG\\.[A-Za-z0-9_-]{22}\\.' + // SendGrid API keys (structured format)
25
+ '|^-----BEGIN(?:\\s[A-Z]+)* PRIVATE KEY'; // PEM private keys (RSA, EC, DSA, OpenSSH, etc.)
26
+ exports.NO_LEAKED_CREDENTIALS = {
27
+ createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.VariableDefinition),
28
+ processSearchResult: async (elements, config, data) => {
29
+ const namePattern = new RegExp(config.credentialNamePattern, 'i');
30
+ const valuePattern = new RegExp(config.credentialValuePattern);
31
+ const normalize = await data.normalize();
32
+ const dfg = (await data.dataflow()).graph;
33
+ let totalChecked = 0;
34
+ const results = elements.getElements().flatMap(element => {
35
+ totalChecked++;
36
+ const name = element.node.lexeme ?? '';
37
+ const vertex = dfg.getVertex(element.node.info.id);
38
+ if (!(0, vertex_1.isVariableDefinitionVertex)(vertex)) {
39
+ return [];
40
+ }
41
+ const nameMatches = namePattern.test(name);
42
+ for (const [targetId, edge] of dfg.outgoingEdges(element.node.info.id) ?? []) {
43
+ if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy)) {
44
+ continue;
45
+ }
46
+ const targetNode = normalize.idMap.get(targetId);
47
+ if (targetNode && r_string_1.RString.is(targetNode) && (nameMatches || valuePattern.test(targetNode.content.str))) {
48
+ return [{
49
+ certainty: linter_format_1.LintingResultCertainty.Uncertain,
50
+ involvedId: element.node.info.id,
51
+ variableName: name,
52
+ loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid()
53
+ }];
54
+ }
55
+ }
56
+ return [];
57
+ }).filter(assert_1.isNotUndefined);
58
+ return { results, '.meta': { totalChecked } };
59
+ },
60
+ prettyPrint: {
61
+ [linter_format_1.LintingPrettyPrintContext.Query]: (result) => `Possible hardcoded credential in \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`,
62
+ [linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Variable \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)} appears to contain a hardcoded credential`
63
+ },
64
+ info: {
65
+ name: 'No Leaked Credentials',
66
+ description: 'Detects hardcoded credentials assigned to variables whose names suggest they hold passwords, tokens, or API keys, or whose values match known credential formats (AWS, GitHub, Slack, Stripe, SSH).',
67
+ tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Experimental, linter_tags_1.LintingRuleTag.Smell],
68
+ certainty: linter_format_1.LintingRuleCertainty.BestEffort,
69
+ defaultConfig: {
70
+ credentialNamePattern: defaultCredentialNamePattern,
71
+ credentialValuePattern: defaultCredentialValuePattern
72
+ }
73
+ }
74
+ };
75
+ //# sourceMappingURL=no-leaked-credentials.js.map
@@ -17,17 +17,10 @@ export interface ProblematicInputsConfig extends MergeableRecord {
17
17
  inputFns?: InputClassifierConfig;
18
18
  pipeCommandFunctions?: PipeCommandFunctionSpec | PipeCommandFunctionSpec[];
19
19
  }
20
- export type ProblematicInputsMetadata = MergeableRecord;
21
20
  export declare const PROBLEMATIC_INPUTS: {
22
21
  readonly createSearch: (config: ProblematicInputsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", [], 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>[]>>;
23
- 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: ProblematicInputsConfig, data: {
24
- normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
25
- dataflow: import("../../dataflow/info").DataflowInformation;
26
- cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
27
- analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
28
- }) => Promise<{
22
+ 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: ProblematicInputsConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
29
23
  results: ProblematicInputsResult[];
30
- '.meta': {};
31
24
  }>;
32
25
  readonly prettyPrint: {
33
26
  readonly query: (result: ProblematicInputsResult) => string;
@@ -90,6 +90,7 @@ exports.PROBLEMATIC_INPUTS = {
90
90
  ]);
91
91
  },
92
92
  processSearchResult: async (elements, config, data) => {
93
+ const df = await data.dataflow();
93
94
  const results = [];
94
95
  const seen = new Set();
95
96
  const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
@@ -108,11 +109,11 @@ exports.PROBLEMATIC_INPUTS = {
108
109
  }
109
110
  const loc = range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid();
110
111
  if (pipeSpec !== undefined) {
111
- const vertex = data.dataflow.graph.getVertex(nid);
112
+ const vertex = df.graph.getVertex(nid);
112
113
  const fileArgId = resolveFileArgId(vertex, pipeSpec.argIdx, pipeSpec.argName);
113
114
  if (fileArgId !== undefined) {
114
115
  const criterion = parse_1.SlicingCriterion.fromId(fileArgId);
115
- const all = await data.analyzer.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
116
+ const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
116
117
  const sources = all['input-sources']?.results?.[criterion] ?? [];
117
118
  const r = checkPipeInjection(nid, loc, name, sources);
118
119
  if (r !== undefined) {
@@ -123,7 +124,7 @@ exports.PROBLEMATIC_INPUTS = {
123
124
  }
124
125
  else {
125
126
  const criterion = parse_1.SlicingCriterion.fromId(nid);
126
- const all = await data.analyzer.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
127
+ const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
127
128
  const sources = all['input-sources']?.results?.[criterion] ?? [];
128
129
  if (isProblematicForAllowed(sources, defaultAccept)) {
129
130
  seen.add(nid);
@@ -131,7 +132,7 @@ exports.PROBLEMATIC_INPUTS = {
131
132
  }
132
133
  }
133
134
  }
134
- return { results, '.meta': {} };
135
+ return { results };
135
136
  },
136
137
  prettyPrint: {
137
138
  [linter_format_1.LintingPrettyPrintContext.Query]: result => {