@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,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiniteDomain = void 0;
|
|
4
|
+
const abstract_domain_1 = require("../abstract-interpretation/domains/abstract-domain");
|
|
5
|
+
const assert_1 = require("../util/assert");
|
|
6
|
+
class FiniteDomain extends abstract_domain_1.AbstractDomain {
|
|
7
|
+
_config;
|
|
8
|
+
constructor(value, config) {
|
|
9
|
+
super(value);
|
|
10
|
+
this._config = config;
|
|
11
|
+
}
|
|
12
|
+
create(value) {
|
|
13
|
+
return new FiniteDomain(value, this._config);
|
|
14
|
+
}
|
|
15
|
+
top() {
|
|
16
|
+
return this.create(this._config.top);
|
|
17
|
+
}
|
|
18
|
+
bottom() {
|
|
19
|
+
return this.create(this._config.bottom);
|
|
20
|
+
}
|
|
21
|
+
isTop() {
|
|
22
|
+
return this.value === this._config.top;
|
|
23
|
+
}
|
|
24
|
+
isBottom() {
|
|
25
|
+
return this.value === this._config.bottom;
|
|
26
|
+
}
|
|
27
|
+
isValue() {
|
|
28
|
+
return this.value !== this._config.top && this.value !== this._config.bottom;
|
|
29
|
+
}
|
|
30
|
+
equalsValue(other) {
|
|
31
|
+
return this.value === other.value;
|
|
32
|
+
}
|
|
33
|
+
leqValue(other) {
|
|
34
|
+
return this.transitiveClosure(this.value).has(other.value);
|
|
35
|
+
}
|
|
36
|
+
joinValue(other) {
|
|
37
|
+
return this.findLeastUpperBound(other);
|
|
38
|
+
}
|
|
39
|
+
meetValue(other) {
|
|
40
|
+
return this.findGreatestLowerBound(other);
|
|
41
|
+
}
|
|
42
|
+
findLeastUpperBound(other) {
|
|
43
|
+
const thisUpper = this.upperClosure(this.value);
|
|
44
|
+
const otherUpper = this.upperClosure(other.value);
|
|
45
|
+
const commonUpper = new Set();
|
|
46
|
+
for (const element of thisUpper) {
|
|
47
|
+
if (otherUpper.has(element)) {
|
|
48
|
+
commonUpper.add(element);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
let minimal;
|
|
52
|
+
for (const candidate of commonUpper) {
|
|
53
|
+
if (minimal === undefined || this.upperClosure(candidate).has(minimal)) {
|
|
54
|
+
minimal = candidate;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return minimal !== undefined ? this.create(minimal) : this.top();
|
|
58
|
+
}
|
|
59
|
+
findGreatestLowerBound(other) {
|
|
60
|
+
const commonLower = new Set();
|
|
61
|
+
for (const candidate of this._config.elements) {
|
|
62
|
+
const upper = this.upperClosure(candidate);
|
|
63
|
+
if (upper.has(this.value) && upper.has(other.value)) {
|
|
64
|
+
commonLower.add(candidate);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
let maximal;
|
|
68
|
+
for (const candidate of commonLower) {
|
|
69
|
+
if (maximal === undefined || this.upperClosure(maximal).has(candidate)) {
|
|
70
|
+
maximal = candidate;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
(0, assert_1.guard)(maximal !== undefined, 'Could not determine greatest lower bound');
|
|
74
|
+
return this.create(maximal);
|
|
75
|
+
}
|
|
76
|
+
/** All elements greater than or equal to the given element (including the element itself). */
|
|
77
|
+
upperClosure(element) {
|
|
78
|
+
const closure = this.transitiveClosure(element);
|
|
79
|
+
closure.add(element);
|
|
80
|
+
return closure;
|
|
81
|
+
}
|
|
82
|
+
/** All elements strictly greater than the given element. */
|
|
83
|
+
transitiveClosure(element) {
|
|
84
|
+
const visited = new Set();
|
|
85
|
+
const stack = [element];
|
|
86
|
+
while (stack.length > 0) {
|
|
87
|
+
const current = stack.pop();
|
|
88
|
+
(0, assert_1.guard)(current, 'Error in transitive lattice closure');
|
|
89
|
+
if (visited.has(current)) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (current !== element) {
|
|
93
|
+
visited.add(current);
|
|
94
|
+
}
|
|
95
|
+
for (const successor of this._config.leq.get(current) ?? []) {
|
|
96
|
+
stack.push(successor);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return visited;
|
|
100
|
+
}
|
|
101
|
+
stringify() {
|
|
102
|
+
return this.value.description ?? this.value.toString();
|
|
103
|
+
}
|
|
104
|
+
jsonify() {
|
|
105
|
+
return this.value.description ?? this.value.toString();
|
|
106
|
+
}
|
|
107
|
+
narrow(other) {
|
|
108
|
+
return this.meet(other); // Using meet for narrowing as the lattice is finite
|
|
109
|
+
}
|
|
110
|
+
widen(other) {
|
|
111
|
+
return this.join(other); // Using join for widening as the lattice is finite
|
|
112
|
+
}
|
|
113
|
+
abstract(_concrete) {
|
|
114
|
+
return this.create(this._value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.FiniteDomain = FiniteDomain;
|
|
118
|
+
//# sourceMappingURL=finite-domain.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ArgProps, CallProps } from '../dataflow/environments/built-in-props';
|
|
2
|
+
import type { AnyAbstractDomain } from '../abstract-interpretation/domains/abstract-domain';
|
|
3
|
+
import type { TaintConditionFunction, TaintMapping } from './taint-mapping';
|
|
4
|
+
import { TaintRole } from './taint-mapping';
|
|
5
|
+
export type TaintArgSelector = {
|
|
6
|
+
/** Argument properties of the function category */
|
|
7
|
+
argProps: ArgProps;
|
|
8
|
+
/**
|
|
9
|
+
* How many arguments are of interest
|
|
10
|
+
* - ExactlyOne: The matching functions need to have exactly one argument fulfilling the {@link TaintArgSelector.argProps}
|
|
11
|
+
* - AtLeastOne: The matching functions should have at least one argument fulfilling the {@link TaintArgSelector.argProps}
|
|
12
|
+
*/
|
|
13
|
+
argSelection: 'ExactlyOne' | 'AtLeastOne';
|
|
14
|
+
};
|
|
15
|
+
export type TaintFnCategory = {
|
|
16
|
+
/** Identifier of the function category, used to trace a resulting mapping back to its category */
|
|
17
|
+
name: string;
|
|
18
|
+
/** Role the functions of the category should get assigned to */
|
|
19
|
+
role: TaintRole;
|
|
20
|
+
/** Call properties of the function category */
|
|
21
|
+
callProps: CallProps;
|
|
22
|
+
/** Argument properties of the function category */
|
|
23
|
+
args: TaintArgSelector;
|
|
24
|
+
/** Handler describing the calculation of the resulting taint */
|
|
25
|
+
handler: TaintConditionFunction<AnyAbstractDomain>;
|
|
26
|
+
};
|
|
27
|
+
export declare const TaintFnCategory: Record<'pureAlias' | 'pureComputer' | 'pureShape', TaintFnCategory>;
|
|
28
|
+
/**
|
|
29
|
+
* Get the set of taint mappings for a given {@link TaintFnCategory}.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveCategoryToTaintMappings<Domain extends AnyAbstractDomain>(category: TaintFnCategory): TaintMapping<Domain>[];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaintFnCategory = void 0;
|
|
4
|
+
exports.resolveCategoryToTaintMappings = resolveCategoryToTaintMappings;
|
|
5
|
+
const built_in_props_1 = require("../dataflow/environments/built-in-props");
|
|
6
|
+
const abstract_domain_1 = require("../abstract-interpretation/domains/abstract-domain");
|
|
7
|
+
const taint_mapping_1 = require("./taint-mapping");
|
|
8
|
+
const lattice_1 = require("../abstract-interpretation/domains/lattice");
|
|
9
|
+
const builtin_index_bridge_1 = require("./builtin-index-bridge");
|
|
10
|
+
exports.TaintFnCategory = {
|
|
11
|
+
/** Pure functions which return a single one of their arguments unchanged */
|
|
12
|
+
pureAlias: {
|
|
13
|
+
name: 'pureAlias',
|
|
14
|
+
role: taint_mapping_1.TaintRole.Transformer,
|
|
15
|
+
callProps: built_in_props_1.CallProp.Pure,
|
|
16
|
+
args: {
|
|
17
|
+
argProps: built_in_props_1.ArgProp.Alias,
|
|
18
|
+
argSelection: 'ExactlyOne',
|
|
19
|
+
},
|
|
20
|
+
/** Pass through of incoming taint */
|
|
21
|
+
handler: ([_arg], [taint]) => taint?.value
|
|
22
|
+
},
|
|
23
|
+
/** Pure functions which calculate their result on one or multiple arguments */
|
|
24
|
+
pureComputer: {
|
|
25
|
+
name: 'pureComputer',
|
|
26
|
+
role: taint_mapping_1.TaintRole.Transformer,
|
|
27
|
+
callProps: built_in_props_1.CallProp.Pure,
|
|
28
|
+
args: {
|
|
29
|
+
argProps: built_in_props_1.ArgProp.Value,
|
|
30
|
+
argSelection: 'AtLeastOne',
|
|
31
|
+
},
|
|
32
|
+
/** Least-upper bound of incoming taints */
|
|
33
|
+
handler: ([_arg], taints) => taints.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(taints).value : lattice_1.Top
|
|
34
|
+
},
|
|
35
|
+
/** Pure functions which calculate their result based on the shape of input data */
|
|
36
|
+
pureShape: {
|
|
37
|
+
name: 'pureShape',
|
|
38
|
+
role: taint_mapping_1.TaintRole.Transformer,
|
|
39
|
+
callProps: built_in_props_1.CallProp.Pure,
|
|
40
|
+
args: {
|
|
41
|
+
argProps: built_in_props_1.ArgProp.Shape,
|
|
42
|
+
argSelection: 'AtLeastOne',
|
|
43
|
+
},
|
|
44
|
+
/** Least-upper bound of incoming taints */
|
|
45
|
+
handler: ([_arg], taints) => taints.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(taints).value : lattice_1.Top
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Get the set of taint mappings for a given {@link TaintFnCategory}.
|
|
50
|
+
*/
|
|
51
|
+
function resolveCategoryToTaintMappings(category) {
|
|
52
|
+
const mappings = (0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)(category.callProps, category.args.argProps, category.handler)
|
|
53
|
+
.map(m => {
|
|
54
|
+
return { role: category.role, category: category.name, ...m };
|
|
55
|
+
});
|
|
56
|
+
if (category.args.argSelection === 'ExactlyOne') {
|
|
57
|
+
return mappings.filter(m => (m.condition.argSignature?.sig.filter(([, p]) => (p & category.args.argProps) !== 0).length ?? 0) === 1);
|
|
58
|
+
}
|
|
59
|
+
return mappings;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=function-categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const taintLogger: import("tslog").Logger<import("tslog").ILogObj>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composite taint analysis combining security and randomness analyses.
|
|
3
|
+
* Tracks both security concerns (user/network/file input) and randomness properties (deterministic vs random)
|
|
4
|
+
* simultaneously during a single control-flow traversal.
|
|
5
|
+
*/
|
|
6
|
+
export declare const determinism: import("../builder/taint-analysis-definition").CompositeTaintAnalysisDefinition<"determinism">;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.determinism = void 0;
|
|
4
|
+
const taint_analysis_definition_1 = require("../builder/taint-analysis-definition");
|
|
5
|
+
const security_analysis_1 = require("./security-analysis");
|
|
6
|
+
const randomness_analysis_1 = require("./randomness-analysis");
|
|
7
|
+
const report_template_1 = require("../builder/report-template");
|
|
8
|
+
/**
|
|
9
|
+
* Composite taint analysis combining security and randomness analyses.
|
|
10
|
+
* Tracks both security concerns (user/network/file input) and randomness properties (deterministic vs random)
|
|
11
|
+
* simultaneously during a single control-flow traversal.
|
|
12
|
+
*/
|
|
13
|
+
exports.determinism = taint_analysis_definition_1.TaintAnalysisDefinition.compose('determinism', [security_analysis_1.securityAnalysis, randomness_analysis_1.randomnessAnalysis], { report: (0, report_template_1.defaultReportTemplate)('Indeterminism flowing to sensitive functions') });
|
|
14
|
+
//# sourceMappingURL=determinism.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Bottom, Top } from '../../abstract-interpretation/domains/lattice';
|
|
2
|
+
import { TaintAnalysisDefinition } from '../builder/taint-analysis-definition';
|
|
3
|
+
export declare const MinMax: unique symbol;
|
|
4
|
+
export declare const ZeroCentered: unique symbol;
|
|
5
|
+
export declare const UnitVariance: unique symbol;
|
|
6
|
+
export declare const ZScore: unique symbol;
|
|
7
|
+
export declare const normalizationDomain: import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof MinMax, typeof ZeroCentered, typeof UnitVariance, typeof ZScore]>;
|
|
8
|
+
/**
|
|
9
|
+
* Detects summary statistics whose result is a statically known constant because the input carries a specific
|
|
10
|
+
* normalization taint (e.g. the mean of zero-centered data is 0, the sd of unit-variance data is 1).
|
|
11
|
+
*/
|
|
12
|
+
export declare const normalizationKnownConstant: TaintAnalysisDefinition<"normalization-constant", import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof MinMax, typeof ZeroCentered, typeof UnitVariance, typeof ZScore]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
13
|
+
/**
|
|
14
|
+
* Detects any normalized value reaching any summary statistic, regardless of which normalization was applied
|
|
15
|
+
* or whether the result is a statically known constant.
|
|
16
|
+
*/
|
|
17
|
+
export declare const normalizationReach: TaintAnalysisDefinition<"normalization-reach", import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof MinMax, typeof ZeroCentered, typeof UnitVariance, typeof ZScore]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizationReach = exports.normalizationKnownConstant = exports.normalizationDomain = exports.ZScore = exports.UnitVariance = exports.ZeroCentered = exports.MinMax = void 0;
|
|
4
|
+
const lattice_1 = require("../../abstract-interpretation/domains/lattice");
|
|
5
|
+
const taint_analysis_definition_1 = require("../builder/taint-analysis-definition");
|
|
6
|
+
const domain_1 = require("../builder/domain");
|
|
7
|
+
const function_categories_1 = require("../function-categories");
|
|
8
|
+
exports.MinMax = Symbol('Min-Max');
|
|
9
|
+
exports.ZeroCentered = Symbol('Zero Centered');
|
|
10
|
+
exports.UnitVariance = Symbol('Unit Variance');
|
|
11
|
+
exports.ZScore = Symbol('z-Score');
|
|
12
|
+
exports.normalizationDomain = new domain_1.FiniteDomainBuilder()
|
|
13
|
+
.addLeqOrder(lattice_1.Bottom, [exports.ZScore, exports.MinMax])
|
|
14
|
+
.addLeqOrder(exports.ZScore, [exports.ZeroCentered, exports.UnitVariance])
|
|
15
|
+
.addLeqOrder(exports.ZeroCentered, lattice_1.Top)
|
|
16
|
+
.addLeqOrder(exports.UnitVariance, lattice_1.Top)
|
|
17
|
+
.addLeqOrder(exports.MinMax, lattice_1.Top)
|
|
18
|
+
.build();
|
|
19
|
+
/** Yield bottom when the input carries one of the given normalization taints. */
|
|
20
|
+
const checkKnownConstant = (...checkedTaints) => {
|
|
21
|
+
return {
|
|
22
|
+
argDefinition: [{ pos: 0, name: 'x' }],
|
|
23
|
+
conditionFn: (_args, [taint]) => checkedTaints.includes(taint.value) ? lattice_1.Bottom : (taint.value ?? lattice_1.Top)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/** Yield bottom for any concrete normalization taint. */
|
|
27
|
+
const checkAnyNormalized = checkKnownConstant(exports.MinMax, exports.ZeroCentered, exports.UnitVariance, exports.ZScore);
|
|
28
|
+
/** Functions producing a normalized value. */
|
|
29
|
+
const normalizationSources = [
|
|
30
|
+
{
|
|
31
|
+
identifier: ['scale', "base" /* PkgName.Base */],
|
|
32
|
+
condition: {
|
|
33
|
+
argValues: [
|
|
34
|
+
{ pos: 1, name: 'center', default: true },
|
|
35
|
+
{ pos: 2, name: 'scale', default: true }
|
|
36
|
+
],
|
|
37
|
+
argDefinition: [{ pos: 0, name: 'x' }],
|
|
38
|
+
conditionFn: ([center, scale], [taint]) => {
|
|
39
|
+
if (center === true && scale === true) {
|
|
40
|
+
return exports.ZScore;
|
|
41
|
+
}
|
|
42
|
+
else if (center === true) {
|
|
43
|
+
return exports.ZeroCentered;
|
|
44
|
+
}
|
|
45
|
+
else if (center === false && scale === false) {
|
|
46
|
+
return taint.value ?? lattice_1.Top;
|
|
47
|
+
}
|
|
48
|
+
return lattice_1.Top;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{ identifier: ['rescale', 'scales'], taint: exports.MinMax },
|
|
53
|
+
];
|
|
54
|
+
/** Transformations changing the normalization taint. */
|
|
55
|
+
const normalizationTransformers = [
|
|
56
|
+
// non-linear elementwise transformations
|
|
57
|
+
{
|
|
58
|
+
identifier: [
|
|
59
|
+
['abs', "base" /* PkgName.Base */],
|
|
60
|
+
// Logarithms
|
|
61
|
+
['log', "base" /* PkgName.Base */],
|
|
62
|
+
['log2', "base" /* PkgName.Base */],
|
|
63
|
+
['log10', "base" /* PkgName.Base */],
|
|
64
|
+
['log1p', "base" /* PkgName.Base */],
|
|
65
|
+
// Exponentials
|
|
66
|
+
['exp', "base" /* PkgName.Base */],
|
|
67
|
+
['expm1', "base" /* PkgName.Base */],
|
|
68
|
+
['sqrt', "base" /* PkgName.Base */],
|
|
69
|
+
// Rounding
|
|
70
|
+
['sign', "base" /* PkgName.Base */],
|
|
71
|
+
['signif', "base" /* PkgName.Base */],
|
|
72
|
+
['floor', "base" /* PkgName.Base */],
|
|
73
|
+
['ceiling', "base" /* PkgName.Base */],
|
|
74
|
+
['trunc', "base" /* PkgName.Base */],
|
|
75
|
+
// Trigonometrics
|
|
76
|
+
['sin', "base" /* PkgName.Base */],
|
|
77
|
+
['cos', "base" /* PkgName.Base */],
|
|
78
|
+
['tan', "base" /* PkgName.Base */],
|
|
79
|
+
],
|
|
80
|
+
taint: lattice_1.Top
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
identifier: ['round', "base" /* PkgName.Base */],
|
|
84
|
+
condition: {
|
|
85
|
+
argDefinition: [{ pos: 0, name: 'x' }],
|
|
86
|
+
// Rounding only removes centering and variance assumption, min-max taint is kept
|
|
87
|
+
conditionFn: (_args, [taint]) => taint.value === exports.ZScore || taint.value === exports.ZeroCentered || taint.value === exports.UnitVariance ? lattice_1.Top : taint.value
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
identifier: [
|
|
92
|
+
// dropping elements
|
|
93
|
+
['subset', "base" /* PkgName.Base */],
|
|
94
|
+
['filter', "base" /* PkgName.Base */],
|
|
95
|
+
['head', "utils" /* PkgName.Utils */],
|
|
96
|
+
['tail', "utils" /* PkgName.Utils */],
|
|
97
|
+
// additional common functions
|
|
98
|
+
['rep', "base" /* PkgName.Base */], ['rep.int', "base" /* PkgName.Base */], ['rep_len', "base" /* PkgName.Base */], ['which', "base" /* PkgName.Base */]
|
|
99
|
+
],
|
|
100
|
+
taint: lattice_1.Top
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
/**
|
|
104
|
+
* Detects summary statistics whose result is a statically known constant because the input carries a specific
|
|
105
|
+
* normalization taint (e.g. the mean of zero-centered data is 0, the sd of unit-variance data is 1).
|
|
106
|
+
*/
|
|
107
|
+
exports.normalizationKnownConstant = taint_analysis_definition_1.TaintAnalysisDefinition.create('normalization-constant', exports.normalizationDomain)
|
|
108
|
+
.on(function_categories_1.TaintFnCategory.pureAlias)
|
|
109
|
+
// assumption: calculation on input data will usually destroy normalization
|
|
110
|
+
.on(function_categories_1.TaintFnCategory.pureComputer, (_args, _taints) => lattice_1.Top)
|
|
111
|
+
.on(function_categories_1.TaintFnCategory.pureShape, (_args, _taints) => lattice_1.Top)
|
|
112
|
+
.from(...normalizationSources)
|
|
113
|
+
.through(...normalizationTransformers)
|
|
114
|
+
.to({ identifier: ['mean', "base" /* PkgName.Base */], condition: checkKnownConstant(exports.ZeroCentered, exports.ZScore) }, { identifier: ['sd', "stats" /* PkgName.Stats */], condition: checkKnownConstant(exports.UnitVariance, exports.ZScore) }, { identifier: ['var', "stats" /* PkgName.Stats */], condition: checkKnownConstant(exports.UnitVariance, exports.ZScore) }, { identifier: [['min', "base" /* PkgName.Base */], ['max', "base" /* PkgName.Base */], ['range', "base" /* PkgName.Base */]], condition: checkKnownConstant(exports.MinMax) }).report((f) => {
|
|
115
|
+
return f.functionName ? `${f.functionName} calculated on normalized data yields a known result [${f.locString}]` : `Known summary statistic calculated on normalized data [${f.locString}]`;
|
|
116
|
+
});
|
|
117
|
+
/**
|
|
118
|
+
* Detects any normalized value reaching any summary statistic, regardless of which normalization was applied
|
|
119
|
+
* or whether the result is a statically known constant.
|
|
120
|
+
*/
|
|
121
|
+
exports.normalizationReach = taint_analysis_definition_1.TaintAnalysisDefinition.create('normalization-reach', exports.normalizationDomain)
|
|
122
|
+
.on(function_categories_1.TaintFnCategory.pureAlias)
|
|
123
|
+
// assumption: calculation on input data will usually destroy normalization
|
|
124
|
+
.on(function_categories_1.TaintFnCategory.pureComputer, (_args, _taints) => lattice_1.Top)
|
|
125
|
+
.on(function_categories_1.TaintFnCategory.pureShape, (_args, _taints) => lattice_1.Top)
|
|
126
|
+
.from(...normalizationSources)
|
|
127
|
+
.through(...normalizationTransformers)
|
|
128
|
+
.to({
|
|
129
|
+
identifier: [
|
|
130
|
+
['mean', "base" /* PkgName.Base */],
|
|
131
|
+
['sum', "base" /* PkgName.Base */],
|
|
132
|
+
['median', "stats" /* PkgName.Stats */],
|
|
133
|
+
['quantile', "stats" /* PkgName.Stats */],
|
|
134
|
+
['range', "base" /* PkgName.Base */],
|
|
135
|
+
['min', "base" /* PkgName.Base */],
|
|
136
|
+
['max', "base" /* PkgName.Base */],
|
|
137
|
+
['sd', "stats" /* PkgName.Stats */],
|
|
138
|
+
['var', "stats" /* PkgName.Stats */],
|
|
139
|
+
['IQR', "stats" /* PkgName.Stats */],
|
|
140
|
+
['fivenum', "stats" /* PkgName.Stats */],
|
|
141
|
+
['colMeans', "base" /* PkgName.Base */],
|
|
142
|
+
['rowMeans', "base" /* PkgName.Base */],
|
|
143
|
+
['colSums', "base" /* PkgName.Base */],
|
|
144
|
+
['rowSums', "base" /* PkgName.Base */],
|
|
145
|
+
],
|
|
146
|
+
condition: checkAnyNormalized
|
|
147
|
+
}).report((f) => {
|
|
148
|
+
return f.functionName ? `${f.functionName} calculated on normalized data [${f.locString}]` : `Summary statistic calculated on normalized data [${f.locString}]`;
|
|
149
|
+
});
|
|
150
|
+
//# sourceMappingURL=normalization.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TaintAnalysisDefinition } from '../builder/taint-analysis-definition';
|
|
2
|
+
export declare const predefinedTaintAnalyses: {
|
|
3
|
+
readonly 'normalization-constant': TaintAnalysisDefinition<"normalization-constant", import("../finite-domain").FiniteDomain<typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, [typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, typeof import("./normalization").MinMax, typeof import("./normalization").ZeroCentered, typeof import("./normalization").UnitVariance, typeof import("./normalization").ZScore]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
4
|
+
readonly 'normalization-reach': TaintAnalysisDefinition<"normalization-reach", import("../finite-domain").FiniteDomain<typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, [typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, typeof import("./normalization").MinMax, typeof import("./normalization").ZeroCentered, typeof import("./normalization").UnitVariance, typeof import("./normalization").ZScore]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
5
|
+
readonly security: TaintAnalysisDefinition<"security", import("../finite-domain").FiniteDomain<typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, [typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, typeof import("./security-analysis").UserInput, typeof import("./security-analysis").NetworkInput, typeof import("./security-analysis").FileInput]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
6
|
+
readonly randomness: TaintAnalysisDefinition<"randomness", import("../finite-domain").FiniteDomain<typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, [typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, typeof import("./randomness-analysis").Random, typeof import("./randomness-analysis").Deterministic]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
7
|
+
readonly determinism: import("../builder/taint-analysis-definition").CompositeTaintAnalysisDefinition<"determinism">;
|
|
8
|
+
readonly secret: TaintAnalysisDefinition<"secret", import("../finite-domain").FiniteDomain<typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, [typeof import("../../abstract-interpretation/domains/lattice").Top, typeof import("../../abstract-interpretation/domains/lattice").Bottom, typeof import("./secret-analysis").Credential, typeof import("./secret-analysis").Secret, typeof import("./secret-analysis").FileContent, typeof import("./secret-analysis").Response]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
9
|
+
};
|
|
10
|
+
export declare const allPredefinedTaintAnalysisNames: AnyPredefinedTaintAnalysisName[];
|
|
11
|
+
export type AnyPredefinedTaintAnalysisName = keyof typeof predefinedTaintAnalyses;
|
|
12
|
+
export type AllPredefinedTaintAnalysisNames = [AnyPredefinedTaintAnalysisName];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allPredefinedTaintAnalysisNames = exports.predefinedTaintAnalyses = void 0;
|
|
4
|
+
const normalization_1 = require("./normalization");
|
|
5
|
+
const security_analysis_1 = require("./security-analysis");
|
|
6
|
+
const randomness_analysis_1 = require("./randomness-analysis");
|
|
7
|
+
const determinism_1 = require("./determinism");
|
|
8
|
+
const secret_analysis_1 = require("./secret-analysis");
|
|
9
|
+
exports.predefinedTaintAnalyses = {
|
|
10
|
+
'normalization-constant': normalization_1.normalizationKnownConstant,
|
|
11
|
+
'normalization-reach': normalization_1.normalizationReach,
|
|
12
|
+
'security': security_analysis_1.securityAnalysis,
|
|
13
|
+
'randomness': randomness_analysis_1.randomnessAnalysis,
|
|
14
|
+
'determinism': determinism_1.determinism,
|
|
15
|
+
'secret': secret_analysis_1.secretAnalysis
|
|
16
|
+
};
|
|
17
|
+
exports.allPredefinedTaintAnalysisNames = Object.keys(exports.predefinedTaintAnalyses);
|
|
18
|
+
//# sourceMappingURL=predefined.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Bottom, Top } from '../../abstract-interpretation/domains/lattice';
|
|
2
|
+
import { TaintAnalysisDefinition } from '../builder/taint-analysis-definition';
|
|
3
|
+
export declare const Random: unique symbol;
|
|
4
|
+
export declare const Deterministic: unique symbol;
|
|
5
|
+
export declare const randomnessDomain: import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof Random, typeof Deterministic]>;
|
|
6
|
+
export declare const randomnessAnalysis: TaintAnalysisDefinition<"randomness", import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof Random, typeof Deterministic]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomnessAnalysis = exports.randomnessDomain = exports.Deterministic = exports.Random = 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 identifier_1 = require("../../dataflow/environments/identifier");
|
|
9
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
10
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
11
|
+
const function_categories_1 = require("../function-categories");
|
|
12
|
+
const builtin_index_bridge_1 = require("../builtin-index-bridge");
|
|
13
|
+
exports.Random = Symbol('Random');
|
|
14
|
+
exports.Deterministic = Symbol('Deterministic');
|
|
15
|
+
exports.randomnessDomain = new domain_1.FiniteDomainBuilder()
|
|
16
|
+
.addLeqOrder(lattice_1.Bottom, [exports.Random, exports.Deterministic])
|
|
17
|
+
.addLeqOrder(exports.Random, lattice_1.Top)
|
|
18
|
+
.addLeqOrder(exports.Deterministic, lattice_1.Top)
|
|
19
|
+
.build();
|
|
20
|
+
const randomnessSinkCondition = (_args, taints) => taints.some(taint => taint.value === exports.Random) ? lattice_1.Bottom
|
|
21
|
+
: taints.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(taints).value : lattice_1.Top;
|
|
22
|
+
exports.randomnessAnalysis = taint_analysis_definition_1.TaintAnalysisDefinition.create('randomness', exports.randomnessDomain)
|
|
23
|
+
.on(function_categories_1.TaintFnCategory.pureAlias)
|
|
24
|
+
// propagate randomness if any incoming argument is random
|
|
25
|
+
.on(function_categories_1.TaintFnCategory.pureComputer, ([_arg], taints) => {
|
|
26
|
+
if (taints.some(t => t?.value === exports.Random)) {
|
|
27
|
+
return exports.Random;
|
|
28
|
+
}
|
|
29
|
+
if (taints.length > 0) {
|
|
30
|
+
return abstract_domain_1.AbstractDomain.joinAll(taints).value;
|
|
31
|
+
}
|
|
32
|
+
return lattice_1.Top;
|
|
33
|
+
})
|
|
34
|
+
// assumption: randomness seldomly affects shape of data
|
|
35
|
+
.on(function_categories_1.TaintFnCategory.pureShape, (_args, _taints) => lattice_1.Top)
|
|
36
|
+
.from({
|
|
37
|
+
identifier: [
|
|
38
|
+
// vector constructor functions
|
|
39
|
+
['vector', "base" /* PkgName.Base */],
|
|
40
|
+
['numeric', "base" /* PkgName.Base */],
|
|
41
|
+
['double', "base" /* PkgName.Base */],
|
|
42
|
+
['integer', "base" /* PkgName.Base */],
|
|
43
|
+
['logical', "base" /* PkgName.Base */],
|
|
44
|
+
['complex', "base" /* PkgName.Base */],
|
|
45
|
+
['raw', "base" /* PkgName.Base */],
|
|
46
|
+
['character', "base" /* PkgName.Base */],
|
|
47
|
+
['single', "base" /* PkgName.Base */],
|
|
48
|
+
['mat.or.vec', "base" /* PkgName.Base */],
|
|
49
|
+
// type checks
|
|
50
|
+
['is.vector', "base" /* PkgName.Base */],
|
|
51
|
+
['is.numeric', "base" /* PkgName.Base */],
|
|
52
|
+
['is.double', "base" /* PkgName.Base */],
|
|
53
|
+
['is.integer', "base" /* PkgName.Base */],
|
|
54
|
+
['is.logical', "base" /* PkgName.Base */],
|
|
55
|
+
['is.complex', "base" /* PkgName.Base */],
|
|
56
|
+
['is.raw', "base" /* PkgName.Base */],
|
|
57
|
+
['is.character', "base" /* PkgName.Base */],
|
|
58
|
+
['is.single', "base" /* PkgName.Base */],
|
|
59
|
+
['is.matrix', "base" /* PkgName.Base */],
|
|
60
|
+
['is.factor', "base" /* PkgName.Base */],
|
|
61
|
+
['is.ordered', "base" /* PkgName.Base */],
|
|
62
|
+
// sequence functions
|
|
63
|
+
['seq', "base" /* PkgName.Base */],
|
|
64
|
+
['seq.Date', "base" /* PkgName.Base */],
|
|
65
|
+
['seq.POSIXt', "base" /* PkgName.Base */],
|
|
66
|
+
['sequence', "base" /* PkgName.Base */],
|
|
67
|
+
['seq_along', "base" /* PkgName.Base */],
|
|
68
|
+
['seq_len', "base" /* PkgName.Base */],
|
|
69
|
+
],
|
|
70
|
+
taint: exports.Deterministic
|
|
71
|
+
}, {
|
|
72
|
+
identifier: [...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.Random)]
|
|
73
|
+
// Exclude set.seed as it does not return a Random value
|
|
74
|
+
.filter(i => !identifier_1.Identifier.matches(i, ['set.seed', "base" /* PkgName.Base */])),
|
|
75
|
+
taint: exports.Random
|
|
76
|
+
})
|
|
77
|
+
.through({
|
|
78
|
+
identifier: [
|
|
79
|
+
// coercion
|
|
80
|
+
['as.vector', "base" /* PkgName.Base */],
|
|
81
|
+
['as.numeric', "base" /* PkgName.Base */],
|
|
82
|
+
['as.double', "base" /* PkgName.Base */],
|
|
83
|
+
['as.integer', "base" /* PkgName.Base */],
|
|
84
|
+
['as.logical', "base" /* PkgName.Base */],
|
|
85
|
+
['as.complex', "base" /* PkgName.Base */],
|
|
86
|
+
['as.raw', "base" /* PkgName.Base */],
|
|
87
|
+
['as.character', "base" /* PkgName.Base */],
|
|
88
|
+
['as.single', "base" /* PkgName.Base */],
|
|
89
|
+
['as.matrix', "base" /* PkgName.Base */],
|
|
90
|
+
['as.factor', "base" /* PkgName.Base */],
|
|
91
|
+
['as.ordered', "base" /* PkgName.Base */],
|
|
92
|
+
// repetition
|
|
93
|
+
['rep', "base" /* PkgName.Base */], ['rep.int', "base" /* PkgName.Base */], ['rep_len', "base" /* PkgName.Base */],
|
|
94
|
+
// additional common functions
|
|
95
|
+
['which', "base" /* PkgName.Base */]
|
|
96
|
+
],
|
|
97
|
+
condition: {
|
|
98
|
+
argDefinition: [{ pos: 0, name: 'x' }],
|
|
99
|
+
conditionFn: (_args, [taint]) => taint.value
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
.to({
|
|
103
|
+
identifier: ['summary', "base" /* PkgName.Base */],
|
|
104
|
+
condition: {
|
|
105
|
+
argDefinition: [{ pos: 0, name: 'object' }],
|
|
106
|
+
conditionFn: randomnessSinkCondition
|
|
107
|
+
}
|
|
108
|
+
}, {
|
|
109
|
+
identifier: ['lm', "base" /* PkgName.Base */],
|
|
110
|
+
condition: {
|
|
111
|
+
argDefinition: [{ pos: 0, name: 'formula' }, { pos: 1, name: 'data' }],
|
|
112
|
+
conditionFn: randomnessSinkCondition
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
identifier: ['ggplot', "ggplot2" /* PkgName.GgPlot2 */],
|
|
116
|
+
condition: {
|
|
117
|
+
argDefinition: [{ pos: 0, name: 'data' }],
|
|
118
|
+
conditionFn: randomnessSinkCondition
|
|
119
|
+
}
|
|
120
|
+
}, ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)([built_in_props_1.SemanticCallTag.Writes, built_in_props_1.SemanticCallTag.Graphics], built_in_props_1.ArgProp.Value, randomnessSinkCondition)).report((f) => {
|
|
121
|
+
return f.functionName ? `Randomness reached write/graphics function '${f.functionName}' [${f.locString}]`
|
|
122
|
+
: `Randomness reached a write/graphics function [${f.locString}]`;
|
|
123
|
+
});
|
|
124
|
+
//# sourceMappingURL=randomness-analysis.js.map
|