@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
|
@@ -15,6 +15,8 @@ const OutputRedirects = [
|
|
|
15
15
|
const WriteFunctionsWithMore = [
|
|
16
16
|
{ package: 'base', name: 'save.image', argIdx: 0, argName: 'file', resolveValue: true, defaultValue: '.RData' },
|
|
17
17
|
{ package: 'utils', name: 'write.csv', argIdx: 1, argName: 'file', resolveValue: true },
|
|
18
|
+
/* the write happens in the `GET` it configures, which the dataflow cannot tell, so only this category knows it */
|
|
19
|
+
{ package: 'httr', name: 'write_disk', argIdx: 0, argName: 'path', resolveValue: true },
|
|
18
20
|
/* without a `plot`, it saves `last_plot()` */
|
|
19
21
|
{ package: 'ggplot2', name: 'ggsave', argIdx: 0, argName: 'filename', resolveValue: true, linkTo: [default_builtin_config_1.LinkToLastGgPlot] },
|
|
20
22
|
{
|
|
@@ -53,6 +55,13 @@ const WriteFunctionsWithMore = [
|
|
|
53
55
|
{ package: 'base', name: 'file.symlink', argIdx: 1, argName: 'to', resolveValue: true },
|
|
54
56
|
{ package: 'base', name: 'file.link', argIdx: 1, argName: 'to', resolveValue: true },
|
|
55
57
|
{ package: 'utils', name: 'download.file', argIdx: 1, argName: 'destfile', resolveValue: true },
|
|
58
|
+
/* an archive unpacks into the working directory unless told otherwise */
|
|
59
|
+
{ package: 'utils', name: 'unzip', argIdx: 5, argName: 'exdir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
60
|
+
{ package: 'utils', name: 'untar', argIdx: 3, argName: 'exdir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
61
|
+
{ package: 'zip', name: 'unzip', argIdx: 4, argName: 'exdir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
62
|
+
{ package: 'archive', name: 'archive_extract', argIdx: 1, argName: 'dir', resolveValue: true, defaultValue: '.', invisible: true },
|
|
63
|
+
/* the name the file has with the extension added or dropped, `Unknown` of the query format, which imports this module */
|
|
64
|
+
...['gzip', 'gunzip', 'bzip2', 'bunzip2', 'compressFile', 'decompressFile'].map(name => ({ package: 'R.utils', name, argIdx: 1, argName: 'destname', resolveValue: true, defaultValue: 'unknown', invisible: true })),
|
|
56
65
|
{ package: 'base', name: 'file', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
57
66
|
{ package: 'base', name: 'url', argIdx: 0, argName: 'description', resolveValue: true, ignoreIf: 'mode-only-read', additionalArgs: { mode: { argIdx: 1, argName: 'open', resolveValue: true } } },
|
|
58
67
|
{ package: 'grDevices', name: 'jpeg', argIdx: 0, argName: 'filename', resolveValue: true },
|
|
@@ -97,8 +106,9 @@ const WriteFunctionsWithMore = [
|
|
|
97
106
|
];
|
|
98
107
|
/** The write entries the given built-in definitions imply, together with the ones written down here. */
|
|
99
108
|
function computeWriteFunctions(definitions, read = (0, read_functions_1.computeReadFunctions)(definitions)) {
|
|
109
|
+
const apart = (0, derived_functions_1.readingAndWritingApart)(read, definitions);
|
|
100
110
|
return [
|
|
101
|
-
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], [...WriteFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...read], definitions),
|
|
111
|
+
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Writes], [...WriteFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...read.filter(f => !apart.has(f))], definitions),
|
|
102
112
|
...WriteFunctionsWithMore
|
|
103
113
|
];
|
|
104
114
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BasicQueryData } from '../../base-query-format';
|
|
2
|
+
import type { TaintQuery, TaintQueryResult } from './taint-query-format';
|
|
3
|
+
import type { AllPredefinedTaintAnalysisNames } from '../../../taint-analysis/predefined/predefined';
|
|
4
|
+
/**
|
|
5
|
+
* Executes the given taint queries using the provided analyzer.
|
|
6
|
+
*/
|
|
7
|
+
export declare function executeTaintQuery({ analyzer }: BasicQueryData, queries: readonly TaintQuery[]): Promise<TaintQueryResult<AllPredefinedTaintAnalysisNames>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeTaintQuery = executeTaintQuery;
|
|
4
|
+
const log_1 = require("../../../util/log");
|
|
5
|
+
/**
|
|
6
|
+
* Executes the given taint queries using the provided analyzer.
|
|
7
|
+
*/
|
|
8
|
+
async function executeTaintQuery({ analyzer }, queries) {
|
|
9
|
+
const flattened = queries.flatMap(q => q.defs);
|
|
10
|
+
const start = Date.now();
|
|
11
|
+
if (flattened.length === 0) {
|
|
12
|
+
log_1.log.warn('Missing taint query definition');
|
|
13
|
+
return {
|
|
14
|
+
results: new Map(),
|
|
15
|
+
'.meta': {
|
|
16
|
+
timing: Date.now() - start
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const analysis = analyzer
|
|
21
|
+
.taint()
|
|
22
|
+
.addPredefined(...flattened);
|
|
23
|
+
return {
|
|
24
|
+
results: await analysis.run(),
|
|
25
|
+
'.meta': {
|
|
26
|
+
timing: Date.now() - start
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=taint-query-executor.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BaseQueryFormat, BaseQueryResult } from '../../base-query-format';
|
|
2
|
+
import type { ReplOutput } from '../../../cli/repl/commands/repl-main';
|
|
3
|
+
import type { FlowrConfig } from '../../../config';
|
|
4
|
+
import type { ParsedQueryLine } from '../../query';
|
|
5
|
+
import Joi from 'joi';
|
|
6
|
+
import { executeTaintQuery } from './taint-query-executor';
|
|
7
|
+
import type { AnyPredefinedTaintAnalysisName } from '../../../taint-analysis/predefined/predefined';
|
|
8
|
+
import type { CommandCompletions } from '../../../cli/repl/core';
|
|
9
|
+
import type { TaintInferenceResult } from '../../../taint-analysis/builder/taint-analysis';
|
|
10
|
+
export interface TaintQuery extends BaseQueryFormat {
|
|
11
|
+
readonly type: 'taint';
|
|
12
|
+
readonly defs: AnyPredefinedTaintAnalysisName[];
|
|
13
|
+
}
|
|
14
|
+
export interface TaintQueryResult<Analyses extends string[]> extends BaseQueryResult {
|
|
15
|
+
readonly results: Map<Analyses[number], TaintInferenceResult>;
|
|
16
|
+
}
|
|
17
|
+
declare function taintQueryCompleter(line: readonly string[], startingNewArg: boolean, _config: FlowrConfig): CommandCompletions;
|
|
18
|
+
declare function taintQueryLineParser(output: ReplOutput, line: readonly string[], _config: FlowrConfig): ParsedQueryLine<'taint'>;
|
|
19
|
+
export declare const TaintQueryDefinition: {
|
|
20
|
+
readonly title: "Taint Analysis Query";
|
|
21
|
+
readonly executor: typeof executeTaintQuery;
|
|
22
|
+
readonly asciiSummarizer: (formatter: import("../../../util/text/ansi").OutputFormatter, _analyzer: import("../../..").ReadonlyFlowrAnalysisProvider<import("../../..").KnownParser>, queryResults: BaseQueryResult, resultStrings: string[]) => true;
|
|
23
|
+
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
24
|
+
readonly completer: typeof taintQueryCompleter;
|
|
25
|
+
readonly fromLine: typeof taintQueryLineParser;
|
|
26
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
27
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.TaintQueryDefinition = void 0;
|
|
7
|
+
const joi_1 = __importDefault(require("joi"));
|
|
8
|
+
const taint_query_executor_1 = require("./taint-query-executor");
|
|
9
|
+
const predefined_1 = require("../../../taint-analysis/predefined/predefined");
|
|
10
|
+
const lattice_1 = require("../../../abstract-interpretation/domains/lattice");
|
|
11
|
+
const ansi_1 = require("../../../util/text/ansi");
|
|
12
|
+
const time_1 = require("../../../util/text/time");
|
|
13
|
+
const retriever_1 = require("../../../r-bridge/retriever");
|
|
14
|
+
const prefix = 'definitions:';
|
|
15
|
+
function taintQueryCompleter(line, startingNewArg, _config) {
|
|
16
|
+
const prefixNotPresent = line.length == 0 || (line.length == 1 && line[0].length < prefix.length);
|
|
17
|
+
const notFinished = line.length == 1 && line[0].startsWith(prefix) && !startingNewArg;
|
|
18
|
+
const endOfOptions = line.length == 1 && startingNewArg || line.length == 2;
|
|
19
|
+
if (prefixNotPresent) {
|
|
20
|
+
return { completions: [`${prefix}`] };
|
|
21
|
+
}
|
|
22
|
+
else if (endOfOptions) {
|
|
23
|
+
return { completions: [retriever_1.fileProtocol] };
|
|
24
|
+
}
|
|
25
|
+
else if (notFinished) {
|
|
26
|
+
const withoutPrefix = line[0].slice(prefix.length);
|
|
27
|
+
const used = withoutPrefix.split(',').map(r => r.trim());
|
|
28
|
+
const all = Object.keys(predefined_1.predefinedTaintAnalyses);
|
|
29
|
+
const unused = all.filter(r => !used.includes(r));
|
|
30
|
+
const last = used[used.length - 1];
|
|
31
|
+
const lastUnfinished = !all.includes(last);
|
|
32
|
+
if (lastUnfinished) {
|
|
33
|
+
// Return all strings that have not been added yet
|
|
34
|
+
return { completions: unused, argumentPart: last };
|
|
35
|
+
}
|
|
36
|
+
else if (unused.length > 0) {
|
|
37
|
+
// Add a comma, if the current last string is complete
|
|
38
|
+
return { completions: [','], argumentPart: '' };
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
// All strings are used, complete with a space
|
|
42
|
+
return { completions: [' '], argumentPart: '' };
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { completions: [] };
|
|
46
|
+
}
|
|
47
|
+
function defsInInput(defsPart) {
|
|
48
|
+
return defsPart
|
|
49
|
+
.reduce((acc, name) => {
|
|
50
|
+
name = name.trim();
|
|
51
|
+
if (name in predefined_1.predefinedTaintAnalyses) {
|
|
52
|
+
acc.valid.push(name);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
acc.invalid.push(name);
|
|
56
|
+
}
|
|
57
|
+
return acc;
|
|
58
|
+
}, { valid: [], invalid: [] });
|
|
59
|
+
}
|
|
60
|
+
function taintQueryLineParser(output, line, _config) {
|
|
61
|
+
let defs = [];
|
|
62
|
+
let input = undefined;
|
|
63
|
+
if (line.length > 0 && line[0].startsWith(prefix)) {
|
|
64
|
+
const defsPart = line[0].slice(prefix.length).split(',');
|
|
65
|
+
const parseResult = defsInInput(defsPart);
|
|
66
|
+
if (parseResult.invalid.length > 0) {
|
|
67
|
+
output.stderr(`Unknown taint definition names: ${parseResult.invalid.map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`
|
|
68
|
+
+ `\nKnown taint definitions are: ${Object.keys(predefined_1.predefinedTaintAnalyses).map(r => (0, ansi_1.bold)(r, output.formatter)).join(', ')}`);
|
|
69
|
+
}
|
|
70
|
+
defs = parseResult.valid;
|
|
71
|
+
input = line[1];
|
|
72
|
+
}
|
|
73
|
+
else if (line.length > 0) {
|
|
74
|
+
input = line[0];
|
|
75
|
+
}
|
|
76
|
+
return { query: [{ type: 'taint', defs: defs }], rCode: input };
|
|
77
|
+
}
|
|
78
|
+
exports.TaintQueryDefinition = {
|
|
79
|
+
title: 'Taint Analysis Query',
|
|
80
|
+
executor: taint_query_executor_1.executeTaintQuery,
|
|
81
|
+
asciiSummarizer: (formatter, _analyzer, queryResults, resultStrings) => {
|
|
82
|
+
const out = queryResults;
|
|
83
|
+
const state = out.results.entries().toArray();
|
|
84
|
+
resultStrings.push(`Query: ${(0, ansi_1.bold)('taint', formatter)} (${(0, time_1.printAsMs)(out['.meta'].timing, 0)})`);
|
|
85
|
+
for (const [name, result] of state) {
|
|
86
|
+
resultStrings.push(` ╰ **${name}**:`);
|
|
87
|
+
const lift = result.domains.value;
|
|
88
|
+
if (result.findings.length > 0) {
|
|
89
|
+
if (result.msg !== undefined) {
|
|
90
|
+
resultStrings.push(` ╰ ${result.msg}:`);
|
|
91
|
+
}
|
|
92
|
+
resultStrings.push(...result.findings.map(finding => ` ╰ ${finding.msg !== undefined ? `${finding.msg} ` : ''}`));
|
|
93
|
+
}
|
|
94
|
+
if (lift === lattice_1.Bottom) {
|
|
95
|
+
resultStrings.push(` ╰ state: ${lattice_1.BottomSymbol}`);
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
resultStrings.push(...lift.entries().take(20)
|
|
99
|
+
.map(([key, domain]) => ` ╰ ${key}: ${domain?.toString()}`));
|
|
100
|
+
if (resultStrings.length > 20) {
|
|
101
|
+
resultStrings.push(' ╰ ... (see JSON)');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return true;
|
|
105
|
+
},
|
|
106
|
+
jsonFormatter: (queryResults) => {
|
|
107
|
+
const { results, ...out } = queryResults;
|
|
108
|
+
const json = new Map(Array.from(results, ([name, { domains, msg, findings }]) => [name, {
|
|
109
|
+
domains: domains.value === lattice_1.Bottom ? domains.value.description : Object.fromEntries(domains.value.entries().map(([key, domain]) => [key, domain?.toJSON() ?? null])),
|
|
110
|
+
msg,
|
|
111
|
+
findings,
|
|
112
|
+
}]));
|
|
113
|
+
const result = { results: json, ...out };
|
|
114
|
+
return result;
|
|
115
|
+
},
|
|
116
|
+
completer: taintQueryCompleter,
|
|
117
|
+
fromLine: taintQueryLineParser,
|
|
118
|
+
schema: joi_1.default.object({
|
|
119
|
+
type: joi_1.default.string().valid('taint').required().description('The type of the query.'),
|
|
120
|
+
defs: joi_1.default.array().description('The taint analyses to run.')
|
|
121
|
+
}).description('The taint query conducts taint analyses and returns their results.'),
|
|
122
|
+
flattenInvolvedNodes: () => []
|
|
123
|
+
};
|
|
124
|
+
//# sourceMappingURL=taint-query-format.js.map
|
package/queries/query.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ import type { DoesCallQuery } from './catalog/does-call-query/does-call-query-fo
|
|
|
36
36
|
import type { InspectExceptionQuery } from './catalog/inspect-exceptions-query/inspect-exception-query-format';
|
|
37
37
|
import type { InputSourcesQuery } from './catalog/input-sources-query/input-sources-query-format';
|
|
38
38
|
import type { ProvenanceQuery } from './catalog/provenance-query/provenance-query-format';
|
|
39
|
+
import type { TaintQuery } from './catalog/taint-query/taint-query-format';
|
|
39
40
|
import type { LintingResult, LintingResultCertainty } from '../linter/linter-format';
|
|
40
41
|
import { type DiceQuery } from './catalog/dice-query/dice-query-format';
|
|
41
42
|
import { type GuessDepVersionsQuery } from './catalog/guess-dep-versions-query/guess-dep-versions-query-format';
|
|
@@ -44,7 +45,7 @@ import { type FunctionInfoQuery } from './catalog/function-info-query/function-i
|
|
|
44
45
|
/**
|
|
45
46
|
* These are all queries that can be executed from within flowR
|
|
46
47
|
*/
|
|
47
|
-
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | InspectFnPropsQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | DiceQuery | GuessDepVersionsQuery | FunctionInfoQuery;
|
|
48
|
+
export type Query = CallContextQuery | ConfigQuery | SearchQuery | DataflowQuery | DoesCallQuery | CallGraphQuery | ControlFlowQuery | DataflowLensQuery | FilesQuery | AbsintQuery | NormalizedAstQuery | IdMapQuery | DataflowClusterQuery | StaticSliceQuery | DependenciesQuery | LocationMapQuery | HappensBeforeQuery | InspectExceptionQuery | InspectHigherOrderQuery | InspectRecursionQuery | InspectFnPropsQuery | ResolveValueQuery | ProjectQuery | SignatureQuery | OriginQuery | LinterQuery | ProvenanceQuery | InputSourcesQuery | TaintQuery | DiceQuery | GuessDepVersionsQuery | FunctionInfoQuery;
|
|
48
49
|
export type QueryArgumentsWithType<QueryType extends BaseQueryFormat['type']> = Query & {
|
|
49
50
|
type: QueryType;
|
|
50
51
|
};
|
|
@@ -145,6 +146,16 @@ export declare const SupportedQueries: {
|
|
|
145
146
|
readonly schema: Joi.ObjectSchema<any>;
|
|
146
147
|
readonly flattenInvolvedNodes: (queryResults: BaseQueryResult) => NodeId[];
|
|
147
148
|
};
|
|
149
|
+
readonly taint: {
|
|
150
|
+
readonly title: "Taint Analysis Query";
|
|
151
|
+
readonly executor: typeof import("./catalog/taint-query/taint-query-executor").executeTaintQuery;
|
|
152
|
+
readonly asciiSummarizer: (formatter: OutputFormatter, _analyzer: ReadonlyFlowrAnalysisProvider<import("..").KnownParser>, queryResults: BaseQueryResult, resultStrings: string[]) => true;
|
|
153
|
+
readonly jsonFormatter: (queryResults: BaseQueryResult) => object;
|
|
154
|
+
readonly completer: (line: readonly string[], startingNewArg: boolean, _config: FlowrConfig) => CommandCompletions;
|
|
155
|
+
readonly fromLine: (output: ReplOutput, line: readonly string[], _config: FlowrConfig) => ParsedQueryLine<"taint">;
|
|
156
|
+
readonly schema: Joi.ObjectSchema<any>;
|
|
157
|
+
readonly flattenInvolvedNodes: () => never[];
|
|
158
|
+
};
|
|
148
159
|
readonly files: {
|
|
149
160
|
readonly title: "Files Query";
|
|
150
161
|
readonly executor: typeof import("./catalog/files-query/files-query-executor").executeFileQuery;
|
package/queries/query.js
CHANGED
|
@@ -46,6 +46,7 @@ const does_call_query_format_1 = require("./catalog/does-call-query/does-call-qu
|
|
|
46
46
|
const inspect_exception_query_format_1 = require("./catalog/inspect-exceptions-query/inspect-exception-query-format");
|
|
47
47
|
const input_sources_query_format_1 = require("./catalog/input-sources-query/input-sources-query-format");
|
|
48
48
|
const provenance_query_format_1 = require("./catalog/provenance-query/provenance-query-format");
|
|
49
|
+
const taint_query_format_1 = require("./catalog/taint-query/taint-query-format");
|
|
49
50
|
const dice_query_format_1 = require("./catalog/dice-query/dice-query-format");
|
|
50
51
|
const guess_dep_versions_query_format_1 = require("./catalog/guess-dep-versions-query/guess-dep-versions-query-format");
|
|
51
52
|
const absint_query_format_1 = require("./catalog/absint-query/absint-query-format");
|
|
@@ -59,6 +60,7 @@ exports.SupportedQueries = {
|
|
|
59
60
|
'does-call': does_call_query_format_1.DoesCallQueryDefinition,
|
|
60
61
|
'dataflow-lens': dataflow_lens_query_format_1.DataflowLensQueryDefinition,
|
|
61
62
|
'absint': absint_query_format_1.AbsintQueryDefinition,
|
|
63
|
+
'taint': taint_query_format_1.TaintQueryDefinition,
|
|
62
64
|
'files': files_query_format_1.FilesQueryDefinition,
|
|
63
65
|
'id-map': id_map_query_format_1.IdMapQueryDefinition,
|
|
64
66
|
'normalized-ast': normalized_ast_query_format_1.NormalizedAstQueryDefinition,
|
package/r-bridge/data/data.d.ts
CHANGED
|
@@ -1560,6 +1560,18 @@ export declare const flowrCapabilities: {
|
|
|
1560
1560
|
readonly name: "uvr";
|
|
1561
1561
|
readonly href: "https://github.com/nbafrank/uvr";
|
|
1562
1562
|
}];
|
|
1563
|
+
}, {
|
|
1564
|
+
readonly name: "rig";
|
|
1565
|
+
readonly id: "version-manager-rig";
|
|
1566
|
+
readonly supported: "fully";
|
|
1567
|
+
readonly description: "_Read the configuration of [rig](https://rig.r-lib.org/proj-guide.html) projects and scripts._ Parses `rproj.toml`, the inline `# /// script` block a script declares its dependencies in, and the resolved `rproj.lock` or `<script>.R.lock`.";
|
|
1568
|
+
readonly url: [{
|
|
1569
|
+
name: string;
|
|
1570
|
+
href: string;
|
|
1571
|
+
}, {
|
|
1572
|
+
readonly name: "rig";
|
|
1573
|
+
readonly href: "https://rig.r-lib.org/scripts.html";
|
|
1574
|
+
}];
|
|
1563
1575
|
}, {
|
|
1564
1576
|
readonly name: "Installed Library";
|
|
1565
1577
|
readonly id: "project-library";
|
|
@@ -1569,6 +1581,16 @@ export declare const flowrCapabilities: {
|
|
|
1569
1581
|
name: string;
|
|
1570
1582
|
href: string;
|
|
1571
1583
|
}];
|
|
1584
|
+
}, {
|
|
1585
|
+
readonly name: "On-Demand Package Sources";
|
|
1586
|
+
readonly id: "project-on-demand-sources";
|
|
1587
|
+
readonly supported: "partially";
|
|
1588
|
+
readonly description: "_Fetch the source of a package no signature database knows when the code uses it, from CRAN, Bioconductor, or GitHub (`solver.sigdb.onDemand`)._ The repository comes from an `install_github`-style call, the `Remotes` of the `DESCRIPTION`, or the configuration. The exports come from the `NAMESPACE` (an `exportPattern` matched against the names the code defines) and the formals from the functions the `R/` files define at the top level, cached per package so a later analysis works offline. A fetched package counts as untrusted: its code is parsed, never run, only `https` to public hosts (or the configured mirrors) is used, what it states is cut down to names, formals, and a version, and it cannot take over a function that matters to security (`system`, `eval`, file and network calls), so those keep being found. Only a trusted configuration can switch this on. Function bodies are not analyzed, and a package loaded under a name only known at run time is not fetched.";
|
|
1589
|
+
readonly example: string;
|
|
1590
|
+
readonly url: [{
|
|
1591
|
+
name: string;
|
|
1592
|
+
href: string;
|
|
1593
|
+
}];
|
|
1572
1594
|
}];
|
|
1573
1595
|
}, {
|
|
1574
1596
|
readonly name: "Startup and Discovery";
|
|
@@ -1648,6 +1670,13 @@ export declare const flowrCapabilities: {
|
|
|
1648
1670
|
name: string;
|
|
1649
1671
|
href: string;
|
|
1650
1672
|
}];
|
|
1673
|
+
}, {
|
|
1674
|
+
readonly name: "File Dependencies";
|
|
1675
|
+
readonly id: "file-dependencies";
|
|
1676
|
+
readonly code: readonly ["file.copy", "unzip", "untar", "zip", "archive::archive_extract", "R.utils::gunzip"];
|
|
1677
|
+
readonly supported: "partially";
|
|
1678
|
+
readonly description: "_A file read after a call that wrote it, also when the call copies, moves, packs, or unpacks it._ A read of a file links to the earlier writes of a file of the same name, and calls like `file.copy(from, to)` or `unzip(zipfile, exdir)` read the files of some arguments and write those of others, so `read.csv(\"data/b.csv\")` after `unzip(\"a.zip\", exdir = \"data\")` keeps the `unzip` and whatever wrote `a.zip`. What an archive holds is unknown, so unpacking one counts as writing any file, and a read of a file nothing named before reads every such write. Paths are compared by name, not against the working directory.";
|
|
1679
|
+
readonly example: string;
|
|
1651
1680
|
}, {
|
|
1652
1681
|
readonly name: "Foreign Function Interface";
|
|
1653
1682
|
readonly id: "foreign-function-interface";
|
package/r-bridge/data/data.js
CHANGED
|
@@ -1362,12 +1362,27 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
|
|
|
1362
1362
|
description: '_Read the configuration of [uvr](https://github.com/nbafrank/uvr), an R project manager modelled on uv._ Parses `uvr.toml` and the `uvr.lock` beside it.',
|
|
1363
1363
|
url: [Plugin('src/project/plugins/file-plugins/files/flowr-manifest-files.ts'), { name: 'uvr', href: 'https://github.com/nbafrank/uvr' }]
|
|
1364
1364
|
},
|
|
1365
|
+
{
|
|
1366
|
+
name: 'rig',
|
|
1367
|
+
id: 'version-manager-rig',
|
|
1368
|
+
supported: 'fully',
|
|
1369
|
+
description: '_Read the configuration of [rig](https://rig.r-lib.org/proj-guide.html) projects and scripts._ Parses `rproj.toml`, the inline `# /// script` block a script declares its dependencies in, and the resolved `rproj.lock` or `<script>.R.lock`.',
|
|
1370
|
+
url: [Plugin('src/project/plugins/file-plugins/files/flowr-manifest-files.ts'), { name: 'rig', href: 'https://rig.r-lib.org/scripts.html' }]
|
|
1371
|
+
},
|
|
1365
1372
|
{
|
|
1366
1373
|
name: 'Installed Library',
|
|
1367
1374
|
id: 'project-library',
|
|
1368
1375
|
supported: 'partially',
|
|
1369
1376
|
description: '_Read the package library a project installs into (`renv/library`, `packrat/lib`, or the platform library)._ Their code is not read.',
|
|
1370
1377
|
url: [Plugin('src/project/plugins/package-version-plugins/flowr-analyzer-package-versions-library-plugin.ts')]
|
|
1378
|
+
},
|
|
1379
|
+
{
|
|
1380
|
+
name: 'On-Demand Package Sources',
|
|
1381
|
+
id: 'project-on-demand-sources',
|
|
1382
|
+
supported: 'partially',
|
|
1383
|
+
description: '_Fetch the source of a package no signature database knows when the code uses it, from CRAN, Bioconductor, or GitHub (`solver.sigdb.onDemand`)._ The repository comes from an `install_github`-style call, the `Remotes` of the `DESCRIPTION`, or the configuration. The exports come from the `NAMESPACE` (an `exportPattern` matched against the names the code defines) and the formals from the functions the `R/` files define at the top level, cached per package so a later analysis works offline. A fetched package counts as untrusted: its code is parsed, never run, only `https` to public hosts (or the configured mirrors) is used, what it states is cut down to names, formals, and a version, and it cannot take over a function that matters to security (`system`, `eval`, file and network calls), so those keep being found. Only a trusted configuration can switch this on. Function bodies are not analyzed, and a package loaded under a name only known at run time is not fetched.',
|
|
1384
|
+
example: (0, doc_code_1.codeBlock)('r', 'remotes::install_github("masurp/ggmirt")\nlibrary(ggmirt)\ntracePlot(fit, theta_range = c(-3, 3))'),
|
|
1385
|
+
url: [Plugin('src/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.ts')]
|
|
1371
1386
|
}
|
|
1372
1387
|
]
|
|
1373
1388
|
},
|
|
@@ -1446,6 +1461,14 @@ ${await (0, doc_dfg_1.printDfGraphForCode)(parser, code, { simplified: true, tim
|
|
|
1446
1461
|
example: (0, doc_code_1.codeBlock)('r', 'd <- read.csv("in.csv")\nwrite.csv(d, "out.csv")'),
|
|
1447
1462
|
url: [RLang('Operating system access')]
|
|
1448
1463
|
},
|
|
1464
|
+
{
|
|
1465
|
+
name: 'File Dependencies',
|
|
1466
|
+
id: 'file-dependencies',
|
|
1467
|
+
code: ['file.copy', 'unzip', 'untar', 'zip', 'archive::archive_extract', 'R.utils::gunzip'],
|
|
1468
|
+
supported: 'partially',
|
|
1469
|
+
description: '_A file read after a call that wrote it, also when the call copies, moves, packs, or unpacks it._ A read of a file links to the earlier writes of a file of the same name, and calls like `file.copy(from, to)` or `unzip(zipfile, exdir)` read the files of some arguments and write those of others, so `read.csv("data/b.csv")` after `unzip("a.zip", exdir = "data")` keeps the `unzip` and whatever wrote `a.zip`. What an archive holds is unknown, so unpacking one counts as writing any file, and a read of a file nothing named before reads every such write. Paths are compared by name, not against the working directory.',
|
|
1470
|
+
example: (0, doc_code_1.codeBlock)('r', 'download.file("https://example.org/a.zip", "a.zip")\nunzip("a.zip", exdir = "data")\nd <- read.csv("data/b.csv")')
|
|
1471
|
+
},
|
|
1449
1472
|
{
|
|
1450
1473
|
name: 'Foreign Function Interface',
|
|
1451
1474
|
id: 'foreign-function-interface',
|
|
@@ -29,6 +29,10 @@ export declare class TreeSitterExecutor implements SyncParser<Parser.Tree> {
|
|
|
29
29
|
parse(request: RParseRequest & {
|
|
30
30
|
filePath?: string;
|
|
31
31
|
}, ctx: FlowrAnalyzerContext): Parser.Tree;
|
|
32
|
+
/** Parses code that belongs to no analysis, like the sources of a package, without incremental reparsing. */
|
|
33
|
+
parseCode(code: string): Parser.Tree;
|
|
34
|
+
/** Whether {@link initTreeSitter} has loaded the R grammar, which every parser needs. */
|
|
35
|
+
static isInitialized(): boolean;
|
|
32
36
|
createQuery(source: string): Query;
|
|
33
37
|
query(source: Query | string, ...tree: readonly Parser.Tree[]): QueryCapture[];
|
|
34
38
|
close(): void;
|
|
@@ -98,6 +98,14 @@ class TreeSitterExecutor {
|
|
|
98
98
|
previousTree.edit(reparseInfo.editRegion);
|
|
99
99
|
return this.parser.parse(sourceCode, previousTree);
|
|
100
100
|
}
|
|
101
|
+
/** Parses code that belongs to no analysis, like the sources of a package, without incremental reparsing. */
|
|
102
|
+
parseCode(code) {
|
|
103
|
+
return this.parser.parse(code);
|
|
104
|
+
}
|
|
105
|
+
/** Whether {@link initTreeSitter} has loaded the R grammar, which every parser needs. */
|
|
106
|
+
static isInitialized() {
|
|
107
|
+
return TreeSitterExecutor.language !== undefined;
|
|
108
|
+
}
|
|
101
109
|
createQuery(source) {
|
|
102
110
|
return this.parser.getLanguage().query(source);
|
|
103
111
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { LatticeElements } from '../finite-domain';
|
|
2
|
+
import { FiniteDomain } from '../finite-domain';
|
|
3
|
+
export declare class FiniteDomainBuilder<Top extends symbol, Bottom extends symbol, Elements extends LatticeElements<Top, Bottom> = [Top, Bottom]> {
|
|
4
|
+
private readonly elements;
|
|
5
|
+
private readonly leqMap;
|
|
6
|
+
private _top;
|
|
7
|
+
private _bottom;
|
|
8
|
+
private addElements;
|
|
9
|
+
setTop(element: Top): this;
|
|
10
|
+
setBottom(element: Bottom): this;
|
|
11
|
+
addLeqOrder(from: Elements[number], to: Elements[number] | Elements[number][]): this;
|
|
12
|
+
private buildConfig;
|
|
13
|
+
build(initialElement?: Elements[number]): FiniteDomain<Top, Bottom, Elements>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FiniteDomainBuilder = void 0;
|
|
4
|
+
const lattice_1 = require("../../abstract-interpretation/domains/lattice");
|
|
5
|
+
const finite_domain_1 = require("../finite-domain");
|
|
6
|
+
const assert_1 = require("../../util/assert");
|
|
7
|
+
class FiniteDomainBuilder {
|
|
8
|
+
elements = new Set();
|
|
9
|
+
leqMap = new Map();
|
|
10
|
+
_top;
|
|
11
|
+
_bottom;
|
|
12
|
+
addElements(...elements) {
|
|
13
|
+
for (const element of elements) {
|
|
14
|
+
if (!this.elements.has(element)) {
|
|
15
|
+
this.elements.add(element);
|
|
16
|
+
}
|
|
17
|
+
if (!this.leqMap.has(element)) {
|
|
18
|
+
this.leqMap.set(element, new Set());
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
setTop(element) {
|
|
23
|
+
this._top = element;
|
|
24
|
+
this.addElements(element);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
setBottom(element) {
|
|
28
|
+
this._bottom = element;
|
|
29
|
+
this.addElements(element);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
addLeqOrder(from, to) {
|
|
33
|
+
this.addElements(from, ...(Array.isArray(to) ? to : [to]));
|
|
34
|
+
if (!this.elements.has(from)) {
|
|
35
|
+
throw new Error(`Source element not registered: ${String(from)}`);
|
|
36
|
+
}
|
|
37
|
+
if (!Array.isArray(to)) {
|
|
38
|
+
to = [to];
|
|
39
|
+
}
|
|
40
|
+
const successors = this.leqMap.get(from);
|
|
41
|
+
(0, assert_1.guard)(successors, 'Internal error: A successor set should always exist');
|
|
42
|
+
for (const t of to) {
|
|
43
|
+
if (!this.elements.has(t)) {
|
|
44
|
+
throw new Error(`Target element not registered: ${String(t)}`);
|
|
45
|
+
}
|
|
46
|
+
successors.add(t);
|
|
47
|
+
}
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
buildConfig() {
|
|
51
|
+
if (!this._top) {
|
|
52
|
+
this.setTop(lattice_1.Top);
|
|
53
|
+
}
|
|
54
|
+
if (!this._bottom) {
|
|
55
|
+
this.setBottom(lattice_1.Bottom);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
top: this._top,
|
|
59
|
+
bottom: this._bottom,
|
|
60
|
+
elements: new Set(this.elements),
|
|
61
|
+
leq: new Map(this.leqMap),
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
build(initialElement) {
|
|
65
|
+
return new finite_domain_1.FiniteDomain(initialElement ?? this._top, this.buildConfig());
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.FiniteDomainBuilder = FiniteDomainBuilder;
|
|
69
|
+
//# sourceMappingURL=domain.js.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { NodeId } from '../../r-bridge/lang-4.x/ast/model/processing/node-id';
|
|
2
|
+
import type { RNode } from '../../r-bridge/lang-4.x/ast/model/model';
|
|
3
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
|
+
import type { SourceLocation } from '../../util/range';
|
|
5
|
+
/** Per-finding context handed to a {@link ReportTemplate}. */
|
|
6
|
+
export interface FindingContext {
|
|
7
|
+
/** The name of the taint analysis */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The AST node ID that reached Bottom */
|
|
10
|
+
readonly nodeId: NodeId;
|
|
11
|
+
/** The resolved AST node, if present in the id map */
|
|
12
|
+
readonly node?: RNode<ParentInformation>;
|
|
13
|
+
/** The source location of the node, if resolvable */
|
|
14
|
+
readonly loc?: SourceLocation;
|
|
15
|
+
/** The formatted source location, if resolvable */
|
|
16
|
+
readonly locString?: string;
|
|
17
|
+
/** 1-based start line of the finding, if known */
|
|
18
|
+
readonly line?: number;
|
|
19
|
+
/** 1-based start column of the finding, if known */
|
|
20
|
+
readonly column?: number;
|
|
21
|
+
/** The source file of the finding, if known */
|
|
22
|
+
readonly file?: string;
|
|
23
|
+
/** The node's lexeme, if known */
|
|
24
|
+
readonly lexeme?: string;
|
|
25
|
+
/** The called function's name, if the node resolves to a named call */
|
|
26
|
+
readonly functionName?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A report message: either a constant string, or a function rendering a message per {@link FindingContext|finding}.
|
|
30
|
+
*/
|
|
31
|
+
export type ReportTemplate = string | ((finding: FindingContext) => string);
|
|
32
|
+
/**
|
|
33
|
+
* Convenience accessor rendering the offending token of a finding: the called function's name when the
|
|
34
|
+
* finding node resolves to a named call, otherwise the node's lexeme.
|
|
35
|
+
*/
|
|
36
|
+
export declare const findingToken: (finding: FindingContext) => string | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Assembles the {@link FindingContext} for a single finding from its node id and resolved node/location.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildFindingContext(name: string, nodeId: NodeId, node: RNode<ParentInformation> | undefined, loc: SourceLocation | undefined): FindingContext;
|
|
41
|
+
/**
|
|
42
|
+
* Renders a {@link ReportTemplate} for a given {@link FindingContext}.
|
|
43
|
+
* Constant strings are returned verbatim.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderReport(report: ReportTemplate, ctx: FindingContext): string;
|
|
46
|
+
/**
|
|
47
|
+
* The default report template which appends the function name or lexeme and line number of the finding to the explanatory string.
|
|
48
|
+
* @param s - Human-readable explanation of the finding
|
|
49
|
+
*/
|
|
50
|
+
export declare function defaultReportTemplate(s: string): (f: FindingContext) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.findingToken = void 0;
|
|
4
|
+
exports.buildFindingContext = buildFindingContext;
|
|
5
|
+
exports.renderReport = renderReport;
|
|
6
|
+
exports.defaultReportTemplate = defaultReportTemplate;
|
|
7
|
+
const range_1 = require("../../util/range");
|
|
8
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
9
|
+
/**
|
|
10
|
+
* Convenience accessor rendering the offending token of a finding: the called function's name when the
|
|
11
|
+
* finding node resolves to a named call, otherwise the node's lexeme.
|
|
12
|
+
*/
|
|
13
|
+
const findingToken = finding => finding.functionName ?? finding.lexeme;
|
|
14
|
+
exports.findingToken = findingToken;
|
|
15
|
+
/**
|
|
16
|
+
* Assembles the {@link FindingContext} for a single finding from its node id and resolved node/location.
|
|
17
|
+
*/
|
|
18
|
+
function buildFindingContext(name, nodeId, node, loc) {
|
|
19
|
+
return {
|
|
20
|
+
name,
|
|
21
|
+
nodeId,
|
|
22
|
+
node,
|
|
23
|
+
loc,
|
|
24
|
+
locString: loc !== undefined ? range_1.SourceLocation.format(loc) : undefined,
|
|
25
|
+
line: loc?.[0],
|
|
26
|
+
column: loc?.[1],
|
|
27
|
+
file: loc !== undefined ? range_1.SourceLocation.getFile(loc) : undefined,
|
|
28
|
+
lexeme: node?.lexeme,
|
|
29
|
+
functionName: r_function_call_1.RFunctionCall.isNamed(node) ? node.functionName.lexeme : undefined,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders a {@link ReportTemplate} for a given {@link FindingContext}.
|
|
34
|
+
* Constant strings are returned verbatim.
|
|
35
|
+
*/
|
|
36
|
+
function renderReport(report, ctx) {
|
|
37
|
+
return typeof report === 'function' ? report(ctx) : report;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The default report template which appends the function name or lexeme and line number of the finding to the explanatory string.
|
|
41
|
+
* @param s - Human-readable explanation of the finding
|
|
42
|
+
*/
|
|
43
|
+
function defaultReportTemplate(s) {
|
|
44
|
+
return (f) => `${s} [${(0, exports.findingToken)(f)} at ${f.locString}]`;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=report-template.js.map
|