@eagleoutice/flowr 2.10.9 → 2.10.10
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 +103 -33
- package/abstract-interpretation/absint-visitor.js +6 -3
- package/abstract-interpretation/domains/abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.d.ts +1 -1
- package/abstract-interpretation/domains/bounded-set-domain.js +1 -1
- package/abstract-interpretation/domains/interval-domain.d.ts +1 -1
- package/abstract-interpretation/domains/interval-domain.js +1 -1
- package/abstract-interpretation/domains/lattice.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.d.ts +1 -1
- package/abstract-interpretation/domains/partial-product-domain.js +2 -2
- package/abstract-interpretation/domains/set-range-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-range-domain.js +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.d.ts +1 -1
- package/abstract-interpretation/domains/set-upper-bound-domain.js +1 -1
- package/abstract-interpretation/domains/singleton-domain.d.ts +1 -1
- package/abstract-interpretation/domains/singleton-domain.js +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +1 -1
- package/abstract-interpretation/domains/state-abstract-domain.js +2 -2
- package/abstract-interpretation/unsupported-functions.d.ts +3 -2
- package/abstract-interpretation/unsupported-functions.js +38 -28
- package/cli/benchmark-app.js +2 -1
- package/cli/common/script.js +3 -2
- package/cli/flowr.js +47 -10
- package/cli/repl/commands/repl-cfg.js +9 -9
- package/cli/repl/commands/repl-commands.js +5 -0
- package/cli/repl/commands/repl-dataflow.js +31 -24
- package/cli/repl/commands/repl-main.d.ts +6 -0
- package/cli/repl/commands/repl-normalize.js +15 -12
- package/cli/repl/commands/repl-parse.js +1 -1
- package/cli/repl/commands/repl-query.js +4 -5
- package/cli/repl/commands/repl-quit.js +2 -1
- package/cli/repl/core.d.ts +11 -0
- package/cli/repl/core.js +101 -3
- package/cli/repl/execute.js +3 -2
- package/cli/repl/parser/slice-query-parser.d.ts +16 -0
- package/cli/repl/parser/slice-query-parser.js +52 -0
- package/cli/repl/server/connection.d.ts +1 -0
- package/cli/repl/server/connection.js +25 -0
- package/cli/repl/server/messages/message-analysis.d.ts +10 -0
- package/cli/repl/server/messages/message-analysis.js +6 -2
- package/cli/repl/server/messages/message-slice.d.ts +1 -1
- package/cli/script-core/statistics-core.js +2 -1
- package/cli/script-core/statistics-helper-core.js +2 -1
- package/cli/wiki.d.ts +2 -1
- package/cli/wiki.js +4 -1
- package/config.d.ts +9 -10
- package/config.js +25 -7
- package/control-flow/diff-cfg.d.ts +1 -1
- package/control-flow/diff-cfg.js +1 -1
- package/control-flow/semantic-cfg-guided-visitor.js +1 -0
- package/control-flow/simple-visitor.js +6 -5
- package/control-flow/useless-loop.js +2 -2
- package/core/print/dataflow-printer.d.ts +2 -2
- package/core/print/dataflow-printer.js +2 -2
- package/core/steps/all/static-slicing/00-slice.js +1 -1
- package/core/steps/pipeline/default-pipelines.d.ts +146 -146
- package/dataflow/environments/append.d.ts +2 -1
- package/dataflow/environments/append.js +2 -1
- package/dataflow/environments/built-in-proc-name.d.ts +2 -0
- package/dataflow/environments/built-in-proc-name.js +2 -0
- package/dataflow/environments/built-in.d.ts +2 -0
- package/dataflow/environments/built-in.js +2 -0
- package/dataflow/environments/default-builtin-config.d.ts +122 -66
- package/dataflow/environments/default-builtin-config.js +324 -145
- package/dataflow/environments/environment.d.ts +2 -1
- package/dataflow/environments/environment.js +13 -9
- package/dataflow/environments/identifier.d.ts +55 -2
- package/dataflow/environments/identifier.js +14 -2
- package/dataflow/environments/reference-to-maybe.d.ts +2 -0
- package/dataflow/environments/reference-to-maybe.js +56 -11
- package/dataflow/environments/resolve-by-name.js +13 -7
- package/dataflow/eval/values/general.js +4 -0
- package/dataflow/extractor.js +12 -2
- package/dataflow/graph/df-helper.d.ts +6 -0
- package/dataflow/graph/df-helper.js +33 -0
- package/dataflow/graph/graph.js +1 -1
- package/dataflow/info.d.ts +1 -1
- package/dataflow/internal/linker.d.ts +5 -1
- package/dataflow/internal/linker.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +53 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.d.ts +13 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-namespace-access.js +58 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-repeat-loop.js +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +38 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +9 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +1 -1
- package/dataflow/internal/process/functions/call/known-call-handling.js +4 -3
- package/dataflow/internal/process/functions/call/named-call-handling.js +6 -0
- package/dataflow/origin/dfg-get-origin.d.ts +1 -1
- package/dataflow/origin/dfg-get-origin.js +1 -1
- package/dataflow/processor.d.ts +6 -0
- package/documentation/data/faq/faqs.d.ts +2 -1
- package/documentation/data/faq/faqs.js +75 -57
- package/documentation/data/server/doc-data-server-messages.d.ts +2 -1
- package/documentation/data/server/doc-data-server-messages.js +15 -7
- package/documentation/doc-readme.js +15 -15
- package/documentation/doc-util/doc-cfg.d.ts +3 -1
- package/documentation/doc-util/doc-cfg.js +3 -3
- package/documentation/doc-util/doc-dfg.d.ts +3 -1
- package/documentation/doc-util/doc-dfg.js +3 -3
- package/documentation/doc-util/doc-files.d.ts +3 -1
- package/documentation/doc-util/doc-files.js +9 -6
- package/documentation/doc-util/doc-normalized-ast.d.ts +3 -1
- package/documentation/doc-util/doc-normalized-ast.js +2 -2
- package/documentation/doc-util/doc-query.d.ts +2 -1
- package/documentation/doc-util/doc-query.js +2 -2
- package/documentation/doc-util/doc-repl.js +1 -0
- package/documentation/doc-util/doc-types.d.ts +6 -6
- package/documentation/doc-util/doc-types.js +11 -9
- package/documentation/issue-linting-rule.js +1 -2
- package/documentation/wiki-analyzer.js +9 -9
- package/documentation/wiki-cfg.js +40 -41
- package/documentation/wiki-core.js +119 -31
- package/documentation/wiki-create-linting-rules.d.ts +6 -0
- package/documentation/wiki-create-linting-rules.js +95 -0
- package/documentation/wiki-dataflow-graph.js +77 -76
- package/documentation/wiki-engine.js +1 -2
- package/documentation/wiki-faq.d.ts +2 -1
- package/documentation/wiki-faq.js +4 -4
- package/documentation/wiki-interface.js +19 -6
- package/documentation/wiki-linter.d.ts +1 -1
- package/documentation/wiki-linter.js +14 -6
- package/documentation/wiki-linting-and-testing.js +2 -2
- package/documentation/wiki-mk/doc-context.d.ts +3 -3
- package/documentation/wiki-mk/doc-maker.d.ts +2 -0
- package/documentation/wiki-mk/doc-maker.js +7 -1
- package/documentation/wiki-normalized-ast.js +5 -5
- package/documentation/wiki-onboarding.d.ts +2 -1
- package/documentation/wiki-onboarding.js +5 -5
- package/documentation/wiki-overview.js +3 -3
- package/documentation/wiki-query.js +85 -84
- package/documentation/wiki-search.js +4 -5
- package/documentation/wiki-setup.js +6 -7
- package/gas.d.ts +74 -0
- package/gas.js +18 -0
- package/linter/linter-executor.js +2 -8
- package/linter/linter-format.d.ts +4 -11
- package/linter/linter-rules.d.ts +88 -86
- package/linter/linter-rules.js +7 -1
- package/linter/rules/absolute-path.d.ts +2 -7
- package/linter/rules/absolute-path.js +6 -4
- package/linter/rules/dataframe-access-validation.d.ts +1 -6
- package/linter/rules/dataframe-access-validation.js +8 -6
- package/linter/rules/dead-code.d.ts +2 -11
- package/linter/rules/dead-code.js +16 -11
- package/linter/rules/deprecated-functions.d.ts +3 -3
- package/linter/rules/file-path-validity.d.ts +1 -6
- package/linter/rules/file-path-validity.js +5 -5
- package/linter/rules/function-finder-util.d.ts +7 -11
- package/linter/rules/function-finder-util.js +9 -6
- package/linter/rules/naming-convention.d.ts +2 -7
- package/linter/rules/naming-convention.js +3 -2
- package/linter/rules/network-functions.d.ts +2 -7
- package/linter/rules/network-functions.js +14 -12
- package/linter/rules/no-leaked-credentials.d.ts +36 -0
- package/linter/rules/no-leaked-credentials.js +75 -0
- package/linter/rules/problematic-inputs.d.ts +1 -8
- package/linter/rules/problematic-inputs.js +5 -4
- package/linter/rules/roxygen-arguments.d.ts +2 -7
- package/linter/rules/roxygen-arguments.js +13 -20
- package/linter/rules/seeded-randomness.d.ts +2 -7
- package/linter/rules/seeded-randomness.js +7 -4
- package/linter/rules/software-has-license.d.ts +31 -0
- package/linter/rules/software-has-license.js +46 -0
- package/linter/rules/software-has-tests.d.ts +38 -0
- package/linter/rules/software-has-tests.js +48 -0
- package/linter/rules/stop-with-call-arg.d.ts +2 -7
- package/linter/rules/stop-with-call-arg.js +3 -2
- package/linter/rules/unused-definition.d.ts +3 -8
- package/linter/rules/unused-definition.js +7 -5
- package/linter/rules/useless-loop.d.ts +2 -7
- package/linter/rules/useless-loop.js +5 -2
- package/package.json +3 -2
- package/project/context/flowr-analyzer-context.d.ts +13 -14
- package/project/context/flowr-analyzer-context.js +4 -0
- package/project/context/flowr-analyzer-files-context.d.ts +12 -0
- package/project/context/flowr-analyzer-files-context.js +12 -2
- package/project/context/flowr-analyzer-gas-context.d.ts +28 -0
- package/project/context/flowr-analyzer-gas-context.js +101 -0
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +13 -7
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +56 -11
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-qmd-file-plugin.js +2 -2
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.d.ts +2 -1
- package/project/plugins/file-plugins/notebooks/flowr-analyzer-rmd-file-plugin.js +5 -5
- package/project/plugins/flowr-analyzer-plugin.d.ts +15 -8
- package/project/plugins/flowr-analyzer-plugin.js +14 -7
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.d.ts +19 -0
- package/project/plugins/gas-plugins/flowr-analyzer-gas-plugin.js +35 -0
- package/project/plugins/plugin-registry.d.ts +2 -1
- package/project/plugins/plugin-registry.js +3 -1
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.d.ts +22 -0
- package/project/plugins/project-discovery/flowr-analyzer-gitignore-project-discovery-plugin.js +47 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +1 -1
- package/queries/catalog/call-context-query/call-context-query-executor.js +54 -8
- package/queries/catalog/call-context-query/call-context-query-format.d.ts +2 -2
- package/queries/catalog/dependencies-query/function-info/test-functions.d.ts +2 -0
- package/queries/catalog/dependencies-query/function-info/test-functions.js +18 -177
- package/queries/catalog/df-shape-query/df-shape-query-format.js +1 -1
- package/queries/catalog/dice-query/dice-query-executor.d.ts +8 -0
- package/queries/catalog/dice-query/dice-query-executor.js +52 -0
- package/queries/catalog/dice-query/dice-query-format.d.ts +53 -0
- package/queries/catalog/dice-query/dice-query-format.js +102 -0
- package/queries/catalog/happens-before-query/happens-before-query-executor.js +2 -2
- package/queries/catalog/input-sources-query/input-sources-query-format.d.ts +2 -0
- package/queries/catalog/input-sources-query/input-sources-query-format.js +1 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.d.ts +2 -0
- package/queries/catalog/inspect-exceptions-query/inspect-exception-query-format.js +1 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.d.ts +2 -0
- package/queries/catalog/inspect-higher-order-query/inspect-higher-order-query-format.js +1 -0
- package/queries/catalog/linter-query/linter-query-executor.js +7 -0
- package/queries/catalog/location-map-query/location-map-query-format.d.ts +2 -0
- package/queries/catalog/location-map-query/location-map-query-format.js +1 -0
- package/queries/catalog/origin-query/origin-query-format.d.ts +2 -0
- package/queries/catalog/origin-query/origin-query-format.js +1 -0
- package/queries/catalog/provenance-query/provenance-query-format.d.ts +2 -0
- package/queries/catalog/provenance-query/provenance-query-format.js +1 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.d.ts +2 -0
- package/queries/catalog/resolve-value-query/resolve-value-query-format.js +1 -0
- package/queries/catalog/static-slice-query/static-slice-query-executor.js +1 -1
- package/queries/catalog/static-slice-query/static-slice-query-format.d.ts +2 -0
- package/queries/catalog/static-slice-query/static-slice-query-format.js +1 -0
- package/queries/query.d.ts +18 -1
- package/queries/query.js +3 -1
- package/r-bridge/data/data.d.ts +5 -0
- package/r-bridge/data/data.js +6 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +0 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-number.js +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.d.ts +1 -1
- package/r-bridge/lang-4.x/ast/parser/main/internal/values/normalize-string.js +1 -1
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-normalize.js +55 -44
- package/r-bridge/parser.js +2 -9
- package/r-bridge/shell.d.ts +8 -1
- package/r-bridge/shell.js +26 -7
- package/search/flowr-search-builder.d.ts +2 -2
- package/search/flowr-search-builder.js +1 -1
- package/search/flowr-search-filters.d.ts +30 -9
- package/search/flowr-search-filters.js +26 -21
- package/search/search-executor/search-enrichers.d.ts +600 -0
- package/search/search-executor/search-enrichers.js +23 -2
- package/slicing/static/static-slicer.d.ts +39 -11
- package/slicing/static/static-slicer.js +44 -14
- package/util/collections/queue.d.ts +16 -0
- package/util/collections/queue.js +38 -0
- package/util/log.d.ts +1 -1
- package/util/log.js +1 -1
- package/util/mermaid/dfg.d.ts +2 -2
- package/util/mermaid/dfg.js +2 -2
- package/util/objects.d.ts +9 -0
- package/util/objects.js +54 -0
- package/util/proc.d.ts +6 -0
- package/util/proc.js +20 -0
- package/util/version.js +1 -1
|
@@ -35,15 +35,10 @@ export interface AbsoluteFilePathMetadata extends MergeableRecord {
|
|
|
35
35
|
}
|
|
36
36
|
export declare const ABSOLUTE_PATH: {
|
|
37
37
|
readonly createSearch: (config: AbsoluteFilePathConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", ["unique"], 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>[]>>;
|
|
38
|
-
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: AbsoluteFilePathConfig, data: {
|
|
39
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
40
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
41
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
42
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
43
|
-
}) => {
|
|
38
|
+
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: AbsoluteFilePathConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
44
39
|
results: AbsoluteFilePathResult[];
|
|
45
40
|
".meta": AbsoluteFilePathMetadata;
|
|
46
|
-
}
|
|
41
|
+
}>;
|
|
47
42
|
readonly prettyPrint: {
|
|
48
43
|
readonly query: (result: AbsoluteFilePathResult) => string;
|
|
49
44
|
readonly full: (result: AbsoluteFilePathResult) => string;
|
|
@@ -103,13 +103,15 @@ exports.ABSOLUTE_PATH = {
|
|
|
103
103
|
}
|
|
104
104
|
return q.unique();
|
|
105
105
|
},
|
|
106
|
-
processSearchResult: (elements, config, data) => {
|
|
106
|
+
processSearchResult: async (elements, config, data) => {
|
|
107
107
|
const metadata = {
|
|
108
108
|
totalConsidered: 0,
|
|
109
109
|
totalUnknown: 0
|
|
110
110
|
};
|
|
111
111
|
const queryResults = elements.enrichmentContent(search_enrichers_1.Enrichment.QueryData)?.queries;
|
|
112
112
|
const regex = config.absolutePathRegex ? new RegExp(config.absolutePathRegex) : undefined;
|
|
113
|
+
const normalize = await data.normalize();
|
|
114
|
+
const dataflow = await data.dataflow();
|
|
113
115
|
return {
|
|
114
116
|
results: elements.getElements().flatMap(element => {
|
|
115
117
|
metadata.totalConsidered++;
|
|
@@ -139,7 +141,7 @@ exports.ABSOLUTE_PATH = {
|
|
|
139
141
|
if (resolved === undefined || !(0, strings_1.isAbsolutePath)(resolved, regex)) {
|
|
140
142
|
return [];
|
|
141
143
|
}
|
|
142
|
-
const elem =
|
|
144
|
+
const elem = normalize.idMap.get(r.nodeId);
|
|
143
145
|
return [{
|
|
144
146
|
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
145
147
|
filePath: resolved,
|
|
@@ -156,10 +158,10 @@ exports.ABSOLUTE_PATH = {
|
|
|
156
158
|
}
|
|
157
159
|
}
|
|
158
160
|
else {
|
|
159
|
-
const dfNode =
|
|
161
|
+
const dfNode = dataflow.graph.getVertex(node.info.id);
|
|
160
162
|
if ((0, vertex_1.isFunctionCallVertex)(dfNode)) {
|
|
161
163
|
const handler = dfNode.name ? PathFunctions.get(dfNode.name) : undefined;
|
|
162
|
-
const strings = handler ? handler(
|
|
164
|
+
const strings = handler ? handler(dataflow.graph, dfNode, data.inspectContext()) : [];
|
|
163
165
|
if (strings) {
|
|
164
166
|
return strings.flatMap(s => {
|
|
165
167
|
const resolved = resolvePathForAbsoluteCheck(s, config.ignoreUrls);
|
|
@@ -27,12 +27,7 @@ export interface DataFrameAccessValidationMetadata extends MergeableRecord {
|
|
|
27
27
|
}
|
|
28
28
|
export declare const DATA_FRAME_ACCESS_VALIDATION: {
|
|
29
29
|
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", [], ParentInformation, FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>>;
|
|
30
|
-
readonly processSearchResult: (elements: FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: DataFrameAccessValidationConfig, data: {
|
|
31
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
32
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
33
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
34
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
35
|
-
}) => Promise<{
|
|
30
|
+
readonly processSearchResult: (elements: FlowrSearchElements<ParentInformation, import("../../search/flowr-search").FlowrSearchElement<ParentInformation>[]>, config: DataFrameAccessValidationConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
36
31
|
results: DataFrameAccessValidationResult[];
|
|
37
32
|
'.meta': DataFrameAccessValidationMetadata;
|
|
38
33
|
}>;
|
|
@@ -15,18 +15,20 @@ const linter_tags_1 = require("../linter-tags");
|
|
|
15
15
|
exports.DATA_FRAME_ACCESS_VALIDATION = {
|
|
16
16
|
createSearch: () => flowr_search_builder_1.Q.all(),
|
|
17
17
|
processSearchResult: async (elements, config, data) => {
|
|
18
|
-
|
|
18
|
+
const normalize = await data.normalize();
|
|
19
|
+
const dataflow = await data.dataflow();
|
|
20
|
+
let ctx = data.inspectContext();
|
|
19
21
|
ctx = {
|
|
20
22
|
...ctx,
|
|
21
|
-
config: config_1.FlowrConfig.amend(data.
|
|
23
|
+
config: config_1.FlowrConfig.amend(data.flowrConfig, flowrConfig => {
|
|
22
24
|
if (config.readLoadedData !== undefined) {
|
|
23
25
|
flowrConfig.abstractInterpretation.dataFrame.readLoadedData.readExternalFiles = config.readLoadedData;
|
|
24
26
|
}
|
|
25
27
|
return flowrConfig;
|
|
26
28
|
})
|
|
27
29
|
};
|
|
28
|
-
const cfg = await data.
|
|
29
|
-
const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg:
|
|
30
|
+
const cfg = await data.controlflow(undefined, cfg_kind_1.CfgKind.NoFunctionDefs);
|
|
31
|
+
const inference = new shape_inference_1.DataFrameShapeInferenceVisitor({ controlFlow: cfg, dfg: dataflow.graph, normalizedAst: normalize, ctx });
|
|
30
32
|
inference.start();
|
|
31
33
|
const accessOperations = getAccessOperations(elements, inference);
|
|
32
34
|
const accesses = [];
|
|
@@ -59,8 +61,8 @@ exports.DATA_FRAME_ACCESS_VALIDATION = {
|
|
|
59
61
|
.map(accessed => ({ nodeId: access.nodeId, operand: access.operand, ...accessed })))
|
|
60
62
|
.map(({ nodeId, operand, ...accessed }) => ({
|
|
61
63
|
...accessed,
|
|
62
|
-
node:
|
|
63
|
-
operand: operand === undefined ? undefined :
|
|
64
|
+
node: normalize.idMap.get(nodeId),
|
|
65
|
+
operand: operand === undefined ? undefined : normalize.idMap.get(operand),
|
|
64
66
|
}))
|
|
65
67
|
.map(({ node, operand, ...accessed }) => ({
|
|
66
68
|
...accessed,
|
|
@@ -10,19 +10,10 @@ export interface DeadCodeConfig extends MergeableRecord {
|
|
|
10
10
|
*/
|
|
11
11
|
simplificationPasses?: CfgSimplificationPassName[];
|
|
12
12
|
}
|
|
13
|
-
export interface DeadCodeMetadata extends MergeableRecord {
|
|
14
|
-
consideredNodes: number;
|
|
15
|
-
}
|
|
16
13
|
export declare const DEAD_CODE: {
|
|
17
|
-
readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["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>[]>>>;
|
|
18
|
-
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: DeadCodeConfig, _data: {
|
|
19
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
20
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
21
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
22
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
23
|
-
}) => {
|
|
14
|
+
readonly createSearch: (config: DeadCodeConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
15
|
+
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: DeadCodeConfig, _data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => {
|
|
24
16
|
results: LintingResult[];
|
|
25
|
-
'.meta': DeadCodeMetadata;
|
|
26
17
|
};
|
|
27
18
|
readonly prettyPrint: {
|
|
28
19
|
readonly query: (result: LintingResult) => string;
|
|
@@ -8,29 +8,34 @@ const linter_tags_1 = require("../linter-tags");
|
|
|
8
8
|
const search_enrichers_1 = require("../../search/search-executor/search-enrichers");
|
|
9
9
|
const assert_1 = require("../../util/assert");
|
|
10
10
|
const cfg_simplification_1 = require("../../control-flow/cfg-simplification");
|
|
11
|
+
const flowr_search_filters_1 = require("../../search/flowr-search-filters");
|
|
11
12
|
exports.DEAD_CODE = {
|
|
12
13
|
createSearch: (config) => flowr_search_builder_1.Q.all().with(search_enrichers_1.Enrichment.CfgInformation, {
|
|
13
14
|
checkReachable: true,
|
|
14
15
|
simplificationPasses: config.simplificationPasses ?? [...cfg_simplification_1.DefaultCfgSimplificationOrder, 'analyze-dead-code']
|
|
15
|
-
})
|
|
16
|
+
}).filter(flowr_search_filters_1.F.not(flowr_search_filters_1.F.or({
|
|
17
|
+
name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
|
|
18
|
+
args: {
|
|
19
|
+
enrichment: search_enrichers_1.Enrichment.CfgInformation,
|
|
20
|
+
test: {
|
|
21
|
+
isReachable: true
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
name: flowr_search_filters_1.FlowrFilter.RoleInParent,
|
|
26
|
+
args: {
|
|
27
|
+
roleInParent: "el-g" /* RoleInParent.ExpressionListGrouping */
|
|
28
|
+
}
|
|
29
|
+
}))),
|
|
16
30
|
processSearchResult: (elements, _config, _data) => {
|
|
17
|
-
const meta = {
|
|
18
|
-
consideredNodes: 0
|
|
19
|
-
};
|
|
20
31
|
return {
|
|
21
32
|
results: combineResults(elements.getElements()
|
|
22
|
-
.filter(element => {
|
|
23
|
-
meta.consideredNodes++;
|
|
24
|
-
const cfgInformation = (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CfgInformation);
|
|
25
|
-
return element.node.info.role !== "el-g" /* RoleInParent.ExpressionListGrouping */ && !cfgInformation.isReachable;
|
|
26
|
-
})
|
|
27
33
|
.map(element => ({
|
|
28
34
|
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
29
35
|
involvedId: element.node.info.id,
|
|
30
36
|
loc: range_1.SourceLocation.fromNode(element.node)
|
|
31
37
|
}))
|
|
32
|
-
.filter(element => (0, assert_1.isNotUndefined)(element.loc)))
|
|
33
|
-
'.meta': meta
|
|
38
|
+
.filter(element => (0, assert_1.isNotUndefined)(element.loc)))
|
|
34
39
|
};
|
|
35
40
|
},
|
|
36
41
|
prettyPrint: {
|
|
@@ -3,12 +3,12 @@ import { LintingRuleTag } from '../linter-tags';
|
|
|
3
3
|
import { type FunctionsMetadata, type FunctionsResult, type FunctionsToDetectConfig } from './function-finder-util';
|
|
4
4
|
export declare const DEPRECATED_FUNCTIONS: {
|
|
5
5
|
readonly createSearch: (config: FunctionsToDetectConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
6
|
-
readonly processSearchResult: <T extends import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>(elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => (T[number] & {
|
|
6
|
+
readonly processSearchResult: <T extends import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>(this: void, elements: import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => import("ts-essentials").AsyncOrSync<(T[number] & {
|
|
7
7
|
certainty?: import("../linter-format").LintingResultCertainty;
|
|
8
|
-
})[]) => {
|
|
8
|
+
})[]>) => Promise<{
|
|
9
9
|
results: FunctionsResult[];
|
|
10
10
|
'.meta': FunctionsMetadata;
|
|
11
|
-
}
|
|
11
|
+
}>;
|
|
12
12
|
readonly prettyPrint: {
|
|
13
13
|
query: (result: FunctionsResult) => string;
|
|
14
14
|
full: (result: FunctionsResult) => string;
|
|
@@ -35,12 +35,7 @@ export interface FilePathValidityMetadata extends MergeableRecord {
|
|
|
35
35
|
}
|
|
36
36
|
export declare const FILE_PATH_VALIDITY: {
|
|
37
37
|
readonly createSearch: (config: FilePathValidityConfig) => 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>[]>>>;
|
|
38
|
-
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: FilePathValidityConfig, data: {
|
|
39
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
40
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
41
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
42
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
43
|
-
}) => Promise<{
|
|
38
|
+
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: FilePathValidityConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
44
39
|
results: FilePathValidityResult[];
|
|
45
40
|
".meta": FilePathValidityMetadata;
|
|
46
41
|
}>;
|
|
@@ -64,9 +64,9 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
64
64
|
// file:// URIs are local paths; resolve and check existence directly
|
|
65
65
|
const localFromFileUrl = (0, strings_1.fileUrlToPath)(matchingRead.value);
|
|
66
66
|
if (localFromFileUrl !== undefined) {
|
|
67
|
-
const paths = (0, built_in_source_1.findSource)(data.
|
|
67
|
+
const paths = (0, built_in_source_1.findSource)(data.flowrConfig.solver.resolveSource, localFromFileUrl, {
|
|
68
68
|
referenceChain: element.node.info.file ? [element.node.info.file] : [],
|
|
69
|
-
ctx: data.
|
|
69
|
+
ctx: data.inspectContext()
|
|
70
70
|
});
|
|
71
71
|
if (paths && paths.length) {
|
|
72
72
|
metadata.totalValid++;
|
|
@@ -97,16 +97,16 @@ exports.FILE_PATH_VALIDITY = {
|
|
|
97
97
|
}];
|
|
98
98
|
}
|
|
99
99
|
// check if any write to the same file happens before the read, and exclude this case if so
|
|
100
|
-
const writesToFile = results.write.filter(r => samePath(r.value, matchingRead.value, data.
|
|
100
|
+
const writesToFile = results.write.filter(r => samePath(r.value, matchingRead.value, data.flowrConfig.solver.resolveSource?.ignoreCapitalization));
|
|
101
101
|
const writesBefore = writesToFile.map(w => (0, happens_before_1.happensBefore)(cfg, w.nodeId, element.node.info.id));
|
|
102
102
|
if (writesBefore.some(w => w === logic_1.Ternary.Always)) {
|
|
103
103
|
metadata.totalWritesBeforeAlways++;
|
|
104
104
|
return [];
|
|
105
105
|
}
|
|
106
106
|
// check if the file exists!
|
|
107
|
-
const paths = (0, built_in_source_1.findSource)(data.
|
|
107
|
+
const paths = (0, built_in_source_1.findSource)(data.flowrConfig.solver.resolveSource, matchingRead.value, {
|
|
108
108
|
referenceChain: element.node.info.file ? [element.node.info.file] : [],
|
|
109
|
-
ctx: data.
|
|
109
|
+
ctx: data.inspectContext()
|
|
110
110
|
});
|
|
111
111
|
if (paths && paths.length) {
|
|
112
112
|
metadata.totalValid++;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type LintingResult, LintingResultCertainty } from '../linter-format';
|
|
2
2
|
import type { FlowrSearchElement, FlowrSearchElements } from '../../search/flowr-search';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ParentInformation } from '../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
4
|
import type { MergeableRecord } from '../../util/objects';
|
|
5
|
-
import type { DataflowInformation } from '../../dataflow/info';
|
|
6
5
|
import type { FunctionInfo } from '../../queries/catalog/dependencies-query/function-info/function-info';
|
|
7
|
-
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
8
6
|
import { Ternary } from '../../util/logic';
|
|
7
|
+
import type { ReadonlyFlowrAnalysisProvider } from '../../project/flowr-analyzer';
|
|
8
|
+
import type { AsyncOrSync } from 'ts-essentials';
|
|
9
9
|
export interface FunctionsResult extends LintingResult {
|
|
10
10
|
function: string;
|
|
11
11
|
}
|
|
@@ -24,19 +24,15 @@ export interface FunctionsToDetectConfig extends MergeableRecord {
|
|
|
24
24
|
*/
|
|
25
25
|
export declare const functionFinderUtil: {
|
|
26
26
|
createSearch: (functions: readonly string[]) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], ParentInformation, Promise<FlowrSearchElements<ParentInformation, [] | FlowrSearchElement<ParentInformation>[]>>>;
|
|
27
|
-
processSearchResult
|
|
27
|
+
processSearchResult<T extends FlowrSearchElement<ParentInformation>[]>(this: void, elements: FlowrSearchElements<ParentInformation, T>, _config: unknown, _data: unknown, refineSearch?: (elements: T) => AsyncOrSync<(T[number] & {
|
|
28
28
|
certainty?: LintingResultCertainty;
|
|
29
|
-
})[])
|
|
29
|
+
})[]>): Promise<{
|
|
30
30
|
results: FunctionsResult[];
|
|
31
31
|
'.meta': FunctionsMetadata;
|
|
32
|
-
}
|
|
32
|
+
}>;
|
|
33
33
|
prettyPrint: (functionType: string) => {
|
|
34
34
|
query: (result: FunctionsResult) => string;
|
|
35
35
|
full: (result: FunctionsResult) => string;
|
|
36
36
|
};
|
|
37
|
-
requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>,
|
|
38
|
-
normalize: NormalizedAst;
|
|
39
|
-
dataflow: DataflowInformation;
|
|
40
|
-
analyzer: ReadonlyFlowrAnalysisProvider;
|
|
41
|
-
}, requireValue: RegExp | string | undefined): Ternary;
|
|
37
|
+
requireArgumentValue(element: FlowrSearchElement<ParentInformation>, pool: ReadonlyMap<string, FunctionInfo>, analyzer: ReadonlyFlowrAnalysisProvider, requireValue: RegExp | string | undefined): Promise<Ternary>;
|
|
42
38
|
};
|
|
@@ -22,16 +22,18 @@ exports.functionFinderUtil = {
|
|
|
22
22
|
name: flowr_search_filters_1.FlowrFilter.MatchesEnrichment,
|
|
23
23
|
args: {
|
|
24
24
|
enrichment: search_enrichers_1.Enrichment.CallTargets,
|
|
25
|
-
test:
|
|
25
|
+
test: {
|
|
26
|
+
targets: (0, flowr_search_filters_1.testFunctionsIgnoringPackage)(functions)
|
|
27
|
+
}
|
|
26
28
|
}
|
|
27
29
|
}));
|
|
28
30
|
},
|
|
29
|
-
processSearchResult
|
|
31
|
+
async processSearchResult(elements, _config, _data, refineSearch = e => e) {
|
|
30
32
|
const metadata = {
|
|
31
33
|
totalCalls: 0,
|
|
32
34
|
totalFunctionDefinitions: 0
|
|
33
35
|
};
|
|
34
|
-
const results = refineSearch(elements.getElements())
|
|
36
|
+
const results = (await refineSearch(elements.getElements()))
|
|
35
37
|
.flatMap(element => {
|
|
36
38
|
metadata.totalCalls++;
|
|
37
39
|
return (0, search_enrichers_1.enrichmentContent)(element, search_enrichers_1.Enrichment.CallTargets).targets.map(target => {
|
|
@@ -60,15 +62,16 @@ exports.functionFinderUtil = {
|
|
|
60
62
|
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Function \`${result.function}\` called at ${range_1.SourceLocation.format(result.loc)} is related to ${functionType}`
|
|
61
63
|
};
|
|
62
64
|
},
|
|
63
|
-
requireArgumentValue(element, pool,
|
|
65
|
+
async requireArgumentValue(element, pool, analyzer, requireValue) {
|
|
64
66
|
const info = pool.get(element.node.lexeme ?? '');
|
|
65
67
|
/* if we have no additional info, we assume they always access the network */
|
|
66
68
|
if (info === undefined) {
|
|
67
69
|
return logic_1.Ternary.Always;
|
|
68
70
|
}
|
|
69
|
-
const
|
|
71
|
+
const dataflow = await analyzer.dataflow();
|
|
72
|
+
const vert = dataflow.graph.getVertex(element.node.info.id);
|
|
70
73
|
if ((0, vertex_1.isFunctionCallVertex)(vert)) {
|
|
71
|
-
const args = (0, resolve_argument_1.getArgumentStringValue)(
|
|
74
|
+
const args = (0, resolve_argument_1.getArgumentStringValue)(analyzer.flowrConfig.solver.variables, dataflow.graph, vert, info.argIdx, info.argName, info.resolveValue, analyzer.inspectContext());
|
|
72
75
|
// we obtain all values, at least one of them has to trigger for the request
|
|
73
76
|
const argValues = args ? args.values().flatMap(s => Array.from(s)).filter(assert_1.isNotUndefined).toArray() : [];
|
|
74
77
|
if (argValues.length === 0) {
|
|
@@ -58,18 +58,13 @@ export declare function fixCasing(identifier: string, convention: CasingConventi
|
|
|
58
58
|
export declare function createNamingConventionQuickFixes(graph: DataflowGraph, nodeId: NodeId, replacement: string, conv: CasingConvention): LintQuickFixReplacement[] | undefined;
|
|
59
59
|
export declare const NAMING_CONVENTION: {
|
|
60
60
|
readonly createSearch: (_config: NamingConventionConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
61
|
-
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: NamingConventionConfig, data: {
|
|
62
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
63
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
64
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
65
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
66
|
-
}) => {
|
|
61
|
+
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: NamingConventionConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
67
62
|
results: NamingConventionResult[];
|
|
68
63
|
'.meta': {
|
|
69
64
|
numMatches: number;
|
|
70
65
|
numBreak: number;
|
|
71
66
|
};
|
|
72
|
-
}
|
|
67
|
+
}>;
|
|
73
68
|
readonly prettyPrint: {
|
|
74
69
|
readonly query: (result: NamingConventionResult) => string;
|
|
75
70
|
readonly full: (result: NamingConventionResult) => string;
|
|
@@ -158,7 +158,8 @@ function createNamingConventionQuickFixes(graph, nodeId, replacement, conv) {
|
|
|
158
158
|
}
|
|
159
159
|
exports.NAMING_CONVENTION = {
|
|
160
160
|
createSearch: (_config) => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.VariableDefinition),
|
|
161
|
-
processSearchResult: (elements, config, data) => {
|
|
161
|
+
processSearchResult: async (elements, config, data) => {
|
|
162
|
+
const dataflow = await data.dataflow();
|
|
162
163
|
const symbols = elements.getElements()
|
|
163
164
|
.map(m => ({
|
|
164
165
|
certainty: linter_format_1.LintingResultCertainty.Certain,
|
|
@@ -175,7 +176,7 @@ exports.NAMING_CONVENTION = {
|
|
|
175
176
|
return {
|
|
176
177
|
...m,
|
|
177
178
|
involvedId: id,
|
|
178
|
-
quickFix: fix ? createNamingConventionQuickFixes(
|
|
179
|
+
quickFix: fix ? createNamingConventionQuickFixes(dataflow.graph, id, fix, casing) : undefined
|
|
179
180
|
};
|
|
180
181
|
});
|
|
181
182
|
return {
|
|
@@ -12,15 +12,10 @@ export interface NetworkFunctionsConfig extends MergeableRecord {
|
|
|
12
12
|
}
|
|
13
13
|
export declare const NETWORK_FUNCTIONS: {
|
|
14
14
|
readonly createSearch: (config: NetworkFunctionsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter", "with", "filter"], ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<ParentInformation, [] | FlowrSearchElement<ParentInformation>[]>>>;
|
|
15
|
-
readonly processSearchResult: (e: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, c: NetworkFunctionsConfig, d: {
|
|
16
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
17
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
18
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
19
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
20
|
-
}) => {
|
|
15
|
+
readonly processSearchResult: (e: import("../../search/flowr-search").FlowrSearchElements<ParentInformation, FlowrSearchElement<ParentInformation>[]>, c: NetworkFunctionsConfig, d: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
21
16
|
results: FunctionsResult[];
|
|
22
17
|
'.meta': FunctionsMetadata;
|
|
23
|
-
}
|
|
18
|
+
}>;
|
|
24
19
|
readonly prettyPrint: {
|
|
25
20
|
query: (result: FunctionsResult) => string;
|
|
26
21
|
full: (result: FunctionsResult) => string;
|
|
@@ -11,19 +11,21 @@ const write_functions_1 = require("../../queries/catalog/dependencies-query/func
|
|
|
11
11
|
const FnPool = new Map(read_functions_1.ReadFunctions.concat(source_functions_1.SourceFunctions, write_functions_1.WriteFunctions).map(f => [f.name, f]));
|
|
12
12
|
exports.NETWORK_FUNCTIONS = {
|
|
13
13
|
createSearch: (config) => function_finder_util_1.functionFinderUtil.createSearch(config.fns),
|
|
14
|
-
processSearchResult: (e, c, d) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
processSearchResult: (e, c, d) => {
|
|
15
|
+
return function_finder_util_1.functionFinderUtil.processSearchResult(e, c, d, async (es) => {
|
|
16
|
+
const res = [];
|
|
17
|
+
for (const e of es) {
|
|
18
|
+
const val = await function_finder_util_1.functionFinderUtil.requireArgumentValue(e, FnPool, d, c.onlyTriggerWithArgument);
|
|
19
|
+
if (val === logic_1.Ternary.Never) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const x = e;
|
|
23
|
+
x.certainty = val === logic_1.Ternary.Always ? linter_format_1.LintingResultCertainty.Certain : linter_format_1.LintingResultCertainty.Uncertain;
|
|
24
|
+
res.push(x);
|
|
20
25
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
return res;
|
|
26
|
-
}),
|
|
26
|
+
return res;
|
|
27
|
+
});
|
|
28
|
+
},
|
|
27
29
|
prettyPrint: function_finder_util_1.functionFinderUtil.prettyPrint('network operations'),
|
|
28
30
|
info: {
|
|
29
31
|
name: 'Network Functions',
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type LintingResult, LintingRuleCertainty } from '../linter-format';
|
|
2
|
+
import type { MergeableRecord } from '../../util/objects';
|
|
3
|
+
import { LintingRuleTag } from '../linter-tags';
|
|
4
|
+
export interface NoLeakedCredentialsResult extends LintingResult {
|
|
5
|
+
readonly variableName: string;
|
|
6
|
+
}
|
|
7
|
+
export interface NoLeakedCredentialsConfig extends MergeableRecord {
|
|
8
|
+
/** Pattern matched (case-insensitively) against variable names to identify potential credential assignments */
|
|
9
|
+
readonly credentialNamePattern: string;
|
|
10
|
+
/** Pattern matched against string literal values to detect known credential formats (e.g., AWS access key IDs, GitHub tokens) */
|
|
11
|
+
readonly credentialValuePattern: string;
|
|
12
|
+
}
|
|
13
|
+
export interface NoLeakedCredentialsMetadata extends MergeableRecord {
|
|
14
|
+
readonly totalChecked: number;
|
|
15
|
+
}
|
|
16
|
+
export declare const NO_LEAKED_CREDENTIALS: {
|
|
17
|
+
readonly createSearch: () => import("../../search/flowr-search-builder").FlowrSearchBuilder<"all", ["filter"], import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, Promise<import("../../search/flowr-search").FlowrSearchElements<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation, [] | import("../../search/flowr-search").FlowrSearchElement<import("../../r-bridge/lang-4.x/ast/model/processing/decorate").ParentInformation>[]>>>;
|
|
18
|
+
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: NoLeakedCredentialsConfig, data: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
19
|
+
results: NoLeakedCredentialsResult[];
|
|
20
|
+
".meta": NoLeakedCredentialsMetadata;
|
|
21
|
+
}>;
|
|
22
|
+
readonly prettyPrint: {
|
|
23
|
+
readonly query: (result: NoLeakedCredentialsResult) => string;
|
|
24
|
+
readonly full: (result: NoLeakedCredentialsResult) => string;
|
|
25
|
+
};
|
|
26
|
+
readonly info: {
|
|
27
|
+
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).";
|
|
29
|
+
readonly tags: readonly [LintingRuleTag.Security, LintingRuleTag.Experimental, LintingRuleTag.Smell];
|
|
30
|
+
readonly certainty: LintingRuleCertainty.BestEffort;
|
|
31
|
+
readonly defaultConfig: {
|
|
32
|
+
readonly credentialNamePattern: "(?:password|passwd|pwd|secret|api[_.]?key|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential)";
|
|
33
|
+
readonly credentialValuePattern: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NO_LEAKED_CREDENTIALS = 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 linter_tags_1 = require("../linter-tags");
|
|
8
|
+
const assert_1 = require("../../util/assert");
|
|
9
|
+
const vertex_1 = require("../../dataflow/graph/vertex");
|
|
10
|
+
const edge_1 = require("../../dataflow/graph/edge");
|
|
11
|
+
const r_string_1 = require("../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
12
|
+
const defaultCredentialNamePattern = '(?:password|passwd|pwd|secret|api[_.]?key|api[_.]?token|access[_.]?token|auth[_.]?token|bearer[_.]?token|private[_.]?key|credential)';
|
|
13
|
+
const defaultCredentialValuePattern = '^(?:AKIA|AIPA|ASIA|AROA)[A-Z0-9]{16}' + // AWS access key IDs (exact 20-char format)
|
|
14
|
+
'|^gh[psoar]_[A-Za-z0-9_]{10,}' + // GitHub Classic/App/OAuth/Actions tokens
|
|
15
|
+
'|^github_pat_[A-Za-z0-9_]{10,}' + // GitHub fine-grained PATs
|
|
16
|
+
'|^glpat-[A-Za-z0-9_-]{20}' + // GitLab Personal Access Tokens (fixed length)
|
|
17
|
+
'|^xox[baprs]-[0-9A-Za-z]{10,}' + // Slack tokens (xoxb-, xoxp-, xoxa-, xoxr-, xoxs-)
|
|
18
|
+
'|^sk_(?:live|test)_[A-Za-z0-9]{24}' + // Stripe secret/test keys (length-anchored)
|
|
19
|
+
'|^rk_live_[A-Za-z0-9]{24}' + // Stripe restricted keys (length-anchored)
|
|
20
|
+
'|^npm_[A-Za-z0-9]{36}' + // npm access tokens (fixed length)
|
|
21
|
+
'|^shp(?:at|ss|pa|ca)_[A-Za-z0-9]{32}' + // Shopify Admin/Shared/Private/Custom tokens
|
|
22
|
+
'|^sk-ant-[A-Za-z0-9_-]{10,}' + // Anthropic API keys
|
|
23
|
+
'|^sk-proj-[A-Za-z0-9_-]{10,}' + // OpenAI project API keys
|
|
24
|
+
'|^SG\\.[A-Za-z0-9_-]{22}\\.' + // SendGrid API keys (structured format)
|
|
25
|
+
'|^-----BEGIN(?:\\s[A-Z]+)* PRIVATE KEY'; // PEM private keys (RSA, EC, DSA, OpenSSH, etc.)
|
|
26
|
+
exports.NO_LEAKED_CREDENTIALS = {
|
|
27
|
+
createSearch: () => flowr_search_builder_1.Q.all().filter(vertex_1.VertexType.VariableDefinition),
|
|
28
|
+
processSearchResult: async (elements, config, data) => {
|
|
29
|
+
const namePattern = new RegExp(config.credentialNamePattern, 'i');
|
|
30
|
+
const valuePattern = new RegExp(config.credentialValuePattern);
|
|
31
|
+
const normalize = await data.normalize();
|
|
32
|
+
const dfg = (await data.dataflow()).graph;
|
|
33
|
+
let totalChecked = 0;
|
|
34
|
+
const results = elements.getElements().flatMap(element => {
|
|
35
|
+
totalChecked++;
|
|
36
|
+
const name = element.node.lexeme ?? '';
|
|
37
|
+
const vertex = dfg.getVertex(element.node.info.id);
|
|
38
|
+
if (!(0, vertex_1.isVariableDefinitionVertex)(vertex)) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
const nameMatches = namePattern.test(name);
|
|
42
|
+
for (const [targetId, edge] of dfg.outgoingEdges(element.node.info.id) ?? []) {
|
|
43
|
+
if (!edge_1.DfEdge.includesType(edge, edge_1.EdgeType.DefinedBy)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const targetNode = normalize.idMap.get(targetId);
|
|
47
|
+
if (targetNode && r_string_1.RString.is(targetNode) && (nameMatches || valuePattern.test(targetNode.content.str))) {
|
|
48
|
+
return [{
|
|
49
|
+
certainty: linter_format_1.LintingResultCertainty.Uncertain,
|
|
50
|
+
involvedId: element.node.info.id,
|
|
51
|
+
variableName: name,
|
|
52
|
+
loc: range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid()
|
|
53
|
+
}];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
}).filter(assert_1.isNotUndefined);
|
|
58
|
+
return { results, '.meta': { totalChecked } };
|
|
59
|
+
},
|
|
60
|
+
prettyPrint: {
|
|
61
|
+
[linter_format_1.LintingPrettyPrintContext.Query]: (result) => `Possible hardcoded credential in \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)}`,
|
|
62
|
+
[linter_format_1.LintingPrettyPrintContext.Full]: (result) => `Variable \`${result.variableName}\` at ${range_1.SourceLocation.format(result.loc)} appears to contain a hardcoded credential`
|
|
63
|
+
},
|
|
64
|
+
info: {
|
|
65
|
+
name: 'No Leaked Credentials',
|
|
66
|
+
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).',
|
|
67
|
+
tags: [linter_tags_1.LintingRuleTag.Security, linter_tags_1.LintingRuleTag.Experimental, linter_tags_1.LintingRuleTag.Smell],
|
|
68
|
+
certainty: linter_format_1.LintingRuleCertainty.BestEffort,
|
|
69
|
+
defaultConfig: {
|
|
70
|
+
credentialNamePattern: defaultCredentialNamePattern,
|
|
71
|
+
credentialValuePattern: defaultCredentialValuePattern
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=no-leaked-credentials.js.map
|
|
@@ -17,17 +17,10 @@ export interface ProblematicInputsConfig extends MergeableRecord {
|
|
|
17
17
|
inputFns?: InputClassifierConfig;
|
|
18
18
|
pipeCommandFunctions?: PipeCommandFunctionSpec | PipeCommandFunctionSpec[];
|
|
19
19
|
}
|
|
20
|
-
export type ProblematicInputsMetadata = MergeableRecord;
|
|
21
20
|
export declare const PROBLEMATIC_INPUTS: {
|
|
22
21
|
readonly createSearch: (config: ProblematicInputsConfig) => import("../../search/flowr-search-builder").FlowrSearchBuilder<"from-query", [], 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>[]>>;
|
|
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: {
|
|
24
|
-
normalize: import("../../r-bridge/lang-4.x/ast/model/processing/decorate").NormalizedAst;
|
|
25
|
-
dataflow: import("../../dataflow/info").DataflowInformation;
|
|
26
|
-
cfg: import("../../control-flow/control-flow-graph").ControlFlowInformation;
|
|
27
|
-
analyzer: import("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider;
|
|
28
|
-
}) => Promise<{
|
|
22
|
+
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("../../project/flowr-analyzer").ReadonlyFlowrAnalysisProvider<import("../../r-bridge/parser").KnownParser>) => Promise<{
|
|
29
23
|
results: ProblematicInputsResult[];
|
|
30
|
-
'.meta': {};
|
|
31
24
|
}>;
|
|
32
25
|
readonly prettyPrint: {
|
|
33
26
|
readonly query: (result: ProblematicInputsResult) => string;
|
|
@@ -90,6 +90,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
90
90
|
]);
|
|
91
91
|
},
|
|
92
92
|
processSearchResult: async (elements, config, data) => {
|
|
93
|
+
const df = await data.dataflow();
|
|
93
94
|
const results = [];
|
|
94
95
|
const seen = new Set();
|
|
95
96
|
const defaultAccept = [simple_input_classifier_1.InputType.Constant, simple_input_classifier_1.InputType.DerivedConstant];
|
|
@@ -108,11 +109,11 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
108
109
|
}
|
|
109
110
|
const loc = range_1.SourceLocation.fromNode(element.node) ?? range_1.SourceLocation.invalid();
|
|
110
111
|
if (pipeSpec !== undefined) {
|
|
111
|
-
const vertex =
|
|
112
|
+
const vertex = df.graph.getVertex(nid);
|
|
112
113
|
const fileArgId = resolveFileArgId(vertex, pipeSpec.argIdx, pipeSpec.argName);
|
|
113
114
|
if (fileArgId !== undefined) {
|
|
114
115
|
const criterion = parse_1.SlicingCriterion.fromId(fileArgId);
|
|
115
|
-
const all = await data.
|
|
116
|
+
const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
|
|
116
117
|
const sources = all['input-sources']?.results?.[criterion] ?? [];
|
|
117
118
|
const r = checkPipeInjection(nid, loc, name, sources);
|
|
118
119
|
if (r !== undefined) {
|
|
@@ -123,7 +124,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
123
124
|
}
|
|
124
125
|
else {
|
|
125
126
|
const criterion = parse_1.SlicingCriterion.fromId(nid);
|
|
126
|
-
const all = await data.
|
|
127
|
+
const all = await data.query([{ type: 'input-sources', criterion, config: config.inputFns }]);
|
|
127
128
|
const sources = all['input-sources']?.results?.[criterion] ?? [];
|
|
128
129
|
if (isProblematicForAllowed(sources, defaultAccept)) {
|
|
129
130
|
seen.add(nid);
|
|
@@ -131,7 +132,7 @@ exports.PROBLEMATIC_INPUTS = {
|
|
|
131
132
|
}
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
|
-
return { results
|
|
135
|
+
return { results };
|
|
135
136
|
},
|
|
136
137
|
prettyPrint: {
|
|
137
138
|
[linter_format_1.LintingPrettyPrintContext.Query]: result => {
|