@eagleoutice/flowr 2.10.4 → 2.10.5

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 (81) hide show
  1. package/README.md +37 -20
  2. package/abstract-interpretation/absint-visitor.d.ts +17 -21
  3. package/abstract-interpretation/absint-visitor.js +47 -48
  4. package/abstract-interpretation/data-frame/dataframe-domain.d.ts +0 -3
  5. package/abstract-interpretation/data-frame/shape-inference.d.ts +2 -1
  6. package/abstract-interpretation/data-frame/shape-inference.js +5 -4
  7. package/abstract-interpretation/domains/abstract-domain.d.ts +17 -16
  8. package/abstract-interpretation/domains/abstract-domain.js +25 -27
  9. package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
  10. package/abstract-interpretation/domains/multi-value-state-domain.d.ts +32 -0
  11. package/abstract-interpretation/domains/multi-value-state-domain.js +60 -0
  12. package/abstract-interpretation/domains/partial-product-domain.d.ts +43 -0
  13. package/abstract-interpretation/domains/partial-product-domain.js +163 -0
  14. package/abstract-interpretation/domains/product-domain.d.ts +2 -29
  15. package/abstract-interpretation/domains/product-domain.js +6 -123
  16. package/abstract-interpretation/domains/set-range-domain.js +3 -3
  17. package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
  18. package/abstract-interpretation/domains/singleton-domain.js +1 -1
  19. package/abstract-interpretation/domains/state-abstract-domain.d.ts +13 -28
  20. package/abstract-interpretation/domains/state-abstract-domain.js +16 -38
  21. package/abstract-interpretation/domains/state-domain-like.d.ts +36 -0
  22. package/abstract-interpretation/domains/state-domain-like.js +3 -0
  23. package/cli/flowr.js +11 -1
  24. package/config.d.ts +7 -0
  25. package/config.js +22 -3
  26. package/control-flow/semantic-cfg-guided-visitor.d.ts +4 -0
  27. package/control-flow/semantic-cfg-guided-visitor.js +20 -32
  28. package/dataflow/environments/default-builtin-config.d.ts +10 -0
  29. package/dataflow/environments/default-builtin-config.js +2 -1
  30. package/dataflow/internal/process/functions/call/built-in/built-in-eval.d.ts +2 -0
  31. package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +38 -21
  32. package/documentation/doc-readme.js +13 -2
  33. package/documentation/wiki-absint.d.ts +1 -2
  34. package/documentation/wiki-absint.js +34 -10
  35. package/documentation/wiki-analyzer.js +3 -4
  36. package/documentation/wiki-interface.js +21 -16
  37. package/linter/linter-rules.d.ts +2 -2
  38. package/linter/rules/problematic-inputs.d.ts +4 -3
  39. package/linter/rules/problematic-inputs.js +3 -4
  40. package/package.json +3 -3
  41. package/project/flowr-analyzer-builder.d.ts +6 -3
  42. package/project/flowr-analyzer-builder.js +12 -5
  43. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +4 -3
  44. package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +17 -4
  45. package/project/plugins/flowr-analyzer-plugin.d.ts +1 -1
  46. package/project/plugins/flowr-analyzer-plugin.js +1 -1
  47. package/queries/catalog/input-sources-query/input-source-functions.d.ts +6 -0
  48. package/queries/catalog/input-sources-query/input-source-functions.js +50 -0
  49. package/queries/catalog/input-sources-query/input-sources-query-executor.d.ts +1 -1
  50. package/queries/catalog/input-sources-query/input-sources-query-executor.js +19 -53
  51. package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -1
  52. package/queries/catalog/input-sources-query/input-sources-query-format.js +26 -11
  53. package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +18 -41
  54. package/queries/catalog/input-sources-query/simple-input-classifier.js +165 -103
  55. package/r-bridge/lang-4.x/ast/model/model.d.ts +4 -4
  56. package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +3 -3
  57. package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -3
  58. package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +3 -3
  59. package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +3 -3
  60. package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +3 -3
  61. package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +3 -3
  62. package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +3 -3
  63. package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +3 -3
  64. package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +3 -3
  65. package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +3 -3
  66. package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +3 -3
  67. package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +3 -3
  68. package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +3 -3
  69. package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +3 -3
  70. package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +3 -3
  71. package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +3 -3
  72. package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +3 -3
  73. package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +3 -3
  74. package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +3 -3
  75. package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +3 -3
  76. package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +3 -3
  77. package/util/record.d.ts +18 -3
  78. package/util/record.js +22 -1
  79. package/util/version.js +1 -1
  80. package/project/plugins/flowr-analyzer-plugin-defaults.d.ts +0 -5
  81. package/project/plugins/flowr-analyzer-plugin-defaults.js +0 -37
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OptionsFunctions = exports.LangFunctions = exports.FfiFunctions = exports.SystemFunctions = exports.PureFunctions = void 0;
4
+ exports.PureFunctions = [
5
+ 'paste', 'paste0', 'parse', '+', '-', '*',
6
+ '/', '^', '%%', '%/%', '&', '|', '!', '&&', '||',
7
+ '<', '>', '<=', '>=', '==', '!=', ':',
8
+ 'abs', 'sign', 'sqrt', 'exp', 'log', 'log10', 'log2',
9
+ 'sin', 'cos', 'tan', 'asin', 'acos', 'atan',
10
+ 'length', 'nchar', 'dim', 'nrow', 'ncol',
11
+ 'c', 'list', 'data.frame',
12
+ 'ifelse', 'switch', 'factor', 'as.factor',
13
+ 'round', 'floor', 'ceiling', 'trunc',
14
+ 'substr', 'substring', 'strsplit',
15
+ 'min', 'max', 'range', 'sum', 'prod', 'mean', 'median', 'var', 'sd',
16
+ 'head', 'tail', 'seq', 'rep',
17
+ 'apply', 'lapply', 'sapply', 'vapply', 'tapply',
18
+ 'matrix', 'array',
19
+ 'rownames', 'colnames',
20
+ 'list.files', 'tolower', 'toupper', 'printf',
21
+ '<-', '->', '=', '<<-', '->>', 'assign', 'get',
22
+ '[', '[[', '$', 'length<-', 'dim<-', 'names<-', 'colnames<-', 'rownames<-',
23
+ 'as.character', 'as.numeric', 'as.logical', 'as.raw', 'as.list', 'as.data.frame', 'as.matrix', 'as.array',
24
+ 'identity', 'invisible', 'return', 'force', 'missing',
25
+ 'print', 'cat', 'message', 'warning', 'stop',
26
+ 'format', 'sprintf', 'formatC',
27
+ 'is.na', 'is.null', 'is.numeric', 'is.character',
28
+ 'which', 'match', 'order', 'sort', 'unique', 'duplicated', 'na.omit',
29
+ 'grep', 'grepl', 'sub', 'gsub', 'regexpr', 'gregexpr', 'regexec', 'regmatches',
30
+ 'as.integer', 'as.double', 'as.complex',
31
+ 'trimws', 'seq_len', 'seq_along', 'rep.int',
32
+ 'pmin', 'pmax', 'cumsum', 'cumprod', 'cummax', 'cummin', 'diff', 'signif',
33
+ 'table', 'prop.table', 'xtabs',
34
+ 'rbind', 'cbind', 't', 'crossprod', 'tcrossprod',
35
+ 'colSums', 'rowSums', 'colMeans', 'rowMeans',
36
+ 'solve', 'det', 'eigen',
37
+ 'is.factor', 'is.logical', 'is.vector', 'is.matrix', 'is.data.frame',
38
+ ];
39
+ exports.SystemFunctions = ['system', 'system2', 'pipe', 'shell', 'shell.exec'];
40
+ exports.FfiFunctions = ['.C', '.Call', '.Fortran', '.External', 'dyn.load', 'sourceCpp', 'getNativeSymbolInfo'];
41
+ exports.LangFunctions = [
42
+ 'substitute', 'quote', 'enquote', 'bquote',
43
+ 'call', 'as.call', 'expression', 'as.expression', // 'str2lang', 'str2expression',
44
+ 'as.name', 'as.symbol', 'alist', 'as.language', 'evalq',
45
+ 'expr', 'exprs', 'enexpr', 'enexprs', 'inject',
46
+ 'quo', 'quos', 'enquo', 'enquos', 'enquo0', 'enquos0',
47
+ 'sym', 'syms', 'ensym', 'ensyms'
48
+ ];
49
+ exports.OptionsFunctions = ['options', 'getOption', 'Sys.getenv'];
50
+ //# sourceMappingURL=input-source-functions.js.map
@@ -1,5 +1,5 @@
1
1
  import type { BasicQueryData } from '../../base-query-format';
