@eagleoutice/flowr 2.15.10 → 2.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +176 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +51 -41
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +31 -4
- package/dataflow/internal/control-flow.js +61 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +446 -78
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +289 -251
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +119 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +54 -57
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +35 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/wiki-setup.js +23 -0
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +114 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +128 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +16 -41
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell.js +6 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +115 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -7,6 +7,7 @@ const range_1 = require("../../util/range");
|
|
|
7
7
|
const linter_tags_1 = require("../linter-tags");
|
|
8
8
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
9
9
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
10
|
+
const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
|
|
10
11
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
11
12
|
const defaultCredentialNamePattern = '(?:password|passwd|pwd|secret|api[_.]?key|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential)';
|
|
12
13
|
const defaultCredentialValuePattern = '^(?:AKIA|AIPA|ASIA|AROA)[A-Z0-9]{16}' + // AWS access key IDs (exact 20-char format)
|
|
@@ -32,27 +33,23 @@ exports.NO_LEAKED_CREDENTIALS = {
|
|
|
32
33
|
let totalChecked = 0;
|
|
33
34
|
const results = elements.getElements().flatMap(element => {
|
|
34
35
|
totalChecked++;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
if (!vertex_1.DfgVertex.isVariableDefinition(vertex)) {
|
|
36
|
+
const id = element.node.info.id;
|
|
37
|
+
if (!vertex_1.DfgVertex.isVariableDefinition(dfg.getVertex(id))) {
|
|
38
38
|
return [];
|
|
39
39
|
}
|
|
40
|
+
const name = element.node.lexeme ?? '';
|
|
40
41
|
const nameMatches = namePattern.test(name);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return [];
|
|
42
|
+
/* a credential-like name only leaks a non-empty string, a credential-like value leaks under any name */
|
|
43
|
+
const leaks = (0, frame_reflection_1.edgeTargets)(dfg, id, edge_1.EdgeType.DefinedBy).some(target => {
|
|
44
|
+
const value = normalize.idMap.get(target);
|
|
45
|
+
return r_string_1.RString.is(value) && ((nameMatches && value.content.str !== '') || valuePattern.test(value.content.str));
|
|
46
|
+
});
|
|
47
|
+
return leaks ? [{
|
|
48
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
49
|
+
involvedId: id,
|
|
50
|
+
variableName: name,
|
|
51
|
+
loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid()
|
|
52
|
+
}] : [];
|
|
56
53
|
});
|
|
57
54
|
return { results, '.meta': { totalChecked } };
|
|
58
55
|
},
|
|
@@ -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 type { InputClassifierConfig, InputSources } from '../../queries/catalog/input-sources-query/simple-input-classifier';
|
|
5
|
+
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
5
6
|
export interface PipeCommandFunctionSpec {
|
|
6
7
|
pattern: string;
|
|
7
8
|
argIdx: number;
|
|
@@ -31,7 +32,7 @@ export declare const PROBLEMATIC_INPUTS: {
|
|
|
31
32
|
readonly description: "Detects uses of dynamic calls (e.g. eval, system) with non-constant inputs, and graphics-device calls (pdf, postscript) where a filename starts with '|' indicating a pipe command injection.";
|
|
32
33
|
readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Smell, LintingRuleTag.Readability, LintingRuleTag.Performance];
|
|
33
34
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
34
|
-
readonly defaultConfig: (ctx:
|
|
35
|
+
readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
|
|
35
36
|
consider: readonly string[];
|
|
36
37
|
pipeCommandFunctions: readonly PipeCommandFunctionSpec[];
|
|
37
38
|
};
|
|
@@ -9,8 +9,10 @@ const linter_tags_1 = require("../linter-tags");
|
|
|
9
9
|
const simple_input_classifier_1 = require("../../queries/catalog/input-sources-query/simple-input-classifier");
|
|
10
10
|
const parse_1 = require("../../slicing/criterion/parse");
|
|
11
11
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
12
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
12
13
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
13
14
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
15
|
+
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
14
16
|
function defaultConsider(index) {
|
|
15
17
|
return ['^eval$', ...index.with(built_in_props_1.SemanticCallTag.Process).map(n => `^${identifier_1.Identifier.quote(identifier_1.Identifier.getName(n))}$`)];
|
|
16
18
|
}
|
|
@@ -25,20 +27,16 @@ function normalizePipeSpecs(cfg) {
|
|
|
25
27
|
const raw = cfg === undefined ? defaultPipeCommandFunctions
|
|
26
28
|
: (0, arrays_1.isArray)(cfg) ? (cfg.length === 0 ? defaultPipeCommandFunctions : cfg)
|
|
27
29
|
: [cfg];
|
|
28
|
-
return raw.map(s => ({ pattern: new RegExp(s.pattern)
|
|
30
|
+
return raw.map(s => ({ ...s, pattern: new RegExp(s.pattern) }));
|
|
29
31
|
}
|
|
30
|
-
function formatInputSources(inputs, inline
|
|
31
|
-
|
|
32
|
-
return inline ? '' : [];
|
|
33
|
-
}
|
|
34
|
-
const fmt = (s) => {
|
|
32
|
+
function formatInputSources(inputs, inline) {
|
|
33
|
+
return inputs.map(s => {
|
|
35
34
|
const t = '[' + s.types.join(',') + ']';
|
|
36
35
|
const c = s.cds ? ', cds: [' + s.cds.join(',') + ']' : '';
|
|
37
36
|
return inline
|
|
38
37
|
? `${s.id} (type: ${t}, trace: ${s.trace}${c})`
|
|
39
38
|
: `- ${s.id}: type=${t}, trace=${s.trace}${c}`;
|
|
40
|
-
};
|
|
41
|
-
return inline ? inputs.map(fmt).join('; ') : inputs.map(fmt);
|
|
39
|
+
});
|
|
42
40
|
}
|
|
43
41
|
function hasUnknownSource(sources) {
|
|
44
42
|
return sources.some(s => s.types.includes(simple_input_classifier_1.InputType.Unknown));
|
|
@@ -46,6 +44,7 @@ function hasUnknownSource(sources) {
|
|
|
46
44
|
function isProblematicForAllowed(sources, allowed) {
|
|
47
45
|
return sources.some(s => s.types.some(t => !allowed.includes(t)));
|
|
48
46
|
}
|
|
47
|
+
/** A path starting with `|` runs a command, so anything but a constant path, user input included, may start one. */
|
|
49
48
|
function getPipeCommandValue(sources) {
|
|
50
49
|
for (const s of sources) {
|
|
51
50
|
if (typeof s.value === 'string' && s.value.startsWith('|')) {
|
|
@@ -54,37 +53,19 @@ function getPipeCommandValue(sources) {
|
|
|
54
53
|
}
|
|
55
54
|
return undefined;
|
|
56
55
|
}
|
|
57
|
-
function resolveFileArgId(vertex, argIdx, argName) {
|
|
58
|
-
|
|
59
|
-
if (!args) {
|
|
60
|
-
return undefined;
|
|
61
|
-
}
|
|
62
|
-
let idx = args.findIndex(a => graph_1.FunctionArgument.isNamed(a) && a.name === argName);
|
|
63
|
-
if (idx < 0) {
|
|
64
|
-
idx = argIdx;
|
|
65
|
-
}
|
|
66
|
-
if (idx >= args.length) {
|
|
56
|
+
function resolveFileArgId(graph, vertex, argIdx, argName, ctx) {
|
|
57
|
+
if (!vertex_1.DfgVertex.isFunctionCall(vertex)) {
|
|
67
58
|
return undefined;
|
|
68
59
|
}
|
|
69
|
-
const arg = args[
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
function checkPipeInjection(nid, loc, name, sources) {
|
|
73
|
-
const pipeCmd = getPipeCommandValue(sources);
|
|
74
|
-
if (pipeCmd !== undefined) {
|
|
75
|
-
return { involvedId: nid, certainty: linter_format_1.LintingResultCertainty.Certain, loc, name, sources, pipeCommand: pipeCmd };
|
|
76
|
-
}
|
|
77
|
-
if (hasUnknownSource(sources)) {
|
|
78
|
-
return { involvedId: nid, certainty: linter_format_1.LintingResultCertainty.Uncertain, loc, name, sources };
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
60
|
+
const arg = vertex.args[(0, resolve_argument_1.boundArgumentIndex)(graph, vertex, argIdx, argName, ctx)];
|
|
61
|
+
return arg === undefined ? undefined : graph_1.FunctionArgument.getReference(arg);
|
|
81
62
|
}
|
|
82
63
|
exports.PROBLEMATIC_INPUTS = {
|
|
83
|
-
createSearch:
|
|
64
|
+
createSearch: config => {
|
|
84
65
|
const toQ = (name, subkind) => ({ type: 'call-context', callName: name, callNameExact: false, subkind });
|
|
85
66
|
return flowr_search_builder_1.Q.fromQuery([
|
|
86
67
|
...normalizePatternList(config.consider).map((n, i) => toQ(n, `fn-${i}`)),
|
|
87
|
-
...normalizePipeSpecs(config
|
|
68
|
+
...normalizePipeSpecs(config.pipeCommandFunctions).map((s, i) => toQ(s.pattern, `pipe-${i}`))
|
|
88
69
|
]);
|
|
89
70
|
},
|
|
90
71
|
processSearchResult: async (elements, config, data) => {
|
|
@@ -93,7 +74,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
93
74
|
const seen = new Set();
|
|
94
75
|
const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
|
|
95
76
|
const considerPats = normalizePatternList(config.consider);
|
|
96
|
-
const pipePats = normalizePipeSpecs(config
|
|
77
|
+
const pipePats = normalizePipeSpecs(config.pipeCommandFunctions);
|
|
97
78
|
for (const element of elements.getElements()) {
|
|
98
79
|
const nid = element.node.info.id;
|
|
99
80
|
if (seen.has(nid)) {
|
|
@@ -101,33 +82,32 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
101
82
|
}
|
|
102
83
|
const name = element.node.lexeme ?? '';
|
|
103
84
|
const pipeSpec = pipePats.find(s => s.pattern.test(name));
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const loc = range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid();
|
|
85
|
+
/* a pipe spec checks the file argument of the call, a considered call the call itself */
|
|
86
|
+
let target;
|
|
109
87
|
if (pipeSpec !== undefined) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
if (r !== undefined) {
|
|
118
|
-
seen.add(nid);
|
|
119
|
-
results.push(r);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
88
|
+
target = resolveFileArgId(df.graph, df.graph.getVertex(nid), pipeSpec.argIdx, pipeSpec.argName, data.inspectContext());
|
|
89
|
+
}
|
|
90
|
+
else if (considerPats.some(p => p.test(name))) {
|
|
91
|
+
target = nid;
|
|
92
|
+
}
|
|
93
|
+
if (target === undefined) {
|
|
94
|
+
continue;
|
|
122
95
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
96
|
+
const criterion = parse_1.SlicingCriterion.fromId(target);
|
|
97
|
+
const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
|
|
98
|
+
const sources = all['input-sources']?.results?.[criterion] ?? [];
|
|
99
|
+
const pipeCommand = pipeSpec === undefined ? undefined : getPipeCommandValue(sources);
|
|
100
|
+
if (pipeCommand !== undefined || isProblematicForAllowed(sources, defaultAccept)) {
|
|
101
|
+
seen.add(nid);
|
|
102
|
+
const uncertain = pipeCommand === undefined && hasUnknownSource(sources);
|
|
103
|
+
results.push({
|
|
104
|
+
involvedId: nid,
|
|
105
|
+
certainty: uncertain ? linter_format_1.LintingResultCertainty.Uncertain : linter_format_1.LintingResultCertainty.Certain,
|
|
106
|
+
loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid(),
|
|
107
|
+
name,
|
|
108
|
+
sources,
|
|
109
|
+
...(pipeCommand === undefined ? {} : { pipeCommand })
|
|
110
|
+
});
|
|
131
111
|
}
|
|
132
112
|
}
|
|
133
113
|
return { results };
|
|
@@ -137,7 +117,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
137
117
|
if (result.pipeCommand !== undefined) {
|
|
138
118
|
return `Pipe command injection via '${result.pipeCommand}' in call to ${result.name} at ${range_1.SourceLocation.format(result.loc)}`;
|
|
139
119
|
}
|
|
140
|
-
const src = formatInputSources(result.sources ?? [], true);
|
|
120
|
+
const src = formatInputSources(result.sources ?? [], true).join('; ');
|
|
141
121
|
return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + (src ? '; inputs: ' + src : '');
|
|
142
122
|
},
|
|
143
123
|
[linter_format_1.LintingPrettyPrintContext.Full]: result => {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
1
|
+
import { type LintingResult, LintingResultCertainty, LintingRuleCertainty } from '../linter-format';
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import { LintingRuleTag } from '../linter-tags';
|
|
4
|
-
import type { Writable } from 'ts-essentials';
|
|
5
4
|
export interface RoxygenArgsResult extends LintingResult {
|
|
6
5
|
readonly overDocumented?: string[];
|
|
7
6
|
readonly underDocumented?: string[];
|
|
@@ -10,8 +9,14 @@ export type RoxygenArgsConfig = MergeableRecord;
|
|
|
10
9
|
export type RoxygenArgsMetadata = MergeableRecord;
|
|
11
10
|
export declare const ROXYGEN_ARGS: {
|
|
12
11
|
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
13
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]
|
|
14
|
-
results:
|
|
12
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>) => {
|
|
13
|
+
results: {
|
|
14
|
+
certainty: LintingResultCertainty.Uncertain;
|
|
15
|
+
involvedId: import("../..").NodeId;
|
|
16
|
+
loc: [startLine: number, startColumn: number, endLine: number, endColumn: number, f?: string | undefined];
|
|
17
|
+
underDocumented: string[];
|
|
18
|
+
overDocumented: string[];
|
|
19
|
+
}[];
|
|
15
20
|
'.meta': {};
|
|
16
21
|
};
|
|
17
22
|
readonly prettyPrint: {
|
|
@@ -5,27 +5,22 @@ const linter_format_1 = require("../linter-format");
|
|
|
5
5
|
const range_1 = require("../../util/range");
|
|
6
6
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
7
7
|
const linter_tags_1 = require("../linter-tags");
|
|
8
|
-
const assert_1 = require("../../util/assert");
|
|
9
8
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
9
|
const roxygen_ast_1 = require("../../r-bridge/roxygen2/roxygen-ast");
|
|
11
10
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
12
11
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
12
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
13
13
|
function calculateArgumentDiff(inheritedParams, functionParam, roxygenParam) {
|
|
14
14
|
//match documented against existing params
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
let overDocumented = new Set(roxygenParam);
|
|
18
|
-
const commonParams = underDocumented.intersection(overDocumented);
|
|
19
|
-
underDocumented = underDocumented.difference(commonParams);
|
|
20
|
-
overDocumented = overDocumented.difference(commonParams);
|
|
15
|
+
const underDocumented = new Set(functionParam).difference(new Set(roxygenParam));
|
|
16
|
+
let overDocumented = new Set(roxygenParam).difference(new Set(functionParam));
|
|
21
17
|
//case: '...', overdocumentation not possible
|
|
22
|
-
if (
|
|
18
|
+
if (functionParam.includes('...')) {
|
|
23
19
|
//if still remaining overdocumented parameters, "..." doesn't need to be documented
|
|
24
20
|
if (overDocumented.size > 0) {
|
|
25
21
|
underDocumented.delete('...');
|
|
26
22
|
}
|
|
27
|
-
|
|
28
|
-
overDocumented.clear();
|
|
23
|
+
overDocumented = new Set();
|
|
29
24
|
}
|
|
30
25
|
//inherited params removed from list of overdocumented params
|
|
31
26
|
overDocumented = overDocumented.difference(new Set(inheritedParams));
|
|
@@ -35,44 +30,30 @@ exports.ROXYGEN_ARGS = {
|
|
|
35
30
|
createSearch: () => flowr_search_builder_1.Q.all()
|
|
36
31
|
.filter(vertex_1.VertexType.FunctionDefinition)
|
|
37
32
|
.with(search_enrichers_1.Enrichment.Roxygen),
|
|
38
|
-
processSearchResult:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
overDocumented.push(...result.over);
|
|
63
|
-
return true;
|
|
64
|
-
})
|
|
65
|
-
.map(({ element, overDocumented, underDocumented }) => ({
|
|
66
|
-
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
67
|
-
involvedId: element.node.info.id,
|
|
68
|
-
loc: range_1.SourceLocation.fromNode(element.node),
|
|
69
|
-
underDocumented: underDocumented,
|
|
70
|
-
overDocumented: overDocumented
|
|
71
|
-
}))
|
|
72
|
-
.filter(element => (0, assert_1.isNotUndefined)(element.loc)),
|
|
73
|
-
'.meta': {}
|
|
74
|
-
};
|
|
75
|
-
},
|
|
33
|
+
processSearchResult: elements => ({
|
|
34
|
+
results: elements.getElements().flatMap(element => {
|
|
35
|
+
const node = element.node;
|
|
36
|
+
const roxygen = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.Roxygen);
|
|
37
|
+
if (!roxygen.documentation.length) {
|
|
38
|
+
return [];
|
|
39
|
+
}
|
|
40
|
+
const params = roxygen.tags[roxygen_ast_1.KnownRoxygenTags.Param] ?? [];
|
|
41
|
+
const functionParamNames = getParameters(node).map(p => identifier_1.Identifier.make(identifier_1.Identifier.getName(p.name.content)).toString());
|
|
42
|
+
/* one `@param a,b` documents several parameters */
|
|
43
|
+
const documented = (tag) => tag.value.name.split(',').map(n => n.trim()).filter(n => n.length > 0);
|
|
44
|
+
const inheritedParams = params.filter(tag => tag.inherited).flatMap(documented);
|
|
45
|
+
const diff = calculateArgumentDiff(inheritedParams, functionParamNames, params.flatMap(documented));
|
|
46
|
+
const loc = range_1.SourceLocation.fromNode(node);
|
|
47
|
+
return diff === false || loc === undefined ? [] : [{
|
|
48
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
49
|
+
involvedId: node.info.id,
|
|
50
|
+
loc,
|
|
51
|
+
underDocumented: diff.under,
|
|
52
|
+
overDocumented: diff.over
|
|
53
|
+
}];
|
|
54
|
+
}),
|
|
55
|
+
'.meta': {}
|
|
56
|
+
}),
|
|
76
57
|
prettyPrint: {
|
|
77
58
|
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`,
|
|
78
59
|
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`
|
|
@@ -30,7 +30,7 @@ export interface SeededRandomnessMeta extends MergeableRecord {
|
|
|
30
30
|
callsWithOtherBranchProducers: number;
|
|
31
31
|
}
|
|
32
32
|
export declare const SEEDED_RANDOMNESS: {
|
|
33
|
-
readonly createSearch: (config: SeededRandomnessConfig
|
|
33
|
+
readonly createSearch: (config: SeededRandomnessConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
34
34
|
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>, config: SeededRandomnessConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
35
35
|
results: {
|
|
36
36
|
involvedId: NodeId;
|
|
@@ -42,10 +42,13 @@ export declare const SEEDED_RANDOMNESS: {
|
|
|
42
42
|
}>;
|
|
43
43
|
readonly info: {
|
|
44
44
|
readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
|
|
45
|
-
randomnessProducers: {
|
|
46
|
-
type: "function"
|
|
45
|
+
randomnessProducers: ({
|
|
46
|
+
readonly type: "function";
|
|
47
|
+
readonly name: string;
|
|
48
|
+
} | {
|
|
49
|
+
type: "assignment";
|
|
47
50
|
name: string;
|
|
48
|
-
}[];
|
|
51
|
+
})[];
|
|
49
52
|
randomnessConsumers: string[];
|
|
50
53
|
};
|
|
51
54
|
readonly tags: readonly [LintingRuleTag.Robustness, LintingRuleTag.Reproducibility];
|