@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,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
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Bottom, Top } from '../../abstract-interpretation/domains/lattice';
|
|
2
|
+
import { TaintAnalysisDefinition } from '../builder/taint-analysis-definition';
|
|
3
|
+
import { Identifier } from '../../dataflow/environments/identifier';
|
|
4
|
+
import type { TaintParameterLocation } from '../taint-mapping';
|
|
5
|
+
/** A confidential value, e.g., an API key read from the environment */
|
|
6
|
+
export declare const Secret: unique symbol;
|
|
7
|
+
/** A secret placed into an authentication channel, e.g., `httr::authenticate(user, key)` */
|
|
8
|
+
export declare const Credential: unique symbol;
|
|
9
|
+
/** The content of a file that may hold secrets, as no file is trusted by default */
|
|
10
|
+
export declare const FileContent: unique symbol;
|
|
11
|
+
/** A server response that keeps the credentials of its request, shown only when the whole object is written out */
|
|
12
|
+
export declare const Response: unique symbol;
|
|
13
|
+
export declare const secretDomain: import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof Credential, typeof Secret, typeof FileContent, typeof Response]>;
|
|
14
|
+
/** Environment variable names that hold credentials */
|
|
15
|
+
export declare const CredentialNamePattern: RegExp;
|
|
16
|
+
/** Files that hold credentials */
|
|
17
|
+
export declare const CredentialFilePattern: RegExp;
|
|
18
|
+
/** How far the content of files is trusted not to hold secrets: `none` (any file but trusted ones may hold secrets) or only `credential-files` */
|
|
19
|
+
export declare enum FileTrust {
|
|
20
|
+
None = "none",
|
|
21
|
+
CredentialFiles = "credential-files"
|
|
22
|
+
}
|
|
23
|
+
/** Urls of endpoints that answer with a token */
|
|
24
|
+
export declare const TokenUrlPattern: RegExp;
|
|
25
|
+
/** Where a secret goes when it reaches a sink, `auth` being an authentication channel, the intended use */
|
|
26
|
+
export declare enum SecretSinkClass {
|
|
27
|
+
Network = "network",
|
|
28
|
+
Auth = "auth",
|
|
29
|
+
Browser = "browser",
|
|
30
|
+
Logs = "logs",
|
|
31
|
+
Files = "files",
|
|
32
|
+
Process = "process",
|
|
33
|
+
Llm = "llm"
|
|
34
|
+
}
|
|
35
|
+
/** functions through which a secret leaves the process */
|
|
36
|
+
export interface SecretSink {
|
|
37
|
+
readonly class: SecretSinkClass;
|
|
38
|
+
readonly fns: readonly Identifier[];
|
|
39
|
+
/** the destination argument (url, host, or request) */
|
|
40
|
+
readonly destination?: TaintParameterLocation;
|
|
41
|
+
/** whether all arguments end up in the url, and thus in server logs */
|
|
42
|
+
readonly inUrl?: boolean;
|
|
43
|
+
/** an argument redirecting output to a file */
|
|
44
|
+
readonly file?: TaintParameterLocation;
|
|
45
|
+
/** what the call returns: the request it builds, holding its secrets, or the response of the server */
|
|
46
|
+
readonly returns?: 'request' | 'response';
|
|
47
|
+
/** whether it writes out the whole object, including the fields print methods hide */
|
|
48
|
+
readonly serializes?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export declare const DefaultSecretSinks: readonly SecretSink[];
|
|
51
|
+
/** Extensions of the {@link secretAnalysis} */
|
|
52
|
+
export interface SecretAnalysisOptions {
|
|
53
|
+
/** environment variable names holding credentials, defaults to {@link CredentialNamePattern} */
|
|
54
|
+
readonly credentialNamePattern?: RegExp;
|
|
55
|
+
/** functions whose result is secret */
|
|
56
|
+
readonly sources?: readonly Identifier[];
|
|
57
|
+
/** functions whose result is never secret */
|
|
58
|
+
readonly declassifiers?: readonly Identifier[];
|
|
59
|
+
/** where secrets leave the process, defaults to {@link DefaultSecretSinks} */
|
|
60
|
+
readonly sinks?: readonly SecretSink[];
|
|
61
|
+
/** how far files are trusted, defaults to {@link FileTrust.None} */
|
|
62
|
+
readonly fileTrust?: FileTrust;
|
|
63
|
+
/** paths of files holding secrets, in addition to {@link CredentialFilePattern} */
|
|
64
|
+
readonly secretFiles?: RegExp;
|
|
65
|
+
/** paths of files holding no secrets */
|
|
66
|
+
readonly trustedFiles?: RegExp;
|
|
67
|
+
}
|
|
68
|
+
/** The {@link secretAnalysis}, extended by the given options */
|
|
69
|
+
export declare function createSecretAnalysis({ credentialNamePattern, sources, declassifiers, sinks, fileTrust, secretFiles, trustedFiles }?: SecretAnalysisOptions): TaintAnalysisDefinition<"secret", import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof Credential, typeof Secret, typeof FileContent, typeof Response]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
70
|
+
/**
|
|
71
|
+
* Tracks secrets (environment, keyrings, config, credential files, tokens, password prompts) to where they leave the process.
|
|
72
|
+
* By default, the content of any file may hold secrets ({@link FileContent}), see {@link FileTrust}.
|
|
73
|
+
* Hashes and presence checks declassify them, authentication channels make them a {@link Credential}, and requests carrying
|
|
74
|
+
* them return a {@link Response}, or a new secret from a token endpoint.
|
|
75
|
+
* Network calls are no findings here, as whether sending a secret leaks it depends on the destination (see `secret-exfiltration`).
|
|
76
|
+
*/
|
|
77
|
+
export declare const secretAnalysis: TaintAnalysisDefinition<"secret", import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof Credential, typeof Secret, typeof FileContent, typeof Response]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secretAnalysis = exports.DefaultSecretSinks = exports.SecretSinkClass = exports.TokenUrlPattern = exports.FileTrust = exports.CredentialFilePattern = exports.CredentialNamePattern = exports.secretDomain = exports.Response = exports.FileContent = exports.Credential = exports.Secret = void 0;
|
|
4
|
+
exports.createSecretAnalysis = createSecretAnalysis;
|
|
5
|
+
const lattice_1 = require("../../abstract-interpretation/domains/lattice");
|
|
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 function_categories_1 = require("../function-categories");
|
|
10
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
11
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
12
|
+
const builtin_index_bridge_1 = require("../builtin-index-bridge");
|
|
13
|
+
/** A confidential value, e.g., an API key read from the environment */
|
|
14
|
+
exports.Secret = Symbol('Secret');
|
|
15
|
+
/** A secret placed into an authentication channel, e.g., `httr::authenticate(user, key)` */
|
|
16
|
+
exports.Credential = Symbol('Credential');
|
|
17
|
+
/** The content of a file that may hold secrets, as no file is trusted by default */
|
|
18
|
+
exports.FileContent = Symbol('FileContent');
|
|
19
|
+
/** A server response that keeps the credentials of its request, shown only when the whole object is written out */
|
|
20
|
+
exports.Response = Symbol('Response');
|
|
21
|
+
exports.secretDomain = new domain_1.FiniteDomainBuilder()
|
|
22
|
+
.addLeqOrder(lattice_1.Bottom, [exports.Credential])
|
|
23
|
+
.addLeqOrder(exports.Credential, [exports.Secret])
|
|
24
|
+
.addLeqOrder(exports.Secret, [exports.FileContent])
|
|
25
|
+
.addLeqOrder(exports.FileContent, [exports.Response])
|
|
26
|
+
.addLeqOrder(exports.Response, lattice_1.Top)
|
|
27
|
+
.build();
|
|
28
|
+
/** Environment variable names that hold credentials */
|
|
29
|
+
exports.CredentialNamePattern = /key|token|secret|pass(?:word)?|pwd|cred|auth|private/i;
|
|
30
|
+
/** Files that hold credentials */
|
|
31
|
+
exports.CredentialFilePattern = /(?:^|[\\/])(?:\.Renviron|[._]netrc|\.pgpass|\.git-credentials|credentials(?:\.\w+)?)$/i;
|
|
32
|
+
/** How far the content of files is trusted not to hold secrets: `none` (any file but trusted ones may hold secrets) or only `credential-files` */
|
|
33
|
+
var FileTrust;
|
|
34
|
+
(function (FileTrust) {
|
|
35
|
+
FileTrust["None"] = "none";
|
|
36
|
+
FileTrust["CredentialFiles"] = "credential-files";
|
|
37
|
+
})(FileTrust || (exports.FileTrust = FileTrust = {}));
|
|
38
|
+
/** Urls of endpoints that answer with a token */
|
|
39
|
+
exports.TokenUrlPattern = /oauth|token|\/auth(?:enticate)?\b|\blogin\b|grant_type/i;
|
|
40
|
+
/** Where a secret goes when it reaches a sink, `auth` being an authentication channel, the intended use */
|
|
41
|
+
var SecretSinkClass;
|
|
42
|
+
(function (SecretSinkClass) {
|
|
43
|
+
SecretSinkClass["Network"] = "network";
|
|
44
|
+
SecretSinkClass["Auth"] = "auth";
|
|
45
|
+
SecretSinkClass["Browser"] = "browser";
|
|
46
|
+
SecretSinkClass["Logs"] = "logs";
|
|
47
|
+
SecretSinkClass["Files"] = "files";
|
|
48
|
+
SecretSinkClass["Process"] = "process";
|
|
49
|
+
SecretSinkClass["Llm"] = "llm";
|
|
50
|
+
})(SecretSinkClass || (exports.SecretSinkClass = SecretSinkClass = {}));
|
|
51
|
+
const index = query_fn_props_1.BuiltInIndex.default();
|
|
52
|
+
/** the calls fetching from the network into a file, like `download.file` */
|
|
53
|
+
const downloads = new Set(index.withAll([built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.Reads, built_in_props_1.SemanticCallTag.Writes]).map(f => identifier_1.Identifier.toString(f)));
|
|
54
|
+
/** functions by package, as `pkg: f g; other: h`, with `$` for methods */
|
|
55
|
+
const fns = (spec) => spec.split(';').flatMap(group => {
|
|
56
|
+
const [pkg, names] = group.split(':').map(p => p.trim());
|
|
57
|
+
return pkg === '$' ? names.split(' ').map(n => identifier_1.Identifier.make(`$${n}`)) : identifier_1.Identifier.fromAll(pkg, names.split(' '));
|
|
58
|
+
});
|
|
59
|
+
const logLevels = 'trace debug info success warn error fatal'.split(' ');
|
|
60
|
+
exports.DefaultSecretSinks = [
|
|
61
|
+
{ class: SecretSinkClass.Network, fns: fns('httr: GET POST PUT PATCH DELETE HEAD'), destination: { pos: 0, name: 'url' }, returns: 'response' },
|
|
62
|
+
{ class: SecretSinkClass.Network, fns: fns('httr: VERB'), destination: { pos: 1, name: 'url' }, returns: 'response' },
|
|
63
|
+
{ class: SecretSinkClass.Network, fns: fns('httr2: request'), destination: { pos: 0, name: 'base_url' }, inUrl: true, returns: 'request' },
|
|
64
|
+
{ class: SecretSinkClass.Network, fns: fns('httr2: req_url req_url_query req_url_path req_url_path_append'), destination: { pos: 0, name: 'req' }, inUrl: true, returns: 'request' },
|
|
65
|
+
{ class: SecretSinkClass.Network, fns: fns('httr2: req_body_json req_body_form req_body_raw req_body_multipart req_body_file'), destination: { pos: 0, name: 'req' }, returns: 'request' },
|
|
66
|
+
{ class: SecretSinkClass.Network, fns: fns('curl: curl_fetch_memory curl_fetch_disk curl_fetch_stream curl curl_download; RCurl: getURL getURLContent postForm getForm'), destination: { pos: 0, name: 'url' }, inUrl: true, returns: 'response' },
|
|
67
|
+
{ class: SecretSinkClass.Network, fns: fns('utils: download.file; base: url'), destination: { pos: 0 }, inUrl: true },
|
|
68
|
+
{ class: SecretSinkClass.Network, fns: fns('base: socketConnection'), destination: { pos: 0, name: 'host' } },
|
|
69
|
+
{ class: SecretSinkClass.Auth, fns: fns('httr2: req_auth_bearer_token req_auth_basic req_headers req_oauth_client_credentials req_oauth_password req_oauth_refresh req_oauth_bearer_jwt req_oauth_auth_code req_auth_aws_v4'), destination: { pos: 0, name: 'req' } },
|
|
70
|
+
{ class: SecretSinkClass.Auth, fns: fns('DBI: dbConnect'), destination: { pos: -1, name: 'host' } },
|
|
71
|
+
{ class: SecretSinkClass.Auth, fns: fns('httr2: oauth_client; httr: oauth_app; curl: new_handle handle_setheaders handle_setopt') },
|
|
72
|
+
{ class: SecretSinkClass.Browser, fns: fns('shiny: renderPrint renderText renderUI renderTable renderDataTable HTML showNotification updateTextInput updateTextAreaInput textInput textAreaInput passwordInput; htmltools: HTML; DT: renderDT renderDataTable datatable; shinyjs: runjs html; $: sendCustomMessage sendInputMessage sendBinaryMessage') },
|
|
73
|
+
{ class: SecretSinkClass.Logs, fns: fns('base: cat'), file: { pos: -1, name: 'file' } },
|
|
74
|
+
{ class: SecretSinkClass.Logs, fns: fns('base: writeLines'), file: { pos: 1, name: 'con' } },
|
|
75
|
+
{ class: SecretSinkClass.Files, fns: fns('base: saveRDS save dput dump serialize; readr: write_rds'), serializes: true },
|
|
76
|
+
{ class: SecretSinkClass.Logs, fns: fns('utils: str'), serializes: true },
|
|
77
|
+
{ class: SecretSinkClass.Logs, fns: [
|
|
78
|
+
...index.with(built_in_props_1.SemanticCallTag.Prints),
|
|
79
|
+
...identifier_1.Identifier.fromAll('logger', logLevels.map(l => `log_${l}`)),
|
|
80
|
+
...identifier_1.Identifier.fromAll('futile.logger', logLevels.map(l => `flog.${l}`)),
|
|
81
|
+
...fns('base: stop packageStartupMessage; rlang: inform abort; cli: cli_alert cli_alert_info cli_alert_success cli_alert_warning cli_alert_danger cli_inform cli_warn cli_abort cli_text; clipr: write_clip')
|
|
82
|
+
] },
|
|
83
|
+
/* a download writes what it fetched rather than its arguments, which reach the network (a sink of their own) */
|
|
84
|
+
{ class: SecretSinkClass.Files, fns: [...index.withAll([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes]).filter(f => !downloads.has(identifier_1.Identifier.toString(f))), ...fns('utils: write.csv write.csv2 write.table; base: writeBin; DBI: dbWriteTable dbAppendTable; pins: pin_write; googlesheets4: sheet_write write_sheet sheet_append; aws.s3: s3saveRDS put_object')] },
|
|
85
|
+
{ class: SecretSinkClass.Process, fns: [...index.with(built_in_props_1.SemanticCallTag.Process), ...fns('utils: browseURL')] },
|
|
86
|
+
{ class: SecretSinkClass.Llm, fns: fns('ellmer: chat chat_openai chat_anthropic chat_claude chat_gemini chat_google_gemini chat_ollama chat_mistral chat_groq chat_azure_openai chat_bedrock; openai: create_chat_completion create_completion; $: chat stream chat_async stream_async chat_structured set_system_prompt') }
|
|
87
|
+
];
|
|
88
|
+
/** functions reading the body of a response */
|
|
89
|
+
const BodyReaders = fns('httr: content; httr2: resp_body_string resp_body_json resp_body_raw resp_body_html resp_body_xml');
|
|
90
|
+
/** functions sending a built request, returning the response */
|
|
91
|
+
const Performers = fns('httr2: req_perform req_perform_sequential req_perform_parallel req_perform_iterative');
|
|
92
|
+
const has = (taints, ...values) => taints.some(t => values.includes(t?.value));
|
|
93
|
+
const isSecret = (taints) => has(taints, exports.Secret, exports.Credential, exports.FileContent);
|
|
94
|
+
/** the first of `order` among the arguments, ignoring constants (Top) */
|
|
95
|
+
const strongest = (...order) => (_args, taints) => order.find(v => has(taints, v)) ?? lattice_1.Top;
|
|
96
|
+
const strongestSecret = strongest(exports.Secret, exports.Credential, exports.FileContent, exports.Response);
|
|
97
|
+
const strings = (value) => (Array.isArray(value) ? value : [value]).filter(v => typeof v === 'string');
|
|
98
|
+
/** the response to a request carrying a secret: a token endpoint answers with a new secret */
|
|
99
|
+
const responseTaint = ([url], taints) => !isSecret(taints) ? strongestSecret([], taints) : typeof url === 'string' && exports.TokenUrlPattern.test(url) ? exports.Secret : exports.Response;
|
|
100
|
+
/** a response is secret only from a token endpoint, the credentials it keeps are not part of its body */
|
|
101
|
+
const bodyTaint = strongest(exports.Secret, exports.FileContent);
|
|
102
|
+
/** The {@link secretAnalysis}, extended by the given options */
|
|
103
|
+
function createSecretAnalysis({ credentialNamePattern = exports.CredentialNamePattern, sources = [], declassifiers = [], sinks = exports.DefaultSecretSinks, fileTrust = FileTrust.None, secretFiles, trustedFiles } = {}) {
|
|
104
|
+
const fileTaint = ([path]) => {
|
|
105
|
+
const paths = strings(path);
|
|
106
|
+
if (paths.some(p => exports.CredentialFilePattern.test(p) || secretFiles?.test(p))) {
|
|
107
|
+
return exports.Secret;
|
|
108
|
+
}
|
|
109
|
+
return fileTrust === FileTrust.CredentialFiles || (paths.length > 0 && paths.every(p => trustedFiles?.test(p))) ? lattice_1.Top : exports.FileContent;
|
|
110
|
+
};
|
|
111
|
+
const credentialNameTaint = ([name]) => strings(name).length === 0 || strings(name).some(n => credentialNamePattern.test(n)) ? exports.Secret : lattice_1.Top;
|
|
112
|
+
const sinksOf = (keep) => sinks.filter(keep).flatMap(s => s.fns);
|
|
113
|
+
return taint_analysis_definition_1.TaintAnalysisDefinition.create('secret', exports.secretDomain)
|
|
114
|
+
.on(function_categories_1.TaintFnCategory.pureAlias)
|
|
115
|
+
.on(function_categories_1.TaintFnCategory.pureComputer, strongestSecret)
|
|
116
|
+
.on(function_categories_1.TaintFnCategory.pureShape, () => lattice_1.Top)
|
|
117
|
+
.from({
|
|
118
|
+
identifier: ['Sys.getenv', "base" /* PkgName.Base */],
|
|
119
|
+
condition: { argValues: [{ pos: 0, name: 'x' }], conditionFn: credentialNameTaint }
|
|
120
|
+
}, {
|
|
121
|
+
identifier: [
|
|
122
|
+
...fns('keyring: key_get key_get_raw; config: get; base: readRenviron; httr: oauth2.0_token oauth1.0_token oauth_service_token; gargle: token_fetch credentials_service_account credentials_user_oauth2 credentials_app_default'),
|
|
123
|
+
...fns('httr2: oauth_flow_auth_code oauth_flow_client_credentials oauth_flow_password oauth_flow_refresh oauth_flow_device oauth_flow_bearer_jwt oauth_flow_token_exchange oauth_token_cached'),
|
|
124
|
+
...fns('AzureAuth: get_azure_token; gh: gh_token; gitcreds: gitcreds_get; askpass: askpass; getPass: getPass; rstudioapi: askForPassword askForSecret'),
|
|
125
|
+
...sources
|
|
126
|
+
],
|
|
127
|
+
taint: exports.Secret
|
|
128
|
+
},
|
|
129
|
+
/* a call that also writes (a copy, an unpack, a download) moves the content and returns a status or paths */
|
|
130
|
+
...(0, builtin_index_bridge_1.argValueMappingFromBuiltInIndex)(built_in_props_1.FileInputProps, built_in_props_1.ArgProp.Resource, fileTaint, built_in_props_1.SemanticCallTag.Writes))
|
|
131
|
+
.through({
|
|
132
|
+
identifier: [
|
|
133
|
+
...fns('digest: digest sha1 hmac; openssl: sha1 sha256 sha512 md5 sha2; sodium: password_store hash sha256; base: nzchar is.na is.null nchar identical == != isTRUE isFALSE'),
|
|
134
|
+
...declassifiers
|
|
135
|
+
],
|
|
136
|
+
taint: lattice_1.Top
|
|
137
|
+
}, {
|
|
138
|
+
identifier: [...fns('base: $ [[ [ @'), ...BodyReaders],
|
|
139
|
+
condition: { argDefinition: [{ pos: 0 }], conditionFn: bodyTaint }
|
|
140
|
+
}, {
|
|
141
|
+
identifier: fns('base: enc2utf8 trimws unname rawToChar do.call; utils: URLencode; jsonlite: fromJSON parse_json toJSON base64_enc; base64enc: base64encode'),
|
|
142
|
+
condition: { argDefinition: [{ pos: 0 }], conditionFn: strongestSecret }
|
|
143
|
+
}, {
|
|
144
|
+
identifier: [...fns('httr: authenticate add_headers config'), ...sinksOf(s => s.class === SecretSinkClass.Auth)],
|
|
145
|
+
condition: { allArgs: true, conditionFn: (_args, taints) => isSecret(taints) ? exports.Credential : lattice_1.Top }
|
|
146
|
+
}, {
|
|
147
|
+
identifier: sinksOf(s => s.returns === 'request'),
|
|
148
|
+
condition: { allArgs: true, conditionFn: strongestSecret }
|
|
149
|
+
}, {
|
|
150
|
+
identifier: [...Performers, ...sinksOf(s => s.returns === 'response')],
|
|
151
|
+
condition: { argValues: [{ pos: 0, name: 'url' }], allArgs: true, conditionFn: responseTaint }
|
|
152
|
+
})
|
|
153
|
+
.to({
|
|
154
|
+
identifier: sinksOf(s => s.serializes === true),
|
|
155
|
+
condition: { allArgs: true, conditionFn: (_args, taints) => has(taints, exports.Secret, exports.Credential, exports.FileContent, exports.Response) ? lattice_1.Bottom : undefined }
|
|
156
|
+
}, {
|
|
157
|
+
identifier: sinksOf(s => s.class !== SecretSinkClass.Auth && s.class !== SecretSinkClass.Network && !s.serializes),
|
|
158
|
+
condition: { allArgs: true, conditionFn: (_args, taints) => isSecret(taints) ? lattice_1.Bottom : undefined }
|
|
159
|
+
})
|
|
160
|
+
.report(f => `A secret reaches '${f.functionName ?? f.lexeme}', where it leaves the process [${f.locString}]`);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Tracks secrets (environment, keyrings, config, credential files, tokens, password prompts) to where they leave the process.
|
|
164
|
+
* By default, the content of any file may hold secrets ({@link FileContent}), see {@link FileTrust}.
|
|
165
|
+
* Hashes and presence checks declassify them, authentication channels make them a {@link Credential}, and requests carrying
|
|
166
|
+
* them return a {@link Response}, or a new secret from a token endpoint.
|
|
167
|
+
* Network calls are no findings here, as whether sending a secret leaks it depends on the destination (see `secret-exfiltration`).
|
|
168
|
+
*/
|
|
169
|
+
exports.secretAnalysis = createSecretAnalysis();
|
|
170
|
+
//# sourceMappingURL=secret-analysis.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Bottom, Top } from '../../abstract-interpretation/domains/lattice';
|
|
2
|
+
import { TaintAnalysisDefinition } from '../builder/taint-analysis-definition';
|
|
3
|
+
export declare const UserInput: unique symbol;
|
|
4
|
+
export declare const NetworkInput: unique symbol;
|
|
5
|
+
export declare const FileInput: unique symbol;
|
|
6
|
+
export declare const securityDomain: import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof UserInput, typeof NetworkInput, typeof FileInput]>;
|
|
7
|
+
export declare const securityAnalysis: TaintAnalysisDefinition<"security", import("../finite-domain").FiniteDomain<typeof Top, typeof Bottom, [typeof Top, typeof Bottom, typeof UserInput, typeof NetworkInput, typeof FileInput]>, import("../../abstract-interpretation/absint-inference").AbsintVisitorConfiguration>;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.securityAnalysis = exports.securityDomain = exports.FileInput = exports.NetworkInput = exports.UserInput = void 0;
|
|
4
|
+
const lattice_1 = require("../../abstract-interpretation/domains/lattice");
|
|
5
|
+
const abstract_domain_1 = require("../../abstract-interpretation/domains/abstract-domain");
|
|
6
|
+
const taint_analysis_definition_1 = require("../builder/taint-analysis-definition");
|
|
7
|
+
const domain_1 = require("../builder/domain");
|
|
8
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
9
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
10
|
+
const builtin_index_bridge_1 = require("../builtin-index-bridge");
|
|
11
|
+
const function_categories_1 = require("../function-categories");
|
|
12
|
+
exports.UserInput = Symbol('User Input');
|
|
13
|
+
exports.NetworkInput = Symbol('Network Input');
|
|
14
|
+
exports.FileInput = Symbol('File Input');
|
|
15
|
+
exports.securityDomain = new domain_1.FiniteDomainBuilder()
|
|
16
|
+
.addLeqOrder(lattice_1.Bottom, [exports.UserInput, exports.NetworkInput, exports.FileInput])
|
|
17
|
+
.addLeqOrder(exports.UserInput, lattice_1.Top)
|
|
18
|
+
.addLeqOrder(exports.NetworkInput, lattice_1.Top)
|
|
19
|
+
.addLeqOrder(exports.FileInput, lattice_1.Top)
|
|
20
|
+
.build();
|
|
21
|
+
/** Matches network protocols in a path argument. */
|
|
22
|
+
const NetworkProtocolRegex = /^(https?|ftps?):\/\//;
|
|
23
|
+
/** Maps a resolved path argument to a network or file taint depending on its protocol. */
|
|
24
|
+
const protocolTaint = ([path]) => typeof path === 'string' && NetworkProtocolRegex.test(path) ? exports.NetworkInput : exports.FileInput;
|
|
25
|
+
/** Tainted input on any argument leads to Bottom taint at sinks */
|
|
26
|
+
const securitySinkCondition = (_args, taints) => taints.some(taint => taint.value === exports.UserInput || taint.value === exports.NetworkInput || taint.value === exports.FileInput) ? lattice_1.Bottom
|
|
27
|
+
: taints.length > 0 ? abstract_domain_1.AbstractDomain.joinAll(taints).value : lattice_1.Top;
|
|
28
|
+
exports.securityAnalysis = taint_analysis_definition_1.TaintAnalysisDefinition.create('security', exports.securityDomain)
|
|
29
|
+
.on(function_categories_1.TaintFnCategory.pureAlias)
|
|
30
|
+
.on(function_categories_1.TaintFnCategory.pureComputer)
|
|
31
|
+
.on(function_categories_1.TaintFnCategory.pureShape)
|
|
32
|
+
.from({
|
|
33
|
+
identifier: [...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.User, [built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.File])],
|
|
34
|
+
taint: exports.UserInput
|
|
35
|
+
}, {
|
|
36
|
+
identifier: [...query_fn_props_1.BuiltInIndex.default().with(built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.User)],
|
|
37
|
+
taint: exports.NetworkInput,
|
|
38
|
+
}, ...(0, builtin_index_bridge_1.argValueMappingFromBuiltInIndex)(built_in_props_1.FileInputProps, built_in_props_1.ArgProp.Resource, protocolTaint, built_in_props_1.SemanticCallTag.User), {
|
|
39
|
+
identifier: ['gzcon', "base" /* PkgName.Base */],
|
|
40
|
+
condition: { argValues: [{ pos: 0, name: 'con' }], conditionFn: protocolTaint }
|
|
41
|
+
})
|
|
42
|
+
.through({
|
|
43
|
+
identifier: ['shQuote', "base" /* PkgName.Base */],
|
|
44
|
+
taint: lattice_1.Top
|
|
45
|
+
}, {
|
|
46
|
+
identifier: [['match.arg', "base" /* PkgName.Base */], ['make.names', "base" /* PkgName.Base */]],
|
|
47
|
+
taint: lattice_1.Top
|
|
48
|
+
}, {
|
|
49
|
+
// additional common functions
|
|
50
|
+
identifier: [
|
|
51
|
+
['rep', "base" /* PkgName.Base */],
|
|
52
|
+
['which', "base" /* PkgName.Base */]
|
|
53
|
+
],
|
|
54
|
+
condition: {
|
|
55
|
+
argDefinition: [{ pos: 0, name: 'x' }],
|
|
56
|
+
conditionFn: (_args, [taint]) => taint.value
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
.to({
|
|
60
|
+
identifier: [
|
|
61
|
+
['source', "base" /* PkgName.Base */],
|
|
62
|
+
['sys.source', "base" /* PkgName.Base */],
|
|
63
|
+
['parse', "base" /* PkgName.Base */]
|
|
64
|
+
],
|
|
65
|
+
condition: {
|
|
66
|
+
argDefinition: [{ pos: 0, name: 'file' }],
|
|
67
|
+
conditionFn: securitySinkCondition
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
70
|
+
identifier: ['unserialize', "base" /* PkgName.Base */],
|
|
71
|
+
condition: {
|
|
72
|
+
argDefinition: [{ pos: 0, name: 'connection' }],
|
|
73
|
+
conditionFn: securitySinkCondition
|
|
74
|
+
}
|
|
75
|
+
}, {
|
|
76
|
+
identifier: ['serialize', "base" /* PkgName.Base */],
|
|
77
|
+
condition: {
|
|
78
|
+
argDefinition: [{ pos: 0, name: 'object' }, { pos: 1, name: 'connection' }],
|
|
79
|
+
conditionFn: securitySinkCondition
|
|
80
|
+
}
|
|
81
|
+
}, {
|
|
82
|
+
identifier: ['dump', "base" /* PkgName.Base */],
|
|
83
|
+
condition: {
|
|
84
|
+
argDefinition: [{ pos: 0, name: 'list' }, { pos: 1, name: 'file' }],
|
|
85
|
+
conditionFn: securitySinkCondition
|
|
86
|
+
}
|
|
87
|
+
}, ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)([built_in_props_1.SemanticCallTag.Eval, built_in_props_1.SemanticCallTag.Process], built_in_props_1.ArgProp.Injectable, securitySinkCondition), ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)(built_in_props_1.CallProp.Ffi, built_in_props_1.ArgProp.Resource, securitySinkCondition), ...(0, builtin_index_bridge_1.taintMappingFromBuiltInIndex)([built_in_props_1.SemanticCallTag.Writes, built_in_props_1.SemanticCallTag.Opens, built_in_props_1.SemanticCallTag.Reads], built_in_props_1.ArgProp.Resource, securitySinkCondition)).report((f) => {
|
|
88
|
+
return f.functionName ? `Untrusted input reached security-sensitive sink function '${f.functionName}' [${f.locString}]`
|
|
89
|
+
: `Untrusted input reached a security-sensitive sink (possible code or command injection) [${f.locString}]`;
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=security-analysis.js.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { AbstractDomain, AbstractValue, AnyAbstractDomain } from '../abstract-interpretation/domains/abstract-domain';
|
|
2
|
+
import type { FunctionParameterLocation } from '../abstract-interpretation/data-frame/arguments';
|
|
3
|
+
import type { ArgProps, FnSig } from '../dataflow/environments/built-in-props';
|
|
4
|
+
import { Identifier } from '../dataflow/environments/identifier';
|
|
5
|
+
export declare class TaintMapper<Domain extends AnyAbstractDomain> {
|
|
6
|
+
readonly mapper: TaintMappingInternal<Domain>[];
|
|
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
|
+
private readonly byName;
|
|
9
|
+
constructor(mapper?: readonly TaintMappingInternal<Domain>[]);
|
|
10
|
+
private add;
|
|
11
|
+
/**
|
|
12
|
+
* Add one or more taint mapping rules to the mapper
|
|
13
|
+
*/
|
|
14
|
+
pushMapping(mappings: TaintMapping<Domain>[]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Add one or more taint mapping rules to the mapper.
|
|
17
|
+
* If a mapping for the same function call and {@link TaintRole} already exists, it is skipped.
|
|
18
|
+
*/
|
|
19
|
+
pushMappingIfNotExists(rules: TaintMapping<Domain>[]): void;
|
|
20
|
+
/**
|
|
21
|
+
* Get all mappings belonging to the given identifier
|
|
22
|
+
*/
|
|
23
|
+
getMappings(identifier: Identifier): TaintMappingInternal<Domain>[];
|
|
24
|
+
/** Whether a mapped identifier applies to a call of `called`, which matches any namespace when it names none */
|
|
25
|
+
static matches(this: void, mapped: Identifier, called: Identifier): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Create a new, independent mapper containing the same taint mappings
|
|
28
|
+
*/
|
|
29
|
+
clone(): TaintMapper<Domain>;
|
|
30
|
+
private hasMappingForRole;
|
|
31
|
+
private mapRulesToInternal;
|
|
32
|
+
private mapRuleToInternal;
|
|
33
|
+
}
|
|
34
|
+
export declare enum TaintRole {
|
|
35
|
+
Source = "Source",
|
|
36
|
+
Transformer = "Transformer",
|
|
37
|
+
Sink = "Sink"
|
|
38
|
+
}
|
|
39
|
+
type TaintMappingBase = {
|
|
40
|
+
readonly role?: TaintRole;
|
|
41
|
+
readonly category?: string;
|
|
42
|
+
readonly identifier: Identifier | Identifier[];
|
|
43
|
+
};
|
|
44
|
+
/** A mapping that assigns a fixed taint to a matched call. */
|
|
45
|
+
export type TaintFixedMapping<Domain extends AnyAbstractDomain> = TaintMappingBase & {
|
|
46
|
+
taint: AbstractValue<Domain>;
|
|
47
|
+
};
|
|
48
|
+
/** A mapping whose taint is computed from a {@link TaintCondition} over the call's argument values and taints. */
|
|
49
|
+
export type TaintConditionMapping<Domain extends AnyAbstractDomain> = TaintMappingBase & {
|
|
50
|
+
condition: TaintCondition<Domain>;
|
|
51
|
+
};
|
|
52
|
+
/** Mapping of incoming function arguments and taints to a resulting taint */
|
|
53
|
+
export type TaintCondition<Domain extends AnyAbstractDomain = AnyAbstractDomain> = {
|
|
54
|
+
argValues?: FunctionParameterLocation<unknown>[];
|
|
55
|
+
argDefinition?: TaintParameterLocation[];
|
|
56
|
+
argSignature?: {
|
|
57
|
+
sig: FnSig;
|
|
58
|
+
props: ArgProps;
|
|
59
|
+
};
|
|
60
|
+
/** additionally consider the taints of every argument of the call */
|
|
61
|
+
allArgs?: boolean;
|
|
62
|
+
conditionFn: TaintConditionFunction<Domain>;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* A taint rule type used for the user-definition of taint analyses
|
|
66
|
+
* Allows for mapping of one or multiple identifiers for convenience and conciseness.
|
|
67
|
+
*/
|
|
68
|
+
export type TaintMapping<Domain extends AnyAbstractDomain> = TaintFixedMapping<Domain> | TaintConditionMapping<Domain>;
|
|
69
|
+
/**
|
|
70
|
+
* Internal representation of a taint rule.
|
|
71
|
+
* Each rule is mapped to a single identifier simplifying search and retrieval.
|
|
72
|
+
*/
|
|
73
|
+
type TaintMappingInternal<Domain extends AnyAbstractDomain> = {
|
|
74
|
+
readonly role?: TaintRole;
|
|
75
|
+
readonly category?: string;
|
|
76
|
+
readonly identifier: Identifier;
|
|
77
|
+
} & ({
|
|
78
|
+
taint: AbstractValue<Domain>;
|
|
79
|
+
} | {
|
|
80
|
+
condition: TaintCondition<Domain>;
|
|
81
|
+
});
|
|
82
|
+
export type TaintConditionDomain<Domain extends AnyAbstractDomain> = Domain extends AbstractDomain<infer Value, infer Top, infer Bot> ? AbstractDomain<Value, Top, Bot> : never;
|
|
83
|
+
/** Function describing how the resulting taint is calculated from incoming arguments and taints */
|
|
84
|
+
export type TaintConditionFunction<Domain extends AnyAbstractDomain> = (args: unknown[], taints: TaintConditionDomain<Domain>[]) => AbstractValue<Domain> | undefined;
|
|
85
|
+
export interface TaintParameterLocation {
|
|
86
|
+
pos: number;
|
|
87
|
+
name?: string;
|
|
88
|
+
}
|
|
89
|
+
export {};
|