2
- import type { InputSourcesQuery, InputSourcesQueryResult } from './input-sources-query-format';
2
+ import { type InputSourcesQuery, type InputSourcesQueryResult } from './input-sources-query-format';
3
3
  /**
4
4
  * Execute an input sources query
5
5
  */
@@ -1,15 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.executeInputSourcesQuery = executeInputSourcesQuery;
4
+ const input_sources_query_format_1 = require("./input-sources-query-format");
4
5
  const log_1 = require("../../../util/log");
5
6
  const parse_1 = require("../../../slicing/criterion/parse");
6
7
  const r_function_definition_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
7
8
  const model_1 = require("../../../r-bridge/lang-4.x/ast/model/model");
8
9
  const df_helper_1 = require("../../../dataflow/graph/df-helper");
9
10
  const simple_input_classifier_1 = require("./simple-input-classifier");
10
- const network_functions_1 = require("../../../linter/rules/network-functions");
11
- const seeded_randomness_1 = require("../../../linter/rules/seeded-randomness");
12
- const read_functions_1 = require("../dependencies-query/function-info/read-functions");
11
+ const flowr_search_executor_1 = require("../../../search/flowr-search-executor");
12
+ const record_1 = require("../../../util/record");
13
13
  /**
14
14
  * Execute an input sources query
15
15
  */
