@eagleoutice/flowr 2.16.6 → 2.16.8
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 +21 -15
- package/abstract-interpretation/data-frame/dataframe-semantics.d.ts +2 -0
- package/abstract-interpretation/data-frame/dataframe-semantics.js +3 -1
- package/abstract-interpretation/data-frame/resolve-args.d.ts +1 -7
- package/abstract-interpretation/data-frame/resolve-args.js +2 -11
- package/cli/repl/commands/repl-cfg.js +5 -19
- package/cli/repl/commands/repl-code-command.d.ts +10 -0
- package/cli/repl/commands/repl-code-command.js +18 -0
- package/cli/repl/commands/repl-dataflow.js +34 -59
- package/cli/repl/commands/repl-normalize.js +24 -41
- package/cli/repl/commands/repl-query.js +10 -17
- package/config.js +3 -3
- package/control-flow/cfg-dead-code.js +15 -2
- package/control-flow/useless-loop.js +1 -2
- package/data/r-base-packages.generated.d.ts +1 -1
- package/data/r-base-packages.generated.js +3 -3
- package/dataflow/environments/ambient-state-name.d.ts +80 -0
- package/dataflow/environments/ambient-state-name.js +113 -0
- package/dataflow/environments/built-in-eval-name.d.ts +3 -1
- package/dataflow/environments/built-in-eval-name.js +2 -0
- package/dataflow/environments/built-in-props.d.ts +27 -7
- package/dataflow/environments/built-in-props.js +59 -44
- package/dataflow/environments/built-in.d.ts +5 -2
- package/dataflow/environments/built-in.js +22 -5
- package/dataflow/environments/default-builtin-config.d.ts +538 -14
- package/dataflow/environments/default-builtin-config.js +189 -123
- package/dataflow/environments/environment.d.ts +7 -1
- package/dataflow/environments/environment.js +19 -1
- package/dataflow/environments/identifier.d.ts +12 -1
- package/dataflow/environments/reference-to-maybe.js +1 -6
- package/dataflow/eval/resolve/alias-tracking.d.ts +13 -3
- package/dataflow/eval/resolve/alias-tracking.js +66 -37
- package/dataflow/eval/resolve/resolve-argument.d.ts +4 -2
- package/dataflow/eval/resolve/resolve-argument.js +23 -11
- package/dataflow/eval/resolve/resolve.d.ts +5 -0
- package/dataflow/eval/resolve/resolve.js +25 -3
- package/dataflow/eval/values/r-value.d.ts +4 -2
- package/dataflow/eval/values/r-value.js +3 -1
- package/dataflow/eval/values/string/string-constants.d.ts +7 -1
- package/dataflow/eval/values/string/string-constants.js +38 -36
- package/dataflow/extractor.js +105 -2
- package/dataflow/fn/argument-roles.js +22 -8
- package/dataflow/fn/function-semantics.d.ts +3 -2
- package/dataflow/fn/strict-function.js +13 -2
- package/dataflow/graph/dataflowgraph-builder.d.ts +4 -4
- package/dataflow/graph/df-helper.d.ts +14 -1
- package/dataflow/graph/df-helper.js +37 -4
- package/dataflow/graph/graph.d.ts +6 -0
- package/dataflow/graph/graph.js +9 -10
- package/dataflow/graph/vertex.d.ts +1 -1
- package/dataflow/hooks.d.ts +1 -1
- package/dataflow/info.d.ts +3 -3
- package/dataflow/internal/linker.d.ts +4 -1
- package/dataflow/internal/linker.js +12 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.d.ts +41 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-keys.js +88 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +21 -46
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +125 -158
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +35 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +10 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +6 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +3 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +21 -12
- 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 +8 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.d.ts +4 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +5 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +11 -12
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +6 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-string-template.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +43 -7
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +11 -0
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +29 -4
- package/dataflow/internal/process/functions/call/common.js +3 -4
- package/dataflow/internal/process/functions/call/deferred.d.ts +3 -2
- package/dataflow/internal/process/functions/call/deferred.js +17 -9
- package/dataflow/internal/process/functions/call/quoted.js +1 -1
- package/dataflow/processor.d.ts +1 -1
- package/documentation/doc-capabilities.js +3 -2
- package/documentation/doc-readme.js +1 -2
- package/documentation/doc-util/doc-dfg.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +3 -1
- package/documentation/doc-util/doc-query.js +4 -4
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-linter.js +16 -206
- package/documentation/wiki-linting-and-testing.js +31 -64
- package/documentation/wiki-query.js +41 -0
- package/index.d.ts +1 -0
- package/index.js +5 -1
- package/linter/linter-format.d.ts +6 -0
- package/linter/linter-format.js +10 -0
- package/linter/linter-rules.d.ts +155 -103
- package/linter/linter-rules.js +2 -0
- package/linter/linter-util.d.ts +23 -0
- package/linter/linter-util.js +58 -0
- package/linter/rules/absolute-path.d.ts +2 -2
- package/linter/rules/absolute-path.js +1 -4
- package/linter/rules/cmd-check/bogus-return.d.ts +2 -2
- package/linter/rules/cmd-check/bogus-return.js +3 -7
- package/linter/rules/cmd-check/call-arguments.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.d.ts +2 -2
- package/linter/rules/cmd-check/class-string-comparison.js +3 -7
- package/linter/rules/cmd-check/cmd-check-util.d.ts +8 -9
- package/linter/rules/cmd-check/cmd-check-util.js +14 -26
- package/linter/rules/cmd-check/compiled-code.d.ts +8 -3
- package/linter/rules/cmd-check/compiled-code.js +3 -13
- package/linter/rules/cmd-check/dependency-declaration.d.ts +2 -2
- package/linter/rules/cmd-check/dependency-declaration.js +6 -7
- package/linter/rules/cmd-check/description-metadata.d.ts +4 -4
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +2 -2
- package/linter/rules/cmd-check/documentation-mismatch.js +4 -11
- package/linter/rules/cmd-check/file-checks.d.ts +19 -6
- package/linter/rules/cmd-check/file-checks.js +13 -5
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.d.ts +2 -2
- package/linter/rules/cmd-check/global-environment-modification.js +3 -2
- package/linter/rules/cmd-check/namespace-tampering.d.ts +2 -2
- package/linter/rules/cmd-check/namespace-tampering.js +9 -9
- package/linter/rules/cmd-check/non-ascii-code.d.ts +2 -2
- package/linter/rules/cmd-check/package-data.d.ts +11 -5
- package/linter/rules/cmd-check/package-data.js +5 -12
- package/linter/rules/cmd-check/package-files.js +4 -10
- package/linter/rules/cmd-check/package-hooks.d.ts +2 -2
- package/linter/rules/cmd-check/package-hooks.js +10 -8
- package/linter/rules/cmd-check/package-metafiles.d.ts +8 -3
- package/linter/rules/cmd-check/package-metafiles.js +3 -12
- package/linter/rules/cmd-check/package-runtime.d.ts +18 -5
- package/linter/rules/cmd-check/package-runtime.js +64 -20
- package/linter/rules/cmd-check/package-structure.d.ts +11 -5
- package/linter/rules/cmd-check/package-structure.js +4 -12
- package/linter/rules/cmd-check/rd-files.d.ts +8 -3
- package/linter/rules/cmd-check/rd-files.js +4 -14
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +2 -2
- package/linter/rules/cmd-check/s-three-method-consistency.js +3 -4
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.d.ts +2 -2
- package/linter/rules/dataframe-access-validation.js +5 -8
- package/linter/rules/dead-code.d.ts +5 -4
- package/linter/rules/dead-code.js +25 -14
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/deprecated-functions.js +16 -23
- package/linter/rules/file-path-validity.d.ts +2 -2
- package/linter/rules/file-path-validity.js +3 -6
- package/linter/rules/function-finder-util.d.ts +3 -3
- package/linter/rules/function-finder-util.js +7 -14
- package/linter/rules/namespace-access.d.ts +2 -2
- package/linter/rules/namespace-access.js +6 -9
- package/linter/rules/naming-convention.d.ts +2 -2
- package/linter/rules/naming-convention.js +1 -4
- package/linter/rules/network-functions.d.ts +3 -3
- package/linter/rules/no-leaked-credentials.d.ts +2 -2
- package/linter/rules/no-leaked-credentials.js +1 -4
- package/linter/rules/overwritten-file.d.ts +38 -0
- package/linter/rules/overwritten-file.js +102 -0
- package/linter/rules/problematic-inputs.d.ts +16 -6
- package/linter/rules/problematic-inputs.js +78 -34
- package/linter/rules/roxygen-arguments.d.ts +2 -2
- package/linter/rules/roxygen-arguments.js +1 -4
- package/linter/rules/seeded-randomness.d.ts +3 -3
- package/linter/rules/seeded-randomness.js +6 -23
- package/linter/rules/software-has-license.d.ts +2 -2
- package/linter/rules/software-has-license.js +1 -4
- package/linter/rules/software-has-tests.d.ts +2 -2
- package/linter/rules/software-has-tests.js +1 -4
- package/linter/rules/stop-with-call-arg.d.ts +2 -2
- package/linter/rules/stop-with-call-arg.js +4 -11
- package/linter/rules/syntactically-valid.d.ts +4 -2
- package/linter/rules/syntactically-valid.js +29 -10
- package/linter/rules/unclosed-connection.d.ts +2 -2
- package/linter/rules/unclosed-connection.js +1 -4
- package/linter/rules/undefined-symbol.d.ts +2 -2
- package/linter/rules/undefined-symbol.js +25 -22
- package/linter/rules/unescaped-arguments.d.ts +2 -2
- package/linter/rules/unescaped-arguments.js +1 -4
- package/linter/rules/unused-definition.d.ts +2 -2
- package/linter/rules/unused-definition.js +37 -25
- package/linter/rules/unused-import.d.ts +2 -2
- package/linter/rules/unused-import.js +9 -14
- package/linter/rules/useless-loop.d.ts +7 -6
- package/linter/rules/useless-loop.js +4 -8
- package/package.json +5 -3
- package/project/cache/flowr-analyzer-cache.d.ts +2 -0
- package/project/cache/flowr-analyzer-cache.js +15 -11
- package/project/context/flowr-analyzer-files-context.d.ts +3 -0
- package/project/context/flowr-analyzer-files-context.js +6 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +6 -1
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +35 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +2 -1
- package/project/plugins/file-plugins/files/flowr-rsession-file.d.ts +26 -0
- package/project/plugins/file-plugins/files/flowr-rsession-file.js +44 -0
- package/project/plugins/file-plugins/files/r-session.d.ts +20 -0
- package/project/plugins/file-plugins/files/r-session.js +58 -0
- package/project/plugins/file-plugins/files/recorded-runs.d.ts +18 -0
- package/project/plugins/file-plugins/files/recorded-runs.js +8 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.d.ts +20 -0
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rsession-file-plugin.js +28 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +2 -0
- package/project/sigdb/spec-query.d.ts +73 -0
- package/project/sigdb/spec-query.js +339 -0
- package/queries/base-query-format.d.ts +1 -1
- package/queries/base-query-format.js +2 -2
- package/queries/catalog/absint-query/absint-query-executor.js +3 -6
- package/queries/catalog/call-context-query/call-context-query-executor.d.ts +1 -0
- package/queries/catalog/call-context-query/call-context-query-executor.js +113 -73
- package/queries/catalog/call-graph-query/call-graph-query-executor.js +2 -3
- package/queries/catalog/cluster-query/cluster-query-executor.js +2 -3
- package/queries/catalog/config-query/config-query-format.d.ts +0 -1
- package/queries/catalog/config-query/config-query-format.js +1 -2
- package/queries/catalog/control-flow-query/control-flow-query-executor.js +2 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-executor.js +2 -4
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.d.ts +0 -1
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +1 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -3
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +7 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +72 -42
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +24 -6
- package/queries/catalog/dependencies-query/dependencies-query-format.js +108 -3
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +6 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +6 -6
- package/queries/catalog/dependencies-query/function-info/write-functions.js +13 -7
- package/queries/catalog/dependencies-query/implicit-echo.js +21 -7
- package/queries/catalog/dice-query/dice-query-executor.js +2 -3
- package/queries/catalog/does-call-query/does-call-query-executor.js +2 -3
- package/queries/catalog/files-query/files-query-executor.js +2 -3
- package/queries/catalog/function-info-query/function-info-query-executor.js +2 -1
- package/queries/catalog/function-info-query/function-info-query-format.d.ts +0 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +1 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +3 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.d.ts +0 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +1 -2
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -3
- package/queries/catalog/happens-before-query/happens-before-query-format.d.ts +0 -1
- package/queries/catalog/happens-before-query/happens-before-query-format.js +1 -2
- package/queries/catalog/id-map-query/id-map-query-executor.js +2 -3
- package/queries/catalog/id-map-query/id-map-query-format.d.ts +0 -1
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -2
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +2 -1
- package/queries/catalog/input-sources-query/simple-input-classifier.js +60 -13
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +2 -3
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +2 -1
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-executor.js +1 -7
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +6 -9
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +8 -33
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.d.ts +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +1 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.d.ts +6 -7
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-format.js +8 -31
- package/queries/catalog/linter-query/linter-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-executor.js +2 -3
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +0 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -2
- package/queries/catalog/normalized-ast-query/normalized-ast-query-executor.js +2 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.d.ts +0 -1
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +1 -2
- package/queries/catalog/origin-query/origin-query-executor.d.ts +0 -5
- package/queries/catalog/origin-query/origin-query-executor.js +3 -11
- package/queries/catalog/project-query/project-query-executor.js +23 -7
- package/queries/catalog/project-query/project-query-format.d.ts +5 -0
- package/queries/catalog/project-query/project-query-format.js +20 -2
- package/queries/catalog/provenance-query/provenance-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-executor.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +0 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -2
- package/queries/catalog/search-query/search-query-executor.js +2 -3
- package/queries/catalog/signature-query/signature-query-executor.js +39 -0
- package/queries/catalog/signature-query/signature-query-format.d.ts +7 -1
- package/queries/catalog/signature-query/signature-query-format.js +15 -1
- package/queries/catalog/signature-query/signature-query-render.js +2 -1
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +2 -3
- package/queries/query-function-property.d.ts +28 -0
- package/queries/query-function-property.js +48 -0
- package/queries/query-meta.d.ts +3 -0
- package/queries/query-meta.js +8 -0
- package/queries/query.d.ts +13 -18
- package/r-bridge/lang-4.x/ast/model/processing/decorate.d.ts +2 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +4 -3
- package/r-bridge/lang-4.x/ast/model/processing/node-id.d.ts +6 -0
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +9 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.d.ts +8 -0
- package/r-bridge/lang-4.x/ast/model/syntax-version.js +49 -0
- package/r-bridge/lang-4.x/ast/model/type.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/type.js +3 -0
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-parameter.js +4 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-single-node.js +1 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +1 -1
- package/reconstruct/reconstruct.js +35 -1
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/static/fingerprint.js +7 -3
- package/slicing/static/static-slicer.js +6 -0
- package/util/assert.js +2 -2
- package/util/collections/arrays.d.ts +4 -0
- package/util/collections/arrays.js +11 -0
- package/util/collections/defaultmap.d.ts +5 -1
- package/util/collections/defaultmap.js +6 -1
- package/util/files.js +26 -5
- package/util/flowr-version.d.ts +10 -0
- package/util/flowr-version.js +20 -0
- package/util/glob.js +6 -4
- package/util/r-regex.d.ts +6 -0
- package/util/r-regex.js +17 -0
- package/util/text/args.d.ts +5 -0
- package/util/text/args.js +28 -22
- package/util/text/name-rank.d.ts +2 -0
- package/util/text/name-rank.js +3 -1
- package/util/text/regex.d.ts +10 -0
- package/util/text/regex.js +29 -0
- package/util/version.d.ts +1 -6
- package/util/version.js +6 -14
- package/documentation/doc-util/doc-functions.d.ts +0 -24
- package/documentation/doc-util/doc-functions.js +0 -65
|
@@ -56,8 +56,8 @@ export declare const FILE_PATH_VALIDITY: {
|
|
|
56
56
|
};
|
|
57
57
|
};
|
|
58
58
|
readonly prettyPrint: {
|
|
59
|
-
readonly query: (
|
|
60
|
-
readonly full: (
|
|
59
|
+
readonly query: (r: FilePathValidityResult, metadata: unknown) => string;
|
|
60
|
+
readonly full: (r: FilePathValidityResult, metadata: unknown) => string;
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
63
|
/** the string-literal path argument of a call whose resolved value is `value`, for anchoring a quick fix */
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FILE_PATH_VALIDITY = void 0;
|
|
4
4
|
exports.pathArgStringNode = pathArgStringNode;
|
|
5
|
+
const cmd_check_util_1 = require("./cmd-check/cmd-check-util");
|
|
5
6
|
const linter_format_1 = require("../linter-format");
|
|
6
7
|
const strings_1 = require("../../util/text/strings");
|
|
7
8
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
@@ -32,7 +33,6 @@ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument
|
|
|
32
33
|
const r_base_packages_1 = require("../../util/r-base-packages");
|
|
33
34
|
const secure_mode_1 = require("../../util/secure-mode");
|
|
34
35
|
const files_1 = require("../../util/files");
|
|
35
|
-
const DataSetExtensions = ['R', 'r', 'RData', 'rdata', 'rda', 'tab', 'txt', 'TXT', 'tab.gz', 'tab.bz2', 'tab.xz', 'txt.gz', 'txt.bz2', 'txt.xz', 'csv', 'CSV'];
|
|
36
36
|
function namesPackage(node) {
|
|
37
37
|
return r_function_call_1.RFunctionCall.is(node) && node.arguments.some(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && ['package', 'lib.loc'].includes(identifier_1.Identifier.getName(a.name.content)));
|
|
38
38
|
}
|
|
@@ -99,7 +99,7 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
99
99
|
}
|
|
100
100
|
metadata.totalReads++;
|
|
101
101
|
const find = finderAt(resolveSource, wdRootsFor(id, file), file, ctx);
|
|
102
|
-
const exists = DataSetExtensions.some(ext => find(`data/${value}.${ext}`).length);
|
|
102
|
+
const exists = cmd_check_util_1.DataSetExtensions.some(ext => find(`data/${value}.${ext}`).length);
|
|
103
103
|
return verdict(exists, `data/${value}`, linter_format_1.LintingResultCertainty.Uncertain);
|
|
104
104
|
}
|
|
105
105
|
metadata.totalReads++;
|
|
@@ -165,10 +165,7 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
165
165
|
checkUrls: false
|
|
166
166
|
})
|
|
167
167
|
},
|
|
168
|
-
prettyPrint: {
|
|
169
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Path \`${result.filePath}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
170
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Path \`${result.filePath}\` at ${range_1.SourceLocation.format(result.loc)} does not point to a valid file`
|
|
171
|
-
}
|
|
168
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Path \`${result.filePath}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `Path \`${result.filePath}\` at ${range_1.SourceLocation.format(result.loc)} does not point to a valid file`)
|
|
172
169
|
};
|
|
173
170
|
/** Whether the read only runs depending on a condition that queries the same file, as in `if(file.exists(p)) readLines(p)`. */
|
|
174
171
|
function guardedByFileQuery(df, read, path, data) {
|
|
@@ -20,7 +20,7 @@ export interface FunctionsMetadata extends MergeableRecord {
|
|
|
20
20
|
* This helper object collects utility functions used to create linting rules that search for specific functions.
|
|
21
21
|
*/
|
|
22
22
|
export declare const functionFinderUtil: {
|
|
23
|
-
createSearch: (functions
|
|
23
|
+
createSearch: (functions?: readonly Identifier[], qualifyNames?: boolean) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], ParentInformation, Promise<FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>>;
|
|
24
24
|
processSearchResult<T extends FlowrSearchElement<ParentInformation>[]>(this: void, elements: FlowrSearchElements<ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => AsyncOrSync<(T[number] & {
|
|
25
25
|
certainty?: LintingResultCertainty;
|
|
26
26
|
})[]>): Promise<{
|
|
@@ -28,8 +28,8 @@ export declare const functionFinderUtil: {
|
|
|
28
28
|
'.meta': FunctionsMetadata;
|
|
29
29
|
}>;
|
|
30
30
|
prettyPrint: (functionType: string) => {
|
|
31
|
-
query: (
|
|
32
|
-
full: (
|
|
31
|
+
readonly query: (r: FunctionsResult, metadata: unknown) => string;
|
|
32
|
+
readonly full: (r: FunctionsResult, metadata: unknown) => string;
|
|
33
33
|
};
|
|
34
34
|
requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, analyzer: ReadonlyFlowrAnalysisProvider, requireValue: RegExp | string | undefined, identifier: Identifier | undefined): Promise<Ternary>;
|
|
35
35
|
};
|
|
@@ -18,18 +18,16 @@ const logic_1 = require("../../util/logic");
|
|
|
18
18
|
* This helper object collects utility functions used to create linting rules that search for specific functions.
|
|
19
19
|
*/
|
|
20
20
|
exports.functionFinderUtil = {
|
|
21
|
-
createSearch: (functions) => {
|
|
22
|
-
|
|
23
|
-
.with(search_enrichers_1.Enrichment.CallTargets, { onlyBuiltin: true })
|
|
24
|
-
|
|
21
|
+
createSearch: (functions, qualifyNames = true) => {
|
|
22
|
+
const search = flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
|
|
23
|
+
.with(search_enrichers_1.Enrichment.CallTargets, { onlyBuiltin: true, qualifyNames });
|
|
24
|
+
return functions === undefined ? search : search.filter({
|
|
25
25
|
name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
|
|
26
26
|
args: {
|
|
27
27
|
enrichment: search_enrichers_1.Enrichment.CallTargets,
|
|
28
|
-
test: {
|
|
29
|
-
targets: identifier_1.Identifier.regex(...functions)
|
|
30
|
-
}
|
|
28
|
+
test: { targets: identifier_1.Identifier.regex(...functions) }
|
|
31
29
|
}
|
|
32
|
-
})
|
|
30
|
+
});
|
|
33
31
|
},
|
|
34
32
|
async processSearchResult(elements, _config, _data, refineSearch = e => e) {
|
|
35
33
|
const metadata = {
|
|
@@ -59,12 +57,7 @@ exports.functionFinderUtil = {
|
|
|
59
57
|
'.meta': metadata
|
|
60
58
|
};
|
|
61
59
|
},
|
|
62
|
-
prettyPrint: (functionType) => {
|
|
63
|
-
return {
|
|
64
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
65
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Function \`${result.function}\` called at ${range_1.SourceLocation.format(result.loc)} is related to ${functionType}`
|
|
66
|
-
};
|
|
67
|
-
},
|
|
60
|
+
prettyPrint: (functionType) => (0, linter_format_1.prettyPrint)((result) => `Function \`${result.function}\` at ${range_1.SourceLocation.format(result.loc)}`, result => `Function \`${result.function}\` called at ${range_1.SourceLocation.format(result.loc)} is related to ${functionType}`),
|
|
68
61
|
async requireArgumentValue(element, pool, analyzer, requireValue, identifier) {
|
|
69
62
|
const dataflow = await analyzer.dataflow();
|
|
70
63
|
/* if we have no additional info, we assume they always access the network */
|
|
@@ -29,8 +29,8 @@ export declare const NAMESPACE_ACCESS: {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
readonly prettyPrint: {
|
|
32
|
-
readonly query: (
|
|
33
|
-
readonly full: (
|
|
32
|
+
readonly query: (r: NamespaceAccessResult, metadata: unknown) => string;
|
|
33
|
+
readonly full: (r: NamespaceAccessResult, metadata: unknown) => string;
|
|
34
34
|
};
|
|
35
35
|
readonly info: {
|
|
36
36
|
readonly name: "Namespace Access Validity";
|
|
@@ -55,15 +55,12 @@ exports.NAMESPACE_ACCESS = {
|
|
|
55
55
|
}
|
|
56
56
|
return { results, '.meta': { unresolved } };
|
|
57
57
|
},
|
|
58
|
-
prettyPrint: {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
: `\`${result.pkg}::${result.name}\` at ${where} fails at runtime - \`${result.name}\` is not exported by \`${result.pkg}\` (use \`${result.pkg}:::${result.name}\` if this is intentional)`;
|
|
65
|
-
}
|
|
66
|
-
},
|
|
58
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `\`${result.pkg}${result.kind === 'unnecessary-internal' ? ':::' : '::'}${result.name}\` at ${range_1.SourceLocation.format(result.loc)}`, result => {
|
|
59
|
+
const where = range_1.SourceLocation.format(result.loc);
|
|
60
|
+
return result.kind === 'unnecessary-internal'
|
|
61
|
+
? `\`${result.pkg}:::${result.name}\` at ${where} is unnecessary - \`${result.name}\` is exported by \`${result.pkg}\`, so \`${result.pkg}::${result.name}\` already works`
|
|
62
|
+
: `\`${result.pkg}::${result.name}\` at ${where} fails at runtime - \`${result.name}\` is not exported by \`${result.pkg}\` (use \`${result.pkg}:::${result.name}\` if this is intentional)`;
|
|
63
|
+
}),
|
|
67
64
|
info: {
|
|
68
65
|
name: 'Namespace Access Validity',
|
|
69
66
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
@@ -66,8 +66,8 @@ export declare const NAMING_CONVENTION: {
|
|
|
66
66
|
};
|
|
67
67
|
}>;
|
|
68
68
|
readonly prettyPrint: {
|
|
69
|
-
readonly query: (
|
|
70
|
-
readonly full: (
|
|
69
|
+
readonly query: (r: NamingConventionResult, metadata: unknown) => string;
|
|
70
|
+
readonly full: (r: NamingConventionResult, metadata: unknown) => string;
|
|
71
71
|
};
|
|
72
72
|
readonly info: {
|
|
73
73
|
readonly name: "Naming Convention";
|
|
@@ -213,10 +213,7 @@ exports.NAMING_CONVENTION = {
|
|
|
213
213
|
}
|
|
214
214
|
};
|
|
215
215
|
},
|
|
216
|
-
prettyPrint: {
|
|
217
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Identifier '${result.name}' at ${range_1.SourceLocation.format(result.loc)} (${result.detectedCasing})`,
|
|
218
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Identifier '${result.name}' at ${range_1.SourceLocation.format(result.loc)} follows wrong convention: ${result.detectedCasing}`
|
|
219
|
-
},
|
|
216
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Identifier '${result.name}' at ${range_1.SourceLocation.format(result.loc)} (${result.detectedCasing})`, result => `Identifier '${result.name}' at ${range_1.SourceLocation.format(result.loc)} follows wrong convention: ${result.detectedCasing}`),
|
|
220
217
|
info: {
|
|
221
218
|
name: 'Naming Convention',
|
|
222
219
|
// detects casing heuristically so correctness is not ensured using default config, but checks all identifiers in the code for naming convention match
|
|
@@ -38,14 +38,14 @@ export interface NetworkFunction extends MergeableRecord {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function networkFunctions(index: BuiltInIndex): NetworkFunction[];
|
|
40
40
|
export declare const NETWORK_FUNCTIONS: {
|
|
41
|
-
readonly createSearch: (config: NetworkFunctionsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"
|
|
41
|
+
readonly createSearch: (config: NetworkFunctionsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>>>;
|
|
42
42
|
readonly processSearchResult: (e: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, c: NetworkFunctionsConfig, d: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
43
43
|
results: FunctionsResult[];
|
|
44
44
|
'.meta': FunctionsMetadata;
|
|
45
45
|
}>;
|
|
46
46
|
readonly prettyPrint: {
|
|
47
|
-
query: (
|
|
48
|
-
full: (
|
|
47
|
+
readonly query: (r: FunctionsResult, metadata: unknown) => string;
|
|
48
|
+
readonly full: (r: FunctionsResult, metadata: unknown) => string;
|
|
49
49
|
};
|
|
50
50
|
readonly info: {
|
|
51
51
|
readonly name: "Network Functions";
|
|
@@ -24,8 +24,8 @@ export declare const NO_LEAKED_CREDENTIALS: {
|
|
|
24
24
|
".meta": NoLeakedCredentialsMetadata;
|
|
25
25
|
}>;
|
|
26
26
|
readonly prettyPrint: {
|
|
27
|
-
readonly query: (
|
|
28
|
-
readonly full: (
|
|
27
|
+
readonly query: (r: NoLeakedCredentialsResult, metadata: unknown) => string;
|
|
28
|
+
readonly full: (r: NoLeakedCredentialsResult, metadata: unknown) => string;
|
|
29
29
|
};
|
|
30
30
|
readonly info: {
|
|
31
31
|
readonly name: "No Leaked Credentials";
|
|
@@ -150,10 +150,7 @@ exports.NO_LEAKED_CREDENTIALS = {
|
|
|
150
150
|
}
|
|
151
151
|
return { results: [...results.values()], '.meta': { totalChecked } };
|
|
152
152
|
},
|
|
153
|
-
prettyPrint: {
|
|
154
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => `Possible hardcoded credential in \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
155
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Variable \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)} appears to contain a hardcoded credential`
|
|
156
|
-
},
|
|
153
|
+
prettyPrint: (0, linter_format_1.prettyPrint)((result) => `Possible hardcoded credential in \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`, (result) => `Variable \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)} appears to contain a hardcoded credential`),
|
|
157
154
|
info: {
|
|
158
155
|
name: 'No Leaked Credentials',
|
|
159
156
|
description: 'Finds hardcoded credentials assigned to variables or passed as arguments whose names suggest they hold passwords, tokens, or API keys, handed to authentication functions, or whose values match known credential formats (AWS, GitHub, Slack, Stripe, Google, JWT, SSH, URLs with passwords).',
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
2
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
3
|
+
import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
|
|
4
|
+
import { LintingRuleTag } from '../linter-tags';
|
|
5
|
+
export interface OverwrittenFileResult extends LintingResult {
|
|
6
|
+
/** the file written again */
|
|
7
|
+
readonly file: string;
|
|
8
|
+
/** the line of the earlier write the later one replaces */
|
|
9
|
+
readonly firstLine: number | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface OverwrittenFileConfig extends MergeableRecord {
|
|
12
|
+
/** functions that write a file, besides the ones the dependencies query knows */
|
|
13
|
+
readonly additionalWriteFunctions: readonly FunctionInfo[];
|
|
14
|
+
}
|
|
15
|
+
export interface OverwrittenFileMetadata extends MergeableRecord {
|
|
16
|
+
/** the number of distinct files written to */
|
|
17
|
+
readonly totalFiles: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const OVERWRITTEN_FILE: {
|
|
20
|
+
readonly createSearch: (config: OverwrittenFileConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["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>[]>>>;
|
|
21
|
+
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: OverwrittenFileConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
22
|
+
results: OverwrittenFileResult[];
|
|
23
|
+
".meta": OverwrittenFileMetadata;
|
|
24
|
+
}>;
|
|
25
|
+
readonly prettyPrint: {
|
|
26
|
+
readonly query: (r: OverwrittenFileResult, metadata: unknown) => string;
|
|
27
|
+
readonly full: (r: OverwrittenFileResult, metadata: unknown) => string;
|
|
28
|
+
};
|
|
29
|
+
readonly info: {
|
|
30
|
+
readonly name: "Overwritten File";
|
|
31
|
+
readonly description: "Finds files the script writes more than once, so the later write replaces what the earlier one wrote, as two figures saved under the same name.";
|
|
32
|
+
readonly tags: readonly [LintingRuleTag.Bug, LintingRuleTag.Reproducibility];
|
|
33
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
34
|
+
readonly defaultConfig: () => {
|
|
35
|
+
additionalWriteFunctions: never[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OVERWRITTEN_FILE = void 0;
|
|
4
|
+
const linter_format_1 = require("../linter-format");
|
|
5
|
+
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
6
|
+
const range_1 = require("../../util/range");
|
|
7
|
+
const dependencies_query_format_1 = require("../../queries/catalog/dependencies-query/dependencies-query-format");
|
|
8
|
+
const linter_tags_1 = require("../linter-tags");
|
|
9
|
+
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
10
|
+
const logic_1 = require("../../util/logic");
|
|
11
|
+
const happens_before_1 = require("../../control-flow/happens-before");
|
|
12
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
13
|
+
const r_logical_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-logical");
|
|
14
|
+
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
15
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
16
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
17
|
+
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
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
|
+
/** `append = TRUE`, or a connection opened in an append mode like `file(p, "a")` */
|
|
22
|
+
function appends(id, idMap, opens) {
|
|
23
|
+
const node = idMap.get(id);
|
|
24
|
+
if (!r_function_call_1.RFunctionCall.is(node)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const named = (a, name) => a !== r_function_call_1.EmptyArgument && a.name !== undefined && identifier_1.Identifier.getName(a.name.content) === name;
|
|
28
|
+
const mode = node.arguments.find(a => named(a, 'open')) ?? (opens(id) ? node.arguments[1] : undefined);
|
|
29
|
+
return node.arguments.some(a => named(a, 'append') && a !== r_function_call_1.EmptyArgument && r_logical_1.RLogical.is(a.value) && a.value.content)
|
|
30
|
+
|| (mode !== undefined && mode !== r_function_call_1.EmptyArgument && (mode.name === undefined || named(mode, 'open')) && r_string_1.RString.is(mode.value) && /^a[tb+]*$/.test(mode.value.content.str));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The writes that each start the file anew, per file. A call of a function of the program stands for the write in its
|
|
34
|
+
* body when it names the same file, and the writes into a connection belong to the call opening it.
|
|
35
|
+
*/
|
|
36
|
+
function writesPerFile(writes, idMap, opens) {
|
|
37
|
+
const named = writes.filter((w) => w.nodeId !== undefined && typeof w.value === 'string' && w.value !== dependencies_query_format_1.Unknown && !ConsoleStreams.has(w.value));
|
|
38
|
+
const viaCalls = new Set(named.filter(w => w.via !== undefined).map(w => `${String(w.via)}\0${w.value}`));
|
|
39
|
+
const opened = new Set(named.filter(w => opens(w.nodeId)).map(w => w.value));
|
|
40
|
+
const perFile = new Map();
|
|
41
|
+
for (const w of named) {
|
|
42
|
+
const stream = opened.has(w.value) && !opens(w.nodeId);
|
|
43
|
+
if (stream || viaCalls.has(`${String(w.nodeId)}\0${w.value}`) || appends(w.nodeId, idMap, opens)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const found = perFile.get(w.value) ?? [];
|
|
47
|
+
if (!found.some(f => f.at === w.nodeId && f.within === w.via)) {
|
|
48
|
+
found.push({ at: w.nodeId, within: w.via });
|
|
49
|
+
}
|
|
50
|
+
perFile.set(w.value, found);
|
|
51
|
+
}
|
|
52
|
+
return perFile;
|
|
53
|
+
}
|
|
54
|
+
exports.OVERWRITTEN_FILE = {
|
|
55
|
+
createSearch: config => flowr_search_builder_1.Q.fromQuery({
|
|
56
|
+
type: 'dependencies',
|
|
57
|
+
enabledCategories: ['write'],
|
|
58
|
+
writeFunctions: config.additionalWriteFunctions
|
|
59
|
+
}).with(search_enrichers_1.Enrichment.CfgInformation),
|
|
60
|
+
processSearchResult: async (elements, _config, data) => {
|
|
61
|
+
const cfg = elements.enrichmentContent(search_enrichers_1.Enrichment.CfgInformation).cfg.graph;
|
|
62
|
+
const writes = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData).queries['dependencies'].write ?? [];
|
|
63
|
+
const df = await data.dataflow();
|
|
64
|
+
const idMap = (await data.normalize()).idMap;
|
|
65
|
+
const opens = (id) => function_semantics_1.FunctionSemantics.call.props.hasAny((0, query_fn_props_1.callFnProps)(id, df), built_in_props_1.SemanticCallTag.Opens);
|
|
66
|
+
const perFile = writesPerFile(writes, idMap, opens);
|
|
67
|
+
const lineOf = (id) => id === undefined ? undefined : range_1.SourceLocation.fromNode(idMap.get(id))?.[0];
|
|
68
|
+
/* a call writing the file twice through the body of the function it calls is told by the writes in that body */
|
|
69
|
+
const where = (w, other) => w.at === other.at && w.within !== undefined ? w.within : w.at;
|
|
70
|
+
const results = [];
|
|
71
|
+
for (const [file, found] of perFile) {
|
|
72
|
+
const ordered = found.toSorted((a, b) => (lineOf(a.at) ?? 0) - (lineOf(b.at) ?? 0) || (lineOf(a.within) ?? 0) - (lineOf(b.within) ?? 0));
|
|
73
|
+
for (let i = 1; i < ordered.length; i++) {
|
|
74
|
+
const [before, after] = [where(ordered[i - 1], ordered[i]), where(ordered[i], ordered[i - 1])];
|
|
75
|
+
const loc = range_1.SourceLocation.fromNode(idMap.get(after));
|
|
76
|
+
if (loc === undefined) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const surely = cfg.hasVertex(before) && cfg.hasVertex(after) && (0, happens_before_1.happensBefore)(cfg, before, after) === logic_1.Ternary.Always;
|
|
80
|
+
results.push({
|
|
81
|
+
certainty: surely ? linter_format_1.LintingResultCertainty.Certain : linter_format_1.LintingResultCertainty.Uncertain,
|
|
82
|
+
involvedId: after,
|
|
83
|
+
loc,
|
|
84
|
+
file,
|
|
85
|
+
firstLine: lineOf(before)
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return { results, '.meta': { totalFiles: perFile.size } };
|
|
90
|
+
},
|
|
91
|
+
prettyPrint: (0, linter_format_1.prettyPrint)((result) => `\`${result.file}\` is written again, replacing what line ${result.firstLine ?? '?'} wrote to it`),
|
|
92
|
+
info: {
|
|
93
|
+
name: 'Overwritten File',
|
|
94
|
+
description: 'Finds files the script writes more than once, so the later write replaces what the earlier one wrote, as two figures saved under the same name.',
|
|
95
|
+
tags: [linter_tags_1.LintingRuleTag.Bug, linter_tags_1.LintingRuleTag.Reproducibility],
|
|
96
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
97
|
+
defaultConfig: () => ({
|
|
98
|
+
additionalWriteFunctions: []
|
|
99
|
+
})
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
//# sourceMappingURL=overwritten-file.js.map
|
|
@@ -2,11 +2,21 @@ 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 { InputType } from '../../queries/catalog/input-sources-query/simple-input-classifier';
|
|
5
6
|
import type { ReadOnlyFlowrAnalyzerContext } from '../../project/context/flowr-analyzer-context';
|
|
6
7
|
export interface PipeCommandFunctionSpec {
|
|
7
|
-
pattern: string;
|
|
8
|
+
pattern: string | RegExp;
|
|
8
9
|
argIdx: number;
|
|
9
10
|
argName: string;
|
|
11
|
+
allowedValues?: string | RegExp;
|
|
12
|
+
disallowedValues?: string | RegExp;
|
|
13
|
+
}
|
|
14
|
+
export interface ConsiderSpec {
|
|
15
|
+
pattern: string | RegExp;
|
|
16
|
+
allowedInputTypes?: InputType[];
|
|
17
|
+
allowedValues?: string | RegExp;
|
|
18
|
+
disallowedValues?: string | RegExp;
|
|
19
|
+
resolveSourceArgs?: boolean;
|
|
10
20
|
}
|
|
11
21
|
export interface ProblematicInputsResult extends LintingResult {
|
|
12
22
|
name: string;
|
|
@@ -14,9 +24,9 @@ export interface ProblematicInputsResult extends LintingResult {
|
|
|
14
24
|
pipeCommand?: string;
|
|
15
25
|
}
|
|
16
26
|
export interface ProblematicInputsConfig extends MergeableRecord {
|
|
17
|
-
consider?: string |
|
|
27
|
+
consider?: string | string[] | ConsiderSpec | ConsiderSpec[];
|
|
18
28
|
inputFns?: InputClassifierConfig;
|
|
19
|
-
pipeCommandFunctions?: PipeCommandFunctionSpec |
|
|
29
|
+
pipeCommandFunctions?: PipeCommandFunctionSpec | PipeCommandFunctionSpec[];
|
|
20
30
|
}
|
|
21
31
|
export declare const PROBLEMATIC_INPUTS: {
|
|
22
32
|
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>[]>>>;
|
|
@@ -24,8 +34,8 @@ export declare const PROBLEMATIC_INPUTS: {
|
|
|
24
34
|
results: ProblematicInputsResult[];
|
|
25
35
|
}>;
|
|
26
36
|
readonly prettyPrint: {
|
|
27
|
-
readonly query: (
|
|
28
|
-
readonly full: (
|
|
37
|
+
readonly query: (r: ProblematicInputsResult, metadata: unknown) => string;
|
|
38
|
+
readonly full: (r: ProblematicInputsResult, metadata: unknown) => string;
|
|
29
39
|
};
|
|
30
40
|
readonly info: {
|
|
31
41
|
readonly name: "Problematic Inputs";
|
|
@@ -33,7 +43,7 @@ export declare const PROBLEMATIC_INPUTS: {
|
|
|
33
43
|
readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Smell, LintingRuleTag.Readability, LintingRuleTag.Performance];
|
|
34
44
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
35
45
|
readonly defaultConfig: (ctx: ReadOnlyFlowrAnalyzerContext) => {
|
|
36
|
-
consider: readonly
|
|
46
|
+
consider: readonly ConsiderSpec[];
|
|
37
47
|
pipeCommandFunctions: readonly PipeCommandFunctionSpec[];
|
|
38
48
|
};
|
|
39
49
|
};
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PROBLEMATIC_INPUTS = void 0;
|
|
4
4
|
const linter_format_1 = require("../linter-format");
|
|
5
|
-
const arrays_1 = require("../../util/collections/arrays");
|
|
6
5
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
7
6
|
const range_1 = require("../../util/range");
|
|
8
7
|
const linter_tags_1 = require("../linter-tags");
|
|
@@ -20,21 +19,42 @@ const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument
|
|
|
20
19
|
/** what runs a command, and what evaluates code beyond looking up a name (`get`) or calling a function it is handed (`do.call`) */
|
|
21
20
|
function defaultConsider(index) {
|
|
22
21
|
const evaluates = index.with(built_in_props_1.SemanticCallTag.Eval).filter(n => ((index.propsOf(n) ?? 0) & built_in_props_1.CallProp.Pure) === 0 && !index.get(n)?.sig?.some(([, p]) => (p & built_in_props_1.ArgProp.Callee) !== 0));
|
|
23
|
-
|
|
22
|
+
const constants = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
|
|
23
|
+
return [
|
|
24
|
+
...index.with(built_in_props_1.SemanticCallTag.Process).map(n => ({ pattern: `^${(0, strings_1.escapeRegex)(identifier_1.Identifier.getName(n))}$` })),
|
|
25
|
+
/* evaluating a known value (`source("a.R")`) is harmless, only `eval` additionally has its code argument inspected */
|
|
26
|
+
...evaluates.map(n => {
|
|
27
|
+
const name = identifier_1.Identifier.getName(n);
|
|
28
|
+
return { pattern: `^${(0, strings_1.escapeRegex)(name)}$`, allowedInputTypes: constants, ...name === 'eval' ? { resolveSourceArgs: true } : {} };
|
|
29
|
+
})
|
|
30
|
+
].concat({ pattern: '^fread$' });
|
|
24
31
|
}
|
|
25
32
|
const defaultPipeCommandFunctions = [
|
|
26
|
-
{ pattern:
|
|
27
|
-
{ pattern:
|
|
28
|
-
{ pattern:
|
|
33
|
+
{ pattern: /^pdf$/, argIdx: 0, argName: 'file' },
|
|
34
|
+
{ pattern: /^postscript$/, argIdx: 0, argName: 'file' },
|
|
35
|
+
{ pattern: /^bitmap$/, argIdx: 0, argName: 'file' }
|
|
29
36
|
];
|
|
30
|
-
function normalizePatternList(cfg
|
|
31
|
-
|
|
37
|
+
function normalizePatternList(cfg) {
|
|
38
|
+
const raw = (Array.isArray(cfg) ? cfg : cfg !== undefined ? [cfg] : []).map(s => typeof s === 'string' ? { pattern: s } : s);
|
|
39
|
+
return raw.map(s => ({
|
|
40
|
+
pattern: typeof s.pattern === 'string' ? new RegExp(s.pattern) : s.pattern,
|
|
41
|
+
allowedInputTypes: s.allowedInputTypes,
|
|
42
|
+
allowedValues: typeof s.allowedValues === 'string' ? new RegExp(s.allowedValues) : s.allowedValues,
|
|
43
|
+
disallowedValues: typeof s.disallowedValues === 'string' ? new RegExp(s.disallowedValues) : s.disallowedValues,
|
|
44
|
+
resolveSourceArgs: s.resolveSourceArgs
|
|
45
|
+
}));
|
|
32
46
|
}
|
|
33
47
|
function normalizePipeSpecs(cfg) {
|
|
34
48
|
const raw = cfg === undefined ? defaultPipeCommandFunctions
|
|
35
|
-
:
|
|
49
|
+
: Array.isArray(cfg) ? (cfg.length === 0 ? defaultPipeCommandFunctions : cfg)
|
|
36
50
|
: [cfg];
|
|
37
|
-
return raw.map(s => ({
|
|
51
|
+
return raw.map(s => ({
|
|
52
|
+
pattern: typeof s.pattern === 'string' ? new RegExp(s.pattern) : s.pattern,
|
|
53
|
+
argIdx: s.argIdx,
|
|
54
|
+
argName: s.argName,
|
|
55
|
+
allowedValues: typeof s.allowedValues === 'string' ? new RegExp(s.allowedValues) : s.allowedValues,
|
|
56
|
+
disallowedValues: typeof s.disallowedValues === 'string' ? new RegExp(s.disallowedValues) : s.disallowedValues
|
|
57
|
+
}));
|
|
38
58
|
}
|
|
39
59
|
function formatInputSources(inputs, inline) {
|
|
40
60
|
return inputs.map(s => {
|
|
@@ -48,15 +68,32 @@ function formatInputSources(inputs, inline) {
|
|
|
48
68
|
function hasUnknownSource(sources) {
|
|
49
69
|
return sources.some(s => s.types.includes(simple_input_classifier_1.InputType.Unknown));
|
|
50
70
|
}
|
|
51
|
-
function isProblematicForAllowed(sources,
|
|
52
|
-
|
|
71
|
+
function isProblematicForAllowed(sources, evalValues, allowedTypes, allowedValues, disallowedValues) {
|
|
72
|
+
if (sources.some(s => s.types.some(t => !allowedTypes.includes(t)))) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
const values = sources.map(s => s.value).concat(evalValues);
|
|
76
|
+
if (allowedValues !== undefined && values.every(v => v === undefined || !allowedValues.test(String(v)))) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
if (disallowedValues !== undefined && values.some(v => v !== undefined && disallowedValues.test(String(v)))) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
return false;
|
|
53
83
|
}
|
|
54
84
|
/** A path starting with `|` runs a command, so anything but a constant path, user input included, may start one. */
|
|
55
|
-
function getPipeCommandValue(sources) {
|
|
85
|
+
function getPipeCommandValue(sources, allowedValues, disallowedValues) {
|
|
56
86
|
for (const s of sources) {
|
|
57
|
-
if (typeof s.value
|
|
58
|
-
|
|
87
|
+
if (typeof s.value !== 'string' || !s.value.startsWith('|')) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (allowedValues !== undefined && allowedValues.test(s.value)) {
|
|
91
|
+
continue;
|
|
59
92
|
}
|
|
93
|
+
if (disallowedValues !== undefined && !disallowedValues.test(s.value)) {
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
return s.value;
|
|
60
97
|
}
|
|
61
98
|
return undefined;
|
|
62
99
|
}
|
|
@@ -73,7 +110,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
73
110
|
const df = await data.dataflow();
|
|
74
111
|
const results = [];
|
|
75
112
|
const seen = new Set();
|
|
76
|
-
const
|
|
113
|
+
const tempFileAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant, simple_input_classifier_1.InputType.TempFile];
|
|
77
114
|
const considerPats = normalizePatternList(config.consider);
|
|
78
115
|
const pipePats = normalizePipeSpecs(config.pipeCommandFunctions);
|
|
79
116
|
for (const element of elements.getElements()) {
|
|
@@ -85,14 +122,15 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
85
122
|
continue;
|
|
86
123
|
}
|
|
87
124
|
const names = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CallTargets).targets.flatMap(t => typeof t === 'string' ? [identifier_1.Identifier.getName(identifier_1.Identifier.parse(t))] : []);
|
|
88
|
-
const name = names.find(n => pipePats.some(s => s.pattern.test(n)) || considerPats.some(p => p.test(n))) ?? '';
|
|
125
|
+
const name = names.find(n => pipePats.some(s => s.pattern.test(n)) || considerPats.some(p => p.pattern.test(n))) ?? '';
|
|
89
126
|
const pipeSpec = pipePats.find(s => s.pattern.test(name));
|
|
127
|
+
const consider = pipeSpec === undefined ? considerPats.find(s => s.pattern.test(name)) : undefined;
|
|
90
128
|
/* a pipe spec checks the file argument of the call, a considered call the call itself */
|
|
91
129
|
let target;
|
|
92
130
|
if (pipeSpec !== undefined) {
|
|
93
131
|
target = resolveFileArgId(df.graph, df.graph.getVertex(nid), pipeSpec.argIdx, pipeSpec.argName, data.inspectContext());
|
|
94
132
|
}
|
|
95
|
-
else if (
|
|
133
|
+
else if (consider !== undefined) {
|
|
96
134
|
target = nid;
|
|
97
135
|
}
|
|
98
136
|
if (target === undefined) {
|
|
@@ -103,8 +141,17 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
103
141
|
const own = res?.[criterion] ?? [];
|
|
104
142
|
/* a file argument that is an input itself (`pdf(readline())`) only shows as a source of the call */
|
|
105
143
|
const sources = target === nid || own.some(s => s.id === target) ? own : own.concat((res?.[call] ?? []).filter(s => s.id === target));
|
|
106
|
-
const pipeCommand = pipeSpec === undefined ? undefined : getPipeCommandValue(sources);
|
|
107
|
-
|
|
144
|
+
const pipeCommand = pipeSpec === undefined ? undefined : getPipeCommandValue(sources, pipeSpec.allowedValues, pipeSpec.disallowedValues);
|
|
145
|
+
const evalValues = [];
|
|
146
|
+
if (consider?.resolveSourceArgs) {
|
|
147
|
+
for (const source of sources) {
|
|
148
|
+
const arg = source.value === undefined ? df.graph.idMap?.get(source.id)?.info?.fullLexeme : undefined;
|
|
149
|
+
if (arg !== undefined) {
|
|
150
|
+
evalValues.push(arg);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (pipeCommand !== undefined || isProblematicForAllowed(sources, evalValues, consider?.allowedInputTypes ?? (pipeSpec !== undefined || sources.some(s => s.types.includes(simple_input_classifier_1.InputType.TempFile)) ? tempFileAccept : []), consider?.allowedValues, consider?.disallowedValues)) {
|
|
108
155
|
seen.add(nid);
|
|
109
156
|
const uncertain = pipeCommand === undefined && hasUnknownSource(sources);
|
|
110
157
|
results.push({
|
|
@@ -119,22 +166,19 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
119
166
|
}
|
|
120
167
|
return { results };
|
|
121
168
|
},
|
|
122
|
-
prettyPrint: {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
return `Pipe command injection via '${result.pipeCommand}' in call to ${result.name} at ${range_1.SourceLocation.format(result.loc)}`;
|
|
126
|
-
}
|
|
127
|
-
const src = formatInputSources(result.sources ?? [], true).join(', ');
|
|
128
|
-
return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + (src ? ' with inputs ' + src : '');
|
|
129
|
-
},
|
|
130
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => {
|
|
131
|
-
const lines = formatInputSources(result.sources ?? [], false);
|
|
132
|
-
const tail = lines.length ? '\nInputs:\n' + lines.join('\n') : '';
|
|
133
|
-
return result.pipeCommand !== undefined
|
|
134
|
-
? `Pipe command injection: '${result.pipeCommand}' passed as filename to ${result.name} at ${range_1.SourceLocation.format(result.loc)}${tail}`
|
|
135
|
-
: 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + ' is potentially problematic' + tail;
|
|
169
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => {
|
|
170
|
+
if (result.pipeCommand !== undefined) {
|
|
171
|
+
return `Pipe command injection via '${result.pipeCommand}' in call to ${result.name} at ${range_1.SourceLocation.format(result.loc)}`;
|
|
136
172
|
}
|
|
137
|
-
|
|
173
|
+
const src = formatInputSources(result.sources ?? [], true).join(', ');
|
|
174
|
+
return 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + (src ? ' with inputs ' + src : '');
|
|
175
|
+
}, result => {
|
|
176
|
+
const lines = formatInputSources(result.sources ?? [], false);
|
|
177
|
+
const tail = lines.length ? '\nInputs:\n' + lines.join('\n') : '';
|
|
178
|
+
return result.pipeCommand !== undefined
|
|
179
|
+
? `Pipe command injection: '${result.pipeCommand}' passed as filename to ${result.name} at ${range_1.SourceLocation.format(result.loc)}${tail}`
|
|
180
|
+
: 'Use of configured dynamic call at ' + range_1.SourceLocation.format(result.loc) + ' is potentially problematic' + tail;
|
|
181
|
+
}),
|
|
138
182
|
info: {
|
|
139
183
|
name: 'Problematic Inputs',
|
|
140
184
|
description: 'Finds 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.',
|
|
@@ -20,8 +20,8 @@ export declare const ROXYGEN_ARGS: {
|
|
|
20
20
|
'.meta': {};
|
|
21
21
|
};
|
|
22
22
|
readonly prettyPrint: {
|
|
23
|
-
readonly query: (
|
|
24
|
-
readonly full: (
|
|
23
|
+
readonly query: (r: RoxygenArgsResult, metadata: unknown) => string;
|
|
24
|
+
readonly full: (r: RoxygenArgsResult, metadata: unknown) => string;
|
|
25
25
|
};
|
|
26
26
|
readonly info: {
|
|
27
27
|
readonly name: "Roxygen Arguments";
|
|
@@ -54,10 +54,7 @@ exports.ROXYGEN_ARGS = {
|
|
|
54
54
|
}),
|
|
55
55
|
'.meta': {}
|
|
56
56
|
}),
|
|
57
|
-
prettyPrint: {
|
|
58
|
-
[linter_format_1.LintingPrettyPrintContext.Query]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`,
|
|
59
|
-
[linter_format_1.LintingPrettyPrintContext.Full]: result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`
|
|
60
|
-
},
|
|
57
|
+
prettyPrint: (0, linter_format_1.prettyPrint)(result => `Function at ${range_1.SourceLocation.format(result.loc)} has ${describeArgumentDiff(result)}`),
|
|
61
58
|
info: {
|
|
62
59
|
name: 'Roxygen Arguments',
|
|
63
60
|
tags: [linter_tags_1.LintingRuleTag.Smell, linter_tags_1.LintingRuleTag.Documentation],
|