@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
|
@@ -36,6 +36,7 @@ const flowr_analyzer_project_discovery_plugin_1 = require("./project-discovery/f
|
|
|
36
36
|
const flowr_analyzer_rprofile_file_plugin_1 = require("./file-plugins/flowr-analyzer-rprofile-file-plugin");
|
|
37
37
|
const flowr_analyzer_loading_order_rprofile_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-rprofile-plugin");
|
|
38
38
|
const flowr_analyzer_package_versions_library_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-library-plugin");
|
|
39
|
+
const flowr_analyzer_package_versions_on_demand_plugin_1 = require("./package-version-plugins/flowr-analyzer-package-versions-on-demand-plugin");
|
|
39
40
|
const flowr_analyzer_loading_order_included_files_plugin_1 = require("./loading-order-plugins/flowr-analyzer-loading-order-included-files-plugin");
|
|
40
41
|
/**
|
|
41
42
|
* The built-in Flowr Analyzer plugins that are always available.
|
|
@@ -45,9 +46,11 @@ exports.BuiltInPlugins = [
|
|
|
45
46
|
['versions:description', flowr_analyzer_package_versions_description_file_plugin_1.FlowrAnalyzerPackageVersionsDescriptionFilePlugin],
|
|
46
47
|
['versions:sigdb', flowr_analyzer_package_versions_sigdb_plugin_1.FlowrAnalyzerPackageVersionsSigDbPlugin],
|
|
47
48
|
['versions:library', flowr_analyzer_package_versions_library_plugin_1.FlowrAnalyzerPackageVersionsLibraryPlugin],
|
|
49
|
+
['versions:on-demand', flowr_analyzer_package_versions_on_demand_plugin_1.FlowrAnalyzerPackageVersionsOnDemandPlugin],
|
|
48
50
|
['versions:renv', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRenvPlugin],
|
|
49
51
|
['versions:rv', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRvPlugin],
|
|
50
52
|
['versions:uvr', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsUvrPlugin],
|
|
53
|
+
['versions:rig', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsRigPlugin],
|
|
51
54
|
['versions:packrat', flowr_analyzer_package_versions_lockfile_plugin_1.FlowrAnalyzerPackageVersionsPackratPlugin],
|
|
52
55
|
['versions:session-info', flowr_analyzer_package_versions_session_info_plugin_1.FlowrAnalyzerPackageVersionsSessionInfoPlugin],
|
|
53
56
|
['loading-order:description', flowr_analyzer_loading_order_description_file_plugin_1.FlowrAnalyzerLoadingOrderDescriptionFilePlugin],
|
|
@@ -57,6 +60,8 @@ exports.BuiltInPlugins = [
|
|
|
57
60
|
['meta:description', flowr_analyzer_meta_description_file_plugin_1.FlowrAnalyzerMetaDescriptionFilePlugin],
|
|
58
61
|
['meta:rproject', flowr_analyzer_meta_manifest_file_plugin_1.FlowrAnalyzerMetaRProjectFilePlugin],
|
|
59
62
|
['meta:uvr', flowr_analyzer_meta_manifest_file_plugin_1.FlowrAnalyzerMetaUvrManifestFilePlugin],
|
|
63
|
+
['meta:rig', flowr_analyzer_meta_manifest_file_plugin_1.FlowrAnalyzerMetaRigProjectFilePlugin],
|
|
64
|
+
['meta:rig-script', flowr_analyzer_meta_manifest_file_plugin_1.FlowrAnalyzerMetaRigScriptPlugin],
|
|
60
65
|
['file-roles:vignette', flowr_analyzer_vignette_file_plugin_1.FlowrAnalyzerMetaVignetteFilesPlugin],
|
|
61
66
|
['file-roles:test', flowr_analyzer_test_file_plugin_1.FlowrAnalyzerMetaTestFilesPlugin],
|
|
62
67
|
['file-roles:inst', flowr_analyzer_inst_file_plugin_1.FlowrAnalyzerMetaInstFilesPlugin],
|
|
@@ -82,6 +87,7 @@ exports.BuiltInPlugins = [
|
|
|
82
87
|
['file:virtualenv', flowr_analyzer_virtualenv_file_plugin_1.FlowrAnalyzerVirtualEnvFilePlugin],
|
|
83
88
|
['file:rproject', flowr_analyzer_manifest_file_plugin_1.FlowrAnalyzerRProjectFilePlugin],
|
|
84
89
|
['file:uvr', flowr_analyzer_manifest_file_plugin_1.FlowrAnalyzerUvrManifestFilePlugin],
|
|
90
|
+
['file:rig', flowr_analyzer_manifest_file_plugin_1.FlowrAnalyzerRigProjectFilePlugin],
|
|
85
91
|
['file:rprofile', flowr_analyzer_rprofile_file_plugin_1.FlowrAnalyzerRprofileFilePlugin],
|
|
86
92
|
['project-discovery:gitignore', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerGitignoreProjectDiscoveryPlugin],
|
|
87
93
|
['project-discovery:rbuildignore', flowr_analyzer_ignore_file_project_discovery_plugin_1.FlowrAnalyzerRbuildignoreProjectDiscoveryPlugin],
|
|
@@ -32,7 +32,7 @@ exports.FlowrAnalyzerProjectDiscoveryPlugin = FlowrAnalyzerProjectDiscoveryPlugi
|
|
|
32
32
|
// `.Rprofile`/`Rprofile.site` carry no extension but are plain R sources, as are the `.S`/`.s`/`.q` files below `R/`
|
|
33
33
|
exports.discoverRSourcesRegex = new RegExp(`(\\.(r|rmd|rmarkdown|ipynb|qmd|rnw)|(^|[\\\\/])\\.?Rprofile(\\.site)?)$|${files_1.rPackageSourceRegex.source}`, 'i');
|
|
34
34
|
// matched against the posix path relative to the project root
|
|
35
|
-
exports.ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|Rtmp[^/]*|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
|
|
35
|
+
exports.ignorePathsWith = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|\.rvenv|Rtmp[^/]*|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles)[^/]*)(\/|$)/i;
|
|
36
36
|
exports.excludeRequestsForPaths = /vignettes?|tests?|revdep|inst|data/i;
|
|
37
37
|
/**
|
|
38
38
|
* Turn the walked `files` (absolute paths under `root`) into the discovery result: R sources become
|
|
@@ -97,7 +97,7 @@ class FlowrAnalyzerFullProjectDiscoveryPlugin extends FlowrAnalyzerProjectDiscov
|
|
|
97
97
|
}
|
|
98
98
|
exports.FlowrAnalyzerFullProjectDiscoveryPlugin = FlowrAnalyzerFullProjectDiscoveryPlugin;
|
|
99
99
|
// noise directories pruned from the scoped walk on top of `ignorePathsWith`: build output, checks, rendered docs, and packaged data
|
|
100
|
-
const noiseDirs = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|[^/]*\.Rcheck|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles|cache)[^/]*|build|dist|_build|_site|_book|\.quarto|\.cache|Rtmp[^/]*|inst\/(extdata|doc))(\/|$)/i;
|
|
100
|
+
const noiseDirs = /(^|\/)(\.git|\.svn|\.hg|node_modules|__pycache__|\.Rproj\.user|\.uvr|\.rvenv|[^/]*\.Rcheck|(packrat|renv|rv)\/(lib|library|src|staging|sandbox|bundles|cache)[^/]*|build|dist|_build|_site|_book|\.quarto|\.cache|Rtmp[^/]*|inst\/(extdata|doc))(\/|$)/i;
|
|
101
101
|
// binary/data blobs, dropped even inside an otherwise kept directory
|
|
102
102
|
const noiseFiles = /\.(rds|rda|rdata|rd|png|jpe?g|gif|svg|pdf|ico|zip|tar|t?gz|bz2|xz|so|o|a|dll|dylib|exe|jar|woff2?|ttf|eot|feather|parquet|xls[xm]?|docx?|pptx?)$/i;
|
|
103
103
|
const descriptionFilePattern = /^DESCRIPTION(\.(txt|in))?$/i;
|
|
@@ -106,8 +106,8 @@ const metadataFilePatterns = [
|
|
|
106
106
|
descriptionFilePattern,
|
|
107
107
|
/^NAMESPACE(\.txt)?$/i,
|
|
108
108
|
/^NEWS(\.(rd|md))?$/i,
|
|
109
|
-
/^(renv|rv|uvr|packrat)\.lock$/i,
|
|
110
|
-
/^(rproject|uvr)\.toml$/i,
|
|
109
|
+
/^(renv|rv|uvr|packrat|rproj|.+\.r)\.lock$/i,
|
|
110
|
+
/^(rproject|uvr|rproj)\.toml$/i,
|
|
111
111
|
/license(\.md|\.txt)?$/i,
|
|
112
112
|
flowr_analyzer_rprofile_file_plugin_1.RprofileFilePattern,
|
|
113
113
|
flowr_analyzer_rprofile_file_plugin_1.RenvironFilePattern
|
package/project/sigdb/decode.js
CHANGED
|
@@ -12,6 +12,7 @@ exports.deriveLibraryExports = deriveLibraryExports;
|
|
|
12
12
|
const schema_1 = require("./schema");
|
|
13
13
|
const sigdb_version_1 = require("./sigdb-version");
|
|
14
14
|
const objects_1 = require("../../util/objects");
|
|
15
|
+
const r_primitives_generated_1 = require("../../data/r-primitives.generated");
|
|
15
16
|
/**
|
|
16
17
|
* Reconstruct the CRAN source blob link which is the newest non-archived version lives under `src/contrib`,
|
|
17
18
|
* every other under `Archive`.
|
|
@@ -75,6 +76,7 @@ function transitiveCallees(functions, name) {
|
|
|
75
76
|
/** decode one of a blob's function records against the global string dictionary */
|
|
76
77
|
function decodeFunction(strings, blob, fnIdx) {
|
|
77
78
|
const [nameIdx, sigIdx, cgIdx, bits, fileIdx, line, topicIdx] = blob.fns[fnIdx];
|
|
79
|
+
const name = strings.at(nameIdx);
|
|
78
80
|
const signature = (sigIdx >= 0 ? blob.sigs[sigIdx] : []).map(p => {
|
|
79
81
|
const [n, props, def] = Array.isArray(p) ? [p[0], p[1], p.length === 3 ? p[2] : -1] : [p, 0, -1];
|
|
80
82
|
return (0, objects_1.compactRecord)({ name: strings.at(n), props, default: def >= 0 ? strings.at(def) : undefined });
|
|
@@ -85,11 +87,11 @@ function decodeFunction(strings, blob, fnIdx) {
|
|
|
85
87
|
callees = blob.cgs[cgIdx].map(d => strings.at(prev += d));
|
|
86
88
|
}
|
|
87
89
|
return (0, objects_1.compactRecord)({
|
|
88
|
-
name
|
|
90
|
+
name,
|
|
89
91
|
topic: topicIdx !== undefined && topicIdx >= 0 ? strings.at(topicIdx) : undefined,
|
|
90
92
|
file: fileIdx >= 0 ? strings.at(fileIdx) : undefined,
|
|
91
93
|
line,
|
|
92
|
-
exported:
|
|
94
|
+
exported: isExportedEntry(bits, name),
|
|
93
95
|
props: Object.entries(schema_1.FnPropNames).filter(([m]) => bits & Number(m)).map(([, n]) => n),
|
|
94
96
|
signature,
|
|
95
97
|
callees
|
|
@@ -145,6 +147,14 @@ function versionFnIndices(blob, ver) {
|
|
|
145
147
|
}
|
|
146
148
|
return out;
|
|
147
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* Whether a stored entry is an export. A method on a primitive generic (`setMethod("+", ...)`) binds nothing in the
|
|
152
|
+
* namespace, so R exports it under no directive, and `pkg::"+"` does not exist; a database built before that was
|
|
153
|
+
* known may still flag it exported, and attaching it would shadow the base primitive for every call.
|
|
154
|
+
*/
|
|
155
|
+
function isExportedEntry(bits, name) {
|
|
156
|
+
return (bits & 1 /* FnProp.Exported */) !== 0 && !((bits & 4096 /* FnProp.S4Method */) !== 0 && r_primitives_generated_1.RPrimitives.has(name));
|
|
157
|
+
}
|
|
148
158
|
/** derive the {@link LibraryExports} export view of one package version from its blob + metadata */
|
|
149
159
|
function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = schema_1.DefaultCranBase) {
|
|
150
160
|
const [latest, archived] = meta;
|
|
@@ -162,7 +172,7 @@ function deriveLibraryExports(strings, blob, meta, pkg, version, cranBase = sche
|
|
|
162
172
|
for (const i of idxs) {
|
|
163
173
|
const [nameIdx, , , bits, fileIdx, line] = blob.fns[i];
|
|
164
174
|
const name = strings.at(nameIdx);
|
|
165
|
-
(bits
|
|
175
|
+
(isExportedEntry(bits, name) ? exported : internal).push(name);
|
|
166
176
|
if (bits & 32 /* FnProp.Deprecated */) {
|
|
167
177
|
deprecated.push(name);
|
|
168
178
|
}
|
|
@@ -20,6 +20,8 @@ export declare function resolveSource(baseDir: string, relPath: string): string;
|
|
|
20
20
|
* volume at the cache dir to persist it).
|
|
21
21
|
*/
|
|
22
22
|
export declare function sigDbCacheDir(override?: string, create?: boolean): string;
|
|
23
|
+
/** a temp path next to `target`, unique even across containers sharing a volume */
|
|
24
|
+
export declare const uniqueTempPath: (target: string, ext: string) => string;
|
|
23
25
|
/** read the (small) header line of a possibly-compressed bundle without decompressing the whole thing */
|
|
24
26
|
export declare function readHeaderOf(source: string): Promise<Record<string, unknown> | undefined>;
|
|
25
27
|
/** where an index for a decompressed source comes from -- a caller-supplied one (e.g. a manifest) or the sibling `.idx` */
|
|
@@ -29,6 +31,8 @@ export interface EnsureOptions {
|
|
|
29
31
|
index?: SigDbIndex;
|
|
30
32
|
/** the source is not a seekable bundle (e.g. a shared dictionary file) -- decompress only, write no `.idx` */
|
|
31
33
|
indexless?: boolean;
|
|
34
|
+
/** the expected decompressed size */
|
|
35
|
+
bytes?: number;
|
|
32
36
|
}
|
|
33
37
|
/** whether a compressed source with the given content hash has already been unpacked into its decompressed cache */
|
|
34
38
|
export declare function isUnpacked(hash: string, cacheDir?: string): boolean;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isCompressed = void 0;
|
|
6
|
+
exports.uniqueTempPath = exports.isCompressed = void 0;
|
|
7
7
|
exports.parseHeader = parseHeader;
|
|
8
8
|
exports.sigDbStream = sigDbStream;
|
|
9
9
|
exports.resolveSource = resolveSource;
|
|
@@ -20,6 +20,7 @@ exports.ensurePlainSync = ensurePlainSync;
|
|
|
20
20
|
*/
|
|
21
21
|
const fs_1 = __importDefault(require("fs"));
|
|
22
22
|
const os_1 = __importDefault(require("os"));
|
|
23
|
+
const crypto_1 = require("crypto");
|
|
23
24
|
const path_1 = __importDefault(require("path"));
|
|
24
25
|
const readline_1 = __importDefault(require("readline"));
|
|
25
26
|
const promises_1 = require("stream/promises");
|
|
@@ -80,19 +81,30 @@ function sigDbCacheDir(override, create = true) {
|
|
|
80
81
|
?? (process.env.LOCALAPPDATA ? path_1.default.join(process.env.LOCALAPPDATA, 'flowr', 'cache') : undefined)
|
|
81
82
|
?? path_1.default.join(os_1.default.homedir?.() || os_1.default.tmpdir(), '.cache', 'flowr');
|
|
82
83
|
const dir = path_1.default.join(base, 'sigdb');
|
|
83
|
-
|
|
84
|
+
const tmp = path_1.default.join(os_1.default.tmpdir(), `flowr-sigdb-cache-${process.getuid?.() ?? os_1.default.userInfo().username}`);
|
|
85
|
+
if (isWritableDir(dir, create) || !(create || fs_1.default.existsSync(tmp))) {
|
|
84
86
|
return dir;
|
|
85
87
|
}
|
|
88
|
+
if (create) {
|
|
89
|
+
fs_1.default.mkdirSync(tmp, { recursive: true, mode: 0o700 });
|
|
90
|
+
}
|
|
91
|
+
return tmp;
|
|
92
|
+
}
|
|
93
|
+
function isWritableDir(dir, create) {
|
|
86
94
|
try {
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
if (create) {
|
|
96
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
97
|
+
}
|
|
98
|
+
fs_1.default.accessSync(dir, fs_1.default.constants.W_OK);
|
|
99
|
+
return true;
|
|
89
100
|
}
|
|
90
101
|
catch {
|
|
91
|
-
|
|
92
|
-
fs_1.default.mkdirSync(tmp, { recursive: true });
|
|
93
|
-
return tmp;
|
|
102
|
+
return false;
|
|
94
103
|
}
|
|
95
104
|
}
|
|
105
|
+
/** a temp path next to `target`, unique even across containers sharing a volume */
|
|
106
|
+
const uniqueTempPath = (target, ext) => `${target}.${process.pid}-${(0, crypto_1.randomBytes)(6).toString('hex')}.${ext}`;
|
|
107
|
+
exports.uniqueTempPath = uniqueTempPath;
|
|
96
108
|
/** read the (small) header line of a possibly-compressed bundle without decompressing the whole thing */
|
|
97
109
|
async function readHeaderOf(source) {
|
|
98
110
|
if (!(0, exports.isCompressed)(source)) {
|
|
@@ -138,6 +150,26 @@ function writeCacheIndex(source, idx, index) {
|
|
|
138
150
|
}
|
|
139
151
|
fs_1.default.copyFileSync(srcIdx, idx);
|
|
140
152
|
}
|
|
153
|
+
function isCachedPlain(plain, idx, opts) {
|
|
154
|
+
try {
|
|
155
|
+
const size = fs_1.default.statSync(plain).size;
|
|
156
|
+
return (opts.bytes === undefined || size === opts.bytes) && (opts.indexless || fs_1.default.existsSync(idx));
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
function commitPlain(source, tmp, plain, idx, opts) {
|
|
163
|
+
const size = fs_1.default.statSync(tmp).size;
|
|
164
|
+
if (opts.bytes !== undefined && size !== opts.bytes) {
|
|
165
|
+
throw new Error(`decompressing ${source} gave ${size} bytes, expected ${opts.bytes}; the file is corrupt or does not match its manifest`);
|
|
166
|
+
}
|
|
167
|
+
fs_1.default.renameSync(tmp, plain);
|
|
168
|
+
if (!opts.indexless) {
|
|
169
|
+
writeCacheIndex(source, idx, opts.index);
|
|
170
|
+
}
|
|
171
|
+
return plain;
|
|
172
|
+
}
|
|
141
173
|
/**
|
|
142
174
|
* Ensure a seekable plain `.sigs.ndjson` (+ its `.idx`) exists for `source`, decompressing a `.br`/`.zst`/`.gz`
|
|
143
175
|
* once into a hash-keyed cache the first time and reusing it on every later startup. The index may be
|
|
@@ -149,20 +181,24 @@ async function ensurePlain(source, opts = {}) {
|
|
|
149
181
|
}
|
|
150
182
|
let hash = opts.hash;
|
|
151
183
|
if (hash === undefined) {
|
|
152
|
-
|
|
153
|
-
|
|
184
|
+
hash = (await readHeaderOf(source))?.content?.hash;
|
|
185
|
+
if (hash === undefined) {
|
|
186
|
+
const { size, mtimeMs } = fs_1.default.statSync(source);
|
|
187
|
+
hash = new hash_1.Hash53().update(`${source}\0${size}\0${mtimeMs}`).digest();
|
|
188
|
+
}
|
|
154
189
|
}
|
|
155
190
|
const { plain, idx } = cachePaths(hash, opts.cacheDir);
|
|
156
|
-
if (
|
|
191
|
+
if (isCachedPlain(plain, idx, opts)) {
|
|
157
192
|
return plain;
|
|
158
193
|
}
|
|
159
|
-
const tmp =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
194
|
+
const tmp = (0, exports.uniqueTempPath)(plain, 'tmp');
|
|
195
|
+
try {
|
|
196
|
+
await (0, promises_1.pipeline)(decompressStream(source), fs_1.default.createWriteStream(tmp));
|
|
197
|
+
return commitPlain(source, tmp, plain, idx, opts);
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
fs_1.default.rmSync(tmp, { force: true });
|
|
164
201
|
}
|
|
165
|
-
return plain;
|
|
166
202
|
}
|
|
167
203
|
/** synchronous {@link ensurePlain} (blocking decompression); the supplied `hash` keys the decompress cache */
|
|
168
204
|
function ensurePlainSync(source, opts) {
|
|
@@ -170,17 +206,16 @@ function ensurePlainSync(source, opts) {
|
|
|
170
206
|
return source;
|
|
171
207
|
}
|
|
172
208
|
const { plain, idx } = cachePaths(opts.hash, opts.cacheDir);
|
|
173
|
-
if (
|
|
209
|
+
if (isCachedPlain(plain, idx, opts)) {
|
|
174
210
|
return plain;
|
|
175
211
|
}
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
212
|
+
const tmp = (0, exports.uniqueTempPath)(plain, 'tmp');
|
|
213
|
+
try {
|
|
214
|
+
fs_1.default.writeFileSync(tmp, (0, codec_1.decompressSyncFor)(source, fs_1.default.readFileSync(source)));
|
|
215
|
+
return commitPlain(source, tmp, plain, idx, opts);
|
|
216
|
+
}
|
|
217
|
+
finally {
|
|
218
|
+
fs_1.default.rmSync(tmp, { force: true });
|
|
183
219
|
}
|
|
184
|
-
return plain;
|
|
185
220
|
}
|
|
186
221
|
//# sourceMappingURL=decompress.js.map
|
|
@@ -59,7 +59,7 @@ export type SigDbScope = 'base' | 'current' | 'full';
|
|
|
59
59
|
export declare function sigDbBundleDirs(watched?: [string, number][]): string[];
|
|
60
60
|
/**
|
|
61
61
|
* Location of a bundled sigdb **manifest**, found by walking up from several roots (this module,
|
|
62
|
-
* `$FLOWR_SIGDB_DIR
|
|
62
|
+
* `$FLOWR_SIGDB_DIR`) across the dev (`src`), build (`dist`), and data-mount
|
|
63
63
|
* layouts. With no `scope` it returns the richest available (`full` > `current` > `base`), so a
|
|
64
64
|
* container that ships the full set uses it automatically while a plain npm install falls back to the
|
|
65
65
|
* bundled `base`. Node only (needs `fs`); pass `searchRoots` to override where it looks.
|
|
@@ -91,7 +91,7 @@ function sigDbBundleDirs(watched) {
|
|
|
91
91
|
return [];
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
/** roots to search for a bundled sigdb
|
|
94
|
+
/** roots to search for a bundled sigdb: this module and `$FLOWR_SIGDB_DIR` (path-delimiter separated) */
|
|
95
95
|
function sigDbSearchRoots(extra) {
|
|
96
96
|
const roots = [...(extra ?? [])];
|
|
97
97
|
const env = typeof process !== 'undefined' ? process.env?.FLOWR_SIGDB_DIR : undefined;
|
|
@@ -101,14 +101,11 @@ function sigDbSearchRoots(extra) {
|
|
|
101
101
|
if (typeof __dirname !== 'undefined') {
|
|
102
102
|
roots.push(__dirname);
|
|
103
103
|
}
|
|
104
|
-
if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
|
|
105
|
-
roots.push(process.cwd());
|
|
106
|
-
}
|
|
107
104
|
return roots;
|
|
108
105
|
}
|
|
109
106
|
/**
|
|
110
107
|
* Location of a bundled sigdb **manifest**, found by walking up from several roots (this module,
|
|
111
|
-
* `$FLOWR_SIGDB_DIR
|
|
108
|
+
* `$FLOWR_SIGDB_DIR`) across the dev (`src`), build (`dist`), and data-mount
|
|
112
109
|
* layouts. With no `scope` it returns the richest available (`full` > `current` > `base`), so a
|
|
113
110
|
* container that ships the full set uses it automatically while a plain npm install falls back to the
|
|
114
111
|
* bundled `base`. Node only (needs `fs`); pass `searchRoots` to override where it looks.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PackageSignatureSource } from './reader';
|
|
2
2
|
import type { VersionRelease } from './sigdb-version';
|
|
3
3
|
import type { LibraryExports } from './schema';
|
|
4
|
-
import type { ResolvedDependency } from './decode';
|
|
4
|
+
import type { DecodedFunction, ResolvedDependency } from './decode';
|
|
5
5
|
import { RVersion } from '../../util/r-version';
|
|
6
6
|
/**
|
|
7
7
|
* One package as {@link MemorySignatureSource} carries it: the exports are what attaching it brings, the rest
|
|
@@ -18,6 +18,8 @@ export interface MemoryPackage {
|
|
|
18
18
|
readonly deps?: readonly ResolvedDependency[];
|
|
19
19
|
/** when that version was released, which is what makes it a release rather than a label */
|
|
20
20
|
readonly released?: Date;
|
|
21
|
+
/** the functions the package defines, exported or not, for the per-function view, absent if unknown */
|
|
22
|
+
readonly functions?: readonly DecodedFunction[];
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* A signature source held entirely in memory, for the places that cannot open a database file: a browser
|
|
@@ -39,9 +41,9 @@ export declare class MemorySignatureSource implements PackageSignatureSource {
|
|
|
39
41
|
lookup(pkg: string, version?: string): LibraryExports | undefined;
|
|
40
42
|
packagesExporting(name: string): readonly string[];
|
|
41
43
|
classOwner(className: string, version?: string): string | undefined;
|
|
42
|
-
/**
|
|
43
|
-
functions(): undefined;
|
|
44
|
-
functionByName(): undefined;
|
|
44
|
+
/** the functions a package was given with, the per-function view stays empty for the others */
|
|
45
|
+
functions(pkg: string, version?: string): DecodedFunction[] | undefined;
|
|
46
|
+
functionByName(pkg: string, name: string, version?: string): DecodedFunction | undefined;
|
|
45
47
|
transitiveCallees(): undefined;
|
|
46
48
|
dependencies(pkg: string, version?: string): ResolvedDependency[] | undefined;
|
|
47
49
|
/** an in-memory package states its exports, never its class relations */
|
|
@@ -68,12 +68,13 @@ class MemorySignatureSource {
|
|
|
68
68
|
this.classIndex ??= (0, reader_1.classOwnerIndexFor)(this, this.packageNames());
|
|
69
69
|
return this.classIndex.get(className);
|
|
70
70
|
}
|
|
71
|
-
/**
|
|
72
|
-
functions() {
|
|
73
|
-
|
|
71
|
+
/** the functions a package was given with, the per-function view stays empty for the others */
|
|
72
|
+
functions(pkg, version) {
|
|
73
|
+
const found = this.packages.get(pkg);
|
|
74
|
+
return found?.functions === undefined || !this.answersFor(pkg, version) ? undefined : [...found.functions];
|
|
74
75
|
}
|
|
75
|
-
functionByName() {
|
|
76
|
-
return
|
|
76
|
+
functionByName(pkg, name, version) {
|
|
77
|
+
return this.functions(pkg, version)?.find(f => f.name === name);
|
|
77
78
|
}
|
|
78
79
|
transitiveCallees() {
|
|
79
80
|
return undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FetchBytes } from './remote-sources';
|
|
2
|
+
/** an archive bigger than its source was allowed to be */
|
|
3
|
+
export declare class TooLargeError extends Error {
|
|
4
|
+
constructor(url: string, max: number);
|
|
5
|
+
}
|
|
6
|
+
/** a URL the on-demand fetch refuses: anything but `https`, or a host on the local machine or network */
|
|
7
|
+
export declare class RefusedUrlError extends Error {
|
|
8
|
+
constructor(url: string, why: string);
|
|
9
|
+
}
|
|
10
|
+
/** whether `host` is this machine or an address of a private network, which a redirect must never lead to */
|
|
11
|
+
export declare function isLocalHost(host: string): boolean;
|
|
12
|
+
/** the URL, if the fetch may go there. `trusted` hosts (the mirrors a trusted configuration names) may be local */
|
|
13
|
+
export declare function checkedUrl(url: string, trusted?: ReadonlySet<string>): URL;
|
|
14
|
+
/**
|
|
15
|
+
* {@link FetchBytes} over HTTPS, see {@link checkedUrl}. A 404 (or 410) means the server does not have it.
|
|
16
|
+
* @param trusted - the hosts (with port) that may be local, as a company mirror is
|
|
17
|
+
*/
|
|
18
|
+
export declare function httpsFetcher(trusted?: ReadonlySet<string>): FetchBytes;
|
|
@@ -0,0 +1,127 @@
|
|
|
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.RefusedUrlError = exports.TooLargeError = void 0;
|
|
7
|
+
exports.isLocalHost = isLocalHost;
|
|
8
|
+
exports.checkedUrl = checkedUrl;
|
|
9
|
+
exports.httpsFetcher = httpsFetcher;
|
|
10
|
+
const https_1 = __importDefault(require("https"));
|
|
11
|
+
const net_1 = __importDefault(require("net"));
|
|
12
|
+
const secure_mode_1 = require("../../../util/secure-mode");
|
|
13
|
+
/** an archive bigger than its source was allowed to be */
|
|
14
|
+
class TooLargeError extends Error {
|
|
15
|
+
constructor(url, max) {
|
|
16
|
+
super(`${url} is larger than ${Math.round(max / 1024 / 1024)} MiB`);
|
|
17
|
+
this.name = 'TooLargeError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.TooLargeError = TooLargeError;
|
|
21
|
+
/** a URL the on-demand fetch refuses: anything but `https`, or a host on the local machine or network */
|
|
22
|
+
class RefusedUrlError extends Error {
|
|
23
|
+
constructor(url, why) {
|
|
24
|
+
super(`refusing ${url}: ${why}`);
|
|
25
|
+
this.name = 'RefusedUrlError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.RefusedUrlError = RefusedUrlError;
|
|
29
|
+
/** whether `host` is this machine or an address of a private network, which a redirect must never lead to */
|
|
30
|
+
function isLocalHost(host) {
|
|
31
|
+
const bare = host.replace(/^\[|\]$/g, '').toLowerCase();
|
|
32
|
+
if (bare === 'localhost' || bare.endsWith('.localhost') || bare.endsWith('.local') || bare.endsWith('.internal')) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
if (net_1.default.isIPv4(bare)) {
|
|
36
|
+
const [a, b] = bare.split('.').map(Number);
|
|
37
|
+
return a === 0 || a === 10 || a === 127 || (a === 169 && b === 254) || (a === 172 && b >= 16 && b <= 31) || (a === 192 && b === 168) || (a === 100 && b >= 64 && b <= 127) || a >= 224;
|
|
38
|
+
}
|
|
39
|
+
if (net_1.default.isIPv6(bare)) {
|
|
40
|
+
return bare === '::' || bare === '::1' || /^(fc|fd|fe8|fe9|fea|feb)/.test(bare) || bare.startsWith('::ffff:');
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
/** the URL, if the fetch may go there. `trusted` hosts (the mirrors a trusted configuration names) may be local */
|
|
45
|
+
function checkedUrl(url, trusted = new Set()) {
|
|
46
|
+
let parsed;
|
|
47
|
+
try {
|
|
48
|
+
parsed = new URL(url);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new RefusedUrlError(url, 'no URL');
|
|
52
|
+
}
|
|
53
|
+
if (parsed.protocol !== 'https:') {
|
|
54
|
+
throw new RefusedUrlError(url, 'only https is allowed');
|
|
55
|
+
}
|
|
56
|
+
if (parsed.username || parsed.password) {
|
|
57
|
+
throw new RefusedUrlError(url, 'no credentials in URLs');
|
|
58
|
+
}
|
|
59
|
+
if (isLocalHost(parsed.hostname) && !trusted.has(parsed.host)) {
|
|
60
|
+
throw new RefusedUrlError(url, 'a local or private host');
|
|
61
|
+
}
|
|
62
|
+
return parsed;
|
|
63
|
+
}
|
|
64
|
+
const IdleTimeoutMs = 30_000;
|
|
65
|
+
const MaxRedirects = 5;
|
|
66
|
+
function get(url, redirects, trusted) {
|
|
67
|
+
secure_mode_1.SecureMode.guard('network access', url);
|
|
68
|
+
const target = checkedUrl(url, trusted);
|
|
69
|
+
return new Promise((resolve, reject) => {
|
|
70
|
+
/* no token or cookie ever goes out: these are public sources */
|
|
71
|
+
const req = https_1.default.get(target, { headers: { 'User-Agent': 'flowr', Accept: '*/*' } }, res => {
|
|
72
|
+
const status = res.statusCode ?? 0;
|
|
73
|
+
if (status >= 300 && status < 400 && res.headers.location) {
|
|
74
|
+
res.resume();
|
|
75
|
+
if (redirects <= 0) {
|
|
76
|
+
reject(new Error(`GET ${url}: too many redirects`));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
/* every hop is checked again, so a redirect cannot lead to plain http or into the local network */
|
|
80
|
+
get(new URL(res.headers.location, target).toString(), redirects - 1, trusted).then(resolve, reject);
|
|
81
|
+
}
|
|
82
|
+
else if (status >= 200 && status < 300) {
|
|
83
|
+
resolve(res);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
res.resume();
|
|
87
|
+
if (status === 404 || status === 410) {
|
|
88
|
+
resolve(undefined);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
reject(new Error(`GET ${url} -> HTTP ${status}`));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
req.setTimeout(IdleTimeoutMs, () => req.destroy(new Error(`GET ${url} -> no data for ${IdleTimeoutMs / 1000}s`)));
|
|
96
|
+
req.on('error', reject);
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* {@link FetchBytes} over HTTPS, see {@link checkedUrl}. A 404 (or 410) means the server does not have it.
|
|
101
|
+
* @param trusted - the hosts (with port) that may be local, as a company mirror is
|
|
102
|
+
*/
|
|
103
|
+
function httpsFetcher(trusted = new Set()) {
|
|
104
|
+
return async (url, maxBytes) => {
|
|
105
|
+
const res = await get(url, MaxRedirects, trusted);
|
|
106
|
+
if (res === undefined) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
const announced = Number(res.headers['content-length'] ?? NaN);
|
|
110
|
+
if (announced > maxBytes) {
|
|
111
|
+
res.destroy();
|
|
112
|
+
throw new TooLargeError(url, maxBytes);
|
|
113
|
+
}
|
|
114
|
+
const chunks = [];
|
|
115
|
+
let total = 0;
|
|
116
|
+
for await (const chunk of res) {
|
|
117
|
+
total += chunk.length;
|
|
118
|
+
if (total > maxBytes) {
|
|
119
|
+
res.destroy();
|
|
120
|
+
throw new TooLargeError(url, maxBytes);
|
|
121
|
+
}
|
|
122
|
+
chunks.push(chunk);
|
|
123
|
+
}
|
|
124
|
+
return Buffer.concat(chunks);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type Parser from 'web-tree-sitter';
|
|
2
|
+
import type { DecodedFunction } from '../decode';
|
|
3
|
+
/**
|
|
4
|
+
* What flowR recovers of a package from its sources: the exports its `NAMESPACE` states (an `exportPattern`
|
|
5
|
+
* matched against the names the code defines) and the formals of every function its `R/` files define at the
|
|
6
|
+
* top level. This is what an on-demand signature source serves for a package no database knows.
|
|
7
|
+
*/
|
|
8
|
+
export interface RecoveredPackage {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly version?: string;
|
|
11
|
+
/** where the sources came from, like `github:masurp/ggmirt` */
|
|
12
|
+
readonly origin: string;
|
|
13
|
+
readonly exported: readonly string[];
|
|
14
|
+
readonly s4Classes: readonly string[];
|
|
15
|
+
readonly functions: readonly DecodedFunction[];
|
|
16
|
+
}
|
|
17
|
+
/** The R files of a package source, the way `R CMD build` picks them: `R/*.R` (and `.r`, `.S`, `.s`, `.q`), not the platform subdirectories. */
|
|
18
|
+
export declare function isPackageCodeFile(path: string): boolean;
|
|
19
|
+
/** the files of a package source the recovery reads */
|
|
20
|
+
export declare function isRecoveredFile(path: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Recovers a package from the files of its source (`DESCRIPTION`, `NAMESPACE`, `R/*.R`, paths relative to its
|
|
23
|
+
* root), parsing the code with `parse`. `undefined` if the files are no R package (no `DESCRIPTION` naming one).
|
|
24
|
+
* Without a `NAMESPACE`, as old packages have, every name not starting with a dot is exported, as R does.
|
|
25
|
+
*/
|
|
26
|
+
export declare function recoverPackage(files: ReadonlyMap<string, string>, parse: (code: string) => Parser.Tree, origin: string): RecoveredPackage | undefined;
|
|
27
|
+
/** the most names, functions, and parameters a recovered package may state, so a crafted one cannot bloat the analysis */
|
|
28
|
+
export declare const RecoveredLimits: {
|
|
29
|
+
readonly names: 20000;
|
|
30
|
+
readonly parameters: 256;
|
|
31
|
+
readonly nameLength: 256;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* What of a recovered package (fresh from its sources, or read back from the cache, both of which an attacker
|
|
35
|
+
* may have shaped) flowR is willing to use: package and bindable names only, a version that is one, bounded
|
|
36
|
+
* sizes, and no properties beyond the ones the recovery itself states. Names in `shielded` are dropped from the
|
|
37
|
+
* exports: a package nobody vetted must not take over a call flowR knows to be security relevant, like `system`,
|
|
38
|
+
* which would hide that call from every analysis looking for it. `undefined` for something that is no package.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sanitizeRecovered(value: unknown, shielded?: ReadonlySet<string>): RecoveredPackage | undefined;
|