@@ -18,6 +18,7 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
18
18
  const results = {};
19
19
  const nast = await analyzer.normalize();
20
20
  const df = await analyzer.dataflow();
21
+ const defaultConfig = await resolveSearches(analyzer, input_sources_query_format_1.DefaultInputClassifierConfig);
21
22
  for (const query of queries) {
22
23
  const key = query.criterion;
23
24
  if (results[key]) {
@@ -27,56 +28,8 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
27
28
  const provenanceNode = nast.idMap.get(criterionId);
28
29
  const fdef = r_function_definition_1.RFunctionDefinition.rootFunctionDefinition(provenanceNode, nast.idMap);
29
30
  const provenance = df_helper_1.Dataflow.provenanceGraph(criterionId, df.graph, fdef ? model_1.RNode.collectAllIds(fdef) : undefined);
30
- results[key] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, {
31
- fullDfg: df.graph,
32
- networkFns: query.config?.networkFns ?? network_functions_1.NETWORK_FUNCTIONS.info.defaultConfig.fns,
33
- randomFns: query.config?.randomFns ?? seeded_randomness_1.SEEDED_RANDOMNESS.info.defaultConfig.randomnessConsumers,
34
- pureFns: query.config?.pureFns ?? ['paste', 'paste0', 'parse', '+', '-', '*',
35
- '/', '^', '%%', '%/%', '&', '|', '!', '&&', '||',
36
- '<', '>', '<=', '>=', '==', '!=', ':',
37
- 'abs', 'sign', 'sqrt', 'exp', 'log', 'log10', 'log2',
38
- 'sin', 'cos', 'tan', 'asin', 'acos', 'atan',
39
- 'length', 'nchar', 'dim', 'nrow', 'ncol',
40
- 'c', 'list', 'data.frame',
41
- 'ifelse', 'switch', 'factor', 'as.factor',
42
- 'round', 'floor', 'ceiling', 'trunc',
43
- 'substr', 'substring', 'strsplit',
44
- 'min', 'max', 'range', 'sum', 'prod', 'mean', 'median', 'var', 'sd',
45
- 'head', 'tail', 'seq', 'rep',
46
- 'apply', 'lapply', 'sapply', 'vapply', 'tapply',
47
- 'matrix', 'array',
48
- 'rownames', 'colnames',
49
- 'list.files', 'tolower', 'toupper', 'printf',
50
- '<-', '->', '=', '<<-', '->>', 'assign', 'get',
51
- '[', '[[', '$', 'length<-', 'dim<-', 'names<-', 'colnames<-', 'rownames<-',
52
- 'as.character', 'as.numeric', 'as.logical', 'as.raw', 'as.list', 'as.data.frame', 'as.matrix', 'as.array',
53
- 'identity', 'invisible', 'return', 'force', 'missing',
54
- 'print', 'cat', 'message', 'warning', 'stop',
55
- 'format', 'sprintf', 'formatC',
56
- 'is.na', 'is.null', 'is.numeric', 'is.character',
57
- 'which', 'match', 'order', 'sort', 'unique', 'duplicated', 'na.omit',
58
- 'grep', 'grepl', 'sub', 'gsub', 'regexpr', 'gregexpr', 'regexec', 'regmatches',
59
- 'as.integer', 'as.double', 'as.complex',
60
- 'trimws', 'seq_len', 'seq_along', 'rep.int',
61
- 'pmin', 'pmax', 'cumsum', 'cumprod', 'cummax', 'cummin', 'diff', 'signif',
62
- 'table', 'prop.table', 'xtabs',
63
- 'rbind', 'cbind', 't', 'crossprod', 'tcrossprod',
64
- 'colSums', 'rowSums', 'colMeans', 'rowMeans',
65
- 'solve', 'det', 'eigen',
66
- 'is.factor', 'is.logical', 'is.vector', 'is.matrix', 'is.data.frame',
67
- ],
68
- readFileFns: query.config?.readFileFns ?? read_functions_1.ReadFunctions.map(f => f.name),
69
- systemFns: query.config?.systemFns ?? ['system', 'system2', 'pipe', 'shell', 'shell.exec'],
70
- ffiFns: query.config?.ffiFns ?? ['.C', '.Call', '.Fortran', '.External', 'dyn.load', 'sourceCpp', 'getNativeSymbolInfo'],
71
- langFns: query.config?.langFns ?? [
72
- 'substitute', 'quote', 'bquote', 'enquote',
73
- 'enexpr', 'enexprs', 'enquo', 'enquos',
74
- 'expression', 'call', 'as.call', 'as.expression',
75
- 'as.name', 'as.symbol', 'alist', 'as.language', 'evalq',
76
- 'expr', 'quo', 'enexpr', 'ensym', 'ensyms'
77
- ],
78
- optionsFns: query.config?.optionsFns ?? ['options', 'getOption', 'Sys.getenv']
79
- });
31
+ const config = { ...defaultConfig, ...(await resolveSearches(analyzer, query?.config ?? {})) };
32
+ results[key] = (0, simple_input_classifier_1.classifyInput)(criterionId, provenance, config, df.graph);
80
33
  }
