@eagleoutice/flowr 2.16.1 → 2.16.3
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 +10 -10
- package/abstract-interpretation/data-frame/arguments.js +4 -3
- package/abstract-interpretation/data-frame/dataframe-semantics.js +1 -2
- package/abstract-interpretation/data-frame/semantics.d.ts +2 -2
- package/abstract-interpretation/data-frame/semantics.js +2 -6
- package/benchmark/slicer.js +1 -3
- package/benchmark/summarizer/first-phase/input.js +1 -12
- package/benchmark/summarizer/second-phase/process.d.ts +7 -0
- package/benchmark/summarizer/second-phase/process.js +15 -12
- package/cli/repl/commands/repl-cfg.js +18 -49
- package/cli/repl/commands/repl-clipboard.d.ts +2 -0
- package/cli/repl/commands/repl-clipboard.js +5 -0
- package/cli/repl/commands/repl-commands.js +2 -2
- package/cli/repl/commands/repl-dataflow.js +21 -55
- package/cli/repl/commands/repl-normalize.js +15 -28
- package/cli/repl/commands/repl-parse.js +2 -2
- package/cli/repl/commands/repl-query.js +10 -10
- package/cli/repl/commands/repl-signature.js +4 -4
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +8 -30
- package/cli/repl/server/messages/message-analysis.js +1 -1
- package/config.d.ts +6 -0
- package/config.js +7 -4
- package/control-flow/cfg-dead-code.js +5 -14
- package/control-flow/cfg-to-basic-blocks.js +1 -6
- package/control-flow/control-flow-graph.d.ts +2 -16
- package/control-flow/control-flow-graph.js +8 -66
- package/control-flow/diff-cfg.js +10 -23
- package/control-flow/semantic-cfg-guided-visitor.js +5 -11
- package/control-flow/simple-visitor.js +2 -2
- package/core/steps/pipeline/default-pipelines.d.ts +138 -138
- package/data/r-base-packages.generated.js +0 -1
- package/data/r-base-primitives.generated.js +0 -1
- package/data/r-s3-generics.generated.d.ts +5 -0
- package/data/r-s3-generics.generated.js +103 -0
- package/dataflow/cluster.js +2 -1
- package/dataflow/environments/append.d.ts +1 -0
- package/dataflow/environments/built-in-props.d.ts +15 -2
- package/dataflow/environments/built-in-props.js +31 -4
- package/dataflow/environments/built-in.js +15 -9
- package/dataflow/environments/clone.d.ts +1 -0
- package/dataflow/environments/clone.js +1 -0
- package/dataflow/environments/default-builtin-config.d.ts +385 -25
- package/dataflow/environments/default-builtin-config.js +186 -106
- package/dataflow/environments/define.d.ts +1 -0
- package/dataflow/environments/define.js +1 -0
- package/dataflow/environments/environment.d.ts +27 -0
- package/dataflow/environments/environment.js +37 -16
- package/dataflow/environments/frame-memory.d.ts +9 -1
- package/dataflow/environments/frame-memory.js +12 -1
- package/dataflow/environments/identifier.d.ts +1 -2
- package/dataflow/environments/identifier.js +5 -7
- package/dataflow/environments/overwrite.js +1 -0
- package/dataflow/environments/query-fn-props.d.ts +3 -0
- package/dataflow/environments/query-fn-props.js +7 -0
- package/dataflow/environments/resolve-by-name.js +11 -4
- package/dataflow/environments/scoping.d.ts +3 -0
- package/dataflow/environments/scoping.js +3 -0
- package/dataflow/eval/resolve/alias-tracking.js +3 -3
- package/dataflow/eval/resolve/resolve-argument.d.ts +7 -3
- package/dataflow/eval/resolve/resolve-argument.js +21 -12
- package/dataflow/eval/resolve/resolve-numbers.js +5 -2
- package/dataflow/eval/resolve/resolve-strings.d.ts +1 -1
- package/dataflow/eval/resolve/resolve-working-directory.js +2 -2
- package/dataflow/eval/resolve/resolve.js +1 -2
- package/dataflow/eval/values/intervals/interval-constants.js +1 -6
- package/dataflow/eval/values/r-value.js +1 -6
- package/dataflow/extractor.js +17 -17
- package/dataflow/fn/argument-roles.js +15 -15
- package/dataflow/fn/class-declaration.js +7 -7
- package/dataflow/fn/frame-reflection.d.ts +1 -23
- package/dataflow/fn/frame-reflection.js +8 -95
- package/dataflow/fn/function-props.d.ts +0 -3
- package/dataflow/fn/function-props.js +9 -11
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/fn/strict-function.js +15 -14
- package/dataflow/graph/call-graph.d.ts +8 -0
- package/dataflow/graph/call-graph.js +40 -25
- package/dataflow/graph/dataflowgraph-builder.d.ts +0 -60
- package/dataflow/graph/dataflowgraph-builder.js +15 -135
- package/dataflow/graph/df-helper.d.ts +56 -4
- package/dataflow/graph/df-helper.js +116 -1
- package/dataflow/graph/diff-dataflow-graph.js +13 -15
- package/dataflow/graph/graph-helper.d.ts +20 -0
- package/dataflow/graph/graph-helper.js +18 -0
- package/dataflow/graph/graph.js +15 -8
- package/dataflow/graph/match-args.d.ts +1 -1
- package/dataflow/graph/match-args.js +3 -3
- package/dataflow/internal/linker.d.ts +4 -10
- package/dataflow/internal/linker.js +21 -29
- package/dataflow/internal/process/functions/call/built-in/built-in-access.js +2 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +5 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +39 -22
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +19 -21
- package/dataflow/internal/process/functions/call/built-in/built-in-attach.js +3 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-env-contents.js +6 -11
- package/dataflow/internal/process/functions/call/built-in/built-in-envir-utils.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-eval.js +14 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +27 -13
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +6 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +33 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +3 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +6 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +12 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-list.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-load.js +7 -8
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-new-env.js +3 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-pipe.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-purrr-formula.js +14 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +6 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-replacement.js +5 -6
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +7 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +1 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +2 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +5 -7
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-stack-env.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +8 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +4 -5
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +3 -3
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +36 -38
- package/dataflow/internal/process/functions/call/common.d.ts +3 -1
- package/dataflow/internal/process/functions/call/common.js +6 -7
- package/dataflow/internal/process/functions/call/deferred.js +8 -8
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +11 -4
- package/dataflow/internal/process/functions/call/known-call-handling.js +11 -7
- package/dataflow/internal/process/functions/call/named-call-handling.js +64 -11
- package/dataflow/internal/process/functions/call/nse.js +4 -4
- package/dataflow/internal/process/functions/call/quoted.js +16 -14
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +2 -2
- package/dataflow/internal/process/functions/process-parameter.js +2 -2
- package/dataflow/internal/process/process-named-call.js +1 -1
- package/dataflow/origin/dfg-get-origin.js +2 -2
- package/dataflow/origin/dfg-get-symbol-refs.d.ts +1 -0
- package/dataflow/origin/dfg-get-symbol-refs.js +3 -8
- package/documentation/data/faq/wiki-faq-store.js +2 -2
- package/documentation/doc-capabilities.js +2 -1
- package/documentation/doc-util/doc-functions.js +2 -2
- package/documentation/doc-util/doc-repl.js +4 -4
- package/documentation/doc-util/doc-types.js +2 -2
- package/documentation/wiki-absint.js +2 -1
- package/documentation/wiki-cfg.js +2 -1
- package/documentation/wiki-create-linting-rules.js +1 -1
- package/documentation/wiki-dataflow-graph.js +6 -6
- package/documentation/wiki-interface.js +3 -2
- package/documentation/wiki-linter.js +54 -4
- package/documentation/wiki-mk/doc-maker.js +1 -2
- package/documentation/wiki-query.js +25 -0
- package/documentation/wiki-search.js +2 -1
- package/documentation/wiki-signature-database.js +0 -2
- package/linter/linter-executor.js +4 -0
- package/linter/linter-rules.d.ts +526 -4
- package/linter/linter-rules.js +39 -1
- package/linter/linter-tags.d.ts +6 -0
- package/linter/linter-tags.js +6 -0
- package/linter/rules/absolute-path.js +4 -3
- package/linter/rules/cmd-check/bogus-return.d.ts +29 -0
- package/linter/rules/cmd-check/bogus-return.js +63 -0
- package/linter/rules/cmd-check/call-arguments.d.ts +63 -0
- package/linter/rules/cmd-check/call-arguments.js +211 -0
- package/linter/rules/cmd-check/class-string-comparison.d.ts +48 -0
- package/linter/rules/cmd-check/class-string-comparison.js +135 -0
- package/linter/rules/cmd-check/cmd-check-util.d.ts +67 -0
- package/linter/rules/cmd-check/cmd-check-util.js +169 -0
- package/linter/rules/cmd-check/compiled-code.d.ts +86 -0
- package/linter/rules/cmd-check/compiled-code.js +350 -0
- package/linter/rules/cmd-check/conformance.d.ts +47 -0
- package/linter/rules/cmd-check/conformance.js +166 -0
- package/linter/rules/cmd-check/dependency-declaration.d.ts +95 -0
- package/linter/rules/cmd-check/dependency-declaration.js +299 -0
- package/linter/rules/cmd-check/description-metadata.d.ts +63 -0
- package/linter/rules/cmd-check/description-metadata.js +393 -0
- package/linter/rules/cmd-check/documentation-mismatch.d.ts +54 -0
- package/linter/rules/cmd-check/documentation-mismatch.js +407 -0
- package/linter/rules/cmd-check/file-checks.d.ts +29 -0
- package/linter/rules/cmd-check/file-checks.js +34 -0
- package/linter/rules/cmd-check/foreign-function-calls.d.ts +54 -0
- package/linter/rules/cmd-check/foreign-function-calls.js +115 -0
- package/linter/rules/cmd-check/global-environment-modification.d.ts +61 -0
- package/linter/rules/cmd-check/global-environment-modification.js +237 -0
- package/linter/rules/cmd-check/namespace-tampering.d.ts +52 -0
- package/linter/rules/cmd-check/namespace-tampering.js +162 -0
- package/linter/rules/cmd-check/non-ascii-code.d.ts +51 -0
- package/linter/rules/cmd-check/non-ascii-code.js +112 -0
- package/linter/rules/cmd-check/package-code.d.ts +30 -0
- package/linter/rules/cmd-check/package-code.js +141 -0
- package/linter/rules/cmd-check/package-data.d.ts +49 -0
- package/linter/rules/cmd-check/package-data.js +181 -0
- package/linter/rules/cmd-check/package-files.d.ts +41 -0
- package/linter/rules/cmd-check/package-files.js +157 -0
- package/linter/rules/cmd-check/package-hooks.d.ts +57 -0
- package/linter/rules/cmd-check/package-hooks.js +165 -0
- package/linter/rules/cmd-check/package-metafiles.d.ts +49 -0
- package/linter/rules/cmd-check/package-metafiles.js +292 -0
- package/linter/rules/cmd-check/package-runtime.d.ts +67 -0
- package/linter/rules/cmd-check/package-runtime.js +284 -0
- package/linter/rules/cmd-check/package-structure.d.ts +85 -0
- package/linter/rules/cmd-check/package-structure.js +320 -0
- package/linter/rules/cmd-check/rd-files.d.ts +67 -0
- package/linter/rules/cmd-check/rd-files.js +621 -0
- package/linter/rules/cmd-check/s-three-method-consistency.d.ts +72 -0
- package/linter/rules/cmd-check/s-three-method-consistency.js +206 -0
- package/linter/rules/cmd-check/true-false-abbreviation.d.ts +45 -0
- package/linter/rules/cmd-check/true-false-abbreviation.js +121 -0
- package/linter/rules/deprecated-functions.js +4 -4
- package/linter/rules/function-finder-util.d.ts +1 -1
- package/linter/rules/function-finder-util.js +1 -3
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +13 -14
- package/linter/rules/network-functions.d.ts +4 -3
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +8 -3
- package/linter/rules/no-leaked-credentials.js +134 -36
- package/linter/rules/problematic-inputs.d.ts +1 -1
- package/linter/rules/problematic-inputs.js +21 -14
- package/linter/rules/seeded-randomness.js +5 -5
- package/linter/rules/software-has-license.d.ts +1 -1
- package/linter/rules/software-has-license.js +1 -1
- package/linter/rules/unclosed-connection.js +3 -3
- package/linter/rules/undefined-symbol-util.js +16 -32
- package/linter/rules/undefined-symbol.d.ts +2 -0
- package/linter/rules/undefined-symbol.js +33 -3
- package/linter/rules/unescaped-arguments.d.ts +13 -2
- package/linter/rules/unescaped-arguments.js +104 -15
- package/linter/rules/unused-definition.js +13 -19
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.js +1 -1
- package/project/context/flowr-analyzer-context.js +1 -1
- package/project/context/flowr-analyzer-environment-context.d.ts +1 -1
- package/project/context/flowr-analyzer-files-context.d.ts +6 -0
- package/project/context/flowr-analyzer-files-context.js +3 -0
- package/project/context/flowr-analyzer-incremental-analysis-context.d.ts +0 -2
- package/project/context/flowr-analyzer-incremental-analysis-context.js +0 -4
- package/project/context/flowr-file.d.ts +4 -0
- package/project/context/flowr-file.js +4 -0
- package/project/flowr-analyzer-builder.js +1 -1
- package/project/plugins/file-plugins/files/flowr-description-file.js +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +11 -14
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +3 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +25 -15
- package/project/plugins/file-plugins/files/flowr-rd-file.d.ts +44 -0
- package/project/plugins/file-plugins/files/flowr-rd-file.js +130 -61
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +0 -1
- package/project/plugins/file-plugins/files/flowr-rda-file.js +4 -16
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +4 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-sweave-file.js +4 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.d.ts +0 -1
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-description-file-plugin.js +1 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +2 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-session-info-plugin.js +3 -7
- package/project/sigdb/build.js +16 -30
- package/project/sigdb/dict.d.ts +4 -6
- package/project/sigdb/dict.js +125 -31
- package/project/sigdb/reader.js +2 -18
- package/project/sigdb/sigdb-download.js +14 -23
- package/queries/base-query-format.d.ts +2 -0
- package/queries/base-query-format.js +10 -2
- package/queries/catalog/absint-query/absint-query-format.d.ts +1 -1
- package/queries/catalog/absint-query/absint-query-format.js +5 -7
- package/queries/catalog/call-context-query/call-context-query-executor.js +26 -33
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +1 -1
- package/queries/catalog/call-context-query/call-context-query-format.js +1 -3
- package/queries/catalog/call-context-query/identify-link-to-last-call-relation.js +2 -4
- package/queries/catalog/call-context-query/identify-link-to-nested-call-relation.js +1 -4
- package/queries/catalog/call-graph-query/call-graph-query-format.js +2 -3
- package/queries/catalog/config-query/config-query-format.js +3 -3
- package/queries/catalog/dataflow-lens-query/dataflow-lens-query-format.js +2 -3
- package/queries/catalog/dataflow-query/dataflow-query-format.js +2 -3
- package/queries/catalog/dependencies-query/data-flow.d.ts +43 -0
- package/queries/catalog/dependencies-query/data-flow.js +173 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.d.ts +18 -0
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +108 -12
- package/queries/catalog/dependencies-query/dependencies-query-format.d.ts +17 -1
- package/queries/catalog/dependencies-query/dependencies-query-format.js +14 -11
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +2 -1
- package/queries/catalog/dependencies-query/function-info/function-info.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/library-functions.js +13 -13
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/remote-functions.js +3 -3
- package/queries/catalog/dependencies-query/function-info/source-functions.js +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.js +8 -8
- package/queries/catalog/dependencies-query/function-info/transform-functions.d.ts +8 -0
- package/queries/catalog/dependencies-query/function-info/transform-functions.js +17 -0
- package/queries/catalog/dependencies-query/function-info/write-functions.js +4 -0
- package/queries/catalog/dependencies-query/implicit-echo.d.ts +5 -3
- package/queries/catalog/dependencies-query/implicit-echo.js +33 -34
- package/queries/catalog/dependencies-query/link-devices.d.ts +3 -2
- package/queries/catalog/dependencies-query/link-devices.js +9 -6
- package/queries/catalog/dependencies-query/plot-description.d.ts +10 -0
- package/queries/catalog/dependencies-query/plot-description.js +119 -0
- package/queries/catalog/dependencies-query/plot-objects.d.ts +13 -0
- package/queries/catalog/dependencies-query/plot-objects.js +61 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +2 -2
- package/queries/catalog/dice-query/dice-query-format.js +3 -40
- package/queries/catalog/does-call-query/does-call-query-format.d.ts +1 -1
- package/queries/catalog/does-call-query/does-call-query-format.js +2 -2
- package/queries/catalog/function-info-query/function-info-query-format.js +2 -2
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-executor.js +2 -1
- package/queries/catalog/guess-dep-versions-query/guess-dep-versions-query-format.js +2 -2
- package/queries/catalog/happens-before-query/happens-before-query-format.js +2 -2
- package/queries/catalog/id-map-query/id-map-query-format.js +1 -3
- package/queries/catalog/input-sources-query/input-source-functions.d.ts +6 -4
- package/queries/catalog/input-sources-query/input-source-functions.js +11 -6
- package/queries/catalog/input-sources-query/input-sources-query-executor.js +3 -3
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +1 -1
- package/queries/catalog/input-sources-query/input-sources-query-format.js +11 -5
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +12 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +237 -40
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +4 -7
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-executor.js +1 -1
- package/queries/catalog/inspect-fn-props-query/inspect-fn-props-query-format.js +3 -2
- package/queries/catalog/inspect-recursion-query/inspect-recursion-query-executor.js +2 -2
- package/queries/catalog/linter-query/linter-query-executor.js +10 -3
- package/queries/catalog/linter-query/linter-query-format.d.ts +4 -1
- package/queries/catalog/linter-query/linter-query-format.js +32 -21
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +1 -1
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -3
- package/queries/catalog/normalized-ast-query/normalized-ast-query-format.js +2 -3
- package/queries/catalog/origin-query/origin-query-executor.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-executor.js +3 -3
- package/queries/catalog/origin-query/origin-query-format.d.ts +1 -1
- package/queries/catalog/origin-query/origin-query-format.js +4 -5
- package/queries/catalog/project-query/project-query-format.js +2 -2
- package/queries/catalog/provenance-query/provenance-query-format.js +2 -3
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +1 -1
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +4 -4
- package/queries/catalog/search-query/search-query-format.js +1 -3
- package/queries/catalog/signature-query/signature-query-executor.js +3 -3
- package/queries/catalog/signature-query/signature-query-format.js +2 -2
- package/queries/catalog/slice-query-options.d.ts +16 -0
- package/queries/catalog/slice-query-options.js +28 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -2
- package/queries/catalog/static-slice-query/static-slice-query-format.js +3 -42
- package/queries/query-print.d.ts +4 -0
- package/queries/query-print.js +17 -1
- package/queries/query.d.ts +3 -3
- package/queries/query.js +3 -4
- package/r-bridge/lang-4.x/ast/model/model.d.ts +27 -3
- package/r-bridge/lang-4.x/ast/model/model.js +28 -1
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/info/r-delimiter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +20 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +25 -1
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +18 -2
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.js +15 -6
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +17 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.js +20 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.js +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +2 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.js +1 -0
- package/r-bridge/lang-4.x/ast/model/operators.js +0 -2
- package/r-bridge/lang-4.x/ast/model/processing/decorate.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/fold.js +1 -6
- package/r-bridge/lang-4.x/ast/model/processing/node-id.js +4 -3
- package/r-bridge/lang-4.x/ast/parser/json/format.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/control/normalize-if-then.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-argument.js +2 -2
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-call.js +4 -20
- package/r-bridge/lang-4.x/ast/parser/main/internal/functions/normalize-definition.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-next.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-repeat.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/loops/normalize-while.js +2 -9
- package/r-bridge/lang-4.x/ast/parser/main/internal/normalize-access.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-binary.js +2 -10
- package/r-bridge/lang-4.x/ast/parser/main/internal/operators/normalize-unary.js +2 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/structure/normalize-expressions.js +3 -11
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-symbol.js +1 -5
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.d.ts +6 -1
- package/r-bridge/lang-4.x/ast/parser/main/normalize-meta.js +7 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.d.ts +0 -10
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +30 -82
- package/r-bridge/retriever.d.ts +0 -4
- package/r-bridge/retriever.js +0 -13
- package/r-bridge/roxygen2/documentation-provider.js +3 -7
- package/r-bridge/shell.js +3 -8
- package/reconstruct/auto-select/magic-comments.js +8 -7
- package/reconstruct/inline/source-inline-map.d.ts +3 -0
- package/reconstruct/inline/source-inline-map.js +8 -7
- package/reconstruct/reconstruct.d.ts +1 -1
- package/reconstruct/reconstruct.js +33 -109
- package/search/flowr-search-printer.js +4 -15
- package/search/search-executor/search-enrichers.js +5 -3
- package/search/search-executor/search-generators.js +1 -1
- package/slicing/criterion/filters/all-variables.js +1 -2
- package/slicing/static/fingerprint.js +11 -2
- package/slicing/static/slice-call.d.ts +2 -8
- package/slicing/static/slice-call.js +8 -18
- package/slicing/static/static-slicer.js +81 -6
- package/util/collections/arrays.js +1 -1
- package/util/collections/set.js +1 -1
- package/util/diff-graph.d.ts +4 -0
- package/util/diff-graph.js +12 -0
- package/util/files.js +2 -6
- package/util/json.js +1 -15
- package/util/mermaid/cfg.js +10 -17
- package/util/mermaid/dfg.js +6 -8
- package/util/objects.d.ts +1 -1
- package/util/quads.js +4 -13
- package/util/r-author.js +5 -5
- package/util/range.d.ts +9 -0
- package/util/range.js +11 -0
- package/util/schema.js +3 -3
- package/util/simple-df/dfg-view.js +2 -1
- package/util/text/ansi.js +1 -2
- package/util/text/playground-link.js +2 -1
- package/util/text/r-highlight.js +2 -1
- package/util/text/strings.d.ts +2 -0
- package/util/text/strings.js +5 -0
- package/util/text/time.js +1 -2
- package/util/version.js +4 -3
- package/dataflow/fn/recursive-function.d.ts +0 -6
- package/dataflow/fn/recursive-function.js +0 -32
- package/dataflow/internal/process/functions/call/argument/unpack-argument.d.ts +0 -16
- package/dataflow/internal/process/functions/call/argument/unpack-argument.js +0 -27
|
@@ -10,13 +10,13 @@ const logic_1 = require("../../util/logic");
|
|
|
10
10
|
const source_functions_1 = require("../../queries/catalog/dependencies-query/function-info/source-functions");
|
|
11
11
|
const write_functions_1 = require("../../queries/catalog/dependencies-query/function-info/write-functions");
|
|
12
12
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
13
|
-
const
|
|
13
|
+
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
14
14
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
15
15
|
/**
|
|
16
16
|
* What an address looks like when one is written down. A call is only a network operation for the argument it
|
|
17
17
|
* is actually handed, so this is what decides that per call site rather than the name alone.
|
|
18
18
|
*/
|
|
19
|
-
const UrlPattern = /^(https?|ftps?):\/\//;
|
|
19
|
+
const UrlPattern = /^(https?|ftps?|sftp|scp|wss?):\/\//;
|
|
20
20
|
/** the parameter names that mean "the address", preferred over any other resource the same call names */
|
|
21
21
|
const AddressNames = new Set(['url', 'urls', 'uri', 'href', 'link', 'address', 'repo', 'repo_spec', 'pull']);
|
|
22
22
|
/**
|
|
@@ -29,16 +29,17 @@ function addressParam(params) {
|
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* Every built-in that may reach the network, read back from the {@link DefaultBuiltinConfig}: the ones labeled
|
|
32
|
-
* {@link SemanticCallTag.Network} always do
|
|
33
|
-
*
|
|
34
|
-
* built-in `Network` or give it a resource
|
|
32
|
+
* {@link SemanticCallTag.Network} always do unless they may open a local {@link SemanticCallTag.File} instead,
|
|
33
|
+
* and any call naming an {@link ArgProp.Resource} does whenever that resource is a url rather than a path --
|
|
34
|
+
* which is what {@link UrlPattern} decides per call site. Label a built-in `Network` or give it a resource
|
|
35
|
+
* parameter and it shows up here; nothing is listed twice.
|
|
35
36
|
*/
|
|
36
37
|
function networkFunctions(index) {
|
|
37
38
|
const resources = new Map();
|
|
38
39
|
for (const param of index.params(built_in_props_1.ArgProp.Resource)) {
|
|
39
|
-
/* R opens a path it writes to as a local file (or a `|` pipe), never as a url */
|
|
40
|
+
/* R opens a path it writes to as a local file (or a `|` pipe), never as a url, and a command is no address either */
|
|
40
41
|
const tags = index.get(param.call)?.tags;
|
|
41
|
-
if (tags?.includes(built_in_props_1.SemanticCallTag.Writes) && !tags.includes(built_in_props_1.SemanticCallTag.Reads)) {
|
|
42
|
+
if ((tags?.includes(built_in_props_1.SemanticCallTag.Writes) && !tags.includes(built_in_props_1.SemanticCallTag.Reads)) || tags?.includes(built_in_props_1.SemanticCallTag.Process)) {
|
|
42
43
|
continue;
|
|
43
44
|
}
|
|
44
45
|
const key = identifier_1.Identifier.toString(param.call);
|
|
@@ -53,17 +54,17 @@ function networkFunctions(index) {
|
|
|
53
54
|
return [...names].map(([key, name]) => {
|
|
54
55
|
const params = resources.get(key);
|
|
55
56
|
const address = params === undefined ? undefined : addressParam(params);
|
|
57
|
+
const tags = index.get(name)?.tags;
|
|
56
58
|
return {
|
|
57
59
|
name,
|
|
58
60
|
...(address === undefined ? {} : { info: { argIdx: address.index, argName: address.name, resolveValue: true } }),
|
|
59
|
-
onlyTriggerWithArgument: UrlPattern
|
|
61
|
+
...(tags?.includes(built_in_props_1.SemanticCallTag.Network) && !tags.includes(built_in_props_1.SemanticCallTag.File) ? {} : { onlyTriggerWithArgument: UrlPattern })
|
|
60
62
|
};
|
|
61
63
|
});
|
|
62
64
|
}
|
|
63
65
|
exports.NETWORK_FUNCTIONS = {
|
|
64
66
|
createSearch: config => function_finder_util_1.functionFinderUtil.createSearch(config.fns.map(f => identifier_1.Identifier.is(f) ? f : f.name)),
|
|
65
67
|
processSearchResult: async (e, c, d) => {
|
|
66
|
-
const df = await d.dataflow();
|
|
67
68
|
const fnPool = new Map([
|
|
68
69
|
...(0, write_functions_1.writeFunctions)(d.inspectContext()).concat((0, read_functions_1.readFunctions)(d.inspectContext()), source_functions_1.SourceFunctions).map(f => [identifier_1.Identifier.toString(identifier_1.Identifier.make(f.name, f.package)), f]),
|
|
69
70
|
...c.fns.flatMap(f => identifier_1.Identifier.is(f) ? [] : f.info === undefined ? [] : [identifier_1.Identifier.getName(f.name), identifier_1.Identifier.toString(f.name)].map(key => [key, { name: identifier_1.Identifier.toString(f.name), ...f.info }]))
|
|
@@ -73,13 +74,14 @@ exports.NETWORK_FUNCTIONS = {
|
|
|
73
74
|
return function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, async (es) => {
|
|
74
75
|
const res = [];
|
|
75
76
|
for (const e of es) {
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
77
|
+
const target = (0, search_enrichers_1.enrichmentContent)(e, search_enrichers_1.Enrichment.CallTargets).targets.find(t => typeof t === 'string');
|
|
78
|
+
if (target === undefined) {
|
|
78
79
|
continue;
|
|
79
80
|
}
|
|
81
|
+
const identifier = identifier_1.Identifier.parse(target);
|
|
80
82
|
// we allow onlyTriggerLookup to contain non-namespaced functions
|
|
81
83
|
const requireValue = onlyTriggerLookup.get(identifier_1.Identifier.toString(identifier)) ?? onlyTriggerLookup.get(identifier_1.Identifier.getName(identifier));
|
|
82
|
-
const val = await function_finder_util_1.functionFinderUtil.requireArgumentValue(e, fnPool, d, requireValue);
|
|
84
|
+
const val = await function_finder_util_1.functionFinderUtil.requireArgumentValue(e, fnPool, d, requireValue, identifier);
|
|
83
85
|
if (val === logic_1.Ternary.Never) {
|
|
84
86
|
continue;
|
|
85
87
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
2
2
|
import type { MergeableRecord } from '../../util/objects';
|
|
3
3
|
import { LintingRuleTag } from '../linter-tags';
|
|
4
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
5
|
export interface NoLeakedCredentialsResult extends LintingResult {
|
|
5
6
|
readonly variableName: string;
|
|
6
7
|
}
|
|
@@ -9,13 +10,16 @@ export interface NoLeakedCredentialsConfig extends MergeableRecord {
|
|
|
9
10
|
readonly credentialNamePattern: string;
|
|
10
11
|
/** Pattern matched against string literal values to detect known credential formats (e.g., AWS access key IDs, GitHub tokens) */
|
|
11
12
|
readonly credentialValuePattern: string;
|
|
13
|
+
/** Pattern matched (case-insensitively) against function names whose unnamed arguments are credentials, like `httr::authenticate` */
|
|
14
|
+
readonly credentialCallPattern: string;
|
|
12
15
|
}
|
|
13
16
|
export interface NoLeakedCredentialsMetadata extends MergeableRecord {
|
|
17
|
+
/** the number of string literals checked */
|
|
14
18
|
readonly totalChecked: number;
|
|
15
19
|
}
|
|
16
20
|
export declare const NO_LEAKED_CREDENTIALS: {
|
|
17
|
-
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"],
|
|
18
|
-
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<
|
|
21
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>>;
|
|
22
|
+
readonly processSearchResult: (elements: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: NoLeakedCredentialsConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
19
23
|
results: NoLeakedCredentialsResult[];
|
|
20
24
|
".meta": NoLeakedCredentialsMetadata;
|
|
21
25
|
}>;
|
|
@@ -25,12 +29,13 @@ export declare const NO_LEAKED_CREDENTIALS: {
|
|
|
25
29
|
};
|
|
26
30
|
readonly info: {
|
|
27
31
|
readonly name: "No Leaked Credentials";
|
|
28
|
-
readonly description: "Detects hardcoded credentials assigned to variables whose names suggest they hold passwords, tokens, or API keys, or whose values match known credential formats (AWS, GitHub, Slack, Stripe, SSH).";
|
|
32
|
+
readonly description: "Detects 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).";
|
|
29
33
|
readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Experimental, LintingRuleTag.Smell];
|
|
30
34
|
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
31
35
|
readonly defaultConfig: () => {
|
|
32
36
|
credentialNamePattern: string;
|
|
33
37
|
credentialValuePattern: string;
|
|
38
|
+
credentialCallPattern: string;
|
|
34
39
|
};
|
|
35
40
|
};
|
|
36
41
|
};
|
|
@@ -7,51 +7,148 @@ 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
|
|
10
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
11
|
+
const r_access_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
12
|
+
const r_argument_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-argument");
|
|
13
|
+
const r_function_call_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
14
|
+
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
15
|
+
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
11
16
|
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
17
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
18
|
+
const defaultCredentialNamePattern = '(?:passw(?:or)?d|authorization|passphrase|(?:^|[_.])pass(?:$|[_.])|pwd|secret|api[_.]?key|access[_.]?key|(?:^|[_.])token$|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential|(?:^|[_.])pat$)';
|
|
19
|
+
const defaultCredentialCallPattern = '(?:auth|login|signin|credential|password|secret|token|key_?set)';
|
|
20
|
+
const defaultCredentialValuePattern = '(?:(?<![A-Za-z0-9_])|(?<=\\\\[nrt]))(?:' +
|
|
21
|
+
'(?:AKIA|AIPA|ASIA|AROA)[A-Z0-9]{16}' + // AWS access key IDs (exact 20-char format)
|
|
22
|
+
'|gh[psoar]_[A-Za-z0-9_]{10,}' + // GitHub Classic/App/OAuth/Actions tokens
|
|
23
|
+
'|github_pat_[A-Za-z0-9_]{10,}' + // GitHub fine-grained PATs
|
|
24
|
+
'|glpat-[A-Za-z0-9_-]{20}' + // GitLab Personal Access Tokens (fixed length)
|
|
25
|
+
'|xox[baprs]-[0-9A-Za-z]{10,}' + // Slack tokens (xoxb-, xoxp-, xoxa-, xoxr-, xoxs-)
|
|
26
|
+
'|sk_(?:live|test)_[A-Za-z0-9]{24}' + // Stripe secret/test keys (length-anchored)
|
|
27
|
+
'|rk_live_[A-Za-z0-9]{24}' + // Stripe restricted keys (length-anchored)
|
|
28
|
+
'|npm_[A-Za-z0-9]{36}' + // npm access tokens (fixed length)
|
|
29
|
+
'|shp(?:at|ss|pa|ca)_[A-Za-z0-9]{32}' + // Shopify Admin/Shared/Private/Custom tokens
|
|
30
|
+
'|sk-ant-[A-Za-z0-9_-]{10,}' + // Anthropic API keys
|
|
31
|
+
'|sk-(?:proj-)?[A-Za-z0-9_-]{20,}' + // OpenAI API keys
|
|
32
|
+
'|SG\\.[A-Za-z0-9_-]{22}\\.' + // SendGrid API keys (structured format)
|
|
33
|
+
'|AIza[0-9A-Za-z_-]{35}' + // Google API keys
|
|
34
|
+
'|hf_[A-Za-z0-9]{30,}' + // Hugging Face tokens
|
|
35
|
+
'|eyJ[A-Za-z0-9_-]{10,}\\.eyJ[A-Za-z0-9_-]{10,}\\.' + // JSON web tokens
|
|
36
|
+
'|[a-z][a-z0-9+.-]*://[^/\\s:@]+:[^/\\s@]+@' + // URLs with an embedded user and password
|
|
37
|
+
'|-----BEGIN(?:\\s[A-Z]+)* PRIVATE KEY' + // PEM private keys (RSA, EC, DSA, OpenSSH, etc.)
|
|
38
|
+
')';
|
|
39
|
+
/** what a credential-like name holds without leaking anything: a placeholder, or a path or link to look the secret up */
|
|
40
|
+
const NoCredentialValue = /^(?:<[^>]*>|\{\{.*\}\}|\$\{.*\}|your[_ -].*|x+|\*+|\.{3}|changeme|placeholder|dummy|(?:~|\.{0,2})\/.*|[a-z]+:\/\/[^@]*|(?:bearer|basic|token)\s*)$/i;
|
|
41
|
+
/** what a function asking for a credential is handed instead: a prompt, not the secret */
|
|
42
|
+
const PromptValue = /\s|[:?]$/;
|
|
43
|
+
/** names that only describe a credential: the label, prompt, or pattern of a password, the variable or file holding a key */
|
|
44
|
+
const NoCredentialName = /[_.](?:label|prompt|pattern|regex|env|var|file|path|dir|url|name|field|col|msg|message|text|title|hint|length|policy)$/i;
|
|
45
|
+
/** how many assignments a literal is followed through to the name or argument it ends up in */
|
|
46
|
+
const MaxCredentialHops = 3;
|
|
47
|
+
/** the name of a defined variable, with the fields of an access it is written through (`cfg$password`) */
|
|
48
|
+
function definedName(node, idMap) {
|
|
49
|
+
let name = node.lexeme ?? '';
|
|
50
|
+
for (const parent of model_1.RNode.iterateParents(node, idMap)) {
|
|
51
|
+
if (!r_access_1.RAccess.is(parent)) {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
for (const arg of parent.access) {
|
|
55
|
+
if (arg !== r_function_call_1.EmptyArgument && arg.value !== undefined) {
|
|
56
|
+
name += '$' + (r_string_1.RString.is(arg.value) ? arg.value.content.str : arg.value.lexeme ?? '');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return name;
|
|
61
|
+
}
|
|
62
|
+
class CredentialContexts {
|
|
63
|
+
dfg;
|
|
64
|
+
idMap;
|
|
65
|
+
callPattern;
|
|
66
|
+
namePattern;
|
|
67
|
+
pure;
|
|
68
|
+
constructor(dfg, idMap, callPattern, namePattern, pure) {
|
|
69
|
+
this.dfg = dfg;
|
|
70
|
+
this.idMap = idMap;
|
|
71
|
+
this.callPattern = callPattern;
|
|
72
|
+
this.namePattern = namePattern;
|
|
73
|
+
this.pure = pure;
|
|
74
|
+
}
|
|
75
|
+
/** the variables, arguments, or credential-taking functions a literal ends up in, followed through up to {@link MaxCredentialHops} uses */
|
|
76
|
+
of(node, hops = 0, seen = new Set()) {
|
|
77
|
+
const found = [];
|
|
78
|
+
let child = node;
|
|
79
|
+
for (const current of [node, ...model_1.RNode.iterateParents(node, this.idMap)]) {
|
|
80
|
+
if (r_function_definition_1.RFunctionDefinition.is(current)) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
const fn = r_function_call_1.RFunctionCall.calledName(current) ?? '';
|
|
84
|
+
const name = identifier_1.Identifier.getName(fn);
|
|
85
|
+
/* only a value built from its arguments carries a literal on to where it is assigned, `assign` assigns its own */
|
|
86
|
+
const opaque = r_function_call_1.RFunctionCall.is(current) && r_argument_1.RArgument.is(child) && !this.pure.has(identifier_1.Identifier.getNamespace(fn) === undefined ? name : identifier_1.Identifier.toString(fn));
|
|
87
|
+
for (const def of df_helper_1.Dataflow.sourcesOf(this.dfg, current.info.id, edge_1.EdgeType.DefinedBy)) {
|
|
88
|
+
const defNode = this.idMap.get(def);
|
|
89
|
+
if (defNode !== undefined && vertex_1.DfgVertex.isVariableDefinition(this.dfg.getVertex(def)) && !seen.has(def) && (!opaque || model_1.RNode.iterateParents(defNode, this.idMap).some(p => p === current))) {
|
|
90
|
+
seen.add(def);
|
|
91
|
+
found.push({ name: definedName(defNode, this.idMap), anchor: defNode }, ...this.usesOf(def, hops, seen));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (r_argument_1.RArgument.isNamed(current) && current !== node) {
|
|
95
|
+
found.push({ name: current.name.lexeme, anchor: current.name });
|
|
96
|
+
return found;
|
|
97
|
+
}
|
|
98
|
+
else if (r_function_call_1.RFunctionCall.is(current) && child === current.arguments.findLast(a => a !== r_function_call_1.EmptyArgument && a.name === undefined) && this.callPattern.test(name)
|
|
99
|
+
/* a secret handed by name (`key_set_with_value(service, password = ...)`) leaves the unnamed ones to say what it is for */
|
|
100
|
+
&& !current.arguments.some(a => a !== r_function_call_1.EmptyArgument && a.name !== undefined && this.namePattern.test(a.name.lexeme))) {
|
|
101
|
+
found.push({ name, anchor: current, handedTo: true });
|
|
102
|
+
}
|
|
103
|
+
if (opaque) {
|
|
104
|
+
return found;
|
|
105
|
+
}
|
|
106
|
+
child = current;
|
|
107
|
+
}
|
|
108
|
+
return found;
|
|
109
|
+
}
|
|
110
|
+
usesOf(def, hops, seen) {
|
|
111
|
+
return hops >= MaxCredentialHops ? [] : df_helper_1.Dataflow.sourcesOf(this.dfg, def, edge_1.EdgeType.Reads).flatMap(r => {
|
|
112
|
+
const reader = this.idMap.get(r);
|
|
113
|
+
return reader === undefined ? [] : this.of(reader, hops + 1, seen);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
26
117
|
exports.NO_LEAKED_CREDENTIALS = {
|
|
27
|
-
createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.
|
|
118
|
+
createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.Value),
|
|
28
119
|
processSearchResult: async (elements, config, data) => {
|
|
29
120
|
const namePattern = new RegExp(config.credentialNamePattern, 'i');
|
|
30
121
|
const valuePattern = new RegExp(config.credentialValuePattern);
|
|
31
122
|
const normalize = await data.normalize();
|
|
32
123
|
const dfg = (await data.dataflow()).graph;
|
|
124
|
+
const contexts = new CredentialContexts(dfg, normalize.idMap, new RegExp(config.credentialCallPattern, 'i'), namePattern, new Set(data.inspectContext().env.builtInIndex.pure.flatMap(p => [identifier_1.Identifier.getName(p), identifier_1.Identifier.toString(p)])));
|
|
33
125
|
let totalChecked = 0;
|
|
34
|
-
const results =
|
|
126
|
+
const results = new Map();
|
|
127
|
+
for (const element of elements.getElements()) {
|
|
128
|
+
const node = element.node;
|
|
129
|
+
if (!r_string_1.RString.is(node)) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
35
132
|
totalChecked++;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return [];
|
|
133
|
+
if (vertex_1.DfgVertex.isVariableDefinition(dfg.getVertex(node.info.id))) {
|
|
134
|
+
continue;
|
|
39
135
|
}
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
/* a credential-like name only leaks a
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
136
|
+
const value = node.content.str;
|
|
137
|
+
const named = contexts.of(node);
|
|
138
|
+
/* a credential-like name only leaks a real value, a credential-like value leaks under any name */
|
|
139
|
+
const leaking = valuePattern.test(value) ? named[0] ?? { name: '', anchor: node }
|
|
140
|
+
: value === '' || NoCredentialValue.test(value) ? undefined
|
|
141
|
+
: named.find(c => c.handedTo ? !PromptValue.test(value) : namePattern.test(c.name) && !NoCredentialName.test(c.name));
|
|
142
|
+
if (leaking !== undefined && !results.has(leaking.anchor.info.id)) {
|
|
143
|
+
results.set(leaking.anchor.info.id, {
|
|
48
144
|
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
49
|
-
involvedId: id,
|
|
50
|
-
variableName: name,
|
|
51
|
-
loc: range_1.SourceLocation.fromNode(
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
|
|
145
|
+
involvedId: leaking.anchor.info.id,
|
|
146
|
+
variableName: leaking.name,
|
|
147
|
+
loc: range_1.SourceLocation.fromNode(leaking.anchor) ?? range_1.SourceLocation.invalid()
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return { results: [...results.values()], '.meta': { totalChecked } };
|
|
55
152
|
},
|
|
56
153
|
prettyPrint: {
|
|
57
154
|
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => `Possible hardcoded credential in \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
@@ -59,12 +156,13 @@ exports.NO_LEAKED_CREDENTIALS = {
|
|
|
59
156
|
},
|
|
60
157
|
info: {
|
|
61
158
|
name: 'No Leaked Credentials',
|
|
62
|
-
description: 'Detects hardcoded credentials assigned to variables whose names suggest they hold passwords, tokens, or API keys, or whose values match known credential formats (AWS, GitHub, Slack, Stripe, SSH).',
|
|
159
|
+
description: 'Detects 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).',
|
|
63
160
|
tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Experimental, linter_tags_1.LintingRuleTag.Smell],
|
|
64
161
|
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
65
162
|
defaultConfig: () => ({
|
|
66
163
|
credentialNamePattern: defaultCredentialNamePattern,
|
|
67
|
-
credentialValuePattern: defaultCredentialValuePattern
|
|
164
|
+
credentialValuePattern: defaultCredentialValuePattern,
|
|
165
|
+
credentialCallPattern: defaultCredentialCallPattern
|
|
68
166
|
})
|
|
69
167
|
}
|
|
70
168
|
};
|
|
@@ -19,7 +19,7 @@ export interface ProblematicInputsConfig extends MergeableRecord {
|
|
|
19
19
|
pipeCommandFunctions?: PipeCommandFunctionSpec | readonly PipeCommandFunctionSpec[];
|
|
20
20
|
}
|
|
21
21
|
export declare const PROBLEMATIC_INPUTS: {
|
|
22
|
-
readonly createSearch: (
|
|
22
|
+
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>[]>>>;
|
|
23
23
|
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: ProblematicInputsConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => Promise<{
|
|
24
24
|
results: ProblematicInputsResult[];
|
|
25
25
|
}>;
|
|
@@ -10,15 +10,22 @@ const simple_input_classifier_1 = require("../../queries/catalog/input-sources-q
|
|
|
10
10
|
const parse_1 = require("../../slicing/criterion/parse");
|
|
11
11
|
const graph_1 = require("../../dataflow/graph/graph");
|
|
12
12
|
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
13
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
14
|
+
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
13
15
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
14
16
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
17
|
+
const strings_1 = require("../../util/text/strings");
|
|
18
|
+
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
15
19
|
const resolve_argument_1 = require("../../dataflow/eval/resolve/resolve-argument");
|
|
20
|
+
/** what runs a command, and what evaluates code beyond looking up a name (`get`) or calling a function it is handed (`do.call`) */
|
|
16
21
|
function defaultConsider(index) {
|
|
17
|
-
|
|
22
|
+
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
|
+
return [...index.with(built_in_props_1.SemanticCallTag.Process), ...evaluates].map(n => `^${(0, strings_1.escapeRegex)(identifier_1.Identifier.getName(n))}$`).concat('^fread$');
|
|
18
24
|
}
|
|
19
25
|
const defaultPipeCommandFunctions = [
|
|
20
26
|
{ pattern: '^pdf$', argIdx: 0, argName: 'file' },
|
|
21
|
-
{ pattern: '^postscript$', argIdx: 0, argName: 'file' }
|
|
27
|
+
{ pattern: '^postscript$', argIdx: 0, argName: 'file' },
|
|
28
|
+
{ pattern: '^bitmap$', argIdx: 0, argName: 'file' }
|
|
22
29
|
];
|
|
23
30
|
function normalizePatternList(cfg = []) {
|
|
24
31
|
return (0, arrays_1.isArray)(cfg) ? Array.from(new Set(cfg), s => new RegExp(s)) : [new RegExp(cfg)];
|
|
@@ -61,18 +68,12 @@ function resolveFileArgId(graph, vertex, argIdx, argName, ctx) {
|
|
|
61
68
|
return arg === undefined ? undefined : graph_1.FunctionArgument.getReference(arg);
|
|
62
69
|
}
|
|
63
70
|
exports.PROBLEMATIC_INPUTS = {
|
|
64
|
-
createSearch:
|
|
65
|
-
const toQ = (name, subkind) => ({ type: 'call-context', callName: name, callNameExact: false, subkind });
|
|
66
|
-
return flowr_search_builder_1.Q.fromQuery([
|
|
67
|
-
...normalizePatternList(config.consider).map((n, i) => toQ(n, `fn-${i}`)),
|
|
68
|
-
...normalizePipeSpecs(config.pipeCommandFunctions).map((s, i) => toQ(s.pattern, `pipe-${i}`))
|
|
69
|
-
]);
|
|
70
|
-
},
|
|
71
|
+
createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall).with(search_enrichers_1.Enrichment.CallTargets),
|
|
71
72
|
processSearchResult: async (elements, config, data) => {
|
|
72
73
|
const df = await data.dataflow();
|
|
73
74
|
const results = [];
|
|
74
75
|
const seen = new Set();
|
|
75
|
-
const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
|
|
76
|
+
const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant, simple_input_classifier_1.InputType.TempFile];
|
|
76
77
|
const considerPats = normalizePatternList(config.consider);
|
|
77
78
|
const pipePats = normalizePipeSpecs(config.pipeCommandFunctions);
|
|
78
79
|
for (const element of elements.getElements()) {
|
|
@@ -80,7 +81,11 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
80
81
|
if (seen.has(nid)) {
|
|
81
82
|
continue;
|
|
82
83
|
}
|
|
83
|
-
|
|
84
|
+
if (df_helper_1.Dataflow.isQuoted(nid, df.graph) && !(0, query_fn_props_1.quotedForWorker)(nid, df.graph, data.inspectContext().env.builtInIndex)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
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))) ?? '';
|
|
84
89
|
const pipeSpec = pipePats.find(s => s.pattern.test(name));
|
|
85
90
|
/* a pipe spec checks the file argument of the call, a considered call the call itself */
|
|
86
91
|
let target;
|
|
@@ -93,9 +98,11 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
93
98
|
if (target === undefined) {
|
|
94
99
|
continue;
|
|
95
100
|
}
|
|
96
|
-
const criterion = parse_1.SlicingCriterion.fromId(target);
|
|
97
|
-
const
|
|
98
|
-
const
|
|
101
|
+
const [criterion, call] = [parse_1.SlicingCriterion.fromId(target), parse_1.SlicingCriterion.fromId(nid)];
|
|
102
|
+
const res = (await data.query([{ type: 'input-sources', criterion: target === nid ? call : [criterion, call], config: config.inputFns }]))['input-sources']?.results;
|
|
103
|
+
const own = res?.[criterion] ?? [];
|
|
104
|
+
/* a file argument that is an input itself (`pdf(readline())`) only shows as a source of the call */
|
|
105
|
+
const sources = target === nid || own.some(s => s.id === target) ? own : own.concat((res?.[call] ?? []).filter(s => s.id === target));
|
|
99
106
|
const pipeCommand = pipeSpec === undefined ? undefined : getPipeCommandValue(sources);
|
|
100
107
|
if (pipeCommand !== undefined || isProblematicForAllowed(sources, defaultAccept)) {
|
|
101
108
|
seen.add(nid);
|
|
@@ -18,13 +18,13 @@ const r_value_1 = require("../../dataflow/eval/values/r-value");
|
|
|
18
18
|
const info_1 = require("../../dataflow/info");
|
|
19
19
|
const built_in_proc_name_1 = require("../../dataflow/environments/built-in-proc-name");
|
|
20
20
|
const edge_1 = require("../../dataflow/graph/edge");
|
|
21
|
-
const frame_reflection_1 = require("../../dataflow/fn/frame-reflection");
|
|
22
21
|
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
23
22
|
const function_semantics_1 = require("../../dataflow/fn/function-semantics");
|
|
24
23
|
const logic_1 = require("../../util/logic");
|
|
25
24
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
26
25
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
27
26
|
const resolve_helper_1 = require("../../dataflow/environments/resolve-helper");
|
|
27
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
28
28
|
exports.SEEDED_RANDOMNESS = {
|
|
29
29
|
createSearch: config => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.FunctionCall)
|
|
30
30
|
.with(search_enrichers_1.Enrichment.CallTargets, {
|
|
@@ -81,13 +81,13 @@ exports.SEEDED_RANDOMNESS = {
|
|
|
81
81
|
return loops.some(loop => writerCds?.some(cd => info_1.ControlDependency.same(cd, loop)));
|
|
82
82
|
};
|
|
83
83
|
/** a call of a draw by another name, like a parameter `f` bound to `runif` */
|
|
84
|
-
const drawsThrough = (call) =>
|
|
84
|
+
const drawsThrough = (call) => df_helper_1.Dataflow.targetsOf(graph, call, edge_1.EdgeType.Calls).some(t => node_id_1.NodeId.isBuiltIn(t) && consumers.has(node_id_1.NodeId.fromBuiltIn(t))) ? 'draw' : undefined;
|
|
85
85
|
/** the writes a draw reads the generator state from: its own, and those of the calls running the function it sits in, which link what was written before them */
|
|
86
86
|
const statesReadBy = (id) => {
|
|
87
87
|
const within = idMap === undefined ? undefined : model_1.RNode.findEnclosing(id, idMap, r_function_definition_1.RFunctionDefinition.is);
|
|
88
|
-
const callers = within === undefined ? [] :
|
|
89
|
-
const ownReads =
|
|
90
|
-
return [...ownReads, ...callers.flatMap(c =>
|
|
88
|
+
const callers = within === undefined ? [] : df_helper_1.Dataflow.sourcesOf(graph, within, edge_1.EdgeType.Calls);
|
|
89
|
+
const ownReads = df_helper_1.Dataflow.targetsOf(graph, id, edge_1.EdgeType.Reads | edge_1.EdgeType.DefinedByOnCall);
|
|
90
|
+
return [...ownReads, ...callers.flatMap(c => df_helper_1.Dataflow.targetsOf(graph, c, edge_1.EdgeType.DefinedByOnCall))];
|
|
91
91
|
};
|
|
92
92
|
/** follows the draws behind the generator state `id` reads back to where it was seeded */
|
|
93
93
|
const collectSeeding = (id, visiting, seeding) => {
|
|
@@ -10,7 +10,7 @@ export interface SoftwareHasLicenseConfig extends MergeableRecord {
|
|
|
10
10
|
}
|
|
11
11
|
export type SoftwareHasLicenseMetadata = MergeableRecord;
|
|
12
12
|
export declare const SOFTWARE_HAS_LICENSE: {
|
|
13
|
-
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from
|
|
13
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from", [], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, 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
14
|
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: SoftwareHasLicenseConfig, data: import("../..").ReadonlyFlowrAnalysisProvider<import("../..").KnownParser>) => {
|
|
15
15
|
results: SoftwareHasLicenseResult[];
|
|
16
16
|
'.meta': {};
|
|
@@ -8,7 +8,7 @@ const linter_tags_1 = require("../linter-tags");
|
|
|
8
8
|
const flowr_file_1 = require("../../project/context/flowr-file");
|
|
9
9
|
const flowr_description_file_1 = require("../../project/plugins/file-plugins/files/flowr-description-file");
|
|
10
10
|
exports.SOFTWARE_HAS_LICENSE = {
|
|
11
|
-
createSearch: () => flowr_search_builder_1.Q.
|
|
11
|
+
createSearch: () => flowr_search_builder_1.Q.from([]),
|
|
12
12
|
processSearchResult: (_elements, config, data) => {
|
|
13
13
|
const ctx = data.inspectContext();
|
|
14
14
|
const licenseFiles = ctx.files.getFilesByRole(flowr_file_1.FileRole.License);
|
|
@@ -11,7 +11,7 @@ const info_1 = require("../../dataflow/info");
|
|
|
11
11
|
const built_in_props_1 = require("../../dataflow/environments/built-in-props");
|
|
12
12
|
const query_fn_props_1 = require("../../dataflow/environments/query-fn-props");
|
|
13
13
|
const identifier_1 = require("../../dataflow/environments/identifier");
|
|
14
|
-
const
|
|
14
|
+
const df_helper_1 = require("../../dataflow/graph/df-helper");
|
|
15
15
|
const flowr_search_builder_1 = require("../../search/flowr-search-builder");
|
|
16
16
|
const range_1 = require("../../util/range");
|
|
17
17
|
const assert_1 = require("../../util/assert");
|
|
@@ -52,7 +52,7 @@ function openCallsReaching(graph, start, opens, out) {
|
|
|
52
52
|
}
|
|
53
53
|
/** The variable definition the opened connection is bound to, if it is bound to one. */
|
|
54
54
|
function bindingOf(graph, open) {
|
|
55
|
-
return
|
|
55
|
+
return df_helper_1.Dataflow.sourcesOf(graph, open, edge_1.EdgeType.DefinedBy).find(source => vertex_1.DfgVertex.isVariableDefinition(graph.getVertex(source)));
|
|
56
56
|
}
|
|
57
57
|
/** The statement `id` belongs to, i.e. the ancestor that is an element of an expression list. */
|
|
58
58
|
function enclosingStatement(idMap, id) {
|
|
@@ -79,7 +79,7 @@ function closeFix(graph, open) {
|
|
|
79
79
|
if (idMap === undefined || definition === undefined || name === undefined) {
|
|
80
80
|
return undefined;
|
|
81
81
|
}
|
|
82
|
-
const reads =
|
|
82
|
+
const reads = df_helper_1.Dataflow.sourcesOf(graph, definition, edge_1.EdgeType.Reads);
|
|
83
83
|
const statements = [definition, ...reads]
|
|
84
84
|
.map(id => range_1.SourceLocation.fromNode(enclosingStatement(idMap, liftedOutOfLoops(idMap, id, definition))))
|
|
85
85
|
.filter(assert_1.isNotUndefined);
|
|
@@ -13,6 +13,7 @@ const vertex_1 = require("../../dataflow/graph/vertex");
|
|
|
13
13
|
const type_1 = require("../../r-bridge/lang-4.x/ast/model/type");
|
|
14
14
|
const r_access_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-access");
|
|
15
15
|
const r_function_definition_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-function-definition");
|
|
16
|
+
const model_1 = require("../../r-bridge/lang-4.x/ast/model/model");
|
|
16
17
|
/**
|
|
17
18
|
* Path heuristic for an R package `inst/` resource (installed verbatim, not namespace source). Fallback for
|
|
18
19
|
* the authoritative `FileRole.Install`, covering requests that bypass the file-role plugins.
|
|
@@ -58,43 +59,34 @@ function isInSubscript(graph, id) {
|
|
|
58
59
|
return false;
|
|
59
60
|
}
|
|
60
61
|
let childId = id;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const parent = idMap.get(parentId);
|
|
64
|
-
if (parent === undefined || r_function_definition_1.RFunctionDefinition.is(parent)) {
|
|
62
|
+
for (const parent of model_1.RNode.iterateParents(idMap.get(id), idMap)) {
|
|
63
|
+
if (r_function_definition_1.RFunctionDefinition.is(parent)) {
|
|
65
64
|
return false;
|
|
66
65
|
}
|
|
67
|
-
if (r_access_1.RAccess.
|
|
66
|
+
if (r_access_1.RAccess.isIndex(parent) && parent.accessed.info.id !== childId) {
|
|
68
67
|
return true; // reached from a subscript, not the accessed object
|
|
69
68
|
}
|
|
70
|
-
childId =
|
|
71
|
-
parentId = parent.info.parent;
|
|
69
|
+
childId = parent.info.id;
|
|
72
70
|
}
|
|
73
71
|
return false;
|
|
74
72
|
}
|
|
75
73
|
/** AST nodes that make their children conditionally executed within their scope. */
|
|
76
74
|
const ConditionalNodeTypes = new Set([type_1.RType.IfThenElse, type_1.RType.ForLoop, type_1.RType.WhileLoop, type_1.RType.RepeatLoop]);
|
|
77
75
|
/**
|
|
78
|
-
* Walk from `
|
|
76
|
+
* Walk from the parent of `id` up to the nearest enclosing {@link RType.FunctionDefinition} (or the top level),
|
|
79
77
|
* reporting that scope and whether the walk crossed no `if`/loop block - so a binding at the origin is
|
|
80
78
|
* guaranteed to execute whenever its scope runs. (`cds` is unsuitable: guard clauses like `if(...) stop()`
|
|
81
79
|
* add a control dependency to otherwise-unconditional sibling statements.)
|
|
82
80
|
*/
|
|
83
|
-
function enclosingScope(idMap,
|
|
84
|
-
let cur = startParent;
|
|
81
|
+
function enclosingScope(idMap, id) {
|
|
85
82
|
let unconditional = true;
|
|
86
|
-
for (
|
|
87
|
-
const node = idMap.get(cur);
|
|
88
|
-
if (node === undefined) {
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
83
|
+
for (const node of model_1.RNode.iterateParents(idMap.get(id), idMap)) {
|
|
91
84
|
if (r_function_definition_1.RFunctionDefinition.is(node)) {
|
|
92
|
-
return { scope:
|
|
85
|
+
return { scope: node.info.id, unconditional };
|
|
93
86
|
}
|
|
94
87
|
if (ConditionalNodeTypes.has(node.type)) {
|
|
95
88
|
unconditional = false;
|
|
96
89
|
}
|
|
97
|
-
cur = node.info.parent;
|
|
98
90
|
}
|
|
99
91
|
return { scope: 'top', unconditional };
|
|
100
92
|
}
|
|
@@ -110,15 +102,13 @@ function collectScopeDefinedNames(graph) {
|
|
|
110
102
|
if (idMap === undefined) {
|
|
111
103
|
return byScope;
|
|
112
104
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}
|
|
117
|
-
const name = idMap.get(id)?.lexeme;
|
|
105
|
+
/* function bindings/params surface as variable definitions of their name symbol */
|
|
106
|
+
for (const [id] of graph.verticesOfType(vertex_1.VertexType.VariableDefinition)) {
|
|
107
|
+
const name = node_id_1.NodeId.recoverName(id, idMap);
|
|
118
108
|
if (name === undefined) {
|
|
119
109
|
continue;
|
|
120
110
|
}
|
|
121
|
-
const { scope, unconditional } = enclosingScope(idMap,
|
|
111
|
+
const { scope, unconditional } = enclosingScope(idMap, id);
|
|
122
112
|
if (!unconditional) {
|
|
123
113
|
continue;
|
|
124
114
|
}
|
|
@@ -139,20 +129,14 @@ function isDefinedInEnclosingScope(graph, defined, useId, name) {
|
|
|
139
129
|
if (idMap === undefined) {
|
|
140
130
|
return false;
|
|
141
131
|
}
|
|
142
|
-
const own = enclosingScope(idMap,
|
|
132
|
+
const own = enclosingScope(idMap, useId).scope;
|
|
143
133
|
if (own !== 'top' && defined.get('top')?.has(name)) {
|
|
144
134
|
return true;
|
|
145
135
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
const node = idMap.get(cur);
|
|
149
|
-
if (node === undefined) {
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
152
|
-
if (r_function_definition_1.RFunctionDefinition.is(node) && cur !== own && defined.get(cur)?.has(name)) {
|
|
136
|
+
for (const node of model_1.RNode.iterateParents(idMap.get(useId), idMap)) {
|
|
137
|
+
if (r_function_definition_1.RFunctionDefinition.is(node) && node.info.id !== own && defined.get(node.info.id)?.has(name)) {
|
|
153
138
|
return true;
|
|
154
139
|
}
|
|
155
|
-
cur = node.info.parent;
|
|
156
140
|
}
|
|
157
141
|
return false;
|
|
158
142
|
}
|
|
@@ -40,6 +40,8 @@ export interface SuppressionCounts {
|
|
|
40
40
|
subscript: number;
|
|
41
41
|
/** a bare name a `library()` flowR could not resolve may export */
|
|
42
42
|
unresolvedLibrary: number;
|
|
43
|
+
/** declared by `utils::globalVariables()` or set by R's method dispatch (`.Generic`, `.Method`, `.Class`) */
|
|
44
|
+
declaredGlobal: number;
|
|
43
45
|
}
|
|
44
46
|
export interface UndefinedSymbolMetadata extends MergeableRecord {
|
|
45
47
|
totalFunctionCalls: number;
|