@eagleoutice/flowr 2.16.8 → 2.17.1
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 +16 -10
- package/abstract-interpretation/absint-inference.d.ts +17 -1
- package/abstract-interpretation/absint-inference.js +118 -3
- package/abstract-interpretation/data-frame/arguments.d.ts +11 -1
- package/abstract-interpretation/data-frame/arguments.js +12 -0
- package/abstract-interpretation/domains/lattice.d.ts +2 -0
- package/abstract-interpretation/domains/lattice.js +0 -6
- package/abstract-interpretation/domains/multi-value-state-domain.d.ts +2 -1
- package/abstract-interpretation/domains/multi-value-state-domain.js +7 -3
- package/abstract-interpretation/domains/partial-product-domain.js +2 -1
- package/abstract-interpretation/domains/state-abstract-domain.d.ts +6 -3
- package/abstract-interpretation/domains/state-abstract-domain.js +13 -7
- package/abstract-interpretation/domains/state-domain.d.ts +4 -0
- package/config.d.ts +32 -0
- package/config.js +23 -3
- package/control-flow/useless-loop.js +10 -8
- package/data/r-primitives.generated.d.ts +1 -0
- package/data/r-primitives.generated.js +9 -0
- package/data/sigdb/sigdb.remote.json +110 -110
- package/dataflow/environments/built-in-props.d.ts +16 -2
- package/dataflow/environments/built-in-props.js +23 -3
- package/dataflow/environments/built-in.js +13 -3
- package/dataflow/environments/default-builtin-config.d.ts +268 -7
- package/dataflow/environments/default-builtin-config.js +72 -13
- package/dataflow/environments/identifier.d.ts +7 -1
- package/dataflow/environments/query-fn-props.d.ts +9 -3
- package/dataflow/environments/query-fn-props.js +13 -5
- package/dataflow/extractor.js +49 -14
- package/dataflow/fn/class-declaration.js +1 -8
- package/dataflow/fn/function-semantics.d.ts +1 -0
- package/dataflow/graph/df-helper.d.ts +2 -0
- package/dataflow/graph/df-helper.js +7 -0
- package/documentation/wiki-linter.js +29 -0
- package/documentation/wiki-query.js +20 -1
- package/linter/linter-executor.js +2 -1
- package/linter/linter-rules.d.ts +65 -0
- package/linter/linter-rules.js +5 -1
- package/linter/rules/cmd-check/global-environment-modification.d.ts +14 -1
- package/linter/rules/cmd-check/global-environment-modification.js +15 -7
- package/linter/rules/network-functions.js +10 -2
- package/linter/rules/no-leaked-credentials.d.ts +1 -0
- package/linter/rules/no-leaked-credentials.js +3 -3
- package/linter/rules/process-state-in-session.d.ts +71 -0
- package/linter/rules/process-state-in-session.js +267 -0
- package/linter/rules/secret-exfiltration.d.ts +80 -0
- package/linter/rules/secret-exfiltration.js +183 -0
- package/linter/rules/unused-import.js +11 -1
- package/package.json +1 -1
- package/project/cache/flowr-analyzer-cache.d.ts +4 -0
- package/project/cache/flowr-analyzer-cache.js +11 -0
- package/project/context/flowr-analyzer-dependencies-context.d.ts +3 -0
- package/project/context/flowr-analyzer-dependencies-context.js +6 -0
- package/project/context/flowr-file.d.ts +2 -2
- package/project/context/flowr-file.js +2 -2
- package/project/flowr-analyzer.d.ts +6 -0
- package/project/flowr-analyzer.js +4 -0
- package/project/plugins/file-plugins/files/flowr-manifest-files.d.ts +39 -4
- package/project/plugins/file-plugins/files/flowr-manifest-files.js +134 -30
- package/project/plugins/file-plugins/files/flowr-namespace-file.d.ts +2 -0
- package/project/plugins/file-plugins/files/flowr-namespace-file.js +22 -3
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.d.ts +7 -0
- package/project/plugins/file-plugins/flowr-analyzer-manifest-file-plugin.js +14 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.d.ts +1 -1
- package/project/plugins/file-plugins/flowr-analyzer-virtualenv-file-plugin.js +3 -3
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.d.ts +18 -5
- package/project/plugins/package-version-plugins/flowr-analyzer-meta-manifest-file-plugin.js +43 -15
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts +12 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js +31 -2
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.d.ts +58 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js +237 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.d.ts +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-plugin.js +8 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts +7 -0
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +24 -18
- package/project/plugins/plugin-registry.d.ts +5 -4
- package/project/plugins/plugin-registry.js +6 -0
- package/project/plugins/project-discovery/flowr-analyzer-project-discovery-plugin.js +4 -4
- package/project/sigdb/decode.js +13 -3
- package/project/sigdb/decompress.d.ts +4 -0
- package/project/sigdb/decompress.js +60 -25
- package/project/sigdb/manifest.d.ts +1 -1
- package/project/sigdb/manifest.js +2 -5
- package/project/sigdb/memory-source.d.ts +6 -4
- package/project/sigdb/memory-source.js +6 -5
- package/project/sigdb/on-demand/fetch.d.ts +18 -0
- package/project/sigdb/on-demand/fetch.js +127 -0
- package/project/sigdb/on-demand/package-sources.d.ts +40 -0
- package/project/sigdb/on-demand/package-sources.js +263 -0
- package/project/sigdb/on-demand/recoverer.d.ts +40 -0
- package/project/sigdb/on-demand/recoverer.js +169 -0
- package/project/sigdb/on-demand/remote-sources.d.ts +72 -0
- package/project/sigdb/on-demand/remote-sources.js +132 -0
- package/project/sigdb/on-demand/tar.d.ts +19 -0
- package/project/sigdb/on-demand/tar.js +119 -0
- package/project/sigdb/reader.js +15 -6
- package/project/sigdb/sigdb-download.d.ts +3 -7
- package/project/sigdb/sigdb-download.js +71 -72
- package/queries/catalog/dependencies-query/function-info/derived-functions.d.ts +5 -0
- package/queries/catalog/dependencies-query/function-info/derived-functions.js +17 -1
- package/queries/catalog/dependencies-query/function-info/read-functions.js +3 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +11 -1
- package/queries/catalog/taint-query/taint-query-executor.d.ts +7 -0
- package/queries/catalog/taint-query/taint-query-executor.js +30 -0
- package/queries/catalog/taint-query/taint-query-format.d.ts +29 -0
- package/queries/catalog/taint-query/taint-query-format.js +124 -0
- package/queries/query.d.ts +12 -1
- package/queries/query.js +2 -0
- package/r-bridge/data/data.d.ts +29 -0
- package/r-bridge/data/data.js +23 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.d.ts +4 -0
- package/r-bridge/lang-4.x/tree-sitter/tree-sitter-executor.js +8 -0
- package/taint-analysis/builder/domain.d.ts +14 -0
- package/taint-analysis/builder/domain.js +69 -0
- package/taint-analysis/builder/report-template.d.ts +50 -0
- package/taint-analysis/builder/report-template.js +46 -0
- package/taint-analysis/builder/taint-analysis-definition.d.ts +108 -0
- package/taint-analysis/builder/taint-analysis-definition.js +128 -0
- package/taint-analysis/builder/taint-analysis.d.ts +124 -0
- package/taint-analysis/builder/taint-analysis.js +93 -0
- package/taint-analysis/builtin-index-bridge.d.ts +20 -0
- package/taint-analysis/builtin-index-bridge.js +48 -0
- package/taint-analysis/eval/eval.d.ts +1 -0
- package/taint-analysis/eval/eval.js +124 -0
- package/taint-analysis/eval/instrumentation.d.ts +59 -0
- package/taint-analysis/eval/instrumentation.js +124 -0
- package/taint-analysis/finite-domain.d.ts +41 -0
- package/taint-analysis/finite-domain.js +118 -0
- package/taint-analysis/function-categories.d.ts +31 -0
- package/taint-analysis/function-categories.js +61 -0
- package/taint-analysis/logger.d.ts +1 -0
- package/taint-analysis/logger.js +6 -0
- package/taint-analysis/predefined/determinism.d.ts +6 -0
- package/taint-analysis/predefined/determinism.js +14 -0
- package/taint-analysis/predefined/normalization.d.ts +17 -0
- package/taint-analysis/predefined/normalization.js +150 -0
- package/taint-analysis/predefined/predefined.d.ts +12 -0
- package/taint-analysis/predefined/predefined.js +18 -0
- package/taint-analysis/predefined/randomness-analysis.d.ts +6 -0
- package/taint-analysis/predefined/randomness-analysis.js +124 -0
- package/taint-analysis/predefined/secret-analysis.d.ts +77 -0
- package/taint-analysis/predefined/secret-analysis.js +170 -0
- package/taint-analysis/predefined/security-analysis.d.ts +7 -0
- package/taint-analysis/predefined/security-analysis.js +91 -0
- package/taint-analysis/taint-mapping.d.ts +89 -0
- package/taint-analysis/taint-mapping.js +81 -0
- package/taint-analysis/taint-resolve.d.ts +26 -0
- package/taint-analysis/taint-resolve.js +86 -0
- package/taint-analysis/taint-visitor.d.ts +80 -0
- package/taint-analysis/taint-visitor.js +82 -0
- package/util/flowr-version.d.ts +1 -1
- package/util/flowr-version.js +2 -2
- package/util/r-version.js +4 -2
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerMetaUvrManifestFilePlugin = exports.FlowrAnalyzerMetaRProjectFilePlugin = void 0;
|
|
3
|
+
exports.FlowrAnalyzerMetaRigScriptPlugin = exports.FlowrAnalyzerMetaRigProjectFilePlugin = exports.FlowrAnalyzerMetaUvrManifestFilePlugin = exports.FlowrAnalyzerMetaRProjectFilePlugin = void 0;
|
|
4
4
|
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
5
5
|
const semver_1 = require("semver");
|
|
6
6
|
const flowr_file_1 = require("../../context/flowr-file");
|
|
7
7
|
const flowr_analyzer_meta_context_1 = require("../../context/flowr-analyzer-meta-context");
|
|
8
8
|
const flowr_manifest_files_1 = require("../file-plugins/files/flowr-manifest-files");
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
11
|
-
* without a namespace
|
|
10
|
+
* Contributes what a manifest declares: its metadata, and the packages needed to run the project. The name is
|
|
11
|
+
* contributed without a namespace, such a project is no package, so `a::b` must not resolve against it.
|
|
12
12
|
*/
|
|
13
|
+
function contributeManifest(ctx, manifest) {
|
|
14
|
+
const declares = manifest.declares();
|
|
15
|
+
ctx.meta.contribute({
|
|
16
|
+
name: manifest.projectName(),
|
|
17
|
+
rVersion: manifest.rVersion(),
|
|
18
|
+
declares
|
|
19
|
+
}, flowr_analyzer_meta_context_1.MetaPriority.Manifest);
|
|
20
|
+
// like a `DESCRIPTION` `Suggests`, anything but the imports (and depends) is reported but not needed to run the project
|
|
21
|
+
for (const pkg of [...declares.depends ?? [], ...declares.imports ?? []]) {
|
|
22
|
+
ctx.deps.addDeclaredDependency(pkg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Extracts the project metadata and the declared dependencies from a project manifest. */
|
|
13
26
|
class FlowrAnalyzerMetaManifestFilePlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
14
27
|
version = new semver_1.SemVer('0.1.0');
|
|
15
28
|
process(ctx) {
|
|
16
29
|
for (const file of ctx.files.getFilesByRole(flowr_file_1.FileRole.Manifest)) {
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
const declares = file.declares();
|
|
21
|
-
ctx.meta.contribute({
|
|
22
|
-
name: file.projectName(),
|
|
23
|
-
rVersion: file.rVersion(),
|
|
24
|
-
declares
|
|
25
|
-
}, flowr_analyzer_meta_context_1.MetaPriority.Manifest);
|
|
26
|
-
// like a `DESCRIPTION` `Suggests`, anything but the imports is reported but not needed to run the project
|
|
27
|
-
for (const pkg of declares.imports ?? []) {
|
|
28
|
-
ctx.deps.addDeclaredDependency(pkg);
|
|
30
|
+
if (file instanceof this.reads) {
|
|
31
|
+
contributeManifest(ctx, file);
|
|
29
32
|
}
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -44,4 +47,29 @@ class FlowrAnalyzerMetaUvrManifestFilePlugin extends FlowrAnalyzerMetaManifestFi
|
|
|
44
47
|
reads = flowr_manifest_files_1.FlowrUvrManifestFile;
|
|
45
48
|
}
|
|
46
49
|
exports.FlowrAnalyzerMetaUvrManifestFilePlugin = FlowrAnalyzerMetaUvrManifestFilePlugin;
|
|
50
|
+
/** Reads a rig `rproj.toml`, whose dependency groups and optional dependencies land in `suggests`. */
|
|
51
|
+
class FlowrAnalyzerMetaRigProjectFilePlugin extends FlowrAnalyzerMetaManifestFilePlugin {
|
|
52
|
+
name = 'flowr-analyzer-meta-rig-project-file-plugin';
|
|
53
|
+
description = 'Extracts project meta information and dependencies from a rig rproj.toml.';
|
|
54
|
+
reads = flowr_manifest_files_1.FlowrRigProjectFile;
|
|
55
|
+
}
|
|
56
|
+
exports.FlowrAnalyzerMetaRigProjectFilePlugin = FlowrAnalyzerMetaRigProjectFilePlugin;
|
|
57
|
+
/**
|
|
58
|
+
* Reads the inline `# /// script` block a rig script states its dependencies in (see {@link rigScriptManifest}),
|
|
59
|
+
* in R scripts and notebooks alike, as the code of a notebook is what its top is checked for.
|
|
60
|
+
*/
|
|
61
|
+
class FlowrAnalyzerMetaRigScriptPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
62
|
+
name = 'flowr-analyzer-meta-rig-script-plugin';
|
|
63
|
+
description = 'Extracts the dependencies a rig script declares in its inline # /// script block.';
|
|
64
|
+
version = new semver_1.SemVer('0.1.0');
|
|
65
|
+
process(ctx) {
|
|
66
|
+
for (const file of ctx.files.getFilesByRole(flowr_file_1.FileRole.Source)) {
|
|
67
|
+
const manifest = (0, flowr_manifest_files_1.rigScriptManifest)(file.content().toString(), file.path());
|
|
68
|
+
if (manifest !== undefined) {
|
|
69
|
+
contributeManifest(ctx, manifest);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.FlowrAnalyzerMetaRigScriptPlugin = FlowrAnalyzerMetaRigScriptPlugin;
|
|
47
75
|
//# sourceMappingURL=flowr-analyzer-meta-manifest-file-plugin.js.map
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.d.ts
CHANGED
|
@@ -32,3 +32,15 @@ export declare class FlowrAnalyzerPackageVersionsUvrPlugin extends FlowrAnalyzer
|
|
|
32
32
|
readonly version: SemVer;
|
|
33
33
|
process(ctx: FlowrAnalyzerContext): void;
|
|
34
34
|
}
|
|
35
|
+
/** a rig lockfile: the project's `rproj.lock`, or `analysis.R.lock` beside the script `analysis.R` */
|
|
36
|
+
export declare const RigLockFilePattern: RegExp;
|
|
37
|
+
/**
|
|
38
|
+
* Reads package versions from a rig lockfile (TOML). rig solves one target per R version and platform, and the
|
|
39
|
+
* targets may pin a package (or R) differently, so only what all targets listing it agree on is a pin.
|
|
40
|
+
*/
|
|
41
|
+
export declare class FlowrAnalyzerPackageVersionsRigPlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
42
|
+
readonly name = "flowr-analyzer-package-versions-rig-plugin";
|
|
43
|
+
readonly description = "Extracts package versions from a rig rproj.lock or script lockfile.";
|
|
44
|
+
readonly version: SemVer;
|
|
45
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
46
|
+
}
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrAnalyzerPackageVersionsUvrPlugin = exports.FlowrAnalyzerPackageVersionsRvPlugin = exports.FlowrAnalyzerPackageVersionsPackratPlugin = exports.FlowrAnalyzerPackageVersionsRenvPlugin = exports.lockfileLog = void 0;
|
|
3
|
+
exports.FlowrAnalyzerPackageVersionsRigPlugin = exports.RigLockFilePattern = exports.FlowrAnalyzerPackageVersionsUvrPlugin = exports.FlowrAnalyzerPackageVersionsRvPlugin = exports.FlowrAnalyzerPackageVersionsPackratPlugin = exports.FlowrAnalyzerPackageVersionsRenvPlugin = exports.lockfileLog = void 0;
|
|
4
4
|
exports.pin = pin;
|
|
5
5
|
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
6
6
|
const semver_1 = require("semver");
|
|
@@ -14,7 +14,10 @@ const flowr_description_file_1 = require("../file-plugins/files/flowr-descriptio
|
|
|
14
14
|
exports.lockfileLog = log_1.log.getSubLogger({ name: 'flowr-analyzer-package-versions-lockfile-plugin' });
|
|
15
15
|
/** The {@link FileRole.VirtualEnv} lockfiles named `name` (e.g. `renv.lock`), matched case-insensitively like the role is assigned. */
|
|
16
16
|
function virtualEnvFiles(ctx, name) {
|
|
17
|
-
return ctx.files.getFilesByRole(flowr_file_1.FileRole.VirtualEnv).filter(f =>
|
|
17
|
+
return ctx.files.getFilesByRole(flowr_file_1.FileRole.VirtualEnv).filter(f => {
|
|
18
|
+
const base = (0, built_in_source_1.platformBasename)(f.path());
|
|
19
|
+
return typeof name === 'string' ? base.toLowerCase() === name : name.test(base);
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
22
|
/** Declares the dependency `name` pinned to the given `version`. */
|
|
20
23
|
function pin(ctx, name, version) {
|
|
@@ -113,4 +116,30 @@ class FlowrAnalyzerPackageVersionsUvrPlugin extends flowr_analyzer_package_versi
|
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
118
|
exports.FlowrAnalyzerPackageVersionsUvrPlugin = FlowrAnalyzerPackageVersionsUvrPlugin;
|
|
119
|
+
/** a rig lockfile: the project's `rproj.lock`, or `analysis.R.lock` beside the script `analysis.R` */
|
|
120
|
+
exports.RigLockFilePattern = /^(rproj|.+\.r)\.lock$/i;
|
|
121
|
+
/**
|
|
122
|
+
* Reads package versions from a rig lockfile (TOML). rig solves one target per R version and platform, and the
|
|
123
|
+
* targets may pin a package (or R) differently, so only what all targets listing it agree on is a pin.
|
|
124
|
+
*/
|
|
125
|
+
class FlowrAnalyzerPackageVersionsRigPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
126
|
+
name = 'flowr-analyzer-package-versions-rig-plugin';
|
|
127
|
+
description = 'Extracts package versions from a rig rproj.lock or script lockfile.';
|
|
128
|
+
version = new semver_1.SemVer('0.1.0');
|
|
129
|
+
process(ctx) {
|
|
130
|
+
pinFromTomlLock(ctx, exports.RigLockFilePattern, lock => {
|
|
131
|
+
const targets = Array.isArray(lock.targets) ? lock.targets : [];
|
|
132
|
+
const versions = new Map();
|
|
133
|
+
for (const p of targets.flatMap((t) => Array.isArray(t.packages) ? t.packages : [])) {
|
|
134
|
+
(versions.get(p.package) ?? versions.set(p.package, new Set()).get(p.package))?.add(p.version);
|
|
135
|
+
}
|
|
136
|
+
const rVersions = new Set(targets.map(t => t.r_version));
|
|
137
|
+
return {
|
|
138
|
+
rVersion: rVersions.size === 1 ? [...rVersions][0] : undefined,
|
|
139
|
+
packages: [...versions].filter(([, vs]) => vs.size === 1).map(([name, vs]) => ({ name, version: [...vs][0] }))
|
|
140
|
+
};
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.FlowrAnalyzerPackageVersionsRigPlugin = FlowrAnalyzerPackageVersionsRigPlugin;
|
|
116
145
|
//# sourceMappingURL=flowr-analyzer-package-versions-lockfile-plugin.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { SemVer } from 'semver';
|
|
2
|
+
import { FlowrAnalyzerPackageVersionsPlugin } from './flowr-analyzer-package-versions-plugin';
|
|
3
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
4
|
+
import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
5
|
+
import type { PackageSignatureSource } from '../../sigdb/reader';
|
|
6
|
+
import { type OnDemandOptions } from '../../sigdb/on-demand/recoverer';
|
|
7
|
+
import { type FetchBytes, type OnDemandSource } from '../../sigdb/on-demand/remote-sources';
|
|
8
|
+
import type { BuiltInIndex } from '../../../dataflow/environments/query-fn-props';
|
|
9
|
+
/** What the code says about the packages it uses: their names, and the repositories it installs some of them from. */
|
|
10
|
+
export declare function packagesNamedIn(ast: NormalizedAst): {
|
|
11
|
+
names: Set<string>;
|
|
12
|
+
github: Map<string, string>;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The names of the security-relevant built-ins, see {@link SecurityRelevant}, and of those with an argument open
|
|
16
|
+
* to injection or naming a resource. A package flowR fetched on demand is no package anyone vetted, so it may not
|
|
17
|
+
* export one of these: `library(evil)` exporting `system` would otherwise turn every later `system(cmd)` into a
|
|
18
|
+
* call of `evil::system`, which no analysis looking for `system` would see.
|
|
19
|
+
*/
|
|
20
|
+
export declare function shieldedNames(index: BuiltInIndex): ReadonlySet<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Recovers packages no signature database knows from their sources when the analyzed code uses them: before the
|
|
23
|
+
* dataflow is built it fetches the source of every package the code loads or names with `::` that nothing else
|
|
24
|
+
* resolves, from GitHub (the repository the project installs it from or the configuration names), CRAN, or
|
|
25
|
+
* Bioconductor, and serves their exports and the formals of their functions. Off unless
|
|
26
|
+
* `solver.sigdb.onDemand.enabled` says otherwise, never in secure mode, and only for packages nothing else knows.
|
|
27
|
+
* Further sources come in through the constructor.
|
|
28
|
+
*/
|
|
29
|
+
export declare class FlowrAnalyzerPackageVersionsOnDemandPlugin extends FlowrAnalyzerPackageVersionsPlugin {
|
|
30
|
+
readonly name = "flowr-analyzer-package-versions-on-demand-plugin";
|
|
31
|
+
readonly description = "Fetches the sources of packages no database knows from CRAN, Bioconductor, or GitHub.";
|
|
32
|
+
readonly version: SemVer;
|
|
33
|
+
private readonly overrides?;
|
|
34
|
+
private readonly extraSources;
|
|
35
|
+
private readonly fetchBytes;
|
|
36
|
+
private readonly recovered;
|
|
37
|
+
private source;
|
|
38
|
+
private recoverer;
|
|
39
|
+
private parser;
|
|
40
|
+
private shielded;
|
|
41
|
+
/**
|
|
42
|
+
* @param overrides - options replacing what `solver.sigdb.onDemand` states, `enabled` included
|
|
43
|
+
* @param extraSources - sources besides the built-in ones, used where `sources` lists their name (or after the listed ones if it does not)
|
|
44
|
+
* @param fetchBytes - how to download, HTTPS to public hosts and the configured mirrors by default
|
|
45
|
+
*/
|
|
46
|
+
constructor(overrides?: Partial<OnDemandOptions>, extraSources?: readonly OnDemandSource[], fetchBytes?: FetchBytes);
|
|
47
|
+
private optionsOf;
|
|
48
|
+
private sourcesOf;
|
|
49
|
+
private recovererOf;
|
|
50
|
+
/** whether the options allow recovering `name` at all */
|
|
51
|
+
private static wanted;
|
|
52
|
+
/** keeps the package, without the exports that would take over a security-relevant built-in, see {@link shieldedNames} */
|
|
53
|
+
private remember;
|
|
54
|
+
process(ctx: FlowrAnalyzerContext): void;
|
|
55
|
+
prepare(ctx: FlowrAnalyzerContext, ast: NormalizedAst): Promise<void>;
|
|
56
|
+
signatureSources(): readonly PackageSignatureSource[];
|
|
57
|
+
packagesExporting(name: string): readonly string[];
|
|
58
|
+
}
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin.js
ADDED
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FlowrAnalyzerPackageVersionsOnDemandPlugin = void 0;
|
|
7
|
+
exports.packagesNamedIn = packagesNamedIn;
|
|
8
|
+
exports.shieldedNames = shieldedNames;
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const semver_1 = require("semver");
|
|
11
|
+
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
12
|
+
const memory_source_1 = require("../../sigdb/memory-source");
|
|
13
|
+
const flowr_analyzer_package_versions_sigdb_plugin_1 = require("./flowr-analyzer-package-versions-sigdb-plugin");
|
|
14
|
+
const recoverer_1 = require("../../sigdb/on-demand/recoverer");
|
|
15
|
+
const remote_sources_1 = require("../../sigdb/on-demand/remote-sources");
|
|
16
|
+
const package_sources_1 = require("../../sigdb/on-demand/package-sources");
|
|
17
|
+
const built_in_props_1 = require("../../../dataflow/environments/built-in-props");
|
|
18
|
+
const fetch_1 = require("../../sigdb/on-demand/fetch");
|
|
19
|
+
const decompress_1 = require("../../sigdb/decompress");
|
|
20
|
+
const tree_sitter_executor_1 = require("../../../r-bridge/lang-4.x/tree-sitter/tree-sitter-executor");
|
|
21
|
+
const flowr_analyzer_description_file_plugin_1 = require("../file-plugins/flowr-analyzer-description-file-plugin");
|
|
22
|
+
const r_symbol_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-symbol");
|
|
23
|
+
const r_string_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-string");
|
|
24
|
+
const r_function_call_1 = require("../../../r-bridge/lang-4.x/ast/model/nodes/r-function-call");
|
|
25
|
+
const identifier_1 = require("../../../dataflow/environments/identifier");
|
|
26
|
+
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
27
|
+
const secure_mode_1 = require("../../../util/secure-mode");
|
|
28
|
+
/** the calls naming the packages to load in their arguments */
|
|
29
|
+
const Loaders = new Set(['library', 'require', 'requireNamespace', 'loadNamespace', 'attachNamespace', 'use', 'p_load', 'pkg_attach', 'pkg_attach2']);
|
|
30
|
+
/** the calls installing packages from where their arguments name, like `remotes::install_github("masurp/ggmirt")` */
|
|
31
|
+
const Installers = new Set(['install_github', 'install_gitlab', 'pkg_install', 'pak', 'p_load_gh', 'p_install_gh', 'install']);
|
|
32
|
+
/** a name or string literal as the text it stands for */
|
|
33
|
+
function literalText(node) {
|
|
34
|
+
if (r_symbol_1.RSymbol.is(node)) {
|
|
35
|
+
return identifier_1.Identifier.getName(node.content);
|
|
36
|
+
}
|
|
37
|
+
else if (r_string_1.RString.is(node)) {
|
|
38
|
+
return node.content.str;
|
|
39
|
+
}
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
/** What the code says about the packages it uses: their names, and the repositories it installs some of them from. */
|
|
43
|
+
function packagesNamedIn(ast) {
|
|
44
|
+
const names = new Set();
|
|
45
|
+
const github = new Map();
|
|
46
|
+
for (const node of ast.idMap.values()) {
|
|
47
|
+
if (r_symbol_1.RSymbol.is(node)) {
|
|
48
|
+
const ns = identifier_1.Identifier.getNamespace(node.content);
|
|
49
|
+
if (ns !== undefined) {
|
|
50
|
+
names.add(ns);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (r_function_call_1.RFunctionCall.isNamed(node)) {
|
|
54
|
+
const fn = identifier_1.Identifier.getName(node.functionName.content);
|
|
55
|
+
const values = node.arguments.map(a => a === null || a === undefined ? undefined : literalText(a.value));
|
|
56
|
+
if (Loaders.has(fn)) {
|
|
57
|
+
/* every one `pacman::p_load(a, b)` names, only the first `library(a, character.only = TRUE)` does */
|
|
58
|
+
(fn === 'p_load' || fn.startsWith('pkg_attach') ? values : values.slice(0, 1)).forEach(v => v !== undefined && names.add(v));
|
|
59
|
+
}
|
|
60
|
+
else if (Installers.has(fn)) {
|
|
61
|
+
for (const value of values) {
|
|
62
|
+
const remote = value === undefined ? undefined : (0, remote_sources_1.parseGitHubRemote)(value);
|
|
63
|
+
if (remote !== undefined) {
|
|
64
|
+
github.set(remote.repo, value);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return { names, github };
|
|
71
|
+
}
|
|
72
|
+
/** what makes a built-in matter to a security analysis: running code or commands, reaching the network, files, or databases, emitting HTML or JavaScript, loading code */
|
|
73
|
+
const SecurityRelevant = [
|
|
74
|
+
built_in_props_1.SemanticCallTag.Eval, built_in_props_1.SemanticCallTag.Process, built_in_props_1.SemanticCallTag.Network, built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Database,
|
|
75
|
+
built_in_props_1.SemanticCallTag.Html, built_in_props_1.SemanticCallTag.JavaScript, built_in_props_1.SemanticCallTag.Opens, built_in_props_1.SemanticCallTag.User, built_in_props_1.SemanticCallTag.Reads,
|
|
76
|
+
built_in_props_1.SemanticCallTag.Writes, built_in_props_1.SemanticCallTag.LoadsPackage, built_in_props_1.SemanticCallTag.AttachesPackage
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* The names of the security-relevant built-ins, see {@link SecurityRelevant}, and of those with an argument open
|
|
80
|
+
* to injection or naming a resource. A package flowR fetched on demand is no package anyone vetted, so it may not
|
|
81
|
+
* export one of these: `library(evil)` exporting `system` would otherwise turn every later `system(cmd)` into a
|
|
82
|
+
* call of `evil::system`, which no analysis looking for `system` would see.
|
|
83
|
+
*/
|
|
84
|
+
function shieldedNames(index) {
|
|
85
|
+
return new Set([
|
|
86
|
+
...index.with(SecurityRelevant), ...index.with(built_in_props_1.CallProp.Ffi),
|
|
87
|
+
...index.params(built_in_props_1.ArgProp.Injectable | built_in_props_1.ArgProp.Resource).map(p => p.call)
|
|
88
|
+
].map(identifier_1.Identifier.getName));
|
|
89
|
+
}
|
|
90
|
+
/** the hosts of the mirrors the (trusted) configuration names, which may be on the local network */
|
|
91
|
+
function mirrorHosts(opts) {
|
|
92
|
+
return new Set([opts.cranMirror, opts.bioconductorMirror].flatMap(m => {
|
|
93
|
+
try {
|
|
94
|
+
return m === undefined ? [] : [new URL(m).host];
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return [];
|
|
98
|
+
}
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
/** the GitHub remotes of the project's `DESCRIPTION` (`Remotes: masurp/ggmirt`), by repository name */
|
|
102
|
+
function descriptionRemotes(ctx) {
|
|
103
|
+
const remotes = new Map();
|
|
104
|
+
const description = flowr_analyzer_description_file_plugin_1.DescriptionFile.single(ctx, 'no DESCRIPTION, so no Remotes');
|
|
105
|
+
for (const entry of description?.content().get('Remotes')?.flatMap(e => e.split(',')) ?? []) {
|
|
106
|
+
const remote = (0, remote_sources_1.parseGitHubRemote)(entry.trim());
|
|
107
|
+
if (remote !== undefined) {
|
|
108
|
+
remotes.set(remote.repo, entry.trim());
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return remotes;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Recovers packages no signature database knows from their sources when the analyzed code uses them: before the
|
|
115
|
+
* dataflow is built it fetches the source of every package the code loads or names with `::` that nothing else
|
|
116
|
+
* resolves, from GitHub (the repository the project installs it from or the configuration names), CRAN, or
|
|
117
|
+
* Bioconductor, and serves their exports and the formals of their functions. Off unless
|
|
118
|
+
* `solver.sigdb.onDemand.enabled` says otherwise, never in secure mode, and only for packages nothing else knows.
|
|
119
|
+
* Further sources come in through the constructor.
|
|
120
|
+
*/
|
|
121
|
+
class FlowrAnalyzerPackageVersionsOnDemandPlugin extends flowr_analyzer_package_versions_plugin_1.FlowrAnalyzerPackageVersionsPlugin {
|
|
122
|
+
name = 'flowr-analyzer-package-versions-on-demand-plugin';
|
|
123
|
+
description = 'Fetches the sources of packages no database knows from CRAN, Bioconductor, or GitHub.';
|
|
124
|
+
version = new semver_1.SemVer('0.1.0');
|
|
125
|
+
overrides;
|
|
126
|
+
extraSources;
|
|
127
|
+
fetchBytes;
|
|
128
|
+
recovered = new Map();
|
|
129
|
+
source;
|
|
130
|
+
recoverer;
|
|
131
|
+
parser;
|
|
132
|
+
shielded;
|
|
133
|
+
/**
|
|
134
|
+
* @param overrides - options replacing what `solver.sigdb.onDemand` states, `enabled` included
|
|
135
|
+
* @param extraSources - sources besides the built-in ones, used where `sources` lists their name (or after the listed ones if it does not)
|
|
136
|
+
* @param fetchBytes - how to download, HTTPS to public hosts and the configured mirrors by default
|
|
137
|
+
*/
|
|
138
|
+
constructor(overrides, extraSources = [], fetchBytes) {
|
|
139
|
+
super();
|
|
140
|
+
this.overrides = overrides;
|
|
141
|
+
this.extraSources = extraSources;
|
|
142
|
+
this.fetchBytes = fetchBytes;
|
|
143
|
+
}
|
|
144
|
+
optionsOf(config) {
|
|
145
|
+
return { ...config.solver.sigdb.onDemand, ...this.overrides };
|
|
146
|
+
}
|
|
147
|
+
sourcesOf(opts) {
|
|
148
|
+
const known = new Map([...(0, remote_sources_1.builtInOnDemandSources)(opts), ...this.extraSources.map(s => [s.name, s])]);
|
|
149
|
+
const listed = opts.sources ?? ['github', 'cran', 'bioconductor'];
|
|
150
|
+
const unknown = listed.filter(n => !known.has(n));
|
|
151
|
+
if (unknown.length > 0) {
|
|
152
|
+
recoverer_1.onDemandLog.warn(`unknown on-demand signature sources: ${unknown.join(', ')}`);
|
|
153
|
+
}
|
|
154
|
+
const sources = listed.flatMap(n => known.get(n) ?? []);
|
|
155
|
+
return [...sources, ...this.extraSources.filter(s => !listed.includes(s.name))];
|
|
156
|
+
}
|
|
157
|
+
recovererOf(ctx, opts) {
|
|
158
|
+
this.recoverer ??= new recoverer_1.OnDemandRecoverer(opts, {
|
|
159
|
+
sources: this.sourcesOf(opts),
|
|
160
|
+
fetch: this.fetchBytes ?? (0, fetch_1.httpsFetcher)(mirrorHosts(opts)),
|
|
161
|
+
parse: code => {
|
|
162
|
+
this.parser ??= new tree_sitter_executor_1.TreeSitterExecutor();
|
|
163
|
+
return this.parser.parseCode(code);
|
|
164
|
+
},
|
|
165
|
+
cacheDir: opts.cacheDir ?? path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'on-demand')
|
|
166
|
+
});
|
|
167
|
+
return this.recoverer;
|
|
168
|
+
}
|
|
169
|
+
/** whether the options allow recovering `name` at all */
|
|
170
|
+
static wanted(opts, name) {
|
|
171
|
+
return !(0, r_base_packages_1.isBaseRPackage)(name) && (opts.packages === undefined || opts.packages.length === 0 || opts.packages.some(p => new RegExp(p).test(name)));
|
|
172
|
+
}
|
|
173
|
+
/** keeps the package, without the exports that would take over a security-relevant built-in, see {@link shieldedNames} */
|
|
174
|
+
remember(ctx, pkg) {
|
|
175
|
+
this.shielded ??= shieldedNames(ctx.env.builtInIndex);
|
|
176
|
+
const safe = (0, package_sources_1.sanitizeRecovered)(pkg, this.shielded);
|
|
177
|
+
const dropped = pkg.exported.filter(n => this.shielded?.has(n));
|
|
178
|
+
if (dropped.length > 0) {
|
|
179
|
+
recoverer_1.onDemandLog.warn(`${pkg.name} (${pkg.origin}) exports names of security-relevant functions, they keep their usual meaning: ${dropped.join(', ')}`);
|
|
180
|
+
}
|
|
181
|
+
if (safe !== undefined) {
|
|
182
|
+
this.recovered.set(safe.name, safe);
|
|
183
|
+
this.source = undefined;
|
|
184
|
+
}
|
|
185
|
+
return safe;
|
|
186
|
+
}
|
|
187
|
+
process(ctx) {
|
|
188
|
+
const opts = this.optionsOf(ctx.config);
|
|
189
|
+
if (!opts.enabled) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
ctx.deps.addLazyResolver((name, existing) => {
|
|
193
|
+
if (existing?.namespaceInfo !== undefined || !FlowrAnalyzerPackageVersionsOnDemandPlugin.wanted(opts, name)) {
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
const known = this.recovered.get(name);
|
|
197
|
+
const cached = known === undefined ? this.recovererOf(ctx, opts).cached(name) : undefined;
|
|
198
|
+
const pkg = known ?? (cached === undefined ? undefined : this.remember(ctx, cached));
|
|
199
|
+
return pkg === undefined ? undefined : (0, flowr_analyzer_package_versions_sigdb_plugin_1.packageFromExports)(name, { ...pkg, version: pkg.version ?? '' }, ctx.env.statedFor(name)?.keys());
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
async prepare(ctx, ast) {
|
|
203
|
+
const opts = this.optionsOf(ctx.config);
|
|
204
|
+
if (!opts.enabled || (secure_mode_1.SecureMode.isEnabled() && !opts.offline)) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
const { names, github } = packagesNamedIn(ast);
|
|
208
|
+
const remotes = new Map([...descriptionRemotes(ctx), ...github, ...Object.entries(opts.repositories ?? {})]);
|
|
209
|
+
const known = ctx.deps.signatures();
|
|
210
|
+
const requests = [...names]
|
|
211
|
+
.filter(n => FlowrAnalyzerPackageVersionsOnDemandPlugin.wanted(opts, n) && !this.recovered.has(n) && !known.has(n))
|
|
212
|
+
.map(n => ({ name: n, version: ctx.deps.getDependency(n)?.resolvedVersion, github: remotes.get(n) }));
|
|
213
|
+
if (requests.length === 0) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (!tree_sitter_executor_1.TreeSitterExecutor.isInitialized()) {
|
|
217
|
+
await tree_sitter_executor_1.TreeSitterExecutor.initTreeSitter(ctx.config.engines.find((e) => e.type === 'tree-sitter'));
|
|
218
|
+
}
|
|
219
|
+
for (const pkg of await this.recovererOf(ctx, opts).recover(requests)) {
|
|
220
|
+
this.remember(ctx, pkg);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
signatureSources() {
|
|
224
|
+
if (this.recovered.size === 0) {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
this.source ??= new memory_source_1.MemorySignatureSource(new Map([...this.recovered].map(([name, p]) => [name, {
|
|
228
|
+
version: p.version, exported: p.exported, s4Classes: p.s4Classes, functions: p.functions
|
|
229
|
+
}])));
|
|
230
|
+
return [this.source];
|
|
231
|
+
}
|
|
232
|
+
packagesExporting(name) {
|
|
233
|
+
return [...this.recovered.values()].filter(p => p.exported.includes(name)).map(p => p.name);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
exports.FlowrAnalyzerPackageVersionsOnDemandPlugin = FlowrAnalyzerPackageVersionsOnDemandPlugin;
|
|
237
|
+
//# sourceMappingURL=flowr-analyzer-package-versions-on-demand-plugin.js.map
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FlowrAnalyzerPlugin, PluginType } from '../flowr-analyzer-plugin';
|
|
2
2
|
import type { PackageSignatureSource } from '../../sigdb/reader';
|
|
3
3
|
import type { FlowrConfig } from '../../../config';
|
|
4
|
+
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
5
|
+
import type { NormalizedAst } from '../../../r-bridge/lang-4.x/ast/model/processing/decorate';
|
|
4
6
|
/** metadata of a package database a plugin currently has loaded */
|
|
5
7
|
export interface SigDbLoadedInfo {
|
|
6
8
|
scope: string;
|
|
@@ -28,6 +30,12 @@ export declare abstract class FlowrAnalyzerPackageVersionsPlugin extends FlowrAn
|
|
|
28
30
|
addDatabaseSource(_source: string): Promise<void>;
|
|
29
31
|
/** Eagerly parse and mount this plugin's databases up front (no-op for plugins without any). */
|
|
30
32
|
preloadDatabasesSync(): void;
|
|
33
|
+
/**
|
|
34
|
+
* Runs once the code is normalized and before its dataflow is built, the one point where a plugin may wait
|
|
35
|
+
* (on the network, say) for what the dataflow will ask of it, as the lookups during the dataflow are synchronous.
|
|
36
|
+
* No-op by default.
|
|
37
|
+
*/
|
|
38
|
+
prepare(_ctx: FlowrAnalyzerContext, _ast: NormalizedAst): Promise<void>;
|
|
31
39
|
/**
|
|
32
40
|
* Whether this plugin can resolve the always-available base-R packages (so their exports can be attached
|
|
33
41
|
* eagerly for bare base calls). `false` for plugins without a versioned base-R signature source.
|
|
@@ -31,6 +31,14 @@ class FlowrAnalyzerPackageVersionsPlugin extends flowr_analyzer_plugin_1.FlowrAn
|
|
|
31
31
|
}
|
|
32
32
|
/** Eagerly parse and mount this plugin's databases up front (no-op for plugins without any). */
|
|
33
33
|
preloadDatabasesSync() { }
|
|
34
|
+
/**
|
|
35
|
+
* Runs once the code is normalized and before its dataflow is built, the one point where a plugin may wait
|
|
36
|
+
* (on the network, say) for what the dataflow will ask of it, as the lookups during the dataflow are synchronous.
|
|
37
|
+
* No-op by default.
|
|
38
|
+
*/
|
|
39
|
+
prepare(_ctx, _ast) {
|
|
40
|
+
return Promise.resolve();
|
|
41
|
+
}
|
|
34
42
|
/**
|
|
35
43
|
* Whether this plugin can resolve the always-available base-R packages (so their exports can be attached
|
|
36
44
|
* eagerly for bare base calls). `false` for plugins without a versioned base-R signature source.
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { FlowrAnalyzerPackageVersionsPlugin, type SigDbLoadedInfo } from './flowr-analyzer-package-versions-plugin';
|
|
2
2
|
import { SemVer } from 'semver';
|
|
3
|
+
import { Package } from './package';
|
|
3
4
|
import type { FlowrAnalyzerContext } from '../../context/flowr-analyzer-context';
|
|
4
5
|
import { type PackageSignatureSource } from '../../sigdb/reader';
|
|
6
|
+
import { type LibraryExports } from '../../sigdb/schema';
|
|
5
7
|
import { type FlowrConfig } from '../../../config';
|
|
6
8
|
/** the plugin's instance name (pass to `unregisterPlugins` to disable the default sigdb resolver) */
|
|
7
9
|
export declare const SigDbPluginName = "flowr-analyzer-package-versions-sigdb-plugin";
|
|
@@ -110,3 +112,8 @@ export declare class FlowrAnalyzerPackageVersionsSigDbPlugin extends FlowrAnalyz
|
|
|
110
112
|
/** build the resolved {@link Package} (namespace + version) from a source's export view */
|
|
111
113
|
private toResolvedPackage;
|
|
112
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The resolved {@link Package} (namespace and version) of a source's export view. What the configuration states
|
|
117
|
+
* for the package (`stated`) is part of its interface, even where the source misses it.
|
|
118
|
+
*/
|
|
119
|
+
export declare function packageFromExports(name: string, info: Pick<LibraryExports, 'exported' | 's4Classes' | 'version'>, stated?: Iterable<unknown>): Package;
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js
CHANGED
|
@@ -38,6 +38,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.FlowrAnalyzerPackageVersionsSigDbPlugin = exports.sigDbLog = exports.SigDbPluginName = void 0;
|
|
40
40
|
exports.reconstructS3Generics = reconstructS3Generics;
|
|
41
|
+
exports.packageFromExports = packageFromExports;
|
|
41
42
|
const flowr_analyzer_package_versions_plugin_1 = require("./flowr-analyzer-package-versions-plugin");
|
|
42
43
|
const strings_1 = require("../../../util/text/strings");
|
|
43
44
|
const semver_1 = require("semver");
|
|
@@ -483,25 +484,30 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
483
484
|
}
|
|
484
485
|
/** build the resolved {@link Package} (namespace + version) from a source's export view */
|
|
485
486
|
toResolvedPackage(name, info) {
|
|
486
|
-
|
|
487
|
-
const stated = this.analyzerCtx?.env.statedFor(name);
|
|
488
|
-
const exported = stated === undefined ? info.exported.slice() : (0, arrays_1.uniqueArray)([...info.exported, ...[...stated.keys()].map(String)]);
|
|
489
|
-
const namespaceInfo = {
|
|
490
|
-
exportedSymbols: exported,
|
|
491
|
-
exportedFunctions: [],
|
|
492
|
-
exportedS4Methods: [],
|
|
493
|
-
/* the database derives these from the very `exportClasses()` directives the field stands for */
|
|
494
|
-
exportedS4Classes: info.s4Classes.slice(),
|
|
495
|
-
exportS3Generics: reconstructS3Generics(exported),
|
|
496
|
-
exportedPatterns: [],
|
|
497
|
-
importedPackages: new Map(),
|
|
498
|
-
loadsWithSideEffects: false,
|
|
499
|
-
callable: exported
|
|
500
|
-
};
|
|
501
|
-
/* a source may know the exports without knowing which release they are from, and then the package
|
|
502
|
-
carries no version rather than a made-up one */
|
|
503
|
-
return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version || undefined });
|
|
487
|
+
return packageFromExports(name, info, this.analyzerCtx?.env.statedFor(name)?.keys());
|
|
504
488
|
}
|
|
505
489
|
}
|
|
506
490
|
exports.FlowrAnalyzerPackageVersionsSigDbPlugin = FlowrAnalyzerPackageVersionsSigDbPlugin;
|
|
491
|
+
/**
|
|
492
|
+
* The resolved {@link Package} (namespace and version) of a source's export view. What the configuration states
|
|
493
|
+
* for the package (`stated`) is part of its interface, even where the source misses it.
|
|
494
|
+
*/
|
|
495
|
+
function packageFromExports(name, info, stated) {
|
|
496
|
+
const exported = stated === undefined ? info.exported.slice() : (0, arrays_1.uniqueArray)([...info.exported, ...[...stated].map(String)]);
|
|
497
|
+
const namespaceInfo = {
|
|
498
|
+
exportedSymbols: exported,
|
|
499
|
+
exportedFunctions: [],
|
|
500
|
+
exportedS4Methods: [],
|
|
501
|
+
/* the database derives these from the very `exportClasses()` directives the field stands for */
|
|
502
|
+
exportedS4Classes: info.s4Classes.slice(),
|
|
503
|
+
exportS3Generics: reconstructS3Generics(exported),
|
|
504
|
+
exportedPatterns: [],
|
|
505
|
+
importedPackages: new Map(),
|
|
506
|
+
loadsWithSideEffects: false,
|
|
507
|
+
callable: exported
|
|
508
|
+
};
|
|
509
|
+
/* a source may know the exports without knowing which release they are from, and then the package
|
|
510
|
+
carries no version rather than a made-up one */
|
|
511
|
+
return new package_1.Package({ name, namespaceInfo, resolvedVersion: info.version || undefined });
|
|
512
|
+
}
|
|
507
513
|
//# sourceMappingURL=flowr-analyzer-package-versions-sigdb-plugin.js.map
|
|
@@ -2,7 +2,7 @@ import type { FlowrAnalyzerPlugin } from './flowr-analyzer-plugin';
|
|
|
2
2
|
import { FlowrAnalyzerDescriptionFilePlugin } from './file-plugins/flowr-analyzer-description-file-plugin';
|
|
3
3
|
import { FlowrAnalyzerPackageVersionsDescriptionFilePlugin } from './package-version-plugins/flowr-analyzer-package-versions-description-file-plugin';
|
|
4
4
|
import { FlowrAnalyzerPackageVersionsSigDbPlugin } from './package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin';
|
|
5
|
-
import { FlowrAnalyzerPackageVersionsPackratPlugin, FlowrAnalyzerPackageVersionsRenvPlugin, FlowrAnalyzerPackageVersionsRvPlugin, FlowrAnalyzerPackageVersionsUvrPlugin } from './package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin';
|
|
5
|
+
import { FlowrAnalyzerPackageVersionsPackratPlugin, FlowrAnalyzerPackageVersionsRenvPlugin, FlowrAnalyzerPackageVersionsRigPlugin, FlowrAnalyzerPackageVersionsRvPlugin, FlowrAnalyzerPackageVersionsUvrPlugin } from './package-version-plugins/flowr-analyzer-package-versions-lockfile-plugin';
|
|
6
6
|
import { FlowrAnalyzerPackageVersionsSessionInfoPlugin } from './package-version-plugins/flowr-analyzer-package-versions-session-info-plugin';
|
|
7
7
|
import { FlowrAnalyzerLoadingOrderDescriptionFilePlugin } from './loading-order-plugins/flowr-analyzer-loading-order-description-file-plugin';
|
|
8
8
|
import { FlowrAnalyzerLoadingOrderImplicitSourcesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-implicit-sources-plugin';
|
|
@@ -21,8 +21,8 @@ import { FlowrAnalyzerMetaTestFilesPlugin } from './file-plugins/flowr-analyzer-
|
|
|
21
21
|
import { FlowrAnalyzerMetaInstFilesPlugin } from './file-plugins/flowr-analyzer-inst-file-plugin';
|
|
22
22
|
import { FlowrAnalyzerLicenseFilePlugin } from './file-plugins/flowr-analyzer-license-file-plugin';
|
|
23
23
|
import { FlowrAnalyzerVirtualEnvFilePlugin } from './file-plugins/flowr-analyzer-virtualenv-file-plugin';
|
|
24
|
-
import { FlowrAnalyzerRProjectFilePlugin, FlowrAnalyzerUvrManifestFilePlugin } from './file-plugins/flowr-analyzer-manifest-file-plugin';
|
|
25
|
-
import { FlowrAnalyzerMetaRProjectFilePlugin, FlowrAnalyzerMetaUvrManifestFilePlugin } from './package-version-plugins/flowr-analyzer-meta-manifest-file-plugin';
|
|
24
|
+
import { FlowrAnalyzerRigProjectFilePlugin, FlowrAnalyzerRProjectFilePlugin, FlowrAnalyzerUvrManifestFilePlugin } from './file-plugins/flowr-analyzer-manifest-file-plugin';
|
|
25
|
+
import { FlowrAnalyzerMetaRigProjectFilePlugin, FlowrAnalyzerMetaRigScriptPlugin, FlowrAnalyzerMetaRProjectFilePlugin, FlowrAnalyzerMetaUvrManifestFilePlugin } from './package-version-plugins/flowr-analyzer-meta-manifest-file-plugin';
|
|
26
26
|
import { FlowrAnalyzerMetaDescriptionFilePlugin } from './package-version-plugins/flowr-analyzer-meta-description-file-plugin';
|
|
27
27
|
import { FlowrAnalyzerSweaveFilePlugin } from './file-plugins/notebooks/flowr-analyzer-sweave-file-plugin';
|
|
28
28
|
import { FlowrAnalyzerGitignoreProjectDiscoveryPlugin, FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin, FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin } from './project-discovery/flowr-analyzer-ignore-file-project-discovery-plugin';
|
|
@@ -30,11 +30,12 @@ import { FlowrAnalyzerDefaultProjectDiscoveryPlugin, FlowrAnalyzerFullProjectDis
|
|
|
30
30
|
import { FlowrAnalyzerRprofileFilePlugin } from './file-plugins/flowr-analyzer-rprofile-file-plugin';
|
|
31
31
|
import { FlowrAnalyzerLoadingOrderRprofilePlugin } from './loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin';
|
|
32
32
|
import { FlowrAnalyzerPackageVersionsLibraryPlugin } from './package-version-plugins/flowr-analyzer-package-versions-library-plugin';
|
|
33
|
+
import { FlowrAnalyzerPackageVersionsOnDemandPlugin } from './package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin';
|
|
33
34
|
import { FlowrAnalyzerLoadingOrderIncludedFilesPlugin } from './loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin';
|
|
34
35
|
/**
|
|
35
36
|
* The built-in Flowr Analyzer plugins that are always available.
|
|
36
37
|
*/
|
|
37
|
-
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
|
|
38
|
+
export declare const BuiltInPlugins: [["file:description", typeof FlowrAnalyzerDescriptionFilePlugin], ["versions:description", typeof FlowrAnalyzerPackageVersionsDescriptionFilePlugin], ["versions:sigdb", typeof FlowrAnalyzerPackageVersionsSigDbPlugin], ["versions:library", typeof FlowrAnalyzerPackageVersionsLibraryPlugin], ["versions:on-demand", typeof FlowrAnalyzerPackageVersionsOnDemandPlugin], ["versions:renv", typeof FlowrAnalyzerPackageVersionsRenvPlugin], ["versions:rv", typeof FlowrAnalyzerPackageVersionsRvPlugin], ["versions:uvr", typeof FlowrAnalyzerPackageVersionsUvrPlugin], ["versions:rig", typeof FlowrAnalyzerPackageVersionsRigPlugin], ["versions:packrat", typeof FlowrAnalyzerPackageVersionsPackratPlugin], ["versions:session-info", typeof FlowrAnalyzerPackageVersionsSessionInfoPlugin], ["loading-order:description", typeof FlowrAnalyzerLoadingOrderDescriptionFilePlugin], ["loading-order:implicit-sources", typeof FlowrAnalyzerLoadingOrderImplicitSourcesPlugin], ["loading-order:rprofile", typeof FlowrAnalyzerLoadingOrderRprofilePlugin], ["loading-order:included-files", typeof FlowrAnalyzerLoadingOrderIncludedFilesPlugin], ["meta:description", typeof FlowrAnalyzerMetaDescriptionFilePlugin], ["meta:rproject", typeof FlowrAnalyzerMetaRProjectFilePlugin], ["meta:uvr", typeof FlowrAnalyzerMetaUvrManifestFilePlugin], ["meta:rig", typeof FlowrAnalyzerMetaRigProjectFilePlugin], ["meta:rig-script", typeof FlowrAnalyzerMetaRigScriptPlugin], ["file-roles:vignette", typeof FlowrAnalyzerMetaVignetteFilesPlugin], ["file-roles:test", typeof FlowrAnalyzerMetaTestFilesPlugin], ["file-roles:inst", typeof FlowrAnalyzerMetaInstFilesPlugin], ["file:rmd", typeof FlowrAnalyzerRmdFilePlugin], ["file:qmd", typeof FlowrAnalyzerQmdFilePlugin], ["file:rnw", typeof FlowrAnalyzerSweaveFilePlugin], ["file:ipynb", typeof FlowrAnalyzerJupyterFilePlugin], ["file:rout", typeof FlowrAnalyzerRSessionFilePlugin], ["file:namespace", typeof FlowrAnalyzerNamespaceFilesPlugin], ["versions:namespace", typeof FlowrAnalyzerPackageVersionsNamespaceFilePlugin], ["file:news", typeof FlowrAnalyzerNewsFilePlugin], ["file:rd-macros", typeof FlowrAnalyzerRdMacroFilePlugin], ["file:rd", typeof FlowrAnalyzerRdFilePlugin], ["file:rd-index", typeof FlowrAnalyzerRdIndexFilePlugin], ["file:rd-topics", typeof FlowrAnalyzerRdTopicIndexFilePlugin], ["file:rd-meta", typeof FlowrAnalyzerRdMetaFilePlugin], ["file:datalist", typeof FlowrAnalyzerDataListFilePlugin], ["file:sysdata", typeof FlowrAnalyzerSysdataFilePlugin], ["file:rda", typeof FlowrAnalyzerRdaFilePlugin], ["file:license", typeof FlowrAnalyzerLicenseFilePlugin], ["file:virtualenv", typeof FlowrAnalyzerVirtualEnvFilePlugin], ["file:rproject", typeof FlowrAnalyzerRProjectFilePlugin], ["file:uvr", typeof FlowrAnalyzerUvrManifestFilePlugin], ["file:rig", typeof FlowrAnalyzerRigProjectFilePlugin], ["file:rprofile", typeof FlowrAnalyzerRprofileFilePlugin], ["project-discovery:gitignore", typeof FlowrAnalyzerGitignoreProjectDiscoveryPlugin], ["project-discovery:rbuildignore", typeof FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin], ["project-discovery:ignore-files", typeof FlowrAnalyzerIgnoreFileProjectDiscoveryPlugin], ["project-discovery:default", typeof FlowrAnalyzerDefaultProjectDiscoveryPlugin], ["project-discovery:full", typeof FlowrAnalyzerFullProjectDiscoveryPlugin]];
|
|
38
39
|
export type BuiltInFlowrPluginName = typeof BuiltInPlugins[number][0];
|
|
39
40
|
export type BuiltInFlowrPluginArgs<N extends BuiltInFlowrPluginName> = N extends typeof BuiltInPlugins[number][0] ? ConstructorParameters<Extract<typeof BuiltInPlugins[number], [N, PluginProducer]>[1]> : never;
|
|
40
41
|
type PluginProducer = new (...args: never[]) => FlowrAnalyzerPlugin;
|