81
34
  return {
82
35
  '.meta': {
@@ -85,4 +38,17 @@ async function executeInputSourcesQuery({ analyzer }, queries) {
85
38
  results
86
39
  };
87
40
  }
41
+ async function resolveSearches(analyzer, config) {
42
+ const result = {};
43
+ for (const [key, value] of record_1.Record.entries(config)) {
44
+ if (value === undefined || Array.isArray(value)) {
45
+ result[key] = value;
46
+ }
47
+ else {
48
+ const searchResult = await (0, flowr_search_executor_1.runSearch)(value, analyzer);
49
+ result[key] = searchResult.getElements().map(element => element.node.info.id);
50
+ }
51
+ }
52
+ return result;
53
+ }
88
54
  //# sourceMappingURL=input-sources-query-executor.js.map
@@ -3,7 +3,7 @@ import type { SlicingCriterion } from '../../../slicing/criterion/parse';
3
3
  import type { ParsedQueryLine } from '../../query';
4
4
  import Joi from 'joi';
5
5
  import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id';
6
- import type { InputClassifierConfig, InputSources } from './simple-input-classifier';
6
+ import { type InputClassifierConfig, type InputSources } from './simple-input-classifier';
7
7
  import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
8
8
  import type { FlowrConfig } from '../../../config';
9
9
  import { executeInputSourcesQuery } from './input-sources-query-executor';
@@ -21,6 +21,7 @@ export interface InputSourcesQuery extends BaseQueryFormat {
21
21
  readonly criterion: SlicingCriterion;
22
22
  readonly config?: InputSourcesQueryConfig;
23
23
  }
24
+ export declare const DefaultInputClassifierConfig: InputClassifierConfig;
24
25
  export interface InputSourcesQueryResult extends BaseQueryResult {
25
26
  /** For each query key, a list of classified input sources (each with id and all traces) */
26
27
  results: Record<string, InputSources>;
@@ -3,13 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.InputSourcesDefinition = void 0;
6
+ exports.InputSourcesDefinition = exports.DefaultInputClassifierConfig = void 0;
7
7
  const ansi_1 = require("../../../util/text/ansi");
8
8
  const time_1 = require("../../../util/text/time");
9
9
  const joi_1 = __importDefault(require("joi"));
10
+ const simple_input_classifier_1 = require("./simple-input-classifier");
10
11
  const slice_query_parser_1 = require("../../../cli/repl/parser/slice-query-parser");
11
12
  const input_sources_query_executor_1 = require("./input-sources-query-executor");
12
13
  const range_1 = require("../../../util/range");
14
+ const flowr_search_builder_1 = require("../../../search/flowr-search-builder");
15
+ const read_functions_1 = require("../dependencies-query/function-info/read-functions");
16
+ const input_source_functions_1 = require("./input-source-functions");
17
+ exports.DefaultInputClassifierConfig = {
18
+ [simple_input_classifier_1.InputTraceType.Pure]: input_source_functions_1.PureFunctions,
19
+ [simple_input_classifier_1.InputType.File]: read_functions_1.ReadFunctions.map(readFunction => readFunction.name),
20
+ [simple_input_classifier_1.InputType.Network]: flowr_search_builder_1.Q.fromQuery({ type: 'linter', rules: ['network-functions'] }),
21
+ [simple_input_classifier_1.InputType.Random]: flowr_search_builder_1.Q.fromQuery({ type: 'linter', rules: ['seeded-randomness'] }),
22
+ [simple_input_classifier_1.InputType.System]: input_source_functions_1.SystemFunctions,
23
+ [simple_input_classifier_1.InputType.Ffi]: input_source_functions_1.FfiFunctions,
24
+ [simple_input_classifier_1.InputType.Lang]: input_source_functions_1.LangFunctions,
25
+ [simple_input_classifier_1.InputType.Options]: input_source_functions_1.OptionsFunctions
26
+ };
13
27
  function inputSourcesQueryLineParser(output, line, _config) {
14
28
  const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
15
29
  if (!criterion || criterion.length !== 1) {
@@ -29,10 +43,11 @@ exports.InputSourcesDefinition = {
29
43
  const nast = (await analyzer.normalize()).idMap;
30
44
  for (const [key, sources] of Object.entries(out.results)) {
31
45
  result.push(` ╰ Input Sources for ${key}`);
32
- for (const { id, trace, types } of sources) {
46
+ for (const { id, trace, types, value } of sources) {
33
47
  const kNode = nast.get(id);
34
48
  const kLoc = kNode ? range_1.SourceLocation.format(range_1.SourceLocation.fromNode(kNode)) : 'unknown location';
35
- result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}`);
49
+ const valueStr = value !== undefined ? `, value: ${JSON.stringify(value)}` : '';
50
+ result.push(` ╰ ${kLoc} (id: ${id}), type: ${JSON.stringify(types)}, trace: ${trace}${valueStr}`);
36
51
  }
37
52
  }
38
53
  return true;
@@ -42,14 +57,14 @@ exports.InputSourcesDefinition = {
42
57
  type: joi_1.default.string().valid('input-sources').required().description('The type of the query.'),
43
58
  criterion: joi_1.default.string().required().description('The slicing criterion to use.'),
44
59
  config: joi_1.default.object({
45
- pureFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Deterministic/pure functions: functions that preserve constantness of their inputs (e.g., arithmetic, parse).'),
46
- networkFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that fetch data from the network (e.g., download.file, url connections).'),
47
- randomFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce randomness (e.g., runif, rnorm).'),
48
- readFileFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read from the filesystem and produce data (e.g., read.csv, readRDS).'),
49
- systemFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that execute system commands (e.g., system, system2, shell, pipe).'),
50
- ffiFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that call native code via the R FFI (.C, .Call, .Fortran, .External, dyn.load).'),
51
- langFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
52
- optionsFns: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
60
+ [simple_input_classifier_1.InputTraceType.Pure]: joi_1.default.array().items(joi_1.default.string()).optional().description('Deterministic/pure functions: functions that preserve constantness of their inputs (e.g., arithmetic, parse).'),
61
+ [simple_input_classifier_1.InputType.File]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that read from the filesystem and produce data (e.g., read.csv, readRDS).'),
62
+ [simple_input_classifier_1.InputType.Network]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that fetch data from the network (e.g., download.file, url connections).'),
63
+ [simple_input_classifier_1.InputType.Random]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce randomness (e.g., runif, rnorm).'),
64
+ [simple_input_classifier_1.InputType.System]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that execute system commands (e.g., system, system2, shell, pipe).'),
65
+ [simple_input_classifier_1.InputType.Ffi]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that call native code via the R FFI (.C, .Call, .Fortran, .External, dyn.load).'),
66
+ [simple_input_classifier_1.InputType.Lang]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that produce language objects (e.g., substitute, quote, bquote, expression).'),
67
+ [simple_input_classifier_1.InputType.Options]: joi_1.default.array().items(joi_1.default.string()).optional().description('Functions that access or set global options (e.g., options, getOption).'),
53
68
  }).optional()
54
69
  }).description('Input Sources query definition'),
55
70
  flattenInvolvedNodes: (queryResults) => {
@@ -2,6 +2,7 @@ import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/nod
2
2
  import type { DataflowGraph } from '../../../dataflow/graph/graph';
3
3
  import type { MergeableRecord } from '../../../util/objects';
4
4
  import { Identifier } from '../../../dataflow/environments/identifier';
5
+ import type { FlowrSearchLike } from '../../../search/flowr-search-builder';
5
6
  /**
6
7
  * Lattice flattening until we have a taint engine :)
7
8
  * Please note that the classifier considers this basis with a set-lift,
@@ -25,7 +26,7 @@ export declare enum InputType {
25
26
  Random = "rand",
26
27
  /** Calls to system/system2 and similar */
27
28
  System = "system",
28
- /** Calls to .C / Fortran interfaces */
29
+ /** Calls to .C / Fortran interfaces (foreign function interfaces) */
29
30
  Ffi = "ffi",
30
31
  /** Language objects (quote/substitute/etc.) */
31
32
  Lang = "lang",
@@ -48,6 +49,12 @@ export declare enum InputTraceType {
48
49
  /** Not fully known origin */
49
50
  Unknown = "unknown"
50
51
  }
52
+ /**
53
+ * Scalar R constant values representable in TypeScript.
54
+ * `null` corresponds to R's `NULL`.
55
+ * NA values are not included (they have no direct TS equivalent).
56
+ */
57
+ export type ConstantValue = string | number | boolean | null;
51
58
  /**
52
59
  * Object attached to an input source
53
60
  * @see {@link InputSources}
@@ -58,6 +65,8 @@ export interface InputSource extends MergeableRecord {
58
65
  trace: InputTraceType;
59
66
  /** if the trace is affected by control dependencies, they are classified too, this is a duplicate free array */
60
67
  cds?: InputType[];
68
+ /** the concrete scalar value when the source is a constant or a pure alias of one */
69
+ value?: ConstantValue;
61
70
  }
62
71
  /**
63
72
  * Map of input sources, keyed by the node id of the input source. Each input source is classified with an {@link InputSource} object.
@@ -67,54 +76,22 @@ export type InputSources = InputSource[];
67
76
  * This is either an {@link NodeId|id} of a known functions all of that category (e.g., you can issue a dependencies query before and then pass all
68
77
  * identified ids to this query here).
69
78
  */
70
- export type InputClassifierFunctionIdentifier = Identifier | NodeId;
79
+ export type InputClassifierFunctionIdentifiers = readonly (Identifier | NodeId)[];
71
80
  /**
72
- * For the specifications of `pureFns` etc. please have a look at {@link InputClassifierFunctionIdentifier}.
81
+ * For the specifications of `pure` etc. please have a look at {@link InputClassifierFunctionIdentifiers}.
73
82
  */
74
- export interface InputClassifierConfig extends MergeableRecord {
83
+ export interface InputClassifierConfig<Functions extends InputClassifierFunctionIdentifiers | FlowrSearchLike = readonly Identifier[] | FlowrSearchLike> extends Partial<Record<InputType, Functions>> {
75
84
  /**
76
85
  * Functions which are considered to be pure (i.e., deterministic, trusted, safe, idempotent on the lub of the input types)
77
86
  */
78
- pureFns: readonly InputClassifierFunctionIdentifier[];
79
- /**
80
- * Functions that read from the network
81
- */
82
- networkFns: readonly InputClassifierFunctionIdentifier[];
83
- /**
84
- * Functions that produce a random value
85
- * Note: may need to check with respect to seeded randomness
86
- */
87
- randomFns: readonly InputClassifierFunctionIdentifier[];
88
- /**
89
- * Functions that read from the file system
90
- */
91
- readFileFns: readonly InputClassifierFunctionIdentifier[];
92
- /**
93
- * Functions that call system utilities (system/system2)
94
- */
95
- systemFns?: readonly InputClassifierFunctionIdentifier[];
96
- /**
97
- * Functions that call native code via .C/.Fortran interfaces
98
- */
99
- ffiFns?: readonly InputClassifierFunctionIdentifier[];
100
- /**
101
- * Functions that produce language objects such as quote/substitute
102
- */
103
- langFns?: readonly InputClassifierFunctionIdentifier[];
104
- /**
105
- * Functions that access or set global options
106
- */
107
- optionsFns?: readonly InputClassifierFunctionIdentifier[];
108
- /**
109
- * For the scope escape analysis, pass on the full, non-reduced DFG here
110
- */
111
- fullDfg?: DataflowGraph;
87
+ [InputTraceType.Pure]?: Functions;
112
88
  }
113
89
  /**
114
90
  * Takes the given id which is expected to either be:
115
91
  * - a function call - in this case all arguments are considered to be inputs (additionally to all read edges from the function call in the dataflow graph)
116
- * - anything else - in that case the node itself is considered as an "input" - please note that in these scenarios the *return* value will only contain one mapping - that for the id you pased in.
92
+ * - anything else - in that case the node itself is considered as an "input" - please note that in these scenarios the *return* value will only contain one mapping - that for the id you passed in.
117
93
  *
118
- * This method traces the dependencies in the dataflow graph using the specification of functions passed in
94
+ * This method traces the dependencies in the dataflow graph using the specification of functions passed in.
95
+ * For the scope escape analysis, pass on the full, non-reduced DFG as `fullDfg`.
119
96
  */
120
- export declare function classifyInput(id: NodeId, dfg: DataflowGraph, config: InputClassifierConfig): InputSources;
97
+ export declare function classifyInput(id: NodeId, dfg: DataflowGraph, config: InputClassifierConfig<InputClassifierFunctionIdentifiers>, fullDfg?: DataflowGraph): InputSources;