@eagleoutice/flowr 2.16.7 → 2.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) 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.js +1 -1
  15. package/control-flow/useless-loop.js +10 -8
  16. package/data/r-primitives.generated.d.ts +1 -0
  17. package/data/r-primitives.generated.js +9 -0
  18. package/data/sigdb/sigdb.remote.json +110 -110
  19. package/dataflow/environments/identifier.d.ts +1 -1
  20. package/dataflow/environments/query-fn-props.d.ts +9 -3
  21. package/dataflow/environments/query-fn-props.js +13 -5
  22. package/dataflow/environments/reference-to-maybe.js +1 -6
  23. package/dataflow/fn/class-declaration.js +1 -8
  24. package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
  25. package/dataflow/graph/df-helper.d.ts +2 -0
  26. package/dataflow/graph/df-helper.js +7 -0
  27. package/dataflow/graph/graph.js +3 -10
  28. package/dataflow/graph/vertex.d.ts +1 -1
  29. package/dataflow/hooks.d.ts +1 -1
  30. package/dataflow/info.d.ts +3 -3
  31. package/dataflow/internal/linker.js +1 -1
  32. package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +2 -2
  33. package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +1 -1
  34. package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +1 -7
  35. package/dataflow/processor.d.ts +1 -1
  36. package/documentation/wiki-linter.js +29 -0
  37. package/documentation/wiki-query.js +20 -1
  38. package/linter/linter-executor.js +2 -1
  39. package/linter/linter-rules.d.ts +65 -0
  40. package/linter/linter-rules.js +5 -1
  41. package/linter/rules/cmd-check/global-environment-modification.d.ts +14 -1
  42. package/linter/rules/cmd-check/global-environment-modification.js +15 -7
  43. package/linter/rules/no-leaked-credentials.d.ts +1 -0
  44. package/linter/rules/no-leaked-credentials.js +3 -3
  45. package/linter/rules/process-state-in-session.d.ts +71 -0
  46. package/linter/rules/process-state-in-session.js +267 -0
  47. package/linter/rules/secret-exfiltration.d.ts +80 -0
  48. package/linter/rules/secret-exfiltration.js +183 -0
  49. package/package.json +1 -1
  50. package/project/flowr-analyzer.d.ts +6 -0
  51. package/project/flowr-analyzer.js +4 -0
  52. package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +2 -0
  53. package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -3
  54. package/project/sigdb/decompress.d.ts +4 -0
  55. package/project/sigdb/decompress.js +60 -25
  56. package/project/sigdb/manifest.d.ts +1 -1
  57. package/project/sigdb/manifest.js +2 -5
  58. package/project/sigdb/reader.js +15 -6
  59. package/project/sigdb/sigdb-download.d.ts +3 -7
  60. package/project/sigdb/sigdb-download.js +71 -72
  61. package/queries/catalog/taint-query/taint-query-executor.d.ts +7 -0
  62. package/queries/catalog/taint-query/taint-query-executor.js +30 -0
  63. package/queries/catalog/taint-query/taint-query-format.d.ts +29 -0
  64. package/queries/catalog/taint-query/taint-query-format.js +124 -0
  65. package/queries/query.d.ts +12 -1
  66. package/queries/query.js +2 -0
  67. package/taint-analysis/builder/domain.d.ts +14 -0
  68. package/taint-analysis/builder/domain.js +69 -0
  69. package/taint-analysis/builder/report-template.d.ts +50 -0
  70. package/taint-analysis/builder/report-template.js +46 -0
  71. package/taint-analysis/builder/taint-analysis-definition.d.ts +108 -0
  72. package/taint-analysis/builder/taint-analysis-definition.js +128 -0
  73. package/taint-analysis/builder/taint-analysis.d.ts +124 -0
  74. package/taint-analysis/builder/taint-analysis.js +93 -0
  75. package/taint-analysis/builtin-index-bridge.d.ts +20 -0
  76. package/taint-analysis/builtin-index-bridge.js +48 -0
  77. package/taint-analysis/eval/eval.d.ts +1 -0
  78. package/taint-analysis/eval/eval.js +124 -0
  79. package/taint-analysis/eval/instrumentation.d.ts +59 -0
  80. package/taint-analysis/eval/instrumentation.js +124 -0
  81. package/taint-analysis/finite-domain.d.ts +41 -0
  82. package/taint-analysis/finite-domain.js +118 -0
  83. package/taint-analysis/function-categories.d.ts +31 -0
  84. package/taint-analysis/function-categories.js +61 -0
  85. package/taint-analysis/logger.d.ts +1 -0
  86. package/taint-analysis/logger.js +6 -0
  87. package/taint-analysis/predefined/determinism.d.ts +6 -0
  88. package/taint-analysis/predefined/determinism.js +14 -0
  89. package/taint-analysis/predefined/normalization.d.ts +17 -0
  90. package/taint-analysis/predefined/normalization.js +150 -0
  91. package/taint-analysis/predefined/predefined.d.ts +12 -0
  92. package/taint-analysis/predefined/predefined.js +18 -0
  93. package/taint-analysis/predefined/randomness-analysis.d.ts +6 -0
  94. package/taint-analysis/predefined/randomness-analysis.js +124 -0
  95. package/taint-analysis/predefined/secret-analysis.d.ts +77 -0
  96. package/taint-analysis/predefined/secret-analysis.js +165 -0
  97. package/taint-analysis/predefined/security-analysis.d.ts +7 -0
  98. package/taint-analysis/predefined/security-analysis.js +91 -0
  99. package/taint-analysis/taint-mapping.d.ts +86 -0
  100. package/taint-analysis/taint-mapping.js +70 -0
  101. package/taint-analysis/taint-resolve.d.ts +26 -0
  102. package/taint-analysis/taint-resolve.js +86 -0
  103. package/taint-analysis/taint-visitor.d.ts +80 -0
  104. package/taint-analysis/taint-visitor.js +82 -0
  105. package/util/flowr-version.d.ts +1 -1
  106. package/util/flowr-version.js +2 -2
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.securityAnalysis = exports.securityDomain = exports.FileInput = exports.NetworkInput = exports.UserInput = void 0;
4
+ const lattice_1 = require("../../abstract-interpretation/domains/lattice");
5
+ const abstract_domain_1 = require("../../abstract-interpretation/domains/abstract-domain");
6
+ const taint_analysis_definition_1 = require("../builder/taint-analysis-definition");
7
+ const domain_1 = require("../builder/domain");
8
+ const built_in_props_1 = require("../../dataflow/environments/built-in-props");
9
+ const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
10
+ const builtin_index_bridge_1 = require("../builtin-index-bridge");
11
+ const function_categories_1 = require("../function-categories");
12
+ exports.UserInput = Symbol('User Input');
13
+ exports.NetworkInput = Symbol('Network Input');
14
+ exports.FileInput = Symbol('File Input');
15
+ exports.securityDomain = new domain_1.FiniteDomainBuilder()
16
+ .addLeqOrder(lattice_1.Bottom, [exports.UserInput, exports.NetworkInput, exports.FileInput])
17
+ .addLeqOrder(exports.UserInput, lattice_1.Top)
18
+ .addLeqOrder(exports.NetworkInput, lattice_1.Top)
19
+ .addLeqOrder(exports.FileInput, lattice_1.Top)
20
+ .build();
21
+ /** Matches network protocols in a path argument. */
22
+ const NetworkProtocolRegex = /^(https?|ftps?):\/\//;
23
+ /** Maps a resolved path argument to a network or file taint depending on its protocol. */
24
+ const protocolTaint = ([path]) => typeof path === 'string' && NetworkProtocolRegex.test(path) ? exports.NetworkInput : exports.FileInput;
25
+ /** Tainted input on any argument leads to Bottom taint at sinks */
26
+ const securitySinkCondition = (_args, taints) => taints.some(taint => taint.value === exports.UserInput || taint.value === exports.NetworkInput || taint.value === exports.FileInput) ? lattice_1.Bottom
27
+ : taints.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(taints).value : lattice_1.Top;
28
+ exports.securityAnalysis = taint_analysis_definition_1.TaintAnalysisDefinition.create('security', exports.securityDomain)
29
+ .on(function_categories_1.TaintFnCategory.pureAlias)
30
+ .on(function_categories_1.TaintFnCategory.pureComputer)
31
+ .on(function_categories_1.TaintFnCategory.pureShape)
32
+ .from({
33
+ identifier: [...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.User, [built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.File])],
34
+ taint: exports.UserInput
35
+ }, {
36
+ identifier: [...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.User)],
37
+ taint: exports.NetworkInput,
38
+ }, ...(0, builtin_index_bridge_1.argValueMappingFromBuiltInIndex)(built_in_props_1.FileInputProps, built_in_props_1.ArgProp.Resource, protocolTaint, built_in_props_1.SemanticCallTag.User), {
39
+ identifier: ['gzcon', "base" /* PkgName.Base */],
40
+ condition: { argValues: [{ pos: 0, name: 'con' }], conditionFn: protocolTaint }
41
+ })
42
+ .through({
43
+ identifier: ['shQuote', "base" /* PkgName.Base */],
44
+ taint: lattice_1.Top
45
+ }, {
46
+ identifier: [['match.arg', "base" /* PkgName.Base */], ['make.names', "base" /* PkgName.Base */]],
47
+ taint: lattice_1.Top
48
+ }, {
49
+ // additional common functions
50
+ identifier: [
51
+ ['rep', "base" /* PkgName.Base */],
52
+ ['which', "base" /* PkgName.Base */]
53
+ ],
54
+ condition: {
55
+ argDefinition: [{ pos: 0, name: 'x' }],
56
+ conditionFn: (_args, [taint]) => taint.value
57
+ }
58
+ })
59
+ .to({
60
+ identifier: [
61
+ ['source', "base" /* PkgName.Base */],
62
+ ['sys.source', "base" /* PkgName.Base */],
63
+ ['parse', "base" /* PkgName.Base */]
64
+ ],
65
+ condition: {
66
+ argDefinition: [{ pos: 0, name: 'file' }],
67
+ conditionFn: securitySinkCondition
68
+ }
69
+ }, {
70
+ identifier: ['unserialize', "base" /* PkgName.Base */],
71
+ condition: {
72
+ argDefinition: [{ pos: 0, name: 'connection' }],
73
+ conditionFn: securitySinkCondition
74
+ }
75
+ }, {
76
+ identifier: ['serialize', "base" /* PkgName.Base */],
77
+ condition: {
78
+ argDefinition: [{ pos: 0, name: 'object' }, { pos: 1, name: 'connection' }],
79
+ conditionFn: securitySinkCondition
80
+ }
81
+ }, {
82
+ identifier: ['dump', "base" /* PkgName.Base */],
83
+ condition: {
84
+ argDefinition: [{ pos: 0, name: 'list' }, { pos: 1, name: 'file' }],
85
+ conditionFn: securitySinkCondition
86
+ }
87
+ }, ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)([built_in_props_1.SemanticCallTag.Eval, built_in_props_1.SemanticCallTag.Process], built_in_props_1.ArgProp.Injectable, securitySinkCondition), ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)(built_in_props_1.CallProp.Ffi, built_in_props_1.ArgProp.Resource, securitySinkCondition), ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)([built_in_props_1.SemanticCallTag.Writes, built_in_props_1.SemanticCallTag.Opens, built_in_props_1.SemanticCallTag.Reads], built_in_props_1.ArgProp.Resource, securitySinkCondition)).report((f) => {
88
+ return f.functionName ? `Untrusted input reached security-sensitive sink function '${f.functionName}' [${f.locString}]`
89
+ : `Untrusted input reached a security-sensitive sink (possible code or command injection) [${f.locString}]`;
90
+ });
91
+ //# sourceMappingURL=security-analysis.js.map
@@ -0,0 +1,86 @@
1
+ import type { AbstractDomain, AbstractValue, AnyAbstractDomain } from '../abstract-interpretation/domains/abstract-domain';
2
+ import type { FunctionParameterLocation } from '../abstract-interpretation/data-frame/arguments';
3
+ import type { ArgProps, FnSig } from '../dataflow/environments/built-in-props';
4
+ import { Identifier } from '../dataflow/environments/identifier';
5
+ export declare class TaintMapper<Domain extends AnyAbstractDomain> {
6
+ mapper: TaintMappingInternal<Domain>[];
7
+ constructor(mapper?: TaintMappingInternal<Domain>[]);
8
+ /**
9
+ * Add one or more taint mapping rules to the mapper
10
+ */
11
+ pushMapping(mappings: TaintMapping<Domain>[]): void;
12
+ /**
13
+ * Add one or more taint mapping rules to the mapper.
14
+ * If a mapping for the same function call and {@link TaintRole} already exists, it is skipped.
15
+ */
16
+ pushMappingIfNotExists(rules: TaintMapping<Domain>[]): void;
17
+ /**
18
+ * Get all mappings belonging to the given identifier
19
+ */
20
+ getMappings(identifier: Identifier): TaintMappingInternal<Domain>[];
21
+ /** Whether a mapped identifier applies to a call of `called`, which matches any namespace when it names none */
22
+ static matches(this: void, mapped: Identifier, called: Identifier): boolean;
23
+ /**
24
+ * Create a new, independent mapper containing the same taint mappings
25
+ */
26
+ clone(): TaintMapper<Domain>;
27
+ private hasMappingForRole;
28
+ private mapRulesToInternal;
29
+ private mapRuleToInternal;
30
+ }
31
+ export declare enum TaintRole {
32
+ Source = "Source",
33
+ Transformer = "Transformer",
34
+ Sink = "Sink"
35
+ }
36
+ type TaintMappingBase = {
37
+ readonly role?: TaintRole;
38
+ readonly category?: string;
39
+ readonly identifier: Identifier | Identifier[];
40
+ };
41
+ /** A mapping that assigns a fixed taint to a matched call. */
42
+ export type TaintFixedMapping<Domain extends AnyAbstractDomain> = TaintMappingBase & {
43
+ taint: AbstractValue<Domain>;
44
+ };
45
+ /** A mapping whose taint is computed from a {@link TaintCondition} over the call's argument values and taints. */
46
+ export type TaintConditionMapping<Domain extends AnyAbstractDomain> = TaintMappingBase & {
47
+ condition: TaintCondition<Domain>;
48
+ };
49
+ /** Mapping of incoming function arguments and taints to a resulting taint */
50
+ export type TaintCondition<Domain extends AnyAbstractDomain = AnyAbstractDomain> = {
51
+ argValues?: FunctionParameterLocation<unknown>[];
52
+ argDefinition?: TaintParameterLocation[];
53
+ argSignature?: {
54
+ sig: FnSig;
55
+ props: ArgProps;
56
+ };
57
+ /** additionally consider the taints of every argument of the call */
58
+ allArgs?: boolean;
59
+ conditionFn: TaintConditionFunction<Domain>;
60
+ };
61
+ /**
62
+ * A taint rule type used for the user-definition of taint analyses
63
+ * Allows for mapping of one or multiple identifiers for convenience and conciseness.
64
+ */
65
+ export type TaintMapping<Domain extends AnyAbstractDomain> = TaintFixedMapping<Domain> | TaintConditionMapping<Domain>;
66
+ /**
67
+ * Internal representation of a taint rule.
68
+ * Each rule is mapped to a single identifier simplifying search and retrieval.
69
+ */
70
+ type TaintMappingInternal<Domain extends AnyAbstractDomain> = {
71
+ readonly role?: TaintRole;
72
+ readonly category?: string;
73
+ readonly identifier: Identifier;
74
+ } & ({
75
+ taint: AbstractValue<Domain>;
76
+ } | {
77
+ condition: TaintCondition<Domain>;
78
+ });
79
+ export type TaintConditionDomain<Domain extends AnyAbstractDomain> = Domain extends AbstractDomain<infer Value, infer Top, infer Bot> ? AbstractDomain<Value, Top, Bot> : never;
80
+ /** Function describing how the resulting taint is calculated from incoming arguments and taints */
81
+ export type TaintConditionFunction<Domain extends AnyAbstractDomain> = (args: unknown[], taints: TaintConditionDomain<Domain>[]) => AbstractValue<Domain> | undefined;
82
+ export interface TaintParameterLocation {
83
+ pos: number;
84
+ name?: string;
85
+ }
86
+ export {};
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaintRole = exports.TaintMapper = void 0;
4
+ const identifier_1 = require("../dataflow/environments/identifier");
5
+ class TaintMapper {
6
+ mapper = [];
7
+ constructor(mapper) {
8
+ if (mapper) {
9
+ this.mapper = mapper;
10
+ }
11
+ }
12
+ /**
13
+ * Add one or more taint mapping rules to the mapper
14
+ */
15
+ pushMapping(mappings) {
16
+ this.mapper.push(...this.mapRulesToInternal(mappings));
17
+ }
18
+ /**
19
+ * Add one or more taint mapping rules to the mapper.
20
+ * If a mapping for the same function call and {@link TaintRole} already exists, it is skipped.
21
+ */
22
+ pushMappingIfNotExists(rules) {
23
+ const internalRules = this.mapRulesToInternal(rules);
24
+ for (const rule of internalRules) {
25
+ if (this.hasMappingForRole(rule)) {
26
+ continue;
27
+ }
28
+ this.mapper.push(rule);
29
+ }
30
+ }
31
+ /**
32
+ * Get all mappings belonging to the given identifier
33
+ */
34
+ getMappings(identifier) {
35
+ return this.mapper.filter(m => TaintMapper.matches(m.identifier, identifier));
36
+ }
37
+ /** Whether a mapped identifier applies to a call of `called`, which matches any namespace when it names none */
38
+ static matches(mapped, called) {
39
+ return identifier_1.Identifier.matches(mapped, called) || (identifier_1.Identifier.getNamespace(called) === undefined && identifier_1.Identifier.matches(called, mapped));
40
+ }
41
+ /**
42
+ * Create a new, independent mapper containing the same taint mappings
43
+ */
44
+ clone() {
45
+ return new TaintMapper([...this.mapper]);
46
+ }
47
+ hasMappingForRole(rule) {
48
+ return this.getMappings(rule.identifier).some(i => i.role === rule.role);
49
+ }
50
+ mapRulesToInternal(rules) {
51
+ return rules.flatMap(r => this.mapRuleToInternal(r));
52
+ }
53
+ mapRuleToInternal(rule) {
54
+ if (identifier_1.Identifier.is(rule.identifier)) {
55
+ return [rule];
56
+ }
57
+ return rule.identifier.map(i => {
58
+ return { role: rule.role, category: rule.category, identifier: i,
59
+ ...('taint' in rule ? { taint: rule.taint } : { condition: rule.condition }) };
60
+ });
61
+ }
62
+ }
63
+ exports.TaintMapper = TaintMapper;
64
+ var TaintRole;
65
+ (function (TaintRole) {
66
+ TaintRole["Source"] = "Source";
67
+ TaintRole["Transformer"] = "Transformer";
68
+ TaintRole["Sink"] = "Sink";
69
+ })(TaintRole || (exports.TaintRole = TaintRole = {}));
70
+ //# sourceMappingURL=taint-mapping.js.map
@@ -0,0 +1,26 @@
1
+ import type { AnyAbstractDomain } from '../abstract-interpretation/domains/abstract-domain';
2
+ import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
3
+ import type { ReadOnlyFlowrAnalyzerContext } from '../project/context/flowr-analyzer-context';
4
+ import type { DataflowGraph } from '../dataflow/graph/graph';
5
+ import { type DataflowGraphVertexFunctionCall } from '../dataflow/graph/vertex';
6
+ import type { TaintMapping } from './taint-mapping';
7
+ import { TaintRole } from './taint-mapping';
8
+ /**
9
+ * Resolves all {@link TaintMapping}s that apply to a function call
10
+ * into a single abstract value of the given abstract domain.
11
+ * Each {@link TaintRole} is resolved and the resulting values are met together.
12
+ * If no mappings match at all, the call maps to the domain's top element.
13
+ * @param call - The function call vertex whose taint is being resolved
14
+ * @param mappings - The mappings that apply to the call
15
+ * @param domain - The abstract domain the resulting abstract value belongs to
16
+ * @param projectArg - Resolves the abstract value of an argument node within `domain` (e.g. the projection of a
17
+ * product state onto the component of the analysis); may return `undefined` if no value is known
18
+ * @param dfg - The dataflow graph used to resolve the call's arguments
19
+ * @param ctx - The analyzer context used when resolving argument values
20
+ * @returns The abstract value to store for the function call within the given domain
21
+ */
22
+ export declare function resolveFnCallToTaint<Domain extends AnyAbstractDomain>(call: DataflowGraphVertexFunctionCall, mappings: TaintMapping<Domain>[], domain: Domain, projectArg: (id: NodeId) => Domain | undefined, dfg: DataflowGraph, ctx: ReadOnlyFlowrAnalyzerContext): {
23
+ value: Domain;
24
+ role?: TaintRole;
25
+ category?: string;
26
+ };
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveFnCallToTaint = resolveFnCallToTaint;
4
+ const identifier_1 = require("../dataflow/environments/identifier");
5
+ const abstract_domain_1 = require("../abstract-interpretation/domains/abstract-domain");
6
+ const config_1 = require("../config");
7
+ const arguments_1 = require("../abstract-interpretation/data-frame/arguments");
8
+ const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
+ const match_args_1 = require("../dataflow/graph/match-args");
10
+ const vertex_1 = require("../dataflow/graph/vertex");
11
+ const assert_1 = require("../util/assert");
12
+ const logger_1 = require("./logger");
13
+ const taint_mapping_1 = require("./taint-mapping");
14
+ /**
15
+ * Resolves all {@link TaintMapping}s that apply to a function call
16
+ * into a single abstract value of the given abstract domain.
17
+ * Each {@link TaintRole} is resolved and the resulting values are met together.
18
+ * If no mappings match at all, the call maps to the domain's top element.
19
+ * @param call - The function call vertex whose taint is being resolved
20
+ * @param mappings - The mappings that apply to the call
21
+ * @param domain - The abstract domain the resulting abstract value belongs to
22
+ * @param projectArg - Resolves the abstract value of an argument node within `domain` (e.g. the projection of a
23
+ * product state onto the component of the analysis); may return `undefined` if no value is known
24
+ * @param dfg - The dataflow graph used to resolve the call's arguments
25
+ * @param ctx - The analyzer context used when resolving argument values
26
+ * @returns The abstract value to store for the function call within the given domain
27
+ */
28
+ function resolveFnCallToTaint(call, mappings, domain, projectArg, dfg, ctx) {
29
+ if (mappings.length === 0) {
30
+ return { value: domain.top() };
31
+ }
32
+ const context = { domain, call, dfg, ctx, projectArg };
33
+ const roleTaints = Object.values(taint_mapping_1.TaintRole)
34
+ .map(role => {
35
+ const mapping = mappings.find(m => m.role === role);
36
+ return { role, category: mapping?.category, taint: resolveMappingToTaint(mapping, context) };
37
+ })
38
+ .filter((entry) => (0, assert_1.isNotUndefined)(entry.taint));
39
+ const value = abstract_domain_1.AbstractDomain.meetAll(roleTaints.map(entry => entry.taint), domain.top());
40
+ // for eval only: the mapping whose taint determined the resolved value, and whether it stems from a function category
41
+ const winner = roleTaints.find(entry => entry.taint.equals(value));
42
+ return { value, role: winner?.role, category: winner?.category };
43
+ }
44
+ function resolveMappingToTaint(mapping, context) {
45
+ if (!mapping) {
46
+ return undefined;
47
+ }
48
+ if ('taint' in mapping) {
49
+ return context.domain.create(mapping.taint);
50
+ }
51
+ const resultingTaint = resolveTaintCondition(mapping, context);
52
+ return resultingTaint === undefined ? undefined : context.domain.create(resultingTaint);
53
+ }
54
+ function resolveTaintCondition(mapping, { call, dfg, ctx, domain, projectArg }) {
55
+ const allArgs = dfg.idMap !== undefined ? (0, arguments_1.getVertexArguments)(call, dfg.idMap) : [];
56
+ const resolveInfo = { graph: dfg, idMap: dfg.idMap, full: true, resolve: config_1.VariableResolve.Alias, ctx: ctx };
57
+ const valArgs = mapping.condition.argValues
58
+ ? mapping.condition.argValues.map(location => (0, arguments_1.getArgumentValue)(allArgs, location, resolveInfo))
59
+ : [];
60
+ const { argSignature, argDefinition, allArgs: everyArg } = mapping.condition;
61
+ const taintIds = argSignature !== undefined
62
+ ? taintIdsFromSignature(dfg, call.id, argSignature)
63
+ : taintIdsFromDef(allArgs, resolveInfo, call.name, argDefinition);
64
+ if (everyArg) {
65
+ taintIds.push(...allArgs.map(arg => arg === r_function_call_1.EmptyArgument ? undefined : arg.value?.info.id));
66
+ }
67
+ const incomingTaints = taintIds
68
+ .map(id => (0, assert_1.isUndefined)(id) ? domain.top() : projectArg(id))
69
+ .map((value) => (0, assert_1.isUndefined)(value) ? domain.top() : value);
70
+ return mapping.condition.conditionFn(valArgs, incomingTaints);
71
+ }
72
+ function taintIdsFromSignature(dfg, id, argTaintSig) {
73
+ const vertex = dfg.getVertex(id);
74
+ return vertex_1.DfgVertex.isFunctionCall(vertex) ? match_args_1.MatchArgs.findWithProps(vertex.args, argTaintSig.sig, argTaintSig.props) : [];
75
+ }
76
+ function taintIdsFromDef(allArgs, resolveInfo, name, argTaints) {
77
+ return (argTaints ?? []).map(location => {
78
+ const arg = (0, arguments_1.getFunctionArgument)(allArgs, location, resolveInfo);
79
+ if ((0, assert_1.isUndefined)(arg)) {
80
+ logger_1.taintLogger.warn(`Could not determine function argument for function call to ${identifier_1.Identifier.getName(name)}: Requested taint at position ${location.pos} with name ${location.name}`);
81
+ return undefined;
82
+ }
83
+ return arg === r_function_call_1.EmptyArgument || !arg.value?.info ? undefined : arg.value.info.id;
84
+ });
85
+ }
86
+ //# sourceMappingURL=taint-resolve.js.map
@@ -0,0 +1,80 @@
1
+ import { AbstractInterpreter, type AbsintVisitorConfiguration } from '../abstract-interpretation/absint-inference';
2
+ import type { AnyAbstractDomain } from '../abstract-interpretation/domains/abstract-domain';
3
+ import type { AbstractProduct, ProductReduction } from '../abstract-interpretation/domains/partial-product-domain';
4
+ import type { NodeId } from '../r-bridge/lang-4.x/ast/model/processing/node-id';
5
+ import type { DataflowGraphVertexFunctionCall } from '../dataflow/graph/vertex';
6
+ import type { FnCallHookInfo } from './builder/taint-analysis';
7
+ import { RFunctionCall } from '../r-bridge/lang-4.x/ast/model/nodes/r-function-call';
8
+ import { RBinaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-binary-op';
9
+ import { RUnaryOp } from '../r-bridge/lang-4.x/ast/model/nodes/r-unary-op';
10
+ import { RAccess } from '../r-bridge/lang-4.x/ast/model/nodes/r-access';
11
+ import { RSymbol } from '../r-bridge/lang-4.x/ast/model/nodes/r-symbol';
12
+ import { Identifier } from '../dataflow/environments/identifier';
13
+ import type { RNode } from '../r-bridge/lang-4.x/ast/model/model';
14
+ import type { ParentInformation } from '../r-bridge/lang-4.x/ast/model/processing/decorate';
15
+ import type { TaintMapper } from './taint-mapping';
16
+ /**
17
+ * Function calls the taint analysis is able to handle:
18
+ * named function calls like `f(x)`, method calls (`obj$f(x)`), operators (`x + y`, `-x`), accesses (`x$a`, `x[[1]]`),
19
+ * and functions applied by others (`readLines` in `do.call(readLines, args)`)
20
+ */
21
+ export type TaintCallNode = RFunctionCall<ParentInformation> | RBinaryOp<ParentInformation> | RUnaryOp<ParentInformation> | RAccess<ParentInformation> | RSymbol<ParentInformation>;
22
+ /** Whether the given AST node can be handled by the taint analysis (see {@link TaintCallNode}). */
23
+ export declare function isTaintableCallNode(node: RNode<ParentInformation> | undefined): node is TaintCallNode;
24
+ /** The name mappings of a call are looked up by: the called function, or `$method` for a method call `obj$method(...)` */
25
+ export declare function taintCallName(call: DataflowGraphVertexFunctionCall, node: RNode<ParentInformation> | undefined): Identifier;
26
+ /**
27
+ * Resolves the inferred abstract taint of an argument node at the current program point, independent of any mapping
28
+ * rule. Returns `undefined` if no taint was inferred for the node.
29
+ */
30
+ export type ArgTaintProjector = (id: NodeId) => AnyAbstractDomain | undefined;
31
+ /**
32
+ * Callback hook invoked when a function call is visited during taint inference.
33
+ * @param taint - The resolved taint information for the function call
34
+ * @param node - The AST node representing the function call
35
+ * @param value - The abstract domain value at this point in the analysis
36
+ * @param projectArg - Resolves the incoming taint of any argument node, regardless of mapping rules
37
+ * @param call - The data flow graph vertex of the function call
38
+ * @param role - The role of the matched mapping (source/propagator/sink), or `undefined` for unmapped calls
39
+ */
40
+ export type TaintVisitorHook = (info: Omit<FnCallHookInfo, 'name' | 'dfg' | 'ctx'>) => void;
41
+ /**
42
+ * Configuration for the taint inference.
43
+ */
44
+ export type TaintVisitorConfiguration = AbsintVisitorConfiguration & {
45
+ /** Callbacks invoked when each function call is visited during taint inference */
46
+ fnCallHook?: TaintVisitorHook;
47
+ };
48
+ /**
49
+ * The abstract product mapping the name of a (component) taint analysis to its (value) abstract domain.
50
+ * Each property of the product holds the inferred taint of the respective component analysis.
51
+ */
52
+ export type TaintProduct = AbstractProduct;
53
+ /**
54
+ * A single component of a taint analysis, i.e. one of the combined taint analyses.
55
+ * It bundles the analysis name (used as the product key), its (value) abstract domain, and its function mapper.
56
+ * Note that {@link TaintAnalysisDefinition} structurally conforms to this interface.
57
+ * @template Domain - The (value) abstract domain of the component analysis
58
+ */
59
+ export interface TaintComponent<Domain extends AnyAbstractDomain = AnyAbstractDomain> {
60
+ /** The unique name of the component analysis, used as the key within the {@link TaintProduct}. */
61
+ readonly name: string;
62
+ /** The (value) abstract domain (taint lattice) of the component analysis. */
63
+ readonly domain: Domain;
64
+ /** The function mapper relating function names to the tainting behavior of the component analysis. */
65
+ readonly mapper: TaintMapper<Domain>;
66
+ }
67
+ /**
68
+ * Abstract interpreter conducting taint analyses, i.e. applying finite taint lattices on the control-flow graph.
69
+ * All components are evaluated simultaneously during a single control-flow traversal and their taints are combined into
70
+ * a product of the lattice values per CFG node, joined (and widened) component-wise. Optional reductions turn the
71
+ * otherwise direct product into a reduced product, allowing the component analyses to refine each other.
72
+ * A node reaching Bottom marks a finding, so it does not collapse the state.
73
+ *
74
+ * Please prefer using the {@link FlowrAnalyzer.taint} method to create a taint analysis.
75
+ */
76
+ export declare class TaintInterpreter extends AbstractInterpreter<TaintProduct> {
77
+ constructor(components: readonly TaintComponent[], config: TaintVisitorConfiguration, reductions?: readonly ProductReduction<TaintProduct>[]);
78
+ start(): void;
79
+ protected isUnsupportedFunctionCall(_nodeId: NodeId): boolean;
80
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TaintInterpreter = void 0;
4
+ exports.isTaintableCallNode = isTaintableCallNode;
5
+ exports.taintCallName = taintCallName;
6
+ const absint_inference_1 = require("../abstract-interpretation/absint-inference");
7
+ const taint_resolve_1 = require("./taint-resolve");
8
+ const r_function_call_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
9
+ const r_binary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-binary-op");
10
+ const r_unary_op_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-unary-op");
11
+ const r_access_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-access");
12
+ const r_symbol_1 = require("../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
13
+ const identifier_1 = require("../dataflow/environments/identifier");
14
+ /** the method `obj$method(...)` calls, as `$method` */
15
+ function methodName(node) {
16
+ const field = r_function_call_1.RFunctionCall.isUnnamed(node) && r_access_1.RAccess.isNamed(node.calledFunction) ? node.calledFunction.access[0]?.value : undefined;
17
+ return r_symbol_1.RSymbol.is(field) ? identifier_1.Identifier.make(`$${identifier_1.Identifier.getName(field.content)}`) : undefined;
18
+ }
19
+ /** Whether the given AST node can be handled by the taint analysis (see {@link TaintCallNode}). */
20
+ function isTaintableCallNode(node) {
21
+ return r_function_call_1.RFunctionCall.isNamed(node) || r_binary_op_1.RBinaryOp.is(node) || r_unary_op_1.RUnaryOp.is(node) || r_access_1.RAccess.is(node) || r_symbol_1.RSymbol.is(node) || methodName(node) !== undefined;
22
+ }
23
+ /** The name mappings of a call are looked up by: the called function, or `$method` for a method call `obj$method(...)` */
24
+ function taintCallName(call, node) {
25
+ return methodName(node) ?? call.name;
26
+ }
27
+ /** The abstract semantics of a taint component: every taintable call gets the taint its mappings resolve to. */
28
+ function taintSemantics({ domain, mapper }, fnCallHook) {
29
+ const handleCall = (state, call, ctx, explicitOnly) => {
30
+ const node = ctx.getAstNode(call.id);
31
+ const name = taintCallName(call, node);
32
+ const mappings = mapper.getMappings(name);
33
+ if (!isTaintableCallNode(node) || ((explicitOnly || name !== call.name || r_symbol_1.RSymbol.is(node)) && !mappings.some(m => m.category === undefined))) {
34
+ return;
35
+ }
36
+ const projectArg = (id) => ctx.getAbstractValue(id);
37
+ const { value, role, category } = (0, taint_resolve_1.resolveFnCallToTaint)(call, mappings, domain, projectArg, ctx.dfg, ctx.context);
38
+ state.set(call.id, value);
39
+ fnCallHook?.({ node, value, wasMapped: mappings.length > 0, projectArg, call, role, category });
40
+ };
41
+ return {
42
+ handleFunctionCall: (state, call, ctx) => handleCall(state, call, ctx, false),
43
+ /* accesses are only tracked with explicit mappings */
44
+ handleAccessCall: (state, call, ctx) => handleCall(state, call, ctx, true),
45
+ handleAssignmentCall(state, _call, ctx, target, source) {
46
+ const value = ctx.getAbstractValue(source);
47
+ if (value === undefined) {
48
+ state.remove(target);
49
+ }
50
+ else {
51
+ state.set(target, value);
52
+ }
53
+ }
54
+ };
55
+ }
56
+ /**
57
+ * Abstract interpreter conducting taint analyses, i.e. applying finite taint lattices on the control-flow graph.
58
+ * All components are evaluated simultaneously during a single control-flow traversal and their taints are combined into
59
+ * a product of the lattice values per CFG node, joined (and widened) component-wise. Optional reductions turn the
60
+ * otherwise direct product into a reduced product, allowing the component analyses to refine each other.
61
+ * A node reaching Bottom marks a finding, so it does not collapse the state.
62
+ *
63
+ * Please prefer using the {@link FlowrAnalyzer.taint} method to create a taint analysis.
64
+ */
65
+ class TaintInterpreter extends absint_inference_1.AbstractInterpreter {
66
+ constructor(components, config, reductions = []) {
67
+ const domains = Object.fromEntries(components.map(c => [c.name, c.domain]));
68
+ const semantics = Object.fromEntries(components.map(c => [c.name, taintSemantics(c, config.fnCallHook)]));
69
+ /* a component missing from a state is simply unknown, so the reductions see the product as partial */
70
+ super(config, { domains, semantics, reductions: reductions, collapseOnBottom: false });
71
+ }
72
+ start() {
73
+ super.start();
74
+ this.interpretUncalledFunctions();
75
+ }
76
+ /* taint flows through environment-changing calls as well, so they do not discard what is known */
77
+ isUnsupportedFunctionCall(_nodeId) {
78
+ return false;
79
+ }
80
+ }
81
+ exports.TaintInterpreter = TaintInterpreter;
82
+ //# sourceMappingURL=taint-visitor.js.map
@@ -3,7 +3,7 @@
3
3
  * @module
4
4
  */
5
5
  import { SemVer } from 'semver';
6
- export declare const versionDate = "2026-10-27T20:44:18Z";
6
+ export declare const versionDate = "2026-11-03T08:51:21Z";
7
7
  /**
8
8
  * Retrieves the current flowR version as a new {@link SemVer} object.
9
9
  */
@@ -8,9 +8,9 @@ exports.flowrVersion = flowrVersion;
8
8
  */
9
9
  const semver_1 = require("semver");
10
10
  // this is automatically replaced with the current version by release-it
11
- const version = '2.16.7';
11
+ const version = '2.17.0';
12
12
  // this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
13
- exports.versionDate = '2026-10-27T20:44:18Z';
13
+ exports.versionDate = '2026-11-03T08:51:21Z';
14
14
  /**
15
15
  * Retrieves the current flowR version as a new {@link SemVer} object.
16
16
  */