@eagleoutice/flowr 2.16.8 → 2.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -10
- package/abstract-interpretation/absint-inference.d.ts +17 -1
- package/abstract-interpretation/absint-inference.js +118 -3
- package/abstract-interpretation/data-frame/arguments.d.ts +11 -1
- package/abstract-interpretation/data-frame/arguments.js +12 -0
- package/abstract-interpretation/domains/lattice.d.ts +2 -0
- package/abstract-interpretation/domains/lattice.js +0 -6
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +2 -1
- package/abstract-interpretation/domains/multi-value-state-domain.js +7 -3
- package/abstract-interpretation/domains/partial-product-domain.js +2 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +6 -3
- package/abstract-interpretation/domains/state-abstract-domain.js +13 -7
- package/abstract-interpretation/domains/state-domain.d.ts +4 -0
- package/config.d.ts +32 -0
- package/config.js +23 -3
- package/control-flow/useless-loop.js +10 -8
- package/data/r-primitives.generated.d.ts +1 -0
- package/data/r-primitives.generated.js +9 -0
- package/data/sigdb/sigdb.remote.json +110 -110
- package/dataflow/environments/built-in-props.d.ts +16 -2
- package/dataflow/environments/built-in-props.js +23 -3
- package/dataflow/environments/built-in.js +13 -3
- package/dataflow/environments/default-builtin-config.d.ts +268 -7
- package/dataflow/environments/default-builtin-config.js +72 -13
- package/dataflow/environments/identifier.d.ts +7 -1
- package/dataflow/environments/query-fn-props.d.ts +9 -3
- package/dataflow/environments/query-fn-props.js +13 -5
- package/dataflow/extractor.js +49 -14
- package/dataflow/fn/class-declaration.js +1 -8
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +7 -0
- package/documentation/wiki-linter.js +29 -0
- package/documentation/wiki-query.js +20 -1
- package/linter/linter-executor.js +2 -1
- package/linter/linter-rules.d.ts +65 -0
- package/linter/linter-rules.js +5 -1
- package/linter/rules/cmd-check/global-environment-modification.d.ts +14 -1
- package/linter/rules/cmd-check/global-environment-modification.js +15 -7
- package/linter/rules/network-functions.js +10 -2
- package/linter/rules/no-leaked-credentials.d.ts +1 -0
- package/linter/rules/no-leaked-credentials.js +3 -3
- package/linter/rules/process-state-in-session.d.ts +71 -0
- package/linter/rules/process-state-in-session.js +267 -0
- package/linter/rules/secret-exfiltration.d.ts +80 -0
- package/linter/rules/secret-exfiltration.js +183 -0
- package/linter/rules/unused-import.js +11 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +4 -0
- package/project/cache/flowr-analyzer-cache.js +11 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -0
- package/project/context/flowr-analyzer-dependencies-context.js +6 -0
- package/project/context/flowr-file.d.ts +2 -2
- package/project/context/flowr-file.js +2 -2
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +4 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +39 -4
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +134 -30
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +7 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +14 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +18 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +43 -15
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +58 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +237 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +24 -18
- package/project/plugins/plugin-registry.d.ts +5 -4
- package/project/plugins/plugin-registry.js +6 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/decode.js +13 -3
- package/project/sigdb/decompress.d.ts +4 -0
- package/project/sigdb/decompress.js +60 -25
- package/project/sigdb/manifest.d.ts +1 -1
- package/project/sigdb/manifest.js +2 -5
- package/project/sigdb/memory-source.d.ts +6 -4
- package/project/sigdb/memory-source.js +6 -5
- package/project/sigdb/on-demand/fetch.d.ts +18 -0
- package/project/sigdb/on-demand/fetch.js +127 -0
- package/project/sigdb/on-demand/package-sources.d.ts +40 -0
- package/project/sigdb/on-demand/package-sources.js +263 -0
- package/project/sigdb/on-demand/recoverer.d.ts +40 -0
- package/project/sigdb/on-demand/recoverer.js +169 -0
- package/project/sigdb/on-demand/remote-sources.d.ts +72 -0
- package/project/sigdb/on-demand/remote-sources.js +132 -0
- package/project/sigdb/on-demand/tar.d.ts +19 -0
- package/project/sigdb/on-demand/tar.js +119 -0
- package/project/sigdb/reader.js +15 -6
- package/project/sigdb/sigdb-download.d.ts +3 -7
- package/project/sigdb/sigdb-download.js +71 -72
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +5 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +17 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +3 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +11 -1
- package/queries/catalog/taint-query/taint-query-executor.d.ts +7 -0
- package/queries/catalog/taint-query/taint-query-executor.js +30 -0
- package/queries/catalog/taint-query/taint-query-format.d.ts +29 -0
- package/queries/catalog/taint-query/taint-query-format.js +124 -0
- package/queries/query.d.ts +12 -1
- package/queries/query.js +2 -0
- package/r-bridge/data/data.d.ts +29 -0
- package/r-bridge/data/data.js +23 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +4 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +8 -0
- package/taint-analysis/builder/domain.d.ts +14 -0
- package/taint-analysis/builder/domain.js +69 -0
- package/taint-analysis/builder/report-template.d.ts +50 -0
- package/taint-analysis/builder/report-template.js +46 -0
- package/taint-analysis/builder/taint-analysis-definition.d.ts +108 -0
- package/taint-analysis/builder/taint-analysis-definition.js +128 -0
- package/taint-analysis/builder/taint-analysis.d.ts +124 -0
- package/taint-analysis/builder/taint-analysis.js +93 -0
- package/taint-analysis/builtin-index-bridge.d.ts +20 -0
- package/taint-analysis/builtin-index-bridge.js +48 -0
- package/taint-analysis/eval/eval.d.ts +1 -0
- package/taint-analysis/eval/eval.js +124 -0
- package/taint-analysis/eval/instrumentation.d.ts +59 -0
- package/taint-analysis/eval/instrumentation.js +124 -0
- package/taint-analysis/finite-domain.d.ts +41 -0
- package/taint-analysis/finite-domain.js +118 -0
- package/taint-analysis/function-categories.d.ts +31 -0
- package/taint-analysis/function-categories.js +61 -0
- package/taint-analysis/logger.d.ts +1 -0
- package/taint-analysis/logger.js +6 -0
- package/taint-analysis/predefined/determinism.d.ts +6 -0
- package/taint-analysis/predefined/determinism.js +14 -0
- package/taint-analysis/predefined/normalization.d.ts +17 -0
- package/taint-analysis/predefined/normalization.js +150 -0
- package/taint-analysis/predefined/predefined.d.ts +12 -0
- package/taint-analysis/predefined/predefined.js +18 -0
- package/taint-analysis/predefined/randomness-analysis.d.ts +6 -0
- package/taint-analysis/predefined/randomness-analysis.js +124 -0
- package/taint-analysis/predefined/secret-analysis.d.ts +77 -0
- package/taint-analysis/predefined/secret-analysis.js +170 -0
- package/taint-analysis/predefined/security-analysis.d.ts +7 -0
- package/taint-analysis/predefined/security-analysis.js +91 -0
- package/taint-analysis/taint-mapping.d.ts +89 -0
- package/taint-analysis/taint-mapping.js +81 -0
- package/taint-analysis/taint-resolve.d.ts +26 -0
- package/taint-analysis/taint-resolve.js +86 -0
- package/taint-analysis/taint-visitor.d.ts +80 -0
- package/taint-analysis/taint-visitor.js +82 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/r-version.js +4 -2
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
/** the mappings by the name they map, in the order they were added; a mapping only ever applies to a call of its name */
|
|
8
|
+
byName = new Map();
|
|
9
|
+
constructor(mapper) {
|
|
10
|
+
mapper?.forEach(m => this.add(m));
|
|
11
|
+
}
|
|
12
|
+
add(mapping) {
|
|
13
|
+
this.mapper.push(mapping);
|
|
14
|
+
const name = identifier_1.Identifier.getName(mapping.identifier);
|
|
15
|
+
const named = this.byName.get(name);
|
|
16
|
+
if (named === undefined) {
|
|
17
|
+
this.byName.set(name, [mapping]);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
named.push(mapping);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Add one or more taint mapping rules to the mapper
|
|
25
|
+
*/
|
|
26
|
+
pushMapping(mappings) {
|
|
27
|
+
this.mapRulesToInternal(mappings).forEach(m => this.add(m));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Add one or more taint mapping rules to the mapper.
|
|
31
|
+
* If a mapping for the same function call and {@link TaintRole} already exists, it is skipped.
|
|
32
|
+
*/
|
|
33
|
+
pushMappingIfNotExists(rules) {
|
|
34
|
+
const internalRules = this.mapRulesToInternal(rules);
|
|
35
|
+
for (const rule of internalRules) {
|
|
36
|
+
if (this.hasMappingForRole(rule)) {
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
this.add(rule);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get all mappings belonging to the given identifier
|
|
44
|
+
*/
|
|
45
|
+
getMappings(identifier) {
|
|
46
|
+
return this.byName.get(identifier_1.Identifier.getName(identifier))?.filter(m => TaintMapper.matches(m.identifier, identifier)) ?? [];
|
|
47
|
+
}
|
|
48
|
+
/** Whether a mapped identifier applies to a call of `called`, which matches any namespace when it names none */
|
|
49
|
+
static matches(mapped, called) {
|
|
50
|
+
return identifier_1.Identifier.matches(mapped, called) || (identifier_1.Identifier.getNamespace(called) === undefined && identifier_1.Identifier.matches(called, mapped));
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a new, independent mapper containing the same taint mappings
|
|
54
|
+
*/
|
|
55
|
+
clone() {
|
|
56
|
+
return new TaintMapper(this.mapper);
|
|
57
|
+
}
|
|
58
|
+
hasMappingForRole(rule) {
|
|
59
|
+
return this.getMappings(rule.identifier).some(i => i.role === rule.role);
|
|
60
|
+
}
|
|
61
|
+
mapRulesToInternal(rules) {
|
|
62
|
+
return rules.flatMap(r => this.mapRuleToInternal(r));
|
|
63
|
+
}
|
|
64
|
+
mapRuleToInternal(rule) {
|
|
65
|
+
if (identifier_1.Identifier.is(rule.identifier)) {
|
|
66
|
+
return [rule];
|
|
67
|
+
}
|
|
68
|
+
return rule.identifier.map(i => {
|
|
69
|
+
return { role: rule.role, category: rule.category, identifier: i,
|
|
70
|
+
...('taint' in rule ? { taint: rule.taint } : { condition: rule.condition }) };
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.TaintMapper = TaintMapper;
|
|
75
|
+
var TaintRole;
|
|
76
|
+
(function (TaintRole) {
|
|
77
|
+
TaintRole["Source"] = "Source";
|
|
78
|
+
TaintRole["Transformer"] = "Transformer";
|
|
79
|
+
TaintRole["Sink"] = "Sink";
|
|
80
|
+
})(TaintRole || (exports.TaintRole = TaintRole = {}));
|
|
81
|
+
//# 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
|
package/util/flowr-version.d.ts
CHANGED
package/util/flowr-version.js
CHANGED
|
@@ -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.
|
|
11
|
+
const version = '2.17.1';
|
|
12
12
|
// this is automatically replaced with the release date by release-it (scripts/bump-version.ts)
|
|
13
|
-
exports.versionDate = '2026-
|
|
13
|
+
exports.versionDate = '2026-11-03T17:01:03Z';
|
|
14
14
|
/**
|
|
15
15
|
* Retrieves the current flowR version as a new {@link SemVer} object.
|
|
16
16
|
*/
|
package/util/r-version.js
CHANGED
|
@@ -65,7 +65,8 @@ function normalizeVersions(versions) {
|
|
|
65
65
|
parts.push(prefix);
|
|
66
66
|
}
|
|
67
67
|
const versionPart = match[1];
|
|
68
|
-
|
|
68
|
+
// keep what separated it from the previous part, else `>= 1.0 < 2.0` would run together
|
|
69
|
+
parts.push(/^\s*/.exec(versionPart)?.[0] + normalizeVersion(versionPart));
|
|
69
70
|
index = match.index + versionPart.length;
|
|
70
71
|
}
|
|
71
72
|
if (index < versions.length) {
|
|
@@ -181,7 +182,8 @@ exports.RRange = {
|
|
|
181
182
|
}
|
|
182
183
|
catch { /* try to normalize R range to SemVer */ }
|
|
183
184
|
try {
|
|
184
|
-
|
|
185
|
+
// a comma joins requirements as semver's space does (`>= 1.0, < 2.0`, as rig and cargo write them)
|
|
186
|
+
return makeRange(normalizeVersions(range.replaceAll(/\s*,\s*/g, ' ')), range);
|
|
185
187
|
}
|
|
186
188
|
catch { /* unparseable even after normalization -> report as "no constraint" */ }
|
|
187
189
|
return undefined;
|