@eagleoutice/flowr 2.16.8 → 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.
- 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.js +1 -1
- 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/query-fn-props.d.ts +9 -3
- package/dataflow/environments/query-fn-props.js +13 -5
- package/dataflow/fn/class-declaration.js +1 -8
- 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/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/package.json +1 -1
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +4 -0
- 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/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/reader.js +15 -6
- package/project/sigdb/sigdb-download.d.ts +3 -7
- package/project/sigdb/sigdb-download.js +71 -72
- 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/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 +165 -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 +86 -0
- package/taint-analysis/taint-mapping.js +70 -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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
3
|
+
import type { FlowrConfig } from '../../../config';
|
|
4
|
+
import type { ParsedQueryLine } from '../../query';
|
|
5
|
+
import Joi from 'joi';
|
|
6
|
+
import { executeTaintQuery } from './taint-query-executor';
|
|
7
|
+
import type { AnyPredefinedTaintAnalysisName } from '../../../taint-analysis/predefined/predefined';
|
|
8
|
+
import type { CommandCompletions } from '../../../cli/repl/core';
|
|
9
|
+
import type { TaintInferenceResult } from '../../../taint-analysis/builder/taint-analysis';
|
|
10
|
+
export interface TaintQuery extends BaseQueryFormat {
|
|
11
|
+
readonly type: 'taint';
|
|
12
|
+
readonly defs: AnyPredefinedTaintAnalysisName[];
|
|
13
|
+
}
|
|
14
|
+
export interface TaintQueryResult<Analyses extends string[]> extends BaseQueryResult {
|
|
15
|
+
readonly results: Map<Analyses[number], TaintInferenceResult>;
|
|
16
|
+
}
|
|
17
|
+
declare function taintQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
|
|
18
|
+
declare function taintQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'taint'>;
|
|
19
|
+
export declare const TaintQueryDefinition: {
|
|
20
|
+
readonly title: "Taint Analysis Query";
|
|
21
|
+
readonly executor: typeof executeTaintQuery;
|
|
22
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, resultStrings: string[]) => true;
|
|
23
|
+
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
24
|
+
readonly completer: typeof taintQueryCompleter;
|
|
25
|
+
readonly fromLine: typeof taintQueryLineParser;
|
|
26
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
27
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TaintQueryDefinition = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const taint_query_executor_1 = require("./taint-query-executor");
|
|
9
|
+
const predefined_1 = require("../../../taint-analysis/predefined/predefined");
|
|
10
|
+
const lattice_1 = require("../../../abstract-interpretation/domains/lattice");
|
|
11
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
12
|
+
const time_1 = require("../../../util/text/time");
|
|
13
|
+
const retriever_1 = require("../../../r-bridge/retriever");
|
|
14
|
+
const prefix = 'definitions:';
|
|
15
|
+
function taintQueryCompleter(line, startingNewArg, _config) {
|
|
16
|
+
const prefixNotPresent = line.length == 0 || (line.length == 1 && line[0].length < prefix.length);
|
|
17
|
+
const notFinished = line.length == 1 && line[0].startsWith(prefix) && !startingNewArg;
|
|
18
|
+
const endOfOptions = line.length == 1 && startingNewArg || line.length == 2;
|
|
19
|
+
if (prefixNotPresent) {
|
|
20
|
+
return { completions: [`${prefix}`] };
|
|
21
|
+
}
|
|
22
|
+
else if (endOfOptions) {
|
|
23
|
+
return { completions: [retriever_1.fileProtocol] };
|
|
24
|
+
}
|
|
25
|
+
else if (notFinished) {
|
|
26
|
+
const withoutPrefix = line[0].slice(prefix.length);
|
|
27
|
+
const used = withoutPrefix.split(',').map(r => r.trim());
|
|
28
|
+
const all = Object.keys(predefined_1.predefinedTaintAnalyses);
|
|
29
|
+
const unused = all.filter(r => !used.includes(r));
|
|
30
|
+
const last = used[used.length - 1];
|
|
31
|
+
const lastUnfinished = !all.includes(last);
|
|
32
|
+
if (lastUnfinished) {
|
|
33
|
+
// Return all strings that have not been added yet
|
|
34
|
+
return { completions: unused, argumentPart: last };
|
|
35
|
+
}
|
|
36
|
+
else if (unused.length > 0) {
|
|
37
|
+
// Add a comma, if the current last string is complete
|
|
38
|
+
return { completions: [','], argumentPart: '' };
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// All strings are used, complete with a space
|
|
42
|
+
return { completions: [' '], argumentPart: '' };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { completions: [] };
|
|
46
|
+
}
|
|
47
|
+
function defsInInput(defsPart) {
|
|
48
|
+
return defsPart
|
|
49
|
+
.reduce((acc, name) => {
|
|
50
|
+
name = name.trim();
|
|
51
|
+
if (name in predefined_1.predefinedTaintAnalyses) {
|
|
52
|
+
acc.valid.push(name);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
acc.invalid.push(name);
|
|
56
|
+
}
|
|
57
|
+
return acc;
|
|
58
|
+
}, { valid: [], invalid: [] });
|
|
59
|
+
}
|
|
60
|
+
function taintQueryLineParser(output, line, _config) {
|
|
61
|
+
let defs = [];
|
|
62
|
+
let input = undefined;
|
|
63
|
+
if (line.length > 0 && line[0].startsWith(prefix)) {
|
|
64
|
+
const defsPart = line[0].slice(prefix.length).split(',');
|
|
65
|
+
const parseResult = defsInInput(defsPart);
|
|
66
|
+
if (parseResult.invalid.length > 0) {
|
|
67
|
+
output.stderr(`Unknown taint definition names: ${parseResult.invalid.map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`
|
|
68
|
+
+ `\nKnown taint definitions are: ${Object.keys(predefined_1.predefinedTaintAnalyses).map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`);
|
|
69
|
+
}
|
|
70
|
+
defs = parseResult.valid;
|
|
71
|
+
input = line[1];
|
|
72
|
+
}
|
|
73
|
+
else if (line.length > 0) {
|
|
74
|
+
input = line[0];
|
|
75
|
+
}
|
|
76
|
+
return { query: [{ type: 'taint', defs: defs }], rCode: input };
|
|
77
|
+
}
|
|
78
|
+
exports.TaintQueryDefinition = {
|
|
79
|
+
title: 'Taint Analysis Query',
|
|
80
|
+
executor: taint_query_executor_1.executeTaintQuery,
|
|
81
|
+
asciiSummarizer: (formatter, _analyzer, queryResults, resultStrings) => {
|
|
82
|
+
const out = queryResults;
|
|
83
|
+
const state = out.results.entries().toArray();
|
|
84
|
+
resultStrings.push(`Query: ${(0, ansi_1.bold)('taint', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
85
|
+
for (const [name, result] of state) {
|
|
86
|
+
resultStrings.push(` ╰ **${name}**:`);
|
|
87
|
+
const lift = result.domains.value;
|
|
88
|
+
if (result.findings.length > 0) {
|
|
89
|
+
if (result.msg !== undefined) {
|
|
90
|
+
resultStrings.push(` ╰ ${result.msg}:`);
|
|
91
|
+
}
|
|
92
|
+
resultStrings.push(...result.findings.map(finding => ` ╰ ${finding.msg !== undefined ? `${finding.msg} ` : ''}`));
|
|
93
|
+
}
|
|
94
|
+
if (lift === lattice_1.Bottom) {
|
|
95
|
+
resultStrings.push(` ╰ state: ${lattice_1.BottomSymbol}`);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
resultStrings.push(...lift.entries().take(20)
|
|
99
|
+
.map(([key, domain]) => ` ╰ ${key}: ${domain?.toString()}`));
|
|
100
|
+
if (resultStrings.length > 20) {
|
|
101
|
+
resultStrings.push(' ╰ ... (see JSON)');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
},
|
|
106
|
+
jsonFormatter: (queryResults) => {
|
|
107
|
+
const { results, ...out } = queryResults;
|
|
108
|
+
const json = new Map(Array.from(results, ([name, { domains, msg, findings }]) => [name, {
|
|
109
|
+
domains: domains.value === lattice_1.Bottom ? domains.value.description : Object.fromEntries(domains.value.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null])),
|
|
110
|
+
msg,
|
|
111
|
+
findings,
|
|
112
|
+
}]));
|
|
113
|
+
const result = { results: json, ...out };
|
|
114
|
+
return result;
|
|
115
|
+
},
|
|
116
|
+
completer: taintQueryCompleter,
|
|
117
|
+
fromLine: taintQueryLineParser,
|
|
118
|
+
schema: joi_1.default.object({
|
|
119
|
+
type: joi_1.default.string().valid('taint').required().description('The type of the query.'),
|
|
120
|
+
defs: joi_1.default.array().description('The taint analyses to run.')
|
|
121
|
+
}).description('The taint query conducts taint analyses and returns their results.'),
|
|
122
|
+
flattenInvolvedNodes: () => []
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=taint-query-format.js.map
|
package/queries/query.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ import type { DoesCallQuery } from './catalog/does-call-query/does-call-query-fo
|
|
|
36
36
|
import type { InspectExceptionQuery } from './catalog/inspect-exceptions-query/inspect-exception-query-format';
|
|
37
37
|
import type { InputSourcesQuery } from './catalog/input-sources-query/input-sources-query-format';
|
|
38
38
|
import type { ProvenanceQuery } from './catalog/provenance-query/provenance-query-format';
|
|
39
|
+
import type { TaintQuery } from './catalog/taint-query/taint-query-format';
|
|
39
40
|
import type { LintingResult, LintingResultCertainty } from '../linter/linter-format';
|
|
40
41
|
import { type DiceQuery } from './catalog/dice-query/dice-query-format';
|
|
41
42
|
import { type GuessDepVersionsQuery } from './catalog/guess-dep-versions-query/guess-dep-versions-query-format';
|
|
@@ -44,7 +45,7 @@ import { type FunctionInfoQuery } from './catalog/function-info-query/function-i
|
|
|
44
45
|
/**
|
|
45
46
|
* These are all queries that can be executed from within flowR
|
|
46
47
|
*/
|
|
47
|
-
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | InspectFnPropsQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | DiceQuery | GuessDepVersionsQuery | FunctionInfoQuery;
|
|
48
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | InspectFnPropsQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | TaintQuery | DiceQuery | GuessDepVersionsQuery | FunctionInfoQuery;
|
|
48
49
|
export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
|
|
49
50
|
type: QueryType;
|
|
50
51
|
};
|
|
@@ -145,6 +146,16 @@ export declare const SupportedQueries: {
|
|
|
145
146
|
readonly schema: Joi.ObjectSchema<any>;
|
|
146
147
|
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
147
148
|
};
|
|
149
|
+
readonly taint: {
|
|
150
|
+
readonly title: "Taint Analysis Query";
|
|
151
|
+
readonly executor: typeof import("./catalog/taint-query/taint-query-executor").executeTaintQuery;
|
|
152
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("..").KnownParser>, queryResults: BaseQueryResult, resultStrings: string[]) => true;
|
|
153
|
+
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
154
|
+
readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
|
|
155
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"taint">;
|
|
156
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
157
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
158
|
+
};
|
|
148
159
|
readonly files: {
|
|
149
160
|
readonly title: "Files Query";
|
|
150
161
|
readonly executor: typeof import("./catalog/files-query/files-query-executor").executeFileQuery;
|
package/queries/query.js
CHANGED
|
@@ -46,6 +46,7 @@ const does_call_query_format_1 = require("./catalog/does-call-query/does-call-qu
|
|
|
46
46
|
const inspect_exception_query_format_1 = require("./catalog/inspect-exceptions-query/inspect-exception-query-format");
|
|
47
47
|
const input_sources_query_format_1 = require("./catalog/input-sources-query/input-sources-query-format");
|
|
48
48
|
const provenance_query_format_1 = require("./catalog/provenance-query/provenance-query-format");
|
|
49
|
+
const taint_query_format_1 = require("./catalog/taint-query/taint-query-format");
|
|
49
50
|
const dice_query_format_1 = require("./catalog/dice-query/dice-query-format");
|
|
50
51
|
const guess_dep_versions_query_format_1 = require("./catalog/guess-dep-versions-query/guess-dep-versions-query-format");
|
|
51
52
|
const absint_query_format_1 = require("./catalog/absint-query/absint-query-format");
|
|
@@ -59,6 +60,7 @@ exports.SupportedQueries = {
|
|
|
59
60
|
'does-call': does_call_query_format_1.DoesCallQueryDefinition,
|
|
60
61
|
'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
|
|
61
62
|
'absint': absint_query_format_1.AbsintQueryDefinition,
|
|
63
|
+
'taint': taint_query_format_1.TaintQueryDefinition,
|
|
62
64
|
'files': files_query_format_1.FilesQueryDefinition,
|
|
63
65
|
'id-map': id_map_query_format_1.IdMapQueryDefinition,
|
|
64
66
|
'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LatticeElements } from '../finite-domain';
|
|
2
|
+
import { FiniteDomain } from '../finite-domain';
|
|
3
|
+
export declare class FiniteDomainBuilder<Top extends symbol, Bottom extends symbol, Elements extends LatticeElements<Top, Bottom> = [Top, Bottom]> {
|
|
4
|
+
private readonly elements;
|
|
5
|
+
private readonly leqMap;
|
|
6
|
+
private _top;
|
|
7
|
+
private _bottom;
|
|
8
|
+
private addElements;
|
|
9
|
+
setTop(element: Top): this;
|
|
10
|
+
setBottom(element: Bottom): this;
|
|
11
|
+
addLeqOrder(from: Elements[number], to: Elements[number] | Elements[number][]): this;
|
|
12
|
+
private buildConfig;
|
|
13
|
+
build(initialElement?: Elements[number]): FiniteDomain<Top, Bottom, Elements>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiniteDomainBuilder = void 0;
|
|
4
|
+
const lattice_1 = require("../../abstract-interpretation/domains/lattice");
|
|
5
|
+
const finite_domain_1 = require("../finite-domain");
|
|
6
|
+
const assert_1 = require("../../util/assert");
|
|
7
|
+
class FiniteDomainBuilder {
|
|
8
|
+
elements = new Set();
|
|
9
|
+
leqMap = new Map();
|
|
10
|
+
_top;
|
|
11
|
+
_bottom;
|
|
12
|
+
addElements(...elements) {
|
|
13
|
+
for (const element of elements) {
|
|
14
|
+
if (!this.elements.has(element)) {
|
|
15
|
+
this.elements.add(element);
|
|
16
|
+
}
|
|
17
|
+
if (!this.leqMap.has(element)) {
|
|
18
|
+
this.leqMap.set(element, new Set());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
setTop(element) {
|
|
23
|
+
this._top = element;
|
|
24
|
+
this.addElements(element);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
setBottom(element) {
|
|
28
|
+
this._bottom = element;
|
|
29
|
+
this.addElements(element);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
addLeqOrder(from, to) {
|
|
33
|
+
this.addElements(from, ...(Array.isArray(to) ? to : [to]));
|
|
34
|
+
if (!this.elements.has(from)) {
|
|
35
|
+
throw new Error(`Source element not registered: ${String(from)}`);
|
|
36
|
+
}
|
|
37
|
+
if (!Array.isArray(to)) {
|
|
38
|
+
to = [to];
|
|
39
|
+
}
|
|
40
|
+
const successors = this.leqMap.get(from);
|
|
41
|
+
(0, assert_1.guard)(successors, 'Internal error: A successor set should always exist');
|
|
42
|
+
for (const t of to) {
|
|
43
|
+
if (!this.elements.has(t)) {
|
|
44
|
+
throw new Error(`Target element not registered: ${String(t)}`);
|
|
45
|
+
}
|
|
46
|
+
successors.add(t);
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
buildConfig() {
|
|
51
|
+
if (!this._top) {
|
|
52
|
+
this.setTop(lattice_1.Top);
|
|
53
|
+
}
|
|
54
|
+
if (!this._bottom) {
|
|
55
|
+
this.setBottom(lattice_1.Bottom);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
top: this._top,
|
|
59
|
+
bottom: this._bottom,
|
|
60
|
+
elements: new Set(this.elements),
|
|
61
|
+
leq: new Map(this.leqMap),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
build(initialElement) {
|
|
65
|
+
return new finite_domain_1.FiniteDomain(initialElement ?? this._top, this.buildConfig());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.FiniteDomainBuilder = FiniteDomainBuilder;
|
|
69
|
+
//# sourceMappingURL=domain.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
3
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import type { SourceLocation } from '../../util/range';
|
|
5
|
+
/** Per-finding context handed to a {@link ReportTemplate}. */
|
|
6
|
+
export interface FindingContext {
|
|
7
|
+
/** The name of the taint analysis */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The AST node ID that reached Bottom */
|
|
10
|
+
readonly nodeId: NodeId;
|
|
11
|
+
/** The resolved AST node, if present in the id map */
|
|
12
|
+
readonly node?: RNode<ParentInformation>;
|
|
13
|
+
/** The source location of the node, if resolvable */
|
|
14
|
+
readonly loc?: SourceLocation;
|
|
15
|
+
/** The formatted source location, if resolvable */
|
|
16
|
+
readonly locString?: string;
|
|
17
|
+
/** 1-based start line of the finding, if known */
|
|
18
|
+
readonly line?: number;
|
|
19
|
+
/** 1-based start column of the finding, if known */
|
|
20
|
+
readonly column?: number;
|
|
21
|
+
/** The source file of the finding, if known */
|
|
22
|
+
readonly file?: string;
|
|
23
|
+
/** The node's lexeme, if known */
|
|
24
|
+
readonly lexeme?: string;
|
|
25
|
+
/** The called function's name, if the node resolves to a named call */
|
|
26
|
+
readonly functionName?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A report message: either a constant string, or a function rendering a message per {@link FindingContext|finding}.
|
|
30
|
+
*/
|
|
31
|
+
export type ReportTemplate = string | ((finding: FindingContext) => string);
|
|
32
|
+
/**
|
|
33
|
+
* Convenience accessor rendering the offending token of a finding: the called function's name when the
|
|
34
|
+
* finding node resolves to a named call, otherwise the node's lexeme.
|
|
35
|
+
*/
|
|
36
|
+
export declare const findingToken: (finding: FindingContext) => string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Assembles the {@link FindingContext} for a single finding from its node id and resolved node/location.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildFindingContext(name: string, nodeId: NodeId, node: RNode<ParentInformation> | undefined, loc: SourceLocation | undefined): FindingContext;
|
|
41
|
+
/**
|
|
42
|
+
* Renders a {@link ReportTemplate} for a given {@link FindingContext}.
|
|
43
|
+
* Constant strings are returned verbatim.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderReport(report: ReportTemplate, ctx: FindingContext): string;
|
|
46
|
+
/**
|
|
47
|
+
* The default report template which appends the function name or lexeme and line number of the finding to the explanatory string.
|
|
48
|
+
* @param s - Human-readable explanation of the finding
|
|
49
|
+
*/
|
|
50
|
+
export declare function defaultReportTemplate(s: string): (f: FindingContext) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findingToken = void 0;
|
|
4
|
+
exports.buildFindingContext = buildFindingContext;
|
|
5
|
+
exports.renderReport = renderReport;
|
|
6
|
+
exports.defaultReportTemplate = defaultReportTemplate;
|
|
7
|
+
const range_1 = require("../../util/range");
|
|
8
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
|
+
/**
|
|
10
|
+
* Convenience accessor rendering the offending token of a finding: the called function's name when the
|
|
11
|
+
* finding node resolves to a named call, otherwise the node's lexeme.
|
|
12
|
+
*/
|
|
13
|
+
const findingToken = finding => finding.functionName ?? finding.lexeme;
|
|
14
|
+
exports.findingToken = findingToken;
|
|
15
|
+
/**
|
|
16
|
+
* Assembles the {@link FindingContext} for a single finding from its node id and resolved node/location.
|
|
17
|
+
*/
|
|
18
|
+
function buildFindingContext(name, nodeId, node, loc) {
|
|
19
|
+
return {
|
|
20
|
+
name,
|
|
21
|
+
nodeId,
|
|
22
|
+
node,
|
|
23
|
+
loc,
|
|
24
|
+
locString: loc !== undefined ? range_1.SourceLocation.format(loc) : undefined,
|
|
25
|
+
line: loc?.[0],
|
|
26
|
+
column: loc?.[1],
|
|
27
|
+
file: loc !== undefined ? range_1.SourceLocation.getFile(loc) : undefined,
|
|
28
|
+
lexeme: node?.lexeme,
|
|
29
|
+
functionName: r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.lexeme : undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders a {@link ReportTemplate} for a given {@link FindingContext}.
|
|
34
|
+
* Constant strings are returned verbatim.
|
|
35
|
+
*/
|
|
36
|
+
function renderReport(report, ctx) {
|
|
37
|
+
return typeof report === 'function' ? report(ctx) : report;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The default report template which appends the function name or lexeme and line number of the finding to the explanatory string.
|
|
41
|
+
* @param s - Human-readable explanation of the finding
|
|
42
|
+
*/
|
|
43
|
+
function defaultReportTemplate(s) {
|
|
44
|
+
return (f) => `${s} [${(0, exports.findingToken)(f)} at ${f.locString}]`;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=report-template.js.map
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { AbsintVisitorConfiguration } from '../../abstract-interpretation/absint-inference';
|
|
2
|
+
import { TaintInterpreter, type TaintProduct, type TaintVisitorConfiguration } from '../taint-visitor';
|
|
3
|
+
import { StateAbstractDomain } from '../../abstract-interpretation/domains/state-abstract-domain';
|
|
4
|
+
import type { ProductReduction } from '../../abstract-interpretation/domains/partial-product-domain';
|
|
5
|
+
import type { AnyAbstractDomain } from '../../abstract-interpretation/domains/abstract-domain';
|
|
6
|
+
import type { ReportTemplate } from './report-template';
|
|
7
|
+
import type { TaintFnCategory } from '../function-categories';
|
|
8
|
+
import type { TaintMapping, TaintConditionFunction } from '../taint-mapping';
|
|
9
|
+
import { TaintMapper } from '../taint-mapping';
|
|
10
|
+
export type TaintAnalysisName<Definition> = Definition extends RunnableTaintAnalysisDefinition<infer Name> ? Name : never;
|
|
11
|
+
/**
|
|
12
|
+
* The common interface of all (runnable) taint analysis definitions, i.e. single {@link TaintAnalysisDefinition|definitions}
|
|
13
|
+
* and {@link CompositeTaintAnalysisDefinition|composite definitions}. A runnable definition knows its name, an optional
|
|
14
|
+
* report message, and how to create the abstract interpretation visitor that conducts the analysis.
|
|
15
|
+
*/
|
|
16
|
+
export interface RunnableTaintAnalysisDefinition<Name extends string = string> {
|
|
17
|
+
/** The unique name of the taint analysis. */
|
|
18
|
+
readonly name: Name;
|
|
19
|
+
/** The optional message reported when the analysis produces a finding. */
|
|
20
|
+
readonly msg?: ReportTemplate;
|
|
21
|
+
/** Creates the abstract interpreter that conducts the taint analysis for the given configuration. */
|
|
22
|
+
createVisitor(config: TaintVisitorConfiguration, fnCategories?: TaintFnCategory[]): TaintInterpreter;
|
|
23
|
+
/** The result state of `interpreter` (created by {@link createVisitor}) for this analysis. */
|
|
24
|
+
resultState(interpreter: TaintInterpreter): StateAbstractDomain<AnyAbstractDomain>;
|
|
25
|
+
}
|
|
26
|
+
/** Options for composing multiple taint analyses into a {@link CompositeTaintAnalysisDefinition}. */
|
|
27
|
+
export interface ComposeOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Optional reductions turning the direct product into a reduced product.
|
|
30
|
+
* Each reduction may refine the inferred taints of the component analyses based on each other.
|
|
31
|
+
*/
|
|
32
|
+
reductions?: readonly ProductReduction<TaintProduct>[];
|
|
33
|
+
/** The optional message reported when the composite analysis produces a finding. */
|
|
34
|
+
report?: ReportTemplate;
|
|
35
|
+
}
|
|
36
|
+
export interface TaintAnalysisReportStage<Name extends string = string, Domain extends AnyAbstractDomain = AnyAbstractDomain> extends TaintAnalysisToStage<Name, Domain> {
|
|
37
|
+
/** Set the message reported when the analysis produces a finding. */
|
|
38
|
+
report(msg: ReportTemplate): TaintAnalysisDefinition<Name, Domain>;
|
|
39
|
+
}
|
|
40
|
+
export interface TaintAnalysisToStage<Name extends string = string, Domain extends AnyAbstractDomain = AnyAbstractDomain> extends TaintAnalysisThroughStage<Name, Domain> {
|
|
41
|
+
/** Add sink rules signaling findings by yielding Bottom. */
|
|
42
|
+
to(...fnMapping: TaintMapping<Domain>[]): TaintAnalysisReportStage<Name, Domain>;
|
|
43
|
+
}
|
|
44
|
+
export interface TaintAnalysisThroughStage<Name extends string = string, Domain extends AnyAbstractDomain = AnyAbstractDomain> extends TaintAnalysisFromStage<Name, Domain> {
|
|
45
|
+
/** Add propagator or sanitizer rules that determine the resulting taint of matching calls. */
|
|
46
|
+
through(...fnMapping: TaintMapping<Domain>[]): TaintAnalysisToStage<Name, Domain>;
|
|
47
|
+
}
|
|
48
|
+
export interface TaintAnalysisFromStage<Name extends string = string, Domain extends AnyAbstractDomain = AnyAbstractDomain> {
|
|
49
|
+
/** Add propagator or sanitizer rules that determine the resulting taint of matching calls. */
|
|
50
|
+
from(...fnMapping: TaintMapping<Domain>[]): TaintAnalysisThroughStage<Name, Domain>;
|
|
51
|
+
/** Add rules for function categories (i.e. sets of functions from {@link BuiltInIndex} fulfilling certain properties) */
|
|
52
|
+
on(category: TaintFnCategory, handler?: TaintConditionFunction<AnyAbstractDomain>): TaintAnalysisFromStage<Name, Domain>;
|
|
53
|
+
/** Shortcut when no transformers, sinks, and/or a report message should be defined */
|
|
54
|
+
getPartialDefinition(): TaintAnalysisDefinition<Name, Domain>;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Fluent builder class for defining new taint analyses.
|
|
58
|
+
* Use {@link TaintAnalysisDefinition.create} to obtain an instance;
|
|
59
|
+
* The methods {@link TaintAnalysis.from}, {@link TaintAnalysis.through},
|
|
60
|
+
* {@link TaintAnalysis.to}, and {@link TaintAnalysis.report} have to be called in order.
|
|
61
|
+
*/
|
|
62
|
+
export declare class TaintAnalysisDefinition<Name extends string = string, Domain extends AnyAbstractDomain = AnyAbstractDomain, Config extends AbsintVisitorConfiguration = AbsintVisitorConfiguration> implements TaintAnalysisReportStage<Name, Domain> {
|
|
63
|
+
readonly domain: Domain;
|
|
64
|
+
mapper: TaintMapper<Domain>;
|
|
65
|
+
categories: TaintFnCategory[];
|
|
66
|
+
name: Name;
|
|
67
|
+
config: Config | undefined;
|
|
68
|
+
private _msg;
|
|
69
|
+
get msg(): ReportTemplate | undefined;
|
|
70
|
+
private constructor();
|
|
71
|
+
/**
|
|
72
|
+
* Create a new taint analysis builder. {@link run} is unreachable on the result until at least
|
|
73
|
+
* one of {@link add}, {@link addComposite}, or {@link addPredefined} has been called on it.
|
|
74
|
+
*/
|
|
75
|
+
static create<Name extends string = string, Domain extends AnyAbstractDomain = AnyAbstractDomain, Config extends AbsintVisitorConfiguration = AbsintVisitorConfiguration>(name: Name, domain: Domain, config?: Config): TaintAnalysisFromStage<Name, Domain>;
|
|
76
|
+
on(category: TaintFnCategory, handler?: TaintConditionFunction<AnyAbstractDomain>): this;
|
|
77
|
+
from(...fnMapping: TaintMapping<Domain>[]): TaintAnalysisThroughStage<Name, Domain>;
|
|
78
|
+
through(...fnMapping: TaintMapping<Domain>[]): TaintAnalysisToStage<Name, Domain>;
|
|
79
|
+
to(...fnMapping: TaintMapping<Domain>[]): TaintAnalysisReportStage<Name, Domain>;
|
|
80
|
+
report(msg: ReportTemplate): this;
|
|
81
|
+
createVisitor(config: TaintVisitorConfiguration, fnCategories?: TaintFnCategory[]): TaintInterpreter;
|
|
82
|
+
/** The end state of this single analysis, holding its own taint lattice values rather than a product of them. */
|
|
83
|
+
resultState(interpreter: TaintInterpreter): StateAbstractDomain<Domain>;
|
|
84
|
+
getPartialDefinition(): this;
|
|
85
|
+
/**
|
|
86
|
+
* Composes at least two taint analysis definitions into a single composite taint analysis.
|
|
87
|
+
* The component analyses are evaluated simultaneously during a single control-flow traversal and their taints are
|
|
88
|
+
* combined into a product of the lattice values per each CFG node (see {@link TaintInterpreter}).
|
|
89
|
+
* @param name - The unique name of the resulting composite taint analysis
|
|
90
|
+
* @param definitions - The component taint analysis definitions to compose (must have unique names)
|
|
91
|
+
* @param options - Optional reductions (for a reduced product) and a report message
|
|
92
|
+
*/
|
|
93
|
+
static compose<Name extends string>(name: Name, definitions: readonly TaintAnalysisDefinition[], options?: ComposeOptions): CompositeTaintAnalysisDefinition<Name>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A composite taint analysis definition combining multiple {@link TaintAnalysisDefinition|component analyses} into a
|
|
97
|
+
* product (or reduced product) taint analysis. Create instances via {@link TaintAnalysisDefinition.compose}.
|
|
98
|
+
*/
|
|
99
|
+
export declare class CompositeTaintAnalysisDefinition<Name extends string> implements RunnableTaintAnalysisDefinition<Name> {
|
|
100
|
+
readonly name: Name;
|
|
101
|
+
readonly definitions: readonly TaintAnalysisDefinition[];
|
|
102
|
+
readonly reductions: readonly ProductReduction<TaintProduct>[];
|
|
103
|
+
msg: ReportTemplate | undefined;
|
|
104
|
+
constructor(name: Name, definitions: readonly TaintAnalysisDefinition[], options?: ComposeOptions);
|
|
105
|
+
report(msg: ReportTemplate): this;
|
|
106
|
+
createVisitor({ fnCallHook: _hook, ...config }: TaintVisitorConfiguration, _fnCategories?: TaintFnCategory[]): TaintInterpreter;
|
|
107
|
+
resultState(interpreter: TaintInterpreter): StateAbstractDomain<AnyAbstractDomain>;
|
|
108
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CompositeTaintAnalysisDefinition = exports.TaintAnalysisDefinition = void 0;
|
|
4
|
+
const taint_visitor_1 = require("../taint-visitor");
|
|
5
|
+
const assert_1 = require("../../util/assert");
|
|
6
|
+
const state_abstract_domain_1 = require("../../abstract-interpretation/domains/state-abstract-domain");
|
|
7
|
+
const function_categories_1 = require("../function-categories");
|
|
8
|
+
const taint_mapping_1 = require("../taint-mapping");
|
|
9
|
+
/**
|
|
10
|
+
* Fluent builder class for defining new taint analyses.
|
|
11
|
+
* Use {@link TaintAnalysisDefinition.create} to obtain an instance;
|
|
12
|
+
* The methods {@link TaintAnalysis.from}, {@link TaintAnalysis.through},
|
|
13
|
+
* {@link TaintAnalysis.to}, and {@link TaintAnalysis.report} have to be called in order.
|
|
14
|
+
*/
|
|
15
|
+
class TaintAnalysisDefinition {
|
|
16
|
+
domain;
|
|
17
|
+
mapper;
|
|
18
|
+
categories = [];
|
|
19
|
+
name;
|
|
20
|
+
config;
|
|
21
|
+
_msg;
|
|
22
|
+
get msg() {
|
|
23
|
+
return this._msg;
|
|
24
|
+
}
|
|
25
|
+
constructor(name, domain, config) {
|
|
26
|
+
this.name = name;
|
|
27
|
+
this.domain = domain;
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.mapper = new taint_mapping_1.TaintMapper();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create a new taint analysis builder. {@link run} is unreachable on the result until at least
|
|
33
|
+
* one of {@link add}, {@link addComposite}, or {@link addPredefined} has been called on it.
|
|
34
|
+
*/
|
|
35
|
+
static create(name, domain, config) {
|
|
36
|
+
return new TaintAnalysisDefinition(name, domain, config);
|
|
37
|
+
}
|
|
38
|
+
on(category, handler) {
|
|
39
|
+
(0, assert_1.guard)(handler || category.handler, 'No handler set for given function category');
|
|
40
|
+
this.categories.push({ ...category, handler: handler ?? category.handler });
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
from(...fnMapping) {
|
|
44
|
+
this.mapper.pushMapping(fnMapping.map(m => ({ ...m, role: taint_mapping_1.TaintRole.Source })));
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
through(...fnMapping) {
|
|
48
|
+
this.mapper.pushMapping(fnMapping.map(m => ({ ...m, role: taint_mapping_1.TaintRole.Transformer })));
|
|
49
|
+
return this;
|
|
50
|
+
}
|
|
51
|
+
to(...fnMapping) {
|
|
52
|
+
this.mapper.pushMapping(fnMapping.map(m => ({ ...m, role: taint_mapping_1.TaintRole.Sink })));
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
report(msg) {
|
|
56
|
+
this._msg = msg;
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
createVisitor(config, fnCategories = []) {
|
|
60
|
+
const completeMapper = this.mapper.clone();
|
|
61
|
+
// Add mappings from function categories.
|
|
62
|
+
// Categories added to the individual analysis take precedence over passed categories.
|
|
63
|
+
const finalFnCategories = [...this.categories, ...fnCategories];
|
|
64
|
+
for (const category of finalFnCategories) {
|
|
65
|
+
const resolved = (0, function_categories_1.resolveCategoryToTaintMappings)(category);
|
|
66
|
+
completeMapper.pushMappingIfNotExists(resolved);
|
|
67
|
+
}
|
|
68
|
+
return new taint_visitor_1.TaintInterpreter([{ name: this.name, domain: this.domain, mapper: completeMapper }], { ...this.config, ...config });
|
|
69
|
+
}
|
|
70
|
+
/** The end state of this single analysis, holding its own taint lattice values rather than a product of them. */
|
|
71
|
+
resultState(interpreter) {
|
|
72
|
+
const end = interpreter.getEndState();
|
|
73
|
+
return end.isBottom()
|
|
74
|
+
? state_abstract_domain_1.StateAbstractDomain.bottom(this.domain, false)
|
|
75
|
+
: new state_abstract_domain_1.StateAbstractDomain(new Map(end.entries(this.name)), this.domain, false);
|
|
76
|
+
}
|
|
77
|
+
getPartialDefinition() {
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Composes at least two taint analysis definitions into a single composite taint analysis.
|
|
82
|
+
* The component analyses are evaluated simultaneously during a single control-flow traversal and their taints are
|
|
83
|
+
* combined into a product of the lattice values per each CFG node (see {@link TaintInterpreter}).
|
|
84
|
+
* @param name - The unique name of the resulting composite taint analysis
|
|
85
|
+
* @param definitions - The component taint analysis definitions to compose (must have unique names)
|
|
86
|
+
* @param options - Optional reductions (for a reduced product) and a report message
|
|
87
|
+
*/
|
|
88
|
+
static compose(name, definitions, options) {
|
|
89
|
+
return new CompositeTaintAnalysisDefinition(name, definitions, options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.TaintAnalysisDefinition = TaintAnalysisDefinition;
|
|
93
|
+
/**
|
|
94
|
+
* A composite taint analysis definition combining multiple {@link TaintAnalysisDefinition|component analyses} into a
|
|
95
|
+
* product (or reduced product) taint analysis. Create instances via {@link TaintAnalysisDefinition.compose}.
|
|
96
|
+
*/
|
|
97
|
+
class CompositeTaintAnalysisDefinition {
|
|
98
|
+
name;
|
|
99
|
+
definitions;
|
|
100
|
+
reductions;
|
|
101
|
+
msg;
|
|
102
|
+
constructor(name, definitions, options) {
|
|
103
|
+
(0, assert_1.guard)(definitions.length >= 2, 'A composite taint analysis must combine at least two taint analysis definitions');
|
|
104
|
+
const names = definitions.map(def => def.name);
|
|
105
|
+
(0, assert_1.guard)(new Set(names).size === names.length, 'A composite taint analysis requires unique component analysis names');
|
|
106
|
+
this.name = name;
|
|
107
|
+
this.definitions = definitions;
|
|
108
|
+
this.reductions = options?.reductions ?? [];
|
|
109
|
+
this.msg = options?.report;
|
|
110
|
+
}
|
|
111
|
+
report(msg) {
|
|
112
|
+
this.msg = msg;
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
115
|
+
createVisitor({ fnCallHook: _hook, ...config }, _fnCategories) {
|
|
116
|
+
const components = this.definitions.map(def => ({
|
|
117
|
+
name: def.name,
|
|
118
|
+
domain: def.domain,
|
|
119
|
+
mapper: def.mapper,
|
|
120
|
+
}));
|
|
121
|
+
return new taint_visitor_1.TaintInterpreter(components, config, this.reductions);
|
|
122
|
+
}
|
|
123
|
+
resultState(interpreter) {
|
|
124
|
+
return interpreter.getEndState();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.CompositeTaintAnalysisDefinition = CompositeTaintAnalysisDefinition;
|
|
128
|
+
//# sourceMappingURL=taint-analysis-definition.js.map
|