@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
|
@@ -0,0 +1,132 @@
|
|
|
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.GitHubSource = void 0;
|
|
7
|
+
exports.parseGitHubRemote = parseGitHubRemote;
|
|
8
|
+
exports.isPackageName = isPackageName;
|
|
9
|
+
exports.cranSource = cranSource;
|
|
10
|
+
exports.parsePackagesIndex = parsePackagesIndex;
|
|
11
|
+
exports.bioconductorSource = bioconductorSource;
|
|
12
|
+
exports.builtInOnDemandSources = builtInOnDemandSources;
|
|
13
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
14
|
+
const GitHubArchive = (owner, repo, ref) => `https://codeload.github.com/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/tar.gz/${ref.split('/').map(encodeURIComponent).join('/')}`;
|
|
15
|
+
/** A GitHub remote as `remotes`/`pak` write it: `owner/repo`, optionally `/subdir`, `@ref`, `#pr`, or a `github::` prefix. */
|
|
16
|
+
function parseGitHubRemote(remote) {
|
|
17
|
+
const match = /^(?:github::)?([A-Za-z0-9-]+)\/([A-Za-z0-9._-]+)((?:\/[A-Za-z0-9._-]+)*)(?:@([A-Za-z0-9._/-]+)|#(\d+))?$/.exec(remote.trim());
|
|
18
|
+
/* no step may leave the repository (`..`) or name a hidden file */
|
|
19
|
+
if (match === null || [match[2], ...(match[3] ?? '').split('/'), ...(match[4] ?? '').split('/')].some(p => p === '..' || p === '.' || p.startsWith('.') && p.length > 0)) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const [, owner, repo, subdir, ref, pr] = match;
|
|
23
|
+
return {
|
|
24
|
+
owner,
|
|
25
|
+
repo: repo.replace(/\.git$/, ''),
|
|
26
|
+
subdir: subdir ? subdir.slice(1) : undefined,
|
|
27
|
+
ref: pr ? `refs/pull/${pr}/head` : ref
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** A package name R accepts, which is all that may go into a URL built from one. */
|
|
31
|
+
function isPackageName(name) {
|
|
32
|
+
return /^[A-Za-z][A-Za-z0-9.]*[A-Za-z0-9]$/.test(name);
|
|
33
|
+
}
|
|
34
|
+
/** a version as it may go into a URL */
|
|
35
|
+
function isVersion(version) {
|
|
36
|
+
return version !== undefined && /^[0-9][0-9.-]*$/.test(version);
|
|
37
|
+
}
|
|
38
|
+
/** The repository a project names for the package, or nothing. */
|
|
39
|
+
exports.GitHubSource = {
|
|
40
|
+
name: 'github',
|
|
41
|
+
archives(request) {
|
|
42
|
+
const remote = request.github === undefined ? undefined : parseGitHubRemote(request.github);
|
|
43
|
+
if (remote === undefined) {
|
|
44
|
+
return Promise.resolve([]);
|
|
45
|
+
}
|
|
46
|
+
return Promise.resolve([{ url: GitHubArchive(remote.owner, remote.repo, remote.ref ?? 'HEAD'), origin: `github:${remote.owner}/${remote.repo}`, subdir: remote.subdir }]);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
/** the `PACKAGES` index at `url` (fetched once), empty if it cannot be had */
|
|
50
|
+
function packagesIndex(url, fetch, cache) {
|
|
51
|
+
let index = cache.get(url);
|
|
52
|
+
if (index === undefined) {
|
|
53
|
+
index = fetch(url, 64 * 1024 * 1024)
|
|
54
|
+
.then(b => b === undefined ? new Map() : parsePackagesIndex((b[0] === 0x1f && b[1] === 0x8b ? zlib_1.default.gunzipSync(b) : b).toString('utf8')))
|
|
55
|
+
.catch(() => new Map());
|
|
56
|
+
cache.set(url, index);
|
|
57
|
+
}
|
|
58
|
+
return index;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* CRAN: a pinned version from the GitHub mirror or CRAN itself (current or archived), else the current version
|
|
62
|
+
* the CRAN index lists. A package CRAN no longer lists is a {@link PackageArchive#fallback} from the mirror.
|
|
63
|
+
*/
|
|
64
|
+
function cranSource(options = {}) {
|
|
65
|
+
const mirror = (options.cranMirror ?? 'https://cloud.r-project.org/src/contrib/').replace(/\/?$/, '/');
|
|
66
|
+
const github = options.githubMirrors !== false;
|
|
67
|
+
const indices = new Map();
|
|
68
|
+
const ofVersion = (name, version) => {
|
|
69
|
+
const file = `${name}_${version}.tar.gz`;
|
|
70
|
+
return [
|
|
71
|
+
...github ? [{ url: GitHubArchive('cran', name, `refs/tags/${version}`), origin: 'cran' }] : [],
|
|
72
|
+
{ url: `${mirror}${file}`, origin: 'cran' },
|
|
73
|
+
{ url: `${mirror}Archive/${name}/${file}`, origin: 'cran' }
|
|
74
|
+
];
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
name: 'cran',
|
|
78
|
+
async archives({ name, version }, fetch) {
|
|
79
|
+
if (isVersion(version)) {
|
|
80
|
+
return ofVersion(name, version);
|
|
81
|
+
}
|
|
82
|
+
const current = (await packagesIndex(`${mirror}PACKAGES.gz`, fetch, indices)).get(name);
|
|
83
|
+
if (current !== undefined && isVersion(current)) {
|
|
84
|
+
return ofVersion(name, current);
|
|
85
|
+
}
|
|
86
|
+
return github ? [{ url: GitHubArchive('cran', name, 'HEAD'), origin: 'cran', fallback: true }] : [];
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/** the Bioconductor repositories a package may live in */
|
|
91
|
+
const BioconductorRepositories = ['bioc', 'data/annotation', 'data/experiment', 'workflows', 'books'];
|
|
92
|
+
/** the `Package`/`Version` pairs of a `PACKAGES` index */
|
|
93
|
+
function parsePackagesIndex(index) {
|
|
94
|
+
const versions = new Map();
|
|
95
|
+
for (const entry of index.split(/\r?\n\s*\r?\n/)) {
|
|
96
|
+
const pkg = /^Package:\s*(\S+)/m.exec(entry)?.[1];
|
|
97
|
+
const version = /^Version:\s*(\S+)/m.exec(entry)?.[1];
|
|
98
|
+
if (pkg !== undefined && version !== undefined) {
|
|
99
|
+
versions.set(pkg, version);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return versions;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Bioconductor: the release tarball the repository index lists, else the GitHub mirror. A Bioconductor release
|
|
106
|
+
* only keeps its current version of a package, so an older pinned one falls back to the mirror's newest.
|
|
107
|
+
*/
|
|
108
|
+
function bioconductorSource(options = {}) {
|
|
109
|
+
const host = (options.bioconductorMirror ?? 'https://bioconductor.org').replace(/\/$/, '');
|
|
110
|
+
const release = options.bioconductorRelease ?? 'release';
|
|
111
|
+
const indices = new Map();
|
|
112
|
+
return {
|
|
113
|
+
name: 'bioconductor',
|
|
114
|
+
async archives({ name }, fetch) {
|
|
115
|
+
for (const repo of BioconductorRepositories) {
|
|
116
|
+
const version = (await packagesIndex(`${host}/packages/${release}/${repo}/src/contrib/PACKAGES`, fetch, indices)).get(name);
|
|
117
|
+
if (version !== undefined && isVersion(version)) {
|
|
118
|
+
return [
|
|
119
|
+
{ url: `${host}/packages/${release}/${repo}/src/contrib/${name}_${version}.tar.gz`, origin: 'bioconductor' },
|
|
120
|
+
...options.githubMirrors !== false ? [{ url: GitHubArchive('bioc', name, 'HEAD'), origin: 'bioconductor' }] : []
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return options.githubMirrors !== false ? [{ url: GitHubArchive('bioc', name, 'HEAD'), origin: 'bioconductor', fallback: true }] : [];
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** The sources flowR knows by name, configured with `options`. */
|
|
129
|
+
function builtInOnDemandSources(options = {}) {
|
|
130
|
+
return new Map([exports.GitHubSource, cranSource(options), bioconductorSource(options)].map(s => [s.name, s]));
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=remote-sources.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** How much an archive may unpack to, so a hostile or broken one cannot exhaust the memory. */
|
|
2
|
+
export interface TarLimits {
|
|
3
|
+
/** the most bytes the (decompressed) archive may hold */
|
|
4
|
+
readonly maxArchiveBytes: number;
|
|
5
|
+
/** the most bytes a single kept file may hold, a bigger one is skipped */
|
|
6
|
+
readonly maxFileBytes: number;
|
|
7
|
+
/** the most files to keep */
|
|
8
|
+
readonly maxFiles: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const DefaultTarLimits: TarLimits;
|
|
11
|
+
/** the error for an archive that is not a tar (or gzip'ed tar) flowR can read */
|
|
12
|
+
export declare class TarError extends Error {
|
|
13
|
+
constructor(message: string);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The regular files of a tar archive, gzip'ed or not, whose path below the top directory `keep` accepts,
|
|
17
|
+
* all held in memory: nothing is written to disk, so no entry can reach outside of where it belongs.
|
|
18
|
+
*/
|
|
19
|
+
export declare function readTarEntries(archive: Buffer, keep: (path: string) => boolean, limits?: TarLimits): Map<string, Buffer>;
|
|
@@ -0,0 +1,119 @@
|
|
|
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.TarError = exports.DefaultTarLimits = void 0;
|
|
7
|
+
exports.readTarEntries = readTarEntries;
|
|
8
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
9
|
+
exports.DefaultTarLimits = { maxArchiveBytes: 128 * 1024 * 1024, maxFileBytes: 8 * 1024 * 1024, maxFiles: 5000 };
|
|
10
|
+
/** the error for an archive that is not a tar (or gzip'ed tar) flowR can read */
|
|
11
|
+
class TarError extends Error {
|
|
12
|
+
constructor(message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'TarError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.TarError = TarError;
|
|
18
|
+
const Block = 512;
|
|
19
|
+
function field(header, offset, length) {
|
|
20
|
+
const raw = header.subarray(offset, offset + length);
|
|
21
|
+
const end = raw.indexOf(0);
|
|
22
|
+
return raw.subarray(0, end < 0 ? raw.length : end).toString('utf8');
|
|
23
|
+
}
|
|
24
|
+
function octal(header, offset, length) {
|
|
25
|
+
/* GNU tar stores big sizes in base-256, marked by the high bit of the first byte */
|
|
26
|
+
if ((header[offset] & 0x80) !== 0) {
|
|
27
|
+
let value = 0;
|
|
28
|
+
for (let i = offset + 1; i < offset + length; i++) {
|
|
29
|
+
value = value * 256 + header[i];
|
|
30
|
+
}
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
const text = field(header, offset, length).trim();
|
|
34
|
+
const value = text.length === 0 ? 0 : parseInt(text, 8);
|
|
35
|
+
if (!Number.isFinite(value) || value < 0) {
|
|
36
|
+
throw new TarError(`invalid number "${text}" in a tar header`);
|
|
37
|
+
}
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
/** the `path` record of a pax extended header, which overrides the name of the entry after it */
|
|
41
|
+
function paxPath(data) {
|
|
42
|
+
let at = 0;
|
|
43
|
+
while (at < data.length) {
|
|
44
|
+
const space = data.indexOf(0x20, at);
|
|
45
|
+
if (space < 0) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
const length = parseInt(data.subarray(at, space).toString('ascii'), 10);
|
|
49
|
+
if (!Number.isFinite(length) || length <= 0) {
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
const record = data.subarray(space + 1, at + length - 1).toString('utf8');
|
|
53
|
+
if (record.startsWith('path=')) {
|
|
54
|
+
return record.slice(5);
|
|
55
|
+
}
|
|
56
|
+
at += length;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
/** the path without the directory every entry of a package tarball sits in (`ggmirt-HEAD/R/a.R` becomes `R/a.R`), `undefined` for one leaving it */
|
|
61
|
+
function relativeEntryPath(name) {
|
|
62
|
+
const parts = name.replaceAll('\\', '/').split('/').filter(p => p.length > 0 && p !== '.');
|
|
63
|
+
if (parts.length < 2 || parts.includes('..') || name.startsWith('/')) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
return parts.slice(1).join('/');
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The regular files of a tar archive, gzip'ed or not, whose path below the top directory `keep` accepts,
|
|
70
|
+
* all held in memory: nothing is written to disk, so no entry can reach outside of where it belongs.
|
|
71
|
+
*/
|
|
72
|
+
function readTarEntries(archive, keep, limits = exports.DefaultTarLimits) {
|
|
73
|
+
let tar = archive;
|
|
74
|
+
if (archive.length >= 2 && archive[0] === 0x1f && archive[1] === 0x8b) {
|
|
75
|
+
try {
|
|
76
|
+
tar = zlib_1.default.gunzipSync(archive, { maxOutputLength: limits.maxArchiveBytes });
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
throw new TarError(`cannot decompress the archive: ${e.message}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const files = new Map();
|
|
83
|
+
let longName;
|
|
84
|
+
for (let at = 0; at + Block <= tar.length;) {
|
|
85
|
+
const header = tar.subarray(at, at + Block);
|
|
86
|
+
if (header.every(b => b === 0)) {
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
const size = octal(header, 124, 12);
|
|
90
|
+
const type = String.fromCharCode(header[156] || 0x30);
|
|
91
|
+
const start = at + Block;
|
|
92
|
+
if (start + size > tar.length) {
|
|
93
|
+
throw new TarError('the archive ends within an entry');
|
|
94
|
+
}
|
|
95
|
+
const data = tar.subarray(start, start + size);
|
|
96
|
+
at = start + Math.ceil(size / Block) * Block;
|
|
97
|
+
if (type === 'L' || type === 'x') {
|
|
98
|
+
longName = type === 'L' ? field(data, 0, data.length) : paxPath(data) ?? longName;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const magic = field(header, 257, 6);
|
|
102
|
+
const prefix = magic.startsWith('ustar') ? field(header, 345, 155) : '';
|
|
103
|
+
const name = longName ?? (prefix ? `${prefix}/${field(header, 0, 100)}` : field(header, 0, 100));
|
|
104
|
+
longName = undefined;
|
|
105
|
+
if (type !== '0' && type !== '\0' && type !== '7') {
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
const relative = relativeEntryPath(name);
|
|
109
|
+
if (relative === undefined || size > limits.maxFileBytes || !keep(relative)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (files.size >= limits.maxFiles) {
|
|
113
|
+
throw new TarError(`the archive holds more than ${limits.maxFiles} wanted files`);
|
|
114
|
+
}
|
|
115
|
+
files.set(relative, Buffer.from(data));
|
|
116
|
+
}
|
|
117
|
+
return files;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=tar.js.map
|
package/project/sigdb/reader.js
CHANGED
|
@@ -31,6 +31,7 @@ const dict_1 = require("./dict");
|
|
|
31
31
|
const hash_1 = require("./hash");
|
|
32
32
|
const manifest_1 = require("./manifest");
|
|
33
33
|
const arrays_1 = require("../../util/collections/arrays");
|
|
34
|
+
const log_1 = require("../../util/log");
|
|
34
35
|
/** the run of names one `d` line (`["d", start, payload]`, newline-blob or legacy `string[]` form) adds */
|
|
35
36
|
function dictLineRun(json) {
|
|
36
37
|
const [, start, payload] = JSON.parse(json);
|
|
@@ -422,7 +423,7 @@ class SigDatabase {
|
|
|
422
423
|
if (opts.hash === undefined) {
|
|
423
424
|
throw new Error('openSyncFrom needs a hash to key the cache for a compressed source');
|
|
424
425
|
}
|
|
425
|
-
plain = (0, decompress_1.ensurePlainSync)(source, { cacheDir: opts.cacheDir, hash: opts.hash, index: opts.index });
|
|
426
|
+
plain = (0, decompress_1.ensurePlainSync)(source, { cacheDir: opts.cacheDir, hash: opts.hash, index: opts.index, bytes: opts.index?.byteCount });
|
|
426
427
|
}
|
|
427
428
|
return SigDatabase.openSync(plain, { index: opts.index, strings: opts.strings });
|
|
428
429
|
}
|
|
@@ -742,9 +743,17 @@ class SigDatabaseSet {
|
|
|
742
743
|
if (full.format !== manifest_1.SigDbManifestMagic) {
|
|
743
744
|
throw new Error(`not a ${manifest_1.SigDbManifestMagic} (got ${String(full.format)})`);
|
|
744
745
|
}
|
|
745
|
-
const
|
|
746
|
+
const selected = selectShards(full.shards, opts.includeShards, opts.excludeShards);
|
|
747
|
+
const present = (rel) => fs_1.default.existsSync((0, decompress_1.resolveSource)(baseDir, rel));
|
|
748
|
+
const active = selected.filter(s => {
|
|
749
|
+
const dict = s.dict === undefined ? undefined : full.dicts?.find(d => d.id === s.dict);
|
|
750
|
+
return present(s.path) && (dict === undefined || present(dict.path));
|
|
751
|
+
});
|
|
752
|
+
if (active.length < selected.length) {
|
|
753
|
+
log_1.log.warn(`sigdb: ${manifestFile} lacks the files of ${selected.length - active.length} shard(s) (${selected.filter(s => !active.includes(s)).map(s => s.path).join(', ')}), ignoring them; download the bundle again to restore them`);
|
|
754
|
+
}
|
|
746
755
|
if (active.length === 0) {
|
|
747
|
-
throw new Error(
|
|
756
|
+
throw new Error(`openManifest: no shards left in ${manifestFile} after include/exclude filtering and dropping absent ones`);
|
|
748
757
|
}
|
|
749
758
|
return { baseDir, manifest: { ...full, shards: active } };
|
|
750
759
|
}
|
|
@@ -797,7 +806,7 @@ class SigDatabaseSet {
|
|
|
797
806
|
if (!ref) {
|
|
798
807
|
throw new Error(`manifest references unknown dictionary '${dictId}'`);
|
|
799
808
|
}
|
|
800
|
-
const plain = (0, decompress_1.ensurePlainSync)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true });
|
|
809
|
+
const plain = (0, decompress_1.ensurePlainSync)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true, bytes: ref.byteCount });
|
|
801
810
|
let strings;
|
|
802
811
|
const fd = fs_1.default.openSync(plain, 'r');
|
|
803
812
|
try {
|
|
@@ -840,10 +849,10 @@ class SigDatabaseSet {
|
|
|
840
849
|
/** decompress the given shards + their shared dictionaries concurrently, then open them (see {@link preload}) */
|
|
841
850
|
async warmShards(need) {
|
|
842
851
|
const dicts = new Set([...need].map(i => this.manifest.shards[i].dict).filter((d) => !!d));
|
|
843
|
-
const shardJobs = [...need].map(i => (0, decompress_1.ensurePlain)((0, decompress_1.resolveSource)(this.baseDir, this.manifest.shards[i].path), { cacheDir: this.cacheDir, hash: this.manifest.shards[i].hash, index: this.indices[i] }));
|
|
852
|
+
const shardJobs = [...need].map(i => (0, decompress_1.ensurePlain)((0, decompress_1.resolveSource)(this.baseDir, this.manifest.shards[i].path), { cacheDir: this.cacheDir, hash: this.manifest.shards[i].hash, index: this.indices[i], bytes: this.indices[i]?.byteCount }));
|
|
844
853
|
const dictJobs = [...dicts].map(id => {
|
|
845
854
|
const ref = this.manifest.dicts?.find(d => d.id === id);
|
|
846
|
-
return ref ? (0, decompress_1.ensurePlain)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true }) : Promise.resolve('');
|
|
855
|
+
return ref ? (0, decompress_1.ensurePlain)((0, decompress_1.resolveSource)(this.baseDir, ref.path), { cacheDir: this.cacheDir, hash: ref.hash, indexless: true, bytes: ref.byteCount }) : Promise.resolve('');
|
|
847
856
|
});
|
|
848
857
|
await Promise.all([...shardJobs, ...dictJobs]);
|
|
849
858
|
// open each shard now so later synchronous queries never block
|
|
@@ -25,7 +25,7 @@ export declare function selectDownloadVariants(names: Iterable<string>): string[
|
|
|
25
25
|
export interface SigDbDownloadOptions {
|
|
26
26
|
/** GitHub `owner/repo` (default `flowr-analysis/flowr`) */
|
|
27
27
|
readonly repo?: string;
|
|
28
|
-
/**
|
|
28
|
+
/** an explicit release (tag `<v>`, `v<v>`, or `sigdb-v<v>`), else the pointer's tag */
|
|
29
29
|
readonly version?: string;
|
|
30
30
|
/** progress callback (one line per step) */
|
|
31
31
|
readonly onProgress?: (msg: string) => void;
|
|
@@ -69,13 +69,9 @@ export declare const isManifestFile: (name: string) => boolean;
|
|
|
69
69
|
* Use the returned {@link SigDbDownloadResult.manifest}, or point `solver.sigdb.additionalPaths` at the dir.
|
|
70
70
|
*/
|
|
71
71
|
export declare function downloadFullSigDb(opts?: SigDbDownloadOptions): Promise<SigDbDownloadResult>;
|
|
72
|
-
/**
|
|
73
|
-
* The cache dir a {@link downloadFullSigDb} for the committed link file would populate, or `undefined` if no
|
|
74
|
-
* pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
|
|
75
|
-
* hitting the network.
|
|
76
|
-
*/
|
|
72
|
+
/** the cache dir {@link downloadFullSigDb} populates, `undefined` if the pointer is broken */
|
|
77
73
|
export declare function syncedSigDbDir(): string | undefined;
|
|
78
|
-
/** the GitHub release
|
|
74
|
+
/** the GitHub release the pointer downloads from, `undefined` if it is broken */
|
|
79
75
|
export declare function sigDbRemoteRelease(): {
|
|
80
76
|
repo: string;
|
|
81
77
|
tag: string;
|
|
@@ -17,7 +17,7 @@ const https_1 = __importDefault(require("https"));
|
|
|
17
17
|
const crypto_1 = __importDefault(require("crypto"));
|
|
18
18
|
const decompress_1 = require("./decompress");
|
|
19
19
|
const codec_1 = require("./codec");
|
|
20
|
-
const
|
|
20
|
+
const sigdb_remote_json_1 = __importDefault(require("../../data/sigdb/sigdb.remote.json"));
|
|
21
21
|
const files_1 = require("../../util/files");
|
|
22
22
|
const secure_mode_1 = require("../../util/secure-mode");
|
|
23
23
|
/** the GitHub `owner/repo` the full-history bundle is published to (see `scripts/publish-sigdb.mjs`) */
|
|
@@ -93,7 +93,7 @@ const mb = (bytes) => `${(bytes / 1e6).toFixed(1)} MB`;
|
|
|
93
93
|
const rate = (bytes, ms) => `${(bytes / 1e6 / Math.max(ms / 1000, 0.001)).toFixed(1)} MB/s`;
|
|
94
94
|
/** Download `url` to `dest` via a temporary file, so a partial or corrupt file never lands there (checked against `sha256`, if given). */
|
|
95
95
|
async function downloadTo(url, dest, name, progress, expected) {
|
|
96
|
-
const part =
|
|
96
|
+
const part = (0, decompress_1.uniqueTempPath)(dest, 'part');
|
|
97
97
|
const start = Date.now();
|
|
98
98
|
try {
|
|
99
99
|
const res = await httpGet(url, 'application/octet-stream');
|
|
@@ -139,26 +139,19 @@ const sha256File = (p) => crypto_1.default.createHash('sha256').update(fs_1.defa
|
|
|
139
139
|
exports.sha256File = sha256File;
|
|
140
140
|
/** the committed link file naming every downloadable shard (base floor + CRAN sets); only this pointer is committed */
|
|
141
141
|
exports.SigDbRemoteFileName = 'sigdb.remote.json';
|
|
142
|
-
/**
|
|
143
|
-
function
|
|
142
|
+
/** the file `$FLOWR_SIGDB_REMOTE` names, else the committed link file (inlined at build time) */
|
|
143
|
+
function remotePointer() {
|
|
144
144
|
const override = process.env.FLOWR_SIGDB_REMOTE;
|
|
145
|
-
|
|
146
|
-
|
|
145
|
+
return override ? readPointerChecked(override) : checkedPointer(sigdb_remote_json_1.default, exports.SigDbRemoteFileName);
|
|
146
|
+
}
|
|
147
|
+
function tryRemotePointer() {
|
|
148
|
+
try {
|
|
149
|
+
return remotePointer();
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined;
|
|
147
153
|
}
|
|
148
|
-
const candidates = [
|
|
149
|
-
// src/ and dist/src/ layouts (same depth); never the working directory, which may be the analyzed (untrusted) project
|
|
150
|
-
path_1.default.join(__dirname, '../../data/sigdb', exports.SigDbRemoteFileName),
|
|
151
|
-
];
|
|
152
|
-
return candidates.find(p => {
|
|
153
|
-
try {
|
|
154
|
-
return fs_1.default.existsSync(p);
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
154
|
}
|
|
161
|
-
const readPointer = (p) => JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
|
|
162
155
|
/** the direct release-asset URL, which avoids the REST API rate limit; `$FLOWR_SIGDB_MIRROR` replaces the host */
|
|
163
156
|
const assetUrl = (repo, tag, name) => `${process.env.FLOWR_SIGDB_MIRROR ?? 'https://github.com'}/${repo}/releases/download/${tag}/${encodeURIComponent(name)}`;
|
|
164
157
|
/** runtime-decodable variant extensions, most-preferred first, ending in plain (`''`) as a last resort */
|
|
@@ -293,17 +286,19 @@ async function syncFiles(tag, repo, planned, opts) {
|
|
|
293
286
|
}
|
|
294
287
|
return { tag, dir, manifest: pickManifest(files), files, downloaded, bytes, ms, stale };
|
|
295
288
|
}
|
|
296
|
-
/** read the committed link file, naming it in the error when it is broken */
|
|
297
289
|
function readPointerChecked(p) {
|
|
298
290
|
let remote;
|
|
299
291
|
try {
|
|
300
|
-
remote =
|
|
292
|
+
remote = JSON.parse(fs_1.default.readFileSync(p, 'utf8'));
|
|
301
293
|
}
|
|
302
294
|
catch (e) {
|
|
303
295
|
throw new Error(`cannot read the signature database link file ${p}: ${e.message}`, { cause: e });
|
|
304
296
|
}
|
|
305
|
-
|
|
306
|
-
|
|
297
|
+
return checkedPointer(remote, p);
|
|
298
|
+
}
|
|
299
|
+
function checkedPointer(remote, origin) {
|
|
300
|
+
if (typeof remote?.tag !== 'string' || typeof remote.shards !== 'object' || remote.shards === null) {
|
|
301
|
+
throw new Error(`the signature database link file ${origin} names no tag or shards`);
|
|
307
302
|
}
|
|
308
303
|
return remote;
|
|
309
304
|
}
|
|
@@ -313,69 +308,73 @@ function readPointerChecked(p) {
|
|
|
313
308
|
* Use the returned {@link SigDbDownloadResult.manifest}, or point `solver.sigdb.additionalPaths` at the dir.
|
|
314
309
|
*/
|
|
315
310
|
async function downloadFullSigDb(opts = {}) {
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (pointerPath) {
|
|
319
|
-
const remote = readPointerChecked(pointerPath);
|
|
320
|
-
const repo = opts.repo ?? remote.repo ?? DefaultRepo;
|
|
321
|
-
// one variant per logical shard/dictionary -- the best this runtime can decompress (never both codecs)
|
|
322
|
-
const planned = selectDownloadVariants(Object.keys(remote.shards)).map(name => ({
|
|
323
|
-
name, url: assetUrl(repo, remote.tag, name), expected: remote.shards[name]
|
|
324
|
-
}));
|
|
325
|
-
return syncFiles(remote.tag, repo, planned, opts);
|
|
311
|
+
if (opts.version !== undefined) {
|
|
312
|
+
return downloadRelease(opts.version, opts);
|
|
326
313
|
}
|
|
327
|
-
|
|
314
|
+
const remote = remotePointer();
|
|
315
|
+
const repo = opts.repo ?? remote.repo ?? DefaultRepo;
|
|
316
|
+
// one variant per shard, the best codec this runtime supports
|
|
317
|
+
const planned = selectDownloadVariants(Object.keys(remote.shards)).map(name => ({
|
|
318
|
+
name, url: assetUrl(repo, remote.tag, name), expected: remote.shards[name]
|
|
319
|
+
}));
|
|
320
|
+
return syncFiles(remote.tag, repo, planned, opts);
|
|
321
|
+
}
|
|
322
|
+
function releaseTagCandidates(version) {
|
|
323
|
+
const bare = version.replace(/^(sigdb-)?v/, '');
|
|
324
|
+
return [...new Set([version, `v${bare}`, `sigdb-v${bare}`])];
|
|
325
|
+
}
|
|
326
|
+
async function downloadRelease(version, opts) {
|
|
327
|
+
const progress = opts.onProgress ?? (() => { });
|
|
328
328
|
const repo = opts.repo ?? DefaultRepo;
|
|
329
|
-
const
|
|
330
|
-
const tag
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
329
|
+
const tried = [];
|
|
330
|
+
for (const tag of releaseTagCandidates(version)) {
|
|
331
|
+
progress(`listing release ${tag} of ${repo}`);
|
|
332
|
+
let release;
|
|
333
|
+
try {
|
|
334
|
+
release = await withRetries(`listing ${tag}`, () => readJson(`https://api.github.com/repos/${repo}/releases/tags/${tag}`), progress);
|
|
335
|
+
}
|
|
336
|
+
catch (e) {
|
|
337
|
+
if (!(e instanceof HttpError) || e.retryable) {
|
|
338
|
+
throw e;
|
|
339
|
+
}
|
|
340
|
+
tried.push(`${tag}: ${e.message}`);
|
|
341
|
+
continue;
|
|
342
|
+
}
|
|
343
|
+
const assets = (release.assets ?? [])
|
|
344
|
+
.filter(a => a.name.endsWith('.br') || a.name.endsWith('.zst') || a.name.endsWith('.manifest.json'));
|
|
345
|
+
if (assets.length === 0) {
|
|
346
|
+
tried.push(`${tag}: no signature-database assets`);
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const byName = new Map(assets.map(a => [a.name, a]));
|
|
350
|
+
const planned = selectDownloadVariants(byName.keys()).map(name => {
|
|
351
|
+
const a = byName.get(name);
|
|
352
|
+
return { name, url: a.browser_download_url, size: a.size };
|
|
353
|
+
});
|
|
354
|
+
return syncFiles(tag, repo, planned, opts);
|
|
337
355
|
}
|
|
338
|
-
|
|
339
|
-
const planned = selectDownloadVariants(byName.keys()).map(name => {
|
|
340
|
-
const a = byName.get(name);
|
|
341
|
-
return { name, url: a.browser_download_url, size: a.size };
|
|
342
|
-
});
|
|
343
|
-
return syncFiles(tag, repo, planned, opts);
|
|
356
|
+
throw new Error(`no signature database release for ${version} in ${repo} (${tried.join('; ')})`);
|
|
344
357
|
}
|
|
345
|
-
/**
|
|
346
|
-
* The cache dir a {@link downloadFullSigDb} for the committed link file would populate, or `undefined` if no
|
|
347
|
-
* pointer is committed. Lets a caller mount an already-synced bundle via `solver.sigdb.additionalPaths` without
|
|
348
|
-
* hitting the network.
|
|
349
|
-
*/
|
|
358
|
+
/** the cache dir {@link downloadFullSigDb} populates, `undefined` if the pointer is broken */
|
|
350
359
|
function syncedSigDbDir() {
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
return undefined;
|
|
354
|
-
}
|
|
355
|
-
return path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', readPointer(pointerPath).tag);
|
|
360
|
+
const remote = tryRemotePointer();
|
|
361
|
+
return remote && path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles', remote.tag);
|
|
356
362
|
}
|
|
357
|
-
/** the GitHub release
|
|
363
|
+
/** the GitHub release the pointer downloads from, `undefined` if it is broken */
|
|
358
364
|
function sigDbRemoteRelease() {
|
|
359
|
-
const
|
|
360
|
-
if (!
|
|
361
|
-
return undefined;
|
|
362
|
-
}
|
|
363
|
-
try {
|
|
364
|
-
const remote = readPointer(pointerPath);
|
|
365
|
-
const repo = remote.repo ?? DefaultRepo;
|
|
366
|
-
return { repo, tag: remote.tag, url: `https://github.com/${repo}/releases/tag/${remote.tag}` };
|
|
367
|
-
}
|
|
368
|
-
catch {
|
|
365
|
+
const remote = tryRemotePointer();
|
|
366
|
+
if (!remote) {
|
|
369
367
|
return undefined;
|
|
370
368
|
}
|
|
369
|
+
const repo = remote.repo ?? DefaultRepo;
|
|
370
|
+
return { repo, tag: remote.tag, url: `https://github.com/${repo}/releases/tag/${remote.tag}` };
|
|
371
371
|
}
|
|
372
372
|
function withSelectedShards(f) {
|
|
373
|
-
const
|
|
374
|
-
if (!
|
|
373
|
+
const remote = tryRemotePointer();
|
|
374
|
+
if (!remote) {
|
|
375
375
|
return false;
|
|
376
376
|
}
|
|
377
377
|
try {
|
|
378
|
-
const remote = readPointer(pointerPath);
|
|
379
378
|
return f(remote, path_1.default.join((0, decompress_1.sigDbCacheDir)(undefined, false), 'bundles', remote.tag), selectDownloadVariants(Object.keys(remote.shards)));
|
|
380
379
|
}
|
|
381
380
|
catch {
|
|
@@ -9,3 +9,8 @@ import type { BuiltInDefinitions } from '../../../../dataflow/environments/built
|
|
|
9
9
|
* wrote them down.
|
|
10
10
|
*/
|
|
11
11
|
export declare function functionInfosFromProps(props: PropSelector, except: readonly FunctionInfo[], definitions: BuiltInDefinitions): FunctionInfo[];
|
|
12
|
+
/**
|
|
13
|
+
* The entries of `entries` for built-ins telling the files they read from the ones they write ({@link FnSig.resources}),
|
|
14
|
+
* like `unzip(zipfile, exdir)`, which are entries of both categories, each with its own argument.
|
|
15
|
+
*/
|
|
16
|
+
export declare function readingAndWritingApart(entries: readonly FunctionInfo[], definitions: BuiltInDefinitions): ReadonlySet<FunctionInfo>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.functionInfosFromProps = functionInfosFromProps;
|
|
4
|
+
exports.readingAndWritingApart = readingAndWritingApart;
|
|
4
5
|
const function_semantics_1 = require("../../../../dataflow/fn/function-semantics");
|
|
5
6
|
const built_in_props_1 = require("../../../../dataflow/environments/built-in-props");
|
|
6
7
|
const query_fn_props_1 = require("../../../../dataflow/environments/query-fn-props");
|
|
@@ -29,12 +30,13 @@ function functionInfosFromProps(props, except, definitions) {
|
|
|
29
30
|
/* a bare name speaks for every package: an entry written down without one, and whatever a link points at */
|
|
30
31
|
const takenEverywhere = new Set(except.flatMap(f => [...f.package === undefined ? [f.name] : [], ...linkTargets(f)]));
|
|
31
32
|
const found = [];
|
|
33
|
+
const written = Array.isArray(props) ? props.includes(built_in_props_1.SemanticCallTag.Writes) : props === built_in_props_1.SemanticCallTag.Writes;
|
|
32
34
|
for (const d of definitions) {
|
|
33
35
|
const info = d.type !== 'constant' ? d.config : undefined;
|
|
34
36
|
if (info?.sig === undefined || !function_semantics_1.FunctionSemantics.call.props.hasAny(info) || !function_semantics_1.FunctionSemantics.call.props.hasAll(info, props)) {
|
|
35
37
|
continue;
|
|
36
38
|
}
|
|
37
|
-
const argIdx = info.sig.findIndex(([, p]) => (p & built_in_props_1.ArgProp.Resource) !== 0);
|
|
39
|
+
const argIdx = built_in_props_1.FnSig.resources(info.sig, written).findIndex(([, p]) => (p & built_in_props_1.ArgProp.Resource) !== 0);
|
|
38
40
|
if (argIdx < 0) {
|
|
39
41
|
continue;
|
|
40
42
|
}
|
|
@@ -49,4 +51,18 @@ function functionInfosFromProps(props, except, definitions) {
|
|
|
49
51
|
}
|
|
50
52
|
return found;
|
|
51
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* The entries of `entries` for built-ins telling the files they read from the ones they write ({@link FnSig.resources}),
|
|
56
|
+
* like `unzip(zipfile, exdir)`, which are entries of both categories, each with its own argument.
|
|
57
|
+
*/
|
|
58
|
+
function readingAndWritingApart(entries, definitions) {
|
|
59
|
+
const apart = new Set();
|
|
60
|
+
for (const d of definitions) {
|
|
61
|
+
const sig = d.type !== 'constant' ? d.config?.sig : undefined;
|
|
62
|
+
if (sig !== undefined && built_in_props_1.FnSig.resources(sig, true) !== sig) {
|
|
63
|
+
(0, query_fn_props_1.builtInNames)(d).forEach(id => apart.add(identifier_1.Identifier.toString(id)));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return new Set(entries.filter(f => apart.has(writtenAs(f))));
|
|
67
|
+
}
|
|
52
68
|
//# sourceMappingURL=derived-functions.js.map
|
|
@@ -46,8 +46,10 @@ const ReadFunctionsWithMore = [
|
|
|
46
46
|
];
|
|
47
47
|
/** The read entries the given built-in definitions imply, together with the ones written down here. */
|
|
48
48
|
function computeReadFunctions(definitions) {
|
|
49
|
+
/* copying reads the file it copies */
|
|
50
|
+
const apart = (0, derived_functions_1.readingAndWritingApart)(other_path_functions_1.OtherPathFunctions, definitions);
|
|
49
51
|
return [
|
|
50
|
-
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads], [...ReadFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions, ...source_functions_1.SourceFunctions], definitions),
|
|
52
|
+
...(0, derived_functions_1.functionInfosFromProps)([built_in_props_1.SemanticCallTag.File, built_in_props_1.SemanticCallTag.Reads], [...ReadFunctionsWithMore, ...other_path_functions_1.OtherPathFunctions.filter(f => !apart.has(f)), ...source_functions_1.SourceFunctions], definitions),
|
|
51
53
|
...ReadFunctionsWithMore
|
|
52
54
|
];
|
|
53
55
|
}
|