@eagleoutice/flowr 2.17.2 → 2.17.4
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 +9 -9
- package/cli/repl/commands/repl-signature.d.ts +1 -1
- package/cli/repl/completion.d.ts +23 -0
- package/cli/repl/completion.js +9 -0
- package/cli/repl/core.d.ts +0 -23
- package/cli/repl/core.js +0 -5
- package/cli/repl/parser/slice-query-parser.d.ts +1 -1
- package/cli/repl/parser/slice-query-parser.js +3 -3
- package/data/r-reexports.generated.d.ts +4 -0
- package/data/r-reexports.generated.js +43 -0
- package/dataflow/environments/built-in-props.d.ts +8 -1
- package/dataflow/environments/built-in-props.js +9 -1
- package/dataflow/environments/built-in.d.ts +5 -3
- package/dataflow/environments/built-in.js +5 -4
- package/dataflow/environments/default-builtin-config.d.ts +21 -3
- package/dataflow/environments/default-builtin-config.js +49 -47
- package/dataflow/eval/resolve/resolve-argument.js +11 -6
- package/dataflow/eval/resolve/resolve-numbers.d.ts +1 -178
- package/dataflow/eval/resolve/resolve-numbers.js +2 -13
- package/dataflow/eval/resolve/resolve-strings.d.ts +1 -93
- package/dataflow/eval/resolve/resolve-strings.js +2 -17
- package/dataflow/eval/resolve/resolve-working-directory.js +3 -4
- package/dataflow/extractor.js +44 -26
- package/dataflow/graph/df-helper.d.ts +10 -1
- package/dataflow/graph/df-helper.js +27 -3
- package/dataflow/internal/linker.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +8 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +44 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +9 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +0 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +11 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +2 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +13 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +15 -5
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +1 -24
- package/dataflow/internal/process/functions/call/known-call-handling.js +8 -34
- package/dataflow/internal/process/functions/call/nse-kind.d.ts +24 -0
- package/dataflow/internal/process/functions/call/nse-kind.js +30 -0
- package/documentation/wiki-dataflow-graph.js +7 -2
- package/documentation/wiki-query.js +3 -2
- package/linter/rules/absolute-path.js +5 -5
- package/linter/rules/cmd-check/dependency-declaration.js +2 -2
- package/linter/rules/cmd-check/package-runtime.js +2 -2
- package/linter/rules/deprecated-functions.js +2 -2
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.js +2 -2
- package/linter/rules/overwritten-file.js +2 -4
- package/linter/rules/secret-exfiltration.d.ts +3 -2
- package/linter/rules/secret-exfiltration.js +8 -3
- package/linter/rules/unused-import.js +20 -6
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-controlflow-cache.d.ts +0 -6
- package/project/cache/flowr-analyzer-controlflow-cache.js +7 -27
- package/project/context/flowr-analyzer-context.d.ts +2 -2
- package/project/context/flowr-analyzer-context.js +2 -2
- package/project/context/flowr-analyzer-files-context.d.ts +8 -0
- package/project/context/flowr-analyzer-files-context.js +51 -6
- package/project/flowr-analyzer.d.ts +0 -9
- package/project/flowr-analyzer.js +7 -28
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +5 -3
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +70 -163
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.d.ts +2 -3
- package/project/plugins/file-plugins/flowr-analyzer-file-plugin.js +2 -3
- package/project/plugins/file-plugins/flowr-analyzer-rprofile-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-namespace-file-plugin.js +1 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +1 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +25 -3
- package/project/plugins/package-version-plugins/package.js +1 -1
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +2 -3
- package/project/sigdb/build.js +7 -6
- package/project/sigdb/decode.d.ts +2 -0
- package/project/sigdb/decode.js +9 -3
- package/project/sigdb/schema.d.ts +8 -3
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.d.ts +1 -1
- package/queries/catalog/config-query/config-query-format.js +4 -4
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +6 -5
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +1 -4
- package/queries/catalog/dependencies-query/dependencies-query-format.js +11 -11
- package/queries/catalog/dependencies-query/dependency-values.d.ts +9 -0
- package/queries/catalog/dependencies-query/dependency-values.js +13 -0
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/write-functions.js +8 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +2 -1
- package/queries/catalog/dependencies-query/plot-description.d.ts +1 -1
- package/queries/catalog/dependencies-query/plot-description.js +2 -2
- package/queries/catalog/dice-query/dice-query-format.d.ts +1 -1
- package/queries/catalog/files-query/files-query-format.d.ts +1 -1
- package/queries/catalog/linter-query/linter-query-format.d.ts +2 -2
- package/queries/catalog/linter-query/linter-query-format.js +13 -9
- package/queries/catalog/signature-query/signature-query-executor.d.ts +1 -1
- package/queries/catalog/taint-query/taint-query-format.d.ts +1 -1
- package/queries/query-function-filter.d.ts +1 -1
- package/queries/query.d.ts +2 -2
- package/r-bridge/init.js +1 -1
- package/search/flowr-search-filters.js +2 -2
- package/search/search-executor/search-generators.d.ts +0 -1
- package/search/search-executor/search-generators.js +5 -6
- package/search/search-logger.d.ts +1 -0
- package/search/search-logger.js +6 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NseKind = exports.NseArguments = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Which arguments of a call {@link markArgumentsAsNonStandardEvaluation|are non-standardly evaluated}:
|
|
6
|
+
* every argument, all but the (data) first one, or only the first one.
|
|
7
|
+
*/
|
|
8
|
+
var NseArguments;
|
|
9
|
+
(function (NseArguments) {
|
|
10
|
+
/** every argument, e.g. the operands of a formula `~` or `aes(x, y)` */
|
|
11
|
+
NseArguments["All"] = "all";
|
|
12
|
+
/** all but the first, e.g. `subset(data, col > 1)` where the first argument is the data object */
|
|
13
|
+
NseArguments["AllButFirst"] = "all-but-first";
|
|
14
|
+
/** only the first, e.g. the native routine name in `.C(routine, ...)` */
|
|
15
|
+
NseArguments["First"] = "first";
|
|
16
|
+
})(NseArguments || (exports.NseArguments = NseArguments = {}));
|
|
17
|
+
/**
|
|
18
|
+
* How an argument escapes standard evaluation, which decides what is marked
|
|
19
|
+
* {@link EdgeType.NonStandardEvaluation}.
|
|
20
|
+
*/
|
|
21
|
+
var NseKind;
|
|
22
|
+
(function (NseKind) {
|
|
23
|
+
/** the argument is not evaluated at all (`quote(x + y)`), so nothing within it is */
|
|
24
|
+
NseKind["Quoted"] = "quoted";
|
|
25
|
+
/** the argument is evaluated in a data mask (`subset(d, a > k)`), where only its symbols may name columns */
|
|
26
|
+
NseKind["DataMasked"] = "data-masked";
|
|
27
|
+
/** evaluated, just not exactly once (a loop body), so only the argument itself is marked */
|
|
28
|
+
NseKind["Reevaluated"] = "reevaluated";
|
|
29
|
+
})(NseKind || (exports.NseKind = NseKind = {}));
|
|
30
|
+
//# sourceMappingURL=nse-kind.js.map
|
|
@@ -770,8 +770,9 @@ function askWhatLibraryDoes(analyzer) {
|
|
|
770
770
|
const ctx = analyzer.context();
|
|
771
771
|
return {
|
|
772
772
|
attaches: df_helper_1.Dataflow.library.attaches(ctx, 'tidyverse'), // the search() entries it adds, dplyr, ggplot2, ... included
|
|
773
|
-
loads: df_helper_1.Dataflow.library.loads(ctx, 'tidyverse'), // every namespace it loads, transitively
|
|
774
|
-
layers: df_helper_1.Dataflow.library.layers(ctx, 'tidyverse') // the namespace and imports environments it attaches
|
|
773
|
+
loads: df_helper_1.Dataflow.library.loads(ctx, 'tidyverse'), // every namespace it loads, transitively, magrittr included
|
|
774
|
+
layers: df_helper_1.Dataflow.library.layers(ctx, 'tidyverse'), // the namespace and imports environments it attaches
|
|
775
|
+
reexports: df_helper_1.Dataflow.library.reexports(ctx, 'dplyr') // what dplyr re-exports, `%>%` from magrittr included
|
|
775
776
|
};
|
|
776
777
|
}
|
|
777
778
|
async function dummyDataflow() {
|
|
@@ -1042,6 +1043,10 @@ To ask what a \`library\` call does without analyzing any code, use ${ctx.link('
|
|
|
1042
1043
|
${ctx.code(askWhatLibraryDoes, { dropLinesStart: 1 })}
|
|
1043
1044
|
|
|
1044
1045
|
It answers from the signature database at the versions the analysis assumes, and also from what flowR states about a package and from the \`NAMESPACE\` files it read.
|
|
1046
|
+
A package R attaches on startup (\`methods\`, \`stats\`, ...) is on the search path already, so a \`Depends\` on it adds no entry.
|
|
1047
|
+
Packages R only loads, such as the \`magrittr\` of \`library(tidyverse)\`, are not attached: their functions are reachable through the re-exports of the attached ones (\`dplyr::%>%\` is \`magrittr::%>%\`).
|
|
1048
|
+
The analysis keeps such a re-export as an export of the re-exporting package, so the two stay apart, and gives it what flowR states about the origin; \`reexports\` names the origin of each.
|
|
1049
|
+
A signature database that records no re-exports falls back to what R reports for the package (\`scripts/gen-r-reexports.R\`, covering the tidyverse and other popular packages).
|
|
1045
1050
|
|
|
1046
1051
|
Last but not least, the information contains the single **entry point** (${JSON.stringify(result.entryPoint)}) and a set of **exit points** (${JSON.stringify(result.exitPoints.map(e => e.nodeId))}).
|
|
1047
1052
|
Besides marking potential exits, the exit points also provide information about why the exit occurs and which control dependencies affect the exit.
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.WikiQuery = void 0;
|
|
4
4
|
const flowr_analyzer_builder_1 = require("../project/flowr-analyzer-builder");
|
|
5
5
|
const dependencies_query_format_1 = require("../queries/catalog/dependencies-query/dependencies-query-format");
|
|
6
|
+
const dependency_values_1 = require("../queries/catalog/dependencies-query/dependency-values");
|
|
6
7
|
const doc_dfg_1 = require("./doc-util/doc-dfg");
|
|
7
8
|
const query_1 = require("../queries/query");
|
|
8
9
|
const doc_files_1 = require("./doc-util/doc-files");
|
|
@@ -585,8 +586,8 @@ What the \`value\` of an entry tells, and the fields that say more:
|
|
|
585
586
|
| Entry | How to tell | Meaning |
|
|
586
587
|
|-------|-------------|---------|
|
|
587
588
|
| a file, package, or URL | \`value\` names it | the call reads or writes it, like \`"data.csv"\` |
|
|
588
|
-
| inline data | \`value\` is \`${
|
|
589
|
-
| an unknown resource | \`value\` is \`${
|
|
589
|
+
| inline data | \`value\` is \`${dependency_values_1.Constant}\` | ${ctx.doc('Constant')} |
|
|
590
|
+
| an unknown resource | \`value\` is \`${dependency_values_1.Unknown}\` | ${ctx.doc('Unknown')} |
|
|
590
591
|
| console output | \`value\` is \`stdout\` or \`stderr\` | \`print\` and \`cat\` write to \`stdout\`, \`message\` and \`warning\` to \`stderr\` |
|
|
591
592
|
| auto-printed output | \`implicit\` is set | ${ctx.doc('DependencyInfo::implicit')} |
|
|
592
593
|
| through a call of the program | \`via\` is set | ${ctx.doc('DependencyInfo::via').replaceAll('\n', ' ')} |
|
|
@@ -15,7 +15,7 @@ const write_functions_1 = require("../../queries/catalog/dependencies-query/func
|
|
|
15
15
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
16
16
|
const source_functions_1 = require("../../queries/catalog/dependencies-query/function-info/source-functions");
|
|
17
17
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
18
|
-
const
|
|
18
|
+
const dependency_values_1 = require("../../queries/catalog/dependencies-query/dependency-values");
|
|
19
19
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
20
20
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
21
21
|
const other_path_functions_1 = require("../../queries/catalog/dependencies-query/function-info/other-path-functions");
|
|
@@ -55,13 +55,13 @@ function filePathStrings(graph, vtx, ctx) {
|
|
|
55
55
|
// in the future we can access `.Platform$file.sep` here
|
|
56
56
|
const fsep = (0, resolve_argument_1.getArgumentStringValue)(variables, graph, vtx, undefined, 'fsep', true, ctx);
|
|
57
57
|
const seps = fsep?.values().flatMap(s => s.values().filter(assert_1.isNotUndefined)).toArray() ?? ['/'];
|
|
58
|
-
if (seps.includes(
|
|
58
|
+
if (seps.includes(dependency_values_1.Unknown)) {
|
|
59
59
|
// if we have no fsep, we cannot construct a path
|
|
60
60
|
return undefined;
|
|
61
61
|
}
|
|
62
62
|
const unnamed = (0, resolve_argument_1.getArgumentStringValue)(variables, graph, vtx, 'unnamed', undefined, true, ctx);
|
|
63
63
|
const args = [...unnamed?.values() ?? []].flatMap(v => [...v]);
|
|
64
|
-
if (args.length === 0 || args.some(v => v ===
|
|
64
|
+
if (args.length === 0 || args.some(v => v === dependency_values_1.Unknown || v === undefined)) {
|
|
65
65
|
// if we have no arguments, we cannot construct a path
|
|
66
66
|
return undefined;
|
|
67
67
|
}
|
|
@@ -136,14 +136,14 @@ exports.ABSOLUTE_PATH = {
|
|
|
136
136
|
const result = queryResults[query.query];
|
|
137
137
|
const reads = result.read.filter(r => r.nodeId === node.info.id);
|
|
138
138
|
const found = reads.flatMap(r => {
|
|
139
|
-
if (r.value === undefined || r.value ===
|
|
139
|
+
if (r.value === undefined || r.value === dependency_values_1.Unknown || r.nodeId === undefined) {
|
|
140
140
|
return [];
|
|
141
141
|
}
|
|
142
142
|
const path = absolute(r.value);
|
|
143
143
|
return path === undefined ? [] : [finding(linter_format_1.LintingResultCertainty.Certain, path, idMap.get(r.nodeId), wd, (0, file_path_validity_1.pathArgStringNode)(idMap, r.nodeId, r.value))];
|
|
144
144
|
});
|
|
145
145
|
// if we have no absolute paths, but all paths are known, we can return an empty array
|
|
146
|
-
if (found.length > 0 || reads.every(r => r.value !==
|
|
146
|
+
if (found.length > 0 || reads.every(r => r.value !== dependency_values_1.Unknown)) {
|
|
147
147
|
return found;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
@@ -14,7 +14,7 @@ const df_helper_1 = require("../../../dataflow/graph/df-helper");
|
|
|
14
14
|
const query_fn_props_1 = require("../../../dataflow/environments/query-fn-props");
|
|
15
15
|
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
16
16
|
const library_functions_1 = require("../../../queries/catalog/dependencies-query/function-info/library-functions");
|
|
17
|
-
const
|
|
17
|
+
const dependency_values_1 = require("../../../queries/catalog/dependencies-query/dependency-values");
|
|
18
18
|
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
19
19
|
const cmd_check_util_1 = require("./cmd-check-util");
|
|
20
20
|
const package_files_1 = require("./package-files");
|
|
@@ -157,7 +157,7 @@ exports.DEPENDENCY_DECLARATION = {
|
|
|
157
157
|
const certain = infos.length === 1;
|
|
158
158
|
for (const info of infos) {
|
|
159
159
|
const name = info.value;
|
|
160
|
-
if (name === undefined || name ===
|
|
160
|
+
if (name === undefined || name === dependency_values_1.Unknown || !PackageName.test(name)) {
|
|
161
161
|
unresolvedLoads++;
|
|
162
162
|
continue;
|
|
163
163
|
}
|
|
@@ -81,7 +81,7 @@ function definitionsOf(ast, pkg, data, declaring) {
|
|
|
81
81
|
const NamespaceInternals = ['.packageName', '.__NAMESPACE__.', '.__S3MethodsTable__.'];
|
|
82
82
|
/** whether a namespace exports anything: an export, a registered S3 method, or a pattern that `matches` a name */
|
|
83
83
|
function exportsAnything(ns, matches) {
|
|
84
|
-
return ns.exportedSymbols.length + ns.
|
|
84
|
+
return ns.exportedSymbols.length + ns.exportedS4Methods.length + ns.exportedS4Classes.length + ns.exportS3Generics.size > 0
|
|
85
85
|
|| ns.exportedPatterns.some(matches)
|
|
86
86
|
|| [...ns.conditional?.values() ?? []].some(c => exportsAnything(c, matches));
|
|
87
87
|
}
|
|
@@ -162,7 +162,7 @@ function namespaceChecks(files, pkg, defs, data, config, shipsData, add) {
|
|
|
162
162
|
/* a package may export what it imports (`importFrom(magrittr, "%>%")` and `export("%>%")`) */
|
|
163
163
|
const imported = new Set([...ns.importedPackages.values()].flatMap(v => v === 'all' ? [] : v));
|
|
164
164
|
const importsWhole = [...ns.importedPackages.values()].includes('all');
|
|
165
|
-
for (const name of config.checkExports ?
|
|
165
|
+
for (const name of config.checkExports ? ns.exportedSymbols : []) {
|
|
166
166
|
if (!defs.names.has(name) && !imported.has(name) && !importsWhole) {
|
|
167
167
|
add({ certainty, loc: files.locate(relative, lineOf(text, name)), kind: 'undefined-export', message: `undefined export: '${name}', installing the package fails` });
|
|
168
168
|
}
|
|
@@ -17,7 +17,7 @@ const r_version_1 = require("../../util/r-version");
|
|
|
17
17
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
18
18
|
const logic_1 = require("../../util/logic");
|
|
19
19
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
20
|
-
const
|
|
20
|
+
const dependency_values_1 = require("../../queries/catalog/dependencies-query/dependency-values");
|
|
21
21
|
/** The entries by bare name, as a call names its package only when written `pkg::fn`. */
|
|
22
22
|
function indexConditionals(conditionally) {
|
|
23
23
|
const index = new Map();
|
|
@@ -64,7 +64,7 @@ function indexAlways(always) {
|
|
|
64
64
|
async function librariesAttachedBy(analyzer) {
|
|
65
65
|
const attached = new Set();
|
|
66
66
|
for (const lib of (await analyzer.query([{ type: 'dependencies', enabledCategories: ['library'] }]))['dependencies'].library) {
|
|
67
|
-
if (lib.value === undefined || lib.value ===
|
|
67
|
+
if (lib.value === undefined || lib.value === dependency_values_1.Unknown) {
|
|
68
68
|
return undefined;
|
|
69
69
|
}
|
|
70
70
|
attached.add(lib.value);
|
|
@@ -7,7 +7,7 @@ const linter_format_1 = require("../linter-format");
|
|
|
7
7
|
const strings_1 = require("../../util/text/strings");
|
|
8
8
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
9
9
|
const range_1 = require("../../util/range");
|
|
10
|
-
const
|
|
10
|
+
const dependency_values_1 = require("../../queries/catalog/dependencies-query/dependency-values");
|
|
11
11
|
const built_in_source_1 = require("../../dataflow/internal/process/functions/call/built-in/built-in-source");
|
|
12
12
|
const logic_1 = require("../../util/logic");
|
|
13
13
|
const happens_before_1 = require("../../control-flow/happens-before");
|
|
@@ -79,7 +79,7 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
79
79
|
const findings = await Promise.all(reads.map(async ({ element, matchingRead }) => {
|
|
80
80
|
const { nodeId, value } = matchingRead;
|
|
81
81
|
/* data built from constants, like `matrix(1:6, 2)`, reads no file */
|
|
82
|
-
if (nodeId === undefined || value ===
|
|
82
|
+
if (nodeId === undefined || value === dependency_values_1.Constant) {
|
|
83
83
|
return [];
|
|
84
84
|
}
|
|
85
85
|
const { id, file } = element.node.info;
|
|
@@ -93,7 +93,7 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
93
93
|
return [{ involvedId: nodeId, loc: loc, filePath, certainty, ...(quickFix ? { quickFix } : {}) }];
|
|
94
94
|
};
|
|
95
95
|
if (namesOnly.has(identifier_1.Identifier.getName(matchingRead.functionName))) {
|
|
96
|
-
if (!loc || typeof value !== 'string' || value ===
|
|
96
|
+
if (!loc || typeof value !== 'string' || value === dependency_values_1.Unknown
|
|
97
97
|
|| librariesLoadedBefore(id) || r_base_packages_1.BaseDatasets.has(value) || namesPackage(element.node)) {
|
|
98
98
|
return [];
|
|
99
99
|
}
|
|
@@ -107,9 +107,9 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
107
107
|
return [];
|
|
108
108
|
}
|
|
109
109
|
// check if we can't parse the file path statically
|
|
110
|
-
if (value ===
|
|
110
|
+
if (value === dependency_values_1.Unknown) {
|
|
111
111
|
metadata.totalUnknown++;
|
|
112
|
-
return config.includeUnknown ? [{ involvedId: nodeId, loc, filePath:
|
|
112
|
+
return config.includeUnknown ? [{ involvedId: nodeId, loc, filePath: dependency_values_1.Unknown, certainty: linter_format_1.LintingResultCertainty.Uncertain }] : [];
|
|
113
113
|
}
|
|
114
114
|
const path = value;
|
|
115
115
|
// file:// URIs are local paths; resolve and check existence directly
|
|
@@ -11,7 +11,7 @@ const linter_format_1 = require("../linter-format");
|
|
|
11
11
|
const assert_1 = require("../../util/assert");
|
|
12
12
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
13
13
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
14
|
-
const
|
|
14
|
+
const dependency_values_1 = require("../../queries/catalog/dependencies-query/dependency-values");
|
|
15
15
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
16
16
|
const logic_1 = require("../../util/logic");
|
|
17
17
|
/**
|
|
@@ -93,7 +93,7 @@ function hasArgumentValue(test, fnVertex, analyzer, dataflow, resolveValue, argN
|
|
|
93
93
|
else if (argValues.some(v => test instanceof RegExp ? test.test(v) : v === test)) {
|
|
94
94
|
return logic_1.Ternary.Always;
|
|
95
95
|
}
|
|
96
|
-
else if (argValues.includes(
|
|
96
|
+
else if (argValues.includes(dependency_values_1.Unknown)) {
|
|
97
97
|
return logic_1.Ternary.Maybe;
|
|
98
98
|
}
|
|
99
99
|
return logic_1.Ternary.Never;
|
|
@@ -4,7 +4,7 @@ exports.OVERWRITTEN_FILE = void 0;
|
|
|
4
4
|
const linter_format_1 = require("../linter-format");
|
|
5
5
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
6
6
|
const range_1 = require("../../util/range");
|
|
7
|
-
const
|
|
7
|
+
const dependency_values_1 = require("../../queries/catalog/dependencies-query/dependency-values");
|
|
8
8
|
const linter_tags_1 = require("../linter-tags");
|
|
9
9
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
10
10
|
const logic_1 = require("../../util/logic");
|
|
@@ -16,8 +16,6 @@ const identifier_1 = require("../../dataflow/environments/identifier");
|
|
|
16
16
|
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
17
17
|
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
18
18
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
19
|
-
/** what goes to the console is printed, not written over */
|
|
20
|
-
const ConsoleStreams = new Set(['stdout', 'stderr']);
|
|
21
19
|
/** `append = TRUE`, or a connection opened in an append mode like `file(p, "a")` */
|
|
22
20
|
function appends(id, idMap, opens) {
|
|
23
21
|
const node = idMap.get(id);
|
|
@@ -34,7 +32,7 @@ function appends(id, idMap, opens) {
|
|
|
34
32
|
* body when it names the same file, and the writes into a connection belong to the call opening it.
|
|
35
33
|
*/
|
|
36
34
|
function writesPerFile(writes, idMap, opens) {
|
|
37
|
-
const named = writes.filter((w) => w.nodeId !== undefined && typeof w.value === 'string' && w.value !==
|
|
35
|
+
const named = writes.filter((w) => w.nodeId !== undefined && typeof w.value === 'string' && w.value !== dependency_values_1.Unknown && !dependency_values_1.ConsoleStreams.has(w.value));
|
|
38
36
|
const viaCalls = new Set(named.filter(w => w.via !== undefined).map(w => `${String(w.via)}\0${w.value}`));
|
|
39
37
|
const opened = new Set(named.filter(w => opens(w.nodeId)).map(w => w.value));
|
|
40
38
|
const perFile = new Map();
|
|
@@ -2,6 +2,7 @@ import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import { LintingRuleTag } from '../linter-tags';
|
|
4
4
|
import { Identifier } from '../../dataflow/environments/identifier';
|
|
5
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
6
|
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
6
7
|
import { InputType } from '../../queries/catalog/input-sources-query/input-types';
|
|
7
8
|
import { FileTrust, type SecretSink, SecretSinkClass } from '../../taint-analysis/predefined/secret-analysis';
|
|
@@ -48,8 +49,8 @@ export interface SecretExfiltrationMetadata extends MergeableRecord {
|
|
|
48
49
|
readonly secretSinkCalls: number;
|
|
49
50
|
}
|
|
50
51
|
export declare const SECRET_EXFILTRATION: {
|
|
51
|
-
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from", [],
|
|
52
|
-
readonly processSearchResult: (_elements: import("../../search/flowr-search").FlowrSearchElements<
|
|
52
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from", [], ParentInformation, import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
|
|
53
|
+
readonly processSearchResult: (_elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: SecretExfiltrationConfig, data: ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
53
54
|
results: SecretExfiltrationResult[];
|
|
54
55
|
'.meta': {
|
|
55
56
|
secretSinkCalls: number;
|
|
@@ -10,7 +10,9 @@ const graph_1 = require("../../dataflow/graph/graph");
|
|
|
10
10
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
11
11
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
12
12
|
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
13
|
-
const
|
|
13
|
+
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
14
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
15
|
+
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
14
16
|
const r_symbol_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
15
17
|
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
16
18
|
const arguments_1 = require("../../abstract-interpretation/data-frame/arguments");
|
|
@@ -44,7 +46,6 @@ const Leaks = {
|
|
|
44
46
|
};
|
|
45
47
|
/** request builders passing their destination on */
|
|
46
48
|
const RequestBuilder = /^(?:request|req_\w+)$/;
|
|
47
|
-
const StandardStreams = new Set(['stdout', 'stderr']);
|
|
48
49
|
const MaxDestinationHops = 5;
|
|
49
50
|
const argumentAt = (call, at, info) => at === undefined ? undefined : r_argument_1.RArgument.valueOf((0, arguments_1.getFunctionArgument)((0, arguments_1.getVertexArguments)(call, info.idMap), at, info))?.info.id;
|
|
50
51
|
function requestBuilder(vertex) {
|
|
@@ -75,11 +76,15 @@ async function classifyDestination(data, id, controlled) {
|
|
|
75
76
|
}
|
|
76
77
|
return types.has(input_types_1.InputType.Parameter) && controlled.includes(input_types_1.InputType.Parameter) ? 'parameter' : 'trusted';
|
|
77
78
|
}
|
|
79
|
+
/** whether the destination `file` is the console, `""` or a call flowR states {@link SemanticCallTag.Console} of */
|
|
80
|
+
function namesConsole(file, info) {
|
|
81
|
+
return file.lexeme === '""' || function_semantics_1.FunctionSemantics.call.props.hasAll((0, query_fn_props_1.callFnProps)(file.info.id, { graph: info.graph, environment: info.environment ?? info.ctx.env.cleanEnv() }), [built_in_props_1.SemanticCallTag.Console]);
|
|
82
|
+
}
|
|
78
83
|
async function leakOf(data, call, untrusted, info, config) {
|
|
79
84
|
const fixed = call.sink.class === secret_analysis_1.SecretSinkClass.Browser ? SecretLeak.Leakage : [SecretLeak.Files, SecretLeak.Process, SecretLeak.Llm].find(l => l === call.sink.class);
|
|
80
85
|
const file = info.idMap.get(argumentAt(call.call, call.sink.file, info) ?? '');
|
|
81
86
|
if (fixed !== undefined || call.sink.class === secret_analysis_1.SecretSinkClass.Logs) {
|
|
82
|
-
return { leak: fixed ?? (file !== undefined && !
|
|
87
|
+
return { leak: fixed ?? (file !== undefined && !namesConsole(file, info) ? SecretLeak.Files : SecretLeak.Leakage), certain: true };
|
|
83
88
|
}
|
|
84
89
|
const destination = destinationOf(call.call, call.sink, info);
|
|
85
90
|
const trust = untrusted ? 'controlled' : destination === undefined ? 'trusted' : await classifyDestination(data, destination, config.controlledInputs);
|
|
@@ -13,7 +13,7 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
13
13
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
14
14
|
const node_id_1 = require("../../r-bridge/lang-4.x/ast/model/processing/node-id");
|
|
15
15
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
16
|
-
const
|
|
16
|
+
const dependency_values_1 = require("../../queries/catalog/dependencies-query/dependency-values");
|
|
17
17
|
const library_functions_1 = require("../../queries/catalog/dependencies-query/function-info/library-functions");
|
|
18
18
|
const r_expression_list_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-expression-list");
|
|
19
19
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
@@ -27,14 +27,28 @@ function isUnbound(graph, id) {
|
|
|
27
27
|
const origins = df_helper_1.Dataflow.origin(graph, id);
|
|
28
28
|
return origins === undefined || origins.every(o => o.type === 3 /* OriginType.BuiltInFunctionOrigin */);
|
|
29
29
|
}
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* Whether removing the call would empty a slot the syntax requires: the attach is an operand or argument, as in
|
|
32
|
+
* `ok <- require(x)` or `suppressMessages(library(x))`, the lone statement of an unbraced `if(c) library(x)`, or in `(library(x))`.
|
|
33
|
+
*/
|
|
31
34
|
function removalWouldBreakSyntax(node, idMap) {
|
|
32
35
|
const parent = model_1.RNode.directParent(node, idMap);
|
|
33
|
-
|
|
36
|
+
if (!r_expression_list_1.RExpressionList.is(parent)) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if (r_expression_list_1.RExpressionList.isImplicit(parent)) {
|
|
40
|
+
return parent.children.length === 1 && parent.info.role !== "root" /* RoleInParent.Root */;
|
|
41
|
+
}
|
|
42
|
+
return r_expression_list_1.RExpressionList.groupStart(parent)?.lexeme !== '{';
|
|
43
|
+
}
|
|
44
|
+
/** a bare call nothing binds reads the whole search path; whether it is a use is up to the package exports */
|
|
45
|
+
function isUnboundCall(graph, id) {
|
|
46
|
+
const vertex = graph.getVertex(id);
|
|
47
|
+
return vertex_1.DfgVertex.isFunctionCall(vertex) && identifier_1.Identifier.getNamespace(vertex.name) === undefined && isUnbound(graph, id);
|
|
34
48
|
}
|
|
35
49
|
/** whether anything reads out of the attach itself */
|
|
36
50
|
function isReadFrom(graph, id) {
|
|
37
|
-
return graph.edgesTo(id).
|
|
51
|
+
return graph.edgesTo(id).entries().some(([from, edge]) => edge_1.DfEdge.includesType(edge, edge_1.EdgeType.Reads) && !isUnboundCall(graph, from));
|
|
38
52
|
}
|
|
39
53
|
/**
|
|
40
54
|
* Which of the `attachments` the program never makes use of. A call that resolves names its package outright;
|
|
@@ -51,7 +65,7 @@ function unusedPackages(attachments, graph, src) {
|
|
|
51
65
|
/* a call or a read of a name the code binds nowhere, like `percent` in `scale_y_continuous(labels = percent)` */
|
|
52
66
|
const unbound = new Set();
|
|
53
67
|
for (const [id, vertex] of graph.vertices(true)) {
|
|
54
|
-
if (vertex_1.DfgVertex.isFunctionCall(vertex) &&
|
|
68
|
+
if (vertex_1.DfgVertex.isFunctionCall(vertex) && isUnboundCall(graph, id)) {
|
|
55
69
|
unbound.add(identifier_1.Identifier.getName(vertex.name));
|
|
56
70
|
}
|
|
57
71
|
else if (vertex_1.DfgVertex.isUse(vertex) && isUnbound(graph, id)) {
|
|
@@ -115,7 +129,7 @@ exports.UNUSED_IMPORT = {
|
|
|
115
129
|
continue;
|
|
116
130
|
}
|
|
117
131
|
const name = infos[0].value;
|
|
118
|
-
if (name === undefined || name ===
|
|
132
|
+
if (name === undefined || name === dependency_values_1.Unknown) {
|
|
119
133
|
metadata.totalUnresolved++;
|
|
120
134
|
continue;
|
|
121
135
|
}
|
package/package.json
CHANGED
|
@@ -19,12 +19,6 @@ export declare class FlowrAnalyzerControlFlowCache {
|
|
|
19
19
|
private readonly cache;
|
|
20
20
|
peek(simplifications: readonly CfgSimplificationPassName[] | undefined): ControlFlowInformation | undefined;
|
|
21
21
|
get(force: boolean | undefined, cfgCacheInfo: CfgInfo, simplifications?: readonly CfgSimplificationPassName[]): Promise<ControlFlowInformation>;
|
|
22
|
-
/**
|
|
23
|
-
* Try to get a cached CFG with some of the requested simplifications already applied.
|
|
24
|
-
* Matches the longest prefix of simplifications available.
|
|
25
|
-
* @returns The cached CFG and the missing simplifications to be applied, or `undefined` if no cached CFG is available.
|
|
26
|
-
*/
|
|
27
|
-
private tryGetCachedCfg;
|
|
28
22
|
/**
|
|
29
23
|
* Normalize the order of simplification passes.
|
|
30
24
|
* Is currently an identity function, but may be extended in the future to enforce a specific order using heuristics.
|
|
@@ -19,39 +19,19 @@ class FlowrAnalyzerControlFlowCache {
|
|
|
19
19
|
async get(force, cfgCacheInfo, simplifications) {
|
|
20
20
|
simplifications ??= [];
|
|
21
21
|
const orderedSimplifications = this.normalizeSimplificationOrder(simplifications);
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let cfg = cached.cfg;
|
|
26
|
-
if (!cfg) {
|
|
27
|
-
cfg = (0, control_flow_graph_1.extractCfg)(await cfgCacheInfo.dfg());
|
|
28
|
-
this.cache.set([[]], cfg);
|
|
22
|
+
const known = force ? undefined : this.cache.get([orderedSimplifications]);
|
|
23
|
+
if (known !== undefined) {
|
|
24
|
+
return known;
|
|
29
25
|
}
|
|
30
|
-
|
|
26
|
+
/* passes like `analyze-dead-code` change the graph in place, so they start from a view of their own rather than one cached for fewer passes */
|
|
27
|
+
let cfg = (0, control_flow_graph_1.extractCfg)(await cfgCacheInfo.dfg());
|
|
28
|
+
if (orderedSimplifications.length > 0) {
|
|
31
29
|
const cfgPassInfo = { dfg: (await cfgCacheInfo.dfg()).graph, ctx: cfgCacheInfo.ctx, ast: await cfgCacheInfo.ast() };
|
|
32
|
-
cfg = (0, cfg_simplification_1.simplifyControlFlowInformation)(cfg, cfgPassInfo,
|
|
30
|
+
cfg = (0, cfg_simplification_1.simplifyControlFlowInformation)(cfg, cfgPassInfo, orderedSimplifications);
|
|
33
31
|
}
|
|
34
32
|
this.cache.set([orderedSimplifications], cfg);
|
|
35
33
|
return cfg;
|
|
36
34
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Try to get a cached CFG with some of the requested simplifications already applied.
|
|
39
|
-
* Matches the longest prefix of simplifications available.
|
|
40
|
-
* @returns The cached CFG and the missing simplifications to be applied, or `undefined` if no cached CFG is available.
|
|
41
|
-
*/
|
|
42
|
-
tryGetCachedCfg(simplifications) {
|
|
43
|
-
for (let prefixLen = simplifications.length; prefixLen >= 0; prefixLen--) {
|
|
44
|
-
const prefix = simplifications.slice(0, prefixLen);
|
|
45
|
-
const cached = this.cache.get([prefix]);
|
|
46
|
-
if (cached !== undefined) {
|
|
47
|
-
return {
|
|
48
|
-
cfg: cached,
|
|
49
|
-
missingSimplifications: simplifications.slice(prefixLen)
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return { cfg: undefined, missingSimplifications: simplifications };
|
|
54
|
-
}
|
|
55
35
|
/**
|
|
56
36
|
* Normalize the order of simplification passes.
|
|
57
37
|
* Is currently an identity function, but may be extended in the future to enforce a specific order using heuristics.
|
|
@@ -6,7 +6,7 @@ import { type FlowrAnalyzerPlugin, PluginType } from '../plugins/flowr-analyzer-
|
|
|
6
6
|
import type { fileProtocol, RParseRequestFromFile, RParseRequests } from '../../r-bridge/retriever';
|
|
7
7
|
import { FlowrConfig } from '../../config';
|
|
8
8
|
import type { DeepPartial } from 'ts-essentials';
|
|
9
|
-
import type { FlowrFileProvider } from './flowr-file';
|
|
9
|
+
import type { FileRole, FlowrFileProvider } from './flowr-file';
|
|
10
10
|
import type { ReadOnlyFlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
|
|
11
11
|
import { FlowrAnalyzerEnvironmentContext } from './flowr-analyzer-environment-context';
|
|
12
12
|
import type { ReadOnlyFlowrAnalyzerMetaContext } from './flowr-analyzer-meta-context';
|
|
@@ -160,7 +160,7 @@ export declare class FlowrAnalyzerContext implements ReadOnlyFlowrAnalyzerContex
|
|
|
160
160
|
inferredRange(name: string): Range | undefined;
|
|
161
161
|
/** delegate request addition */
|
|
162
162
|
addRequests(requests: readonly RAnalysisRequest[]): void;
|
|
163
|
-
addFile(f: string | FlowrFileProvider | RParseRequestFromFile): void;
|
|
163
|
+
addFile(f: string | FlowrFileProvider | RParseRequestFromFile, roles?: readonly FileRole[]): void;
|
|
164
164
|
addFiles(f: (string | FlowrFileProvider | RParseRequestFromFile)[]): void;
|
|
165
165
|
/**
|
|
166
166
|
* Get a read-only version of this context.
|
|
@@ -184,6 +184,7 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
184
184
|
private readonly readdirCache;
|
|
185
185
|
constructor(context: FlowrAnalyzerContext, loadingOrder: FlowrAnalyzerLoadingOrderContext, plugins: readonly FlowrAnalyzerProjectDiscoveryPlugin[], fileLoaders: readonly FlowrAnalyzerFilePlugin[]);
|
|
186
186
|
reset(): void;
|
|
187
|
+
private addRoot;
|
|
187
188
|
/** The directory the analysis was asked about: a `project`'s folder, or the one holding the requested file(s). */
|
|
188
189
|
root(): string | undefined;
|
|
189
190
|
/** The path of `filePath` seen from the {@link root}, see {@link relativeTo}. */
|
|
@@ -226,15 +227,22 @@ export declare class FlowrAnalyzerFilesContext extends AbstractFlowrAnalyzerCont
|
|
|
226
227
|
/**
|
|
227
228
|
* Add a file to the context. If the file has a special role, it will be added to the corresponding list of special files.
|
|
228
229
|
* This method also applies any registered {@link FlowrAnalyzerFilePlugin}s to the file before adding it to the context.
|
|
230
|
+
* A file already known under the same path (e.g., reached by both a request and implicit-source discovery) is kept, it only gains the new roles.
|
|
229
231
|
*/
|
|
230
232
|
addFile(file: string | FlowrFileProvider | RParseRequestFromFile | undefined, roles?: readonly FileRole[]): FlowrFileProvider<{
|
|
231
233
|
toString(): string;
|
|
232
234
|
}> | undefined;
|
|
235
|
+
private forget;
|
|
236
|
+
private addRoles;
|
|
233
237
|
hasCached(path: string): boolean;
|
|
234
238
|
hasFile(path: string): boolean;
|
|
235
239
|
private fileIndex;
|
|
236
240
|
private readdir;
|
|
237
241
|
exists(p: string, ignoreCase: boolean): string | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Runs the file loaders on `f`. They match the path below the folder `f` shares with the {@link root}, so the folders
|
|
244
|
+
* holding the project (say, a package checked out below a `test` folder) assign no role.
|
|
245
|
+
*/
|
|
238
246
|
private fileLoadPlugins;
|
|
239
247
|
/** Resolve the file at `path`, loading it from disk through the {@link FlowrAnalyzerFilePlugin}s if unknown. */
|
|
240
248
|
resolveFile(path: string): FlowrFileProvider | undefined;
|