@eagleoutice/flowr 2.15.10 → 2.16.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 +23 -26
- package/abstract-interpretation/data-frame/arguments.js +11 -7
- package/cli/flowr-main-options.d.ts +15 -0
- package/cli/flowr-main-options.js +18 -0
- package/cli/flowr.d.ts +18 -0
- package/cli/flowr.js +13 -2
- package/cli/repl/commands/repl-clipboard.js +2 -1
- package/cli/repl/commands/repl-commands.js +2 -0
- package/cli/repl/commands/repl-main.d.ts +5 -0
- package/cli/repl/commands/repl-signature.js +2 -0
- package/cli/repl/core.d.ts +7 -1
- package/cli/repl/core.js +17 -8
- package/cli/repl/execute.js +2 -0
- package/cli/repl/server/connection.js +2 -1
- package/cli/repl/server/net.d.ts +10 -0
- package/cli/repl/server/net.js +34 -1
- package/cli/slicer-app.js +2 -1
- package/config.d.ts +12 -2
- package/config.js +91 -14
- package/control-flow/happens-before.d.ts +5 -0
- package/control-flow/happens-before.js +48 -34
- package/control-flow/useless-loop.d.ts +1 -1
- package/control-flow/useless-loop.js +29 -42
- package/dataflow/environments/built-in-props.d.ts +9 -0
- package/dataflow/environments/built-in-props.js +25 -19
- package/dataflow/environments/built-in.d.ts +2 -2
- package/dataflow/environments/built-in.js +41 -77
- package/dataflow/environments/default-builtin-config.d.ts +181 -29
- package/dataflow/environments/default-builtin-config.js +38 -24
- package/dataflow/environments/environment.d.ts +6 -4
- package/dataflow/environments/environment.js +54 -121
- package/dataflow/environments/identifier.d.ts +4 -2
- package/dataflow/environments/identifier.js +23 -69
- package/dataflow/environments/reference-to-maybe.d.ts +9 -0
- package/dataflow/environments/reference-to-maybe.js +23 -51
- package/dataflow/environments/resolve-by-name.js +37 -76
- package/dataflow/eval/resolve/resolve-argument.d.ts +3 -1
- package/dataflow/eval/resolve/resolve-argument.js +61 -64
- package/dataflow/eval/resolve/resolve-working-directory.d.ts +8 -2
- package/dataflow/eval/resolve/resolve-working-directory.js +12 -20
- package/dataflow/eval/resolve/resolve.d.ts +4 -0
- package/dataflow/eval/resolve/resolve.js +23 -14
- package/dataflow/extractor.js +185 -59
- package/dataflow/fn/class-declaration.d.ts +8 -2
- package/dataflow/fn/class-declaration.js +96 -97
- package/dataflow/fn/exceptions-of-function.js +68 -37
- package/dataflow/fn/frame-reflection.d.ts +12 -4
- package/dataflow/fn/frame-reflection.js +64 -42
- package/dataflow/fn/function-props.js +15 -33
- package/dataflow/fn/function-semantics.d.ts +11 -3
- package/dataflow/fn/function-semantics.js +6 -0
- package/dataflow/fn/higher-order-function.js +13 -17
- package/dataflow/fn/strict-function.d.ts +13 -0
- package/dataflow/fn/strict-function.js +285 -122
- package/dataflow/graph/call-graph.d.ts +7 -6
- package/dataflow/graph/call-graph.js +35 -46
- package/dataflow/graph/graph.d.ts +6 -1
- package/dataflow/graph/graph.js +57 -66
- package/dataflow/info.d.ts +8 -1
- package/dataflow/info.js +24 -30
- package/dataflow/internal/control-flow.d.ts +42 -4
- package/dataflow/internal/control-flow.js +76 -39
- package/dataflow/internal/linker.d.ts +15 -9
- package/dataflow/internal/linker.js +253 -241
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.d.ts +80 -14
- package/dataflow/internal/process/functions/call/built-in/built-in-ambient-state.js +441 -79
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.d.ts +3 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-apply.js +51 -48
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.d.ts +2 -2
- package/dataflow/internal/process/functions/call/built-in/built-in-assignment.js +119 -185
- package/dataflow/internal/process/functions/call/built-in/built-in-class-generator.js +7 -9
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-expression-list.js +122 -147
- package/dataflow/internal/process/functions/call/built-in/built-in-for-loop.js +55 -25
- package/dataflow/internal/process/functions/call/built-in/built-in-function-definition.js +290 -252
- package/dataflow/internal/process/functions/call/built-in/built-in-get.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-get.js +30 -32
- package/dataflow/internal/process/functions/call/built-in/built-in-if-then-else.js +68 -67
- package/dataflow/internal/process/functions/call/built-in/built-in-library.js +72 -126
- package/dataflow/internal/process/functions/call/built-in/built-in-local.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-local.js +10 -10
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.d.ts +4 -4
- package/dataflow/internal/process/functions/call/built-in/built-in-quote.js +9 -35
- package/dataflow/internal/process/functions/call/built-in/built-in-rm.js +8 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-four.js +12 -28
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-s-seven-new-generic.js +40 -118
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-s-three-dispatch.js +16 -24
- package/dataflow/internal/process/functions/call/built-in/built-in-source.d.ts +2 -0
- package/dataflow/internal/process/functions/call/built-in/built-in-source.js +93 -102
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.d.ts +7 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-try-catch.js +173 -114
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.d.ts +1 -3
- package/dataflow/internal/process/functions/call/built-in/built-in-while-loop.js +22 -27
- package/dataflow/internal/process/functions/call/built-in/built-in-with.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/built-in-with.js +34 -9
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.d.ts +1 -1
- package/dataflow/internal/process/functions/call/built-in/transitive-side-effects.js +120 -93
- package/dataflow/internal/process/functions/call/common.d.ts +1 -3
- package/dataflow/internal/process/functions/call/common.js +36 -76
- package/dataflow/internal/process/functions/call/deferred.d.ts +6 -2
- package/dataflow/internal/process/functions/call/deferred.js +60 -58
- package/dataflow/internal/process/functions/call/known-call-handling.d.ts +4 -2
- package/dataflow/internal/process/functions/call/known-call-handling.js +65 -68
- package/dataflow/internal/process/functions/call/named-call-handling.d.ts +3 -5
- package/dataflow/internal/process/functions/call/named-call-handling.js +44 -21
- package/dataflow/internal/process/functions/call/quoted.d.ts +2 -0
- package/dataflow/internal/process/functions/call/quoted.js +162 -172
- package/dataflow/internal/process/functions/call/unnamed-call-handling.js +17 -38
- package/dataflow/internal/process/functions/process-parameter.js +25 -32
- package/dataflow/internal/process/process-symbol.js +3 -6
- package/dataflow/internal/program-order.d.ts +26 -0
- package/dataflow/internal/program-order.js +49 -0
- package/documentation/doc-capabilities.js +4 -1
- package/documentation/wiki-interface.js +4 -0
- package/documentation/wiki-setup.js +23 -0
- package/engines.js +11 -3
- package/linter/linter-executor.js +19 -1
- package/linter/linter-rules.d.ts +17 -8
- package/linter/rules/absolute-path.js +63 -87
- package/linter/rules/file-path-validity.d.ts +4 -2
- package/linter/rules/file-path-validity.js +117 -80
- package/linter/rules/namespace-access.js +21 -33
- package/linter/rules/naming-convention.d.ts +1 -1
- package/linter/rules/naming-convention.js +60 -48
- package/linter/rules/network-functions.js +11 -7
- package/linter/rules/no-leaked-credentials.js +15 -18
- package/linter/rules/problematic-inputs.d.ts +2 -1
- package/linter/rules/problematic-inputs.js +39 -59
- package/linter/rules/roxygen-arguments.d.ts +9 -4
- package/linter/rules/roxygen-arguments.js +29 -48
- package/linter/rules/seeded-randomness.d.ts +7 -4
- package/linter/rules/seeded-randomness.js +130 -89
- package/linter/rules/stop-with-call-arg.d.ts +4 -2
- package/linter/rules/stop-with-call-arg.js +25 -22
- package/linter/rules/unclosed-connection.js +31 -24
- package/linter/rules/undefined-symbol.d.ts +4 -6
- package/linter/rules/undefined-symbol.js +58 -75
- package/linter/rules/unescaped-arguments.js +18 -44
- package/linter/rules/unused-definition.d.ts +6 -0
- package/linter/rules/unused-definition.js +105 -145
- package/linter/rules/unused-import.d.ts +3 -0
- package/linter/rules/unused-import.js +25 -43
- package/package.json +5 -2
- package/project/flowr-analyzer.js +6 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.d.ts +2 -2
- package/project/plugins/file-plugins/files/flowr-jupyter-file.js +8 -12
- package/project/plugins/file-plugins/files/flowr-rda-file.d.ts +14 -5
- package/project/plugins/file-plugins/files/flowr-rda-file.js +35 -24
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.d.ts +7 -5
- package/project/plugins/file-plugins/files/flowr-rmarkdown-file.js +34 -56
- package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js +18 -42
- package/project/sigdb/decompress.js +3 -1
- package/project/sigdb/sigdb-download.js +9 -6
- package/queries/base-query-format.js +1 -2
- package/queries/catalog/absint-query/absint-query-format.js +1 -1
- package/queries/catalog/config-query/config-query-executor.js +9 -2
- package/queries/catalog/dataflow-query/dataflow-query-executor.js +2 -2
- package/queries/catalog/dataflow-query/dataflow-query-format.d.ts +2 -0
- package/queries/catalog/dataflow-query/dataflow-query-format.js +4 -7
- package/queries/catalog/dependencies-query/dependencies-query-executor.js +50 -114
- package/queries/catalog/dependencies-query/function-info/library-functions.d.ts +5 -9
- package/queries/catalog/dependencies-query/function-info/library-functions.js +6 -0
- package/queries/catalog/dependencies-query/function-info/read-functions.js +1 -1
- package/queries/catalog/dependencies-query/function-info/write-functions.js +7 -3
- package/queries/catalog/input-sources-query/simple-input-classifier.d.ts +4 -4
- package/queries/catalog/input-sources-query/simple-input-classifier.js +192 -301
- package/r-bridge/lang-4.x/ast/model/model.d.ts +3 -1
- package/r-bridge/lang-4.x/ast/model/model.js +19 -43
- package/r-bridge/lang-4.x/ast/model/nodes/r-access.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.d.ts +3 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-argument.js +5 -12
- package/r-bridge/lang-4.x/ast/model/nodes/r-binary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-break.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-comment.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-expression-list.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-for-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-call.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-function-definition.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-if-then-else.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-line-directive.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-logical.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-next.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-number.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-parameter.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-pipe.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-repeat-loop.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-string.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-symbol.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-unary-op.d.ts +1 -0
- package/r-bridge/lang-4.x/ast/model/nodes/r-while-loop.d.ts +1 -0
- package/r-bridge/roxygen2/roxygen-parse.js +28 -42
- package/r-bridge/shell-executor.js +2 -0
- package/r-bridge/shell.js +8 -0
- package/search/search-executor/search-enrichers.js +25 -37
- package/slicing/static/slice-call.d.ts +4 -3
- package/slicing/static/slice-call.js +56 -88
- package/slicing/static/static-slicer.js +120 -79
- package/slicing/static/visiting-queue.d.ts +4 -6
- package/slicing/static/visiting-queue.js +9 -13
- package/util/files.d.ts +6 -0
- package/util/files.js +12 -0
- package/util/parallel.js +2 -0
- package/util/proc.js +2 -1
- package/util/r-base-packages.d.ts +2 -0
- package/util/r-base-packages.js +23 -13
- package/util/secure-mode.d.ts +42 -0
- package/util/secure-mode.js +70 -0
- package/util/text/playground-link.d.ts +12 -3
- package/util/text/playground-link.js +18 -27
- package/util/version.js +4 -10
|
@@ -165,6 +165,15 @@ export declare enum SerializationFormat {
|
|
|
165
165
|
Ascii = "ASCII",
|
|
166
166
|
Binary = "BINARY"
|
|
167
167
|
}
|
|
168
|
+
/** The parts of the (untyped) `bzip2` package we use. */
|
|
169
|
+
export interface Bzip2 {
|
|
170
|
+
array(bytes: Uint8Array): unknown;
|
|
171
|
+
header(bits: unknown): number;
|
|
172
|
+
/** decompresses the next block (stopping after `len` bytes), `-1` after the last one */
|
|
173
|
+
decompress(bits: unknown, size: number, len?: number): Uint8Array | -1;
|
|
174
|
+
}
|
|
175
|
+
/** Decompresses a bzip2 stream block by block, throwing a `RangeError` if it would yield more than `limit` bytes. */
|
|
176
|
+
export declare function bunzip(bzip2: Bzip2, content: Buffer, limit?: number): Buffer;
|
|
168
177
|
/**
|
|
169
178
|
* Parser for RDA files.
|
|
170
179
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c | R source: serialize.c}
|
|
@@ -176,7 +185,6 @@ export declare class RDAParser {
|
|
|
176
185
|
private buffer;
|
|
177
186
|
private currentDepth;
|
|
178
187
|
private static readonly INITIAL_DEPTH;
|
|
179
|
-
private lastName;
|
|
180
188
|
private offset;
|
|
181
189
|
private static readonly R_CODE_SET_MAX;
|
|
182
190
|
private RWeakRefs;
|
|
@@ -250,15 +258,16 @@ export declare class RDAParser {
|
|
|
250
258
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L2117-L2121 | R source: ReadItem}
|
|
251
259
|
*/
|
|
252
260
|
readItem(): RObject;
|
|
253
|
-
/** Runs `code` in R and answers an `EnvSxp`, `value` set to {@link RValues.GlobalEnv} when the result names it. Shared by {@link R_FindNamespace} and {@link R_FindNamespace1}. */
|
|
254
|
-
private runNamespaceLookup;
|
|
255
261
|
/**
|
|
256
|
-
* Resolves a namespace reference by name
|
|
262
|
+
* Resolves a namespace reference by name. Simpler variant of {@link R_FindNamespace1}.
|
|
263
|
+
* R would load the namespace (`getNamespace()`), but flowR analyzes R code and data without running it: the name comes
|
|
264
|
+
* from the (untrusted) file, and loading a namespace runs the package's code. Hence, this answers an `EnvSxp` standing
|
|
265
|
+
* for the (unknown) namespace environment without consulting R.
|
|
257
266
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3795-L3804 | R source: R_FindNamespace}
|
|
258
267
|
*/
|
|
259
268
|
R_FindNamespace(info: RObjectData): RObjectData;
|
|
260
269
|
/**
|
|
261
|
-
* Resolves a serialized namespace reference
|
|
270
|
+
* Resolves a serialized namespace reference, see {@link R_FindNamespace} for why this does not ask R.
|
|
262
271
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1785-L1796 | R source: R_FindNamespace1}
|
|
263
272
|
*/
|
|
264
273
|
R_FindNamespace1(info: RObjectData): RObjectData;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RDAParser = exports.SerializationFormat = exports.SexpType = exports.SerializationTypeTag = exports.CompressionType = exports.FlowrRDAFile = void 0;
|
|
7
|
+
exports.bunzip = bunzip;
|
|
7
8
|
exports.attributeOf = attributeOf;
|
|
8
9
|
exports.stringsOf = stringsOf;
|
|
9
10
|
exports.namesOf = namesOf;
|
|
@@ -12,8 +13,8 @@ const flowr_file_1 = require("../../../context/flowr-file");
|
|
|
12
13
|
const fs_1 = __importDefault(require("fs"));
|
|
13
14
|
const assert_1 = require("../../../../util/assert");
|
|
14
15
|
const r_fun_tab_1 = require("./r-fun-tab");
|
|
15
|
-
const shell_executor_1 = require("../../../../r-bridge/shell-executor");
|
|
16
16
|
const log_1 = require("../../../../util/log");
|
|
17
|
+
const secure_mode_1 = require("../../../../util/secure-mode");
|
|
17
18
|
const rdaLog = log_1.log.getSubLogger({ name: 'flowr-rda-file' });
|
|
18
19
|
/**
|
|
19
20
|
* This decorates a text file and provides access to its content in the format of an {@link RObjectData}.
|
|
@@ -227,6 +228,21 @@ const SpecialValueSxps = new Map([
|
|
|
227
228
|
[SexpType.MissingArgSxp, { value: RValues.MissingArg, type: SexpType.EnvSxp }],
|
|
228
229
|
[SexpType.BaseNamespaceSxp, { value: RValues.BaseNamespace, type: SexpType.EnvSxp }],
|
|
229
230
|
]);
|
|
231
|
+
/** Decompresses a bzip2 stream block by block, throwing a `RangeError` if it would yield more than `limit` bytes. */
|
|
232
|
+
function bunzip(bzip2, content, limit = Infinity) {
|
|
233
|
+
const bits = bzip2.array(content);
|
|
234
|
+
const size = bzip2.header(bits);
|
|
235
|
+
const chunks = [];
|
|
236
|
+
let total = 0;
|
|
237
|
+
for (let chunk = bzip2.decompress(bits, size, limit - total + 1); chunk !== -1; chunk = bzip2.decompress(bits, size, limit - total + 1)) {
|
|
238
|
+
total += chunk.byteLength;
|
|
239
|
+
if (total > limit) {
|
|
240
|
+
throw new RangeError(`Refusing to decompress more than ${limit} bytes`);
|
|
241
|
+
}
|
|
242
|
+
chunks.push(chunk);
|
|
243
|
+
}
|
|
244
|
+
return Buffer.concat(chunks);
|
|
245
|
+
}
|
|
230
246
|
/**
|
|
231
247
|
* Parser for RDA files.
|
|
232
248
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c | R source: serialize.c}
|
|
@@ -238,7 +254,6 @@ class RDAParser {
|
|
|
238
254
|
buffer;
|
|
239
255
|
currentDepth = 0;
|
|
240
256
|
static INITIAL_DEPTH = 1;
|
|
241
|
-
lastName = undefined;
|
|
242
257
|
offset = 0;
|
|
243
258
|
static R_CODE_SET_MAX = 2 ** 6 - 1;
|
|
244
259
|
RWeakRefs = null;
|
|
@@ -290,27 +305,29 @@ class RDAParser {
|
|
|
290
305
|
/** Decompresses `fileContent` per the {@link detectCompression} result `compressionType`. Throws error for unsupported compression types. */
|
|
291
306
|
decompress(fileContent, compressionType) {
|
|
292
307
|
let buffer;
|
|
308
|
+
// the file belongs to the (possibly hostile) project, so the secure mode bounds what it may decompress to
|
|
309
|
+
const limit = secure_mode_1.SecureMode.decompressionLimit();
|
|
293
310
|
switch (compressionType) {
|
|
294
311
|
case CompressionType.CompGz: {
|
|
295
312
|
// eslint-disable-next-line @typescript-eslint/no-require-imports,@typescript-eslint/no-unsafe-assignment
|
|
296
313
|
const zlib = require('zlib');
|
|
297
314
|
try {
|
|
298
315
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
299
|
-
buffer = zlib.gunzipSync(fileContent);
|
|
316
|
+
buffer = zlib.gunzipSync(fileContent, { maxOutputLength: limit });
|
|
300
317
|
}
|
|
301
|
-
catch {
|
|
318
|
+
catch (e) {
|
|
319
|
+
if (e.code === 'ERR_BUFFER_TOO_LARGE') {
|
|
320
|
+
throw e;
|
|
321
|
+
}
|
|
302
322
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
303
|
-
buffer = zlib.inflateSync(fileContent);
|
|
323
|
+
buffer = zlib.inflateSync(fileContent, { maxOutputLength: limit });
|
|
304
324
|
}
|
|
305
325
|
break;
|
|
306
326
|
}
|
|
307
327
|
case CompressionType.CompBz: {
|
|
308
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
328
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
309
329
|
const bzip2 = require('bzip2');
|
|
310
|
-
|
|
311
|
-
const decompressed = bzip2.simple(bzip2.array(fileContent));
|
|
312
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
313
|
-
buffer = Buffer.from(decompressed);
|
|
330
|
+
buffer = bunzip(bzip2, fileContent, limit);
|
|
314
331
|
break;
|
|
315
332
|
}
|
|
316
333
|
case CompressionType.CompXz:
|
|
@@ -614,26 +631,23 @@ class RDAParser {
|
|
|
614
631
|
const flags = this.assertInteger(this.inInteger());
|
|
615
632
|
return this.readItemRecursive(flags);
|
|
616
633
|
}
|
|
617
|
-
/** Runs `code` in R and answers an `EnvSxp`, `value` set to {@link RValues.GlobalEnv} when the result names it. Shared by {@link R_FindNamespace} and {@link R_FindNamespace1}. */
|
|
618
|
-
runNamespaceLookup(code) {
|
|
619
|
-
const shell = new shell_executor_1.RShellExecutor();
|
|
620
|
-
const result = shell.run(code);
|
|
621
|
-
shell.close();
|
|
622
|
-
return result === '<environment: R_GlobalEnv>' ? { type: SexpType.EnvSxp, value: RValues.GlobalEnv } : { type: SexpType.EnvSxp };
|
|
623
|
-
}
|
|
624
634
|
/**
|
|
625
|
-
* Resolves a namespace reference by name
|
|
635
|
+
* Resolves a namespace reference by name. Simpler variant of {@link R_FindNamespace1}.
|
|
636
|
+
* R would load the namespace (`getNamespace()`), but flowR analyzes R code and data without running it: the name comes
|
|
637
|
+
* from the (untrusted) file, and loading a namespace runs the package's code. Hence, this answers an `EnvSxp` standing
|
|
638
|
+
* for the (unknown) namespace environment without consulting R.
|
|
626
639
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/envir.c#L3795-L3804 | R source: R_FindNamespace}
|
|
627
640
|
*/
|
|
628
641
|
R_FindNamespace(info) {
|
|
629
|
-
|
|
642
|
+
rdaLog.trace(`Not loading namespace ${JSON.stringify(info.value?.name)} of a serialized object`);
|
|
643
|
+
return { type: SexpType.EnvSxp };
|
|
630
644
|
}
|
|
631
645
|
/**
|
|
632
|
-
* Resolves a serialized namespace reference
|
|
646
|
+
* Resolves a serialized namespace reference, see {@link R_FindNamespace} for why this does not ask R.
|
|
633
647
|
* @see {@link https://github.com/wch/r-source/blob/2196e6982a8f49082ee5c3d3521f6dd6596ea72c/src/main/serialize.c#L1785-L1796 | R source: R_FindNamespace1}
|
|
634
648
|
*/
|
|
635
649
|
R_FindNamespace1(info) {
|
|
636
|
-
return this.
|
|
650
|
+
return this.R_FindNamespace({ ...info, value: info.value?.[0] });
|
|
637
651
|
}
|
|
638
652
|
/**
|
|
639
653
|
* Deserializes a single SEXP node, dispatching on its encoded {@link SexpType}.
|
|
@@ -1076,9 +1090,6 @@ class RDAParser {
|
|
|
1076
1090
|
this.currentDepth++;
|
|
1077
1091
|
s.attributes = hasAttr ? [this.shortcut ? this.skipItem() : this.assertRObjectData(this.readItem())] : undefined;
|
|
1078
1092
|
s.tag = hasTag ? this.readItem() : RValues.NilValue;
|
|
1079
|
-
if (hasTag && this.currentDepth == RDAParser.INITIAL_DEPTH && typeof s.tag === 'object') {
|
|
1080
|
-
this.lastName = s.tag.name;
|
|
1081
|
-
}
|
|
1082
1093
|
s.car = this.shortcut ? this.skipItem() : this.readItem();
|
|
1083
1094
|
this.currentDepth--;
|
|
1084
1095
|
if (sFirst === null) {
|
|
@@ -7,17 +7,17 @@ import type { FlowrAnalyzerContext } from '../../../context/flowr-analyzer-conte
|
|
|
7
7
|
* Finally, it provides access to the single cells, and all cells fused together as one R file.
|
|
8
8
|
*/
|
|
9
9
|
export declare class FlowrRMarkdownFile extends FlowrFile {
|
|
10
|
-
private data?;
|
|
11
|
-
private mergedCode?;
|
|
12
10
|
private readonly wrapped;
|
|
13
11
|
private readonly context;
|
|
12
|
+
private data?;
|
|
13
|
+
private mergedCode?;
|
|
14
14
|
private readonly included;
|
|
15
15
|
/**
|
|
16
16
|
* Prefer the static {@link FlowrRMarkdownFile.from} method
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
17
|
+
* @param wrapped - the file to load as R Markdown
|
|
18
|
+
* @param context - the analyzer context the chunks are read with
|
|
19
19
|
*/
|
|
20
|
-
constructor(
|
|
20
|
+
constructor(wrapped: FlowrFileProvider<string>, context: FlowrAnalyzerContext);
|
|
21
21
|
/**
|
|
22
22
|
* Gets the parsed R Markdown information
|
|
23
23
|
*/
|
|
@@ -74,6 +74,8 @@ export declare function globalChunkOptions(frontmatter: object): CodeBlockOption
|
|
|
74
74
|
* @returns Rmd Info
|
|
75
75
|
*/
|
|
76
76
|
export declare function parseRMarkdownFile(raw: string): RmdInfo;
|
|
77
|
+
/** The info string of an R chunk, `{r}` or `{r label, eval = FALSE}`; the `[\s,]` keeps `{rust}` out */
|
|
78
|
+
export declare const RTagRegex: RegExp;
|
|
77
79
|
/**
|
|
78
80
|
* Checks whether a CommonMark node is an R code block
|
|
79
81
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FlowrRMarkdownFile = void 0;
|
|
3
|
+
exports.RTagRegex = exports.FlowrRMarkdownFile = void 0;
|
|
4
4
|
exports.isExecutableCell = isExecutableCell;
|
|
5
5
|
exports.continuesAfterError = continuesAfterError;
|
|
6
6
|
exports.globalChunkOptions = globalChunkOptions;
|
|
@@ -19,20 +19,20 @@ const built_in_source_1 = require("../../../../dataflow/internal/process/functio
|
|
|
19
19
|
* Finally, it provides access to the single cells, and all cells fused together as one R file.
|
|
20
20
|
*/
|
|
21
21
|
class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
|
|
22
|
-
data;
|
|
23
|
-
mergedCode;
|
|
24
22
|
wrapped;
|
|
25
23
|
context;
|
|
24
|
+
data;
|
|
25
|
+
mergedCode;
|
|
26
26
|
included = [];
|
|
27
27
|
/**
|
|
28
28
|
* Prefer the static {@link FlowrRMarkdownFile.from} method
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
29
|
+
* @param wrapped - the file to load as R Markdown
|
|
30
|
+
* @param context - the analyzer context the chunks are read with
|
|
31
31
|
*/
|
|
32
|
-
constructor(
|
|
33
|
-
super(
|
|
34
|
-
this.wrapped =
|
|
35
|
-
this.context =
|
|
32
|
+
constructor(wrapped, context) {
|
|
33
|
+
super(wrapped.path(), wrapped.roles ? [...wrapped.roles, flowr_file_1.FileRole.Source] : [flowr_file_1.FileRole.Source]);
|
|
34
|
+
this.wrapped = wrapped;
|
|
35
|
+
this.context = context;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Gets the parsed R Markdown information
|
|
@@ -68,10 +68,7 @@ class FlowrRMarkdownFile extends flowr_file_1.FlowrFile {
|
|
|
68
68
|
(0, assert_1.guard)(this.data !== undefined);
|
|
69
69
|
for (const block of this.data.blocks) {
|
|
70
70
|
const childOpt = block.options.get('child');
|
|
71
|
-
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
const childPath = (0, built_in_source_1.findSource)(this.context.config.solver.resolveSource, childOpt, {
|
|
71
|
+
const childPath = childOpt === undefined ? undefined : (0, built_in_source_1.findSource)(this.context.config.solver.resolveSource, childOpt, {
|
|
75
72
|
ctx: this.context,
|
|
76
73
|
referenceChain: [this.path()]
|
|
77
74
|
});
|
|
@@ -138,8 +135,12 @@ function wrapErrorTolerant(code) {
|
|
|
138
135
|
*/
|
|
139
136
|
function globalChunkOptions(frontmatter) {
|
|
140
137
|
const knitr = frontmatter.knitr;
|
|
138
|
+
return scalarOptions([frontmatter.execute, knitr?.opts_chunk]);
|
|
139
|
+
}
|
|
140
|
+
/** The scalar entries of the given yaml objects as options, later ones overriding earlier ones. */
|
|
141
|
+
function scalarOptions(sources) {
|
|
141
142
|
const options = new Map();
|
|
142
|
-
for (const source of
|
|
143
|
+
for (const source of sources) {
|
|
143
144
|
if (typeof source !== 'object' || source === null) {
|
|
144
145
|
continue;
|
|
145
146
|
}
|
|
@@ -183,20 +184,14 @@ function parseFrontmatter(raw) {
|
|
|
183
184
|
* @returns Rmd Info
|
|
184
185
|
*/
|
|
185
186
|
function parseRMarkdownFile(raw) {
|
|
186
|
-
// Read and Parse Markdown
|
|
187
|
-
const parser = new commonmark_1.Parser();
|
|
188
|
-
const ast = parser.parse(raw);
|
|
189
|
-
// Parse Frontmatter
|
|
190
187
|
let frontmatter;
|
|
191
188
|
try {
|
|
192
189
|
frontmatter = parseFrontmatter(raw);
|
|
193
190
|
}
|
|
194
191
|
catch (e) {
|
|
195
192
|
log_1.log.warn(`Failed to parse frontmatter of Rmd file, ignoring it. Error was: ${JSON.stringify(e)}`);
|
|
196
|
-
frontmatter = undefined;
|
|
197
193
|
}
|
|
198
|
-
|
|
199
|
-
const walker = ast.walker();
|
|
194
|
+
const walker = new commonmark_1.Parser().parse(raw).walker();
|
|
200
195
|
const blocks = [];
|
|
201
196
|
let e;
|
|
202
197
|
while ((e = walker.next())) {
|
|
@@ -206,48 +201,42 @@ function parseRMarkdownFile(raw) {
|
|
|
206
201
|
}
|
|
207
202
|
const options = parseCodeBlockOptions(node.info, node.literal);
|
|
208
203
|
const engineOpt = options.get('engine');
|
|
209
|
-
if (engineOpt
|
|
210
|
-
|
|
204
|
+
if (engineOpt === undefined || engineOpt.trim().toLowerCase() === 'r') {
|
|
205
|
+
blocks.push({
|
|
206
|
+
code: node.literal,
|
|
207
|
+
options,
|
|
208
|
+
header: node.info,
|
|
209
|
+
startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
|
|
210
|
+
});
|
|
211
211
|
}
|
|
212
|
-
blocks.push({
|
|
213
|
-
code: node.literal,
|
|
214
|
-
options: options,
|
|
215
|
-
header: node.info,
|
|
216
|
-
startpos: { line: node.sourcepos[0][0] + 1, col: 0 }
|
|
217
|
-
});
|
|
218
212
|
}
|
|
219
213
|
blocks.push(...parseIncludeShortcodes(raw));
|
|
220
214
|
blocks.sort((a, b) => a.startpos.line - b.startpos.line);
|
|
221
215
|
return {
|
|
222
|
-
blocks
|
|
216
|
+
blocks,
|
|
223
217
|
options: typeof frontmatter === 'object' && frontmatter !== null ? frontmatter : {}
|
|
224
218
|
};
|
|
225
219
|
}
|
|
226
220
|
const IncludeShortcodeRegex = /{{<\s*include\s+["']?(.+?)["']?\s*>}}/;
|
|
227
221
|
/** Collects quarto's `{{< include other.qmd >}}` as blocks carrying a `child`, resolved like knitr's option */
|
|
228
222
|
function parseIncludeShortcodes(raw) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const match = IncludeShortcodeRegex.exec(lines[i]);
|
|
233
|
-
if (match) {
|
|
234
|
-
blocks.push({
|
|
223
|
+
return raw.split(LineRegex).flatMap((line, i) => {
|
|
224
|
+
const match = IncludeShortcodeRegex.exec(line);
|
|
225
|
+
return match ? [{
|
|
235
226
|
code: '',
|
|
236
227
|
options: new Map([['child', match[1]]]),
|
|
237
228
|
header: '',
|
|
238
229
|
startpos: { line: i + 1, col: 0 }
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
}
|
|
242
|
-
return blocks;
|
|
230
|
+
}] : [];
|
|
231
|
+
});
|
|
243
232
|
}
|
|
244
|
-
|
|
245
|
-
|
|
233
|
+
/** The info string of an R chunk, `{r}` or `{r label, eval = FALSE}`; the `[\s,]` keeps `{rust}` out */
|
|
234
|
+
exports.RTagRegex = /{[rR](?:[\s,][^}]*)?}/;
|
|
246
235
|
/**
|
|
247
236
|
* Checks whether a CommonMark node is an R code block
|
|
248
237
|
*/
|
|
249
238
|
function isRCodeBlock(node) {
|
|
250
|
-
return node.type === 'code_block' && node.literal !== null && node.info !== null && RTagRegex.test(node.info);
|
|
239
|
+
return node.type === 'code_block' && node.literal !== null && node.info !== null && exports.RTagRegex.test(node.info);
|
|
251
240
|
}
|
|
252
241
|
const LineRegex = /\r\n|\r|\n/;
|
|
253
242
|
function countNewlines(str) {
|
|
@@ -269,7 +258,6 @@ function restoreBlocksWithoutMd(blocks, totalLines) {
|
|
|
269
258
|
output += block.code;
|
|
270
259
|
line += countNewlines(block.code);
|
|
271
260
|
}
|
|
272
|
-
// Add remainder of file
|
|
273
261
|
goToLine(totalLines + 1);
|
|
274
262
|
return output;
|
|
275
263
|
}
|
|
@@ -289,11 +277,7 @@ function parseCodeBlockOptions(header, content) {
|
|
|
289
277
|
// keep the indentation, yaml block scalars rely on it
|
|
290
278
|
cellLines.push(line.trim().slice(2).replace(/^ /, ''));
|
|
291
279
|
}
|
|
292
|
-
|
|
293
|
-
for (const [key, value] of parseCellOptions(cellLines)) {
|
|
294
|
-
options.set(key, value);
|
|
295
|
-
}
|
|
296
|
-
return options;
|
|
280
|
+
return new Map([...parseOptionString(headerOpts), ...parseCellOptions(cellLines)]);
|
|
297
281
|
}
|
|
298
282
|
/** Parses knitr's `key=value` option syntax as used in the chunk header */
|
|
299
283
|
function parseOptionString(opts) {
|
|
@@ -314,13 +298,7 @@ function parseCellOptions(lines) {
|
|
|
314
298
|
const parsed = parseFrontmatter(`---\n${lines.join('\n')}\n---\n`);
|
|
315
299
|
// a bare scalar is knitr's `key=value` syntax, not yaml
|
|
316
300
|
if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed) && Object.keys(parsed).length > 0) {
|
|
317
|
-
|
|
318
|
-
for (const [key, value] of Object.entries(parsed)) {
|
|
319
|
-
if (value !== null && typeof value !== 'object') {
|
|
320
|
-
options.set(key, String(value));
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
return options;
|
|
301
|
+
return scalarOptions([parsed]);
|
|
324
302
|
}
|
|
325
303
|
}
|
|
326
304
|
catch (e) {
|
package/project/plugins/package-version-plugins/flowr-analyzer-package-versions-sigdb-plugin.js
CHANGED
|
@@ -55,24 +55,18 @@ const r_version_1 = require("../../../util/r-version");
|
|
|
55
55
|
const r_base_packages_1 = require("../../../util/r-base-packages");
|
|
56
56
|
const defaultmap_1 = require("../../../util/collections/defaultmap");
|
|
57
57
|
const arrays_1 = require("../../../util/collections/arrays");
|
|
58
|
+
const secure_mode_1 = require("../../../util/secure-mode");
|
|
58
59
|
/** the plugin's instance name (pass to `unregisterPlugins` to disable the default sigdb resolver) */
|
|
59
60
|
exports.SigDbPluginName = 'flowr-analyzer-package-versions-sigdb-plugin';
|
|
60
|
-
/**
|
|
61
|
-
|
|
62
|
-
switch (ext) {
|
|
63
|
-
case '.zst': return 'zstd';
|
|
64
|
-
case '.br': return 'brotli';
|
|
65
|
-
case '.gz': return 'gzip';
|
|
66
|
-
default: return 'plain';
|
|
67
|
-
}
|
|
68
|
-
}
|
|
61
|
+
/** a resolved source's compressed extension as a codec name for display, a file without one is `plain` */
|
|
62
|
+
const CodecNames = { '.zst': 'zstd', '.br': 'brotli', '.gz': 'gzip' };
|
|
69
63
|
/** the codec name of a manifest's resolved shard + dict sources, or `mixed` when they do not all agree */
|
|
70
64
|
function manifestFormat(set) {
|
|
71
65
|
const paths = [
|
|
72
66
|
...set.manifest.shards.map(s => s.path),
|
|
73
67
|
...(set.manifest.dicts?.map(d => d.path) ?? [])
|
|
74
68
|
];
|
|
75
|
-
const codecs = (0, arrays_1.uniqueArray)(paths.map(p =>
|
|
69
|
+
const codecs = (0, arrays_1.uniqueArray)(paths.map(p => CodecNames[(0, codec_1.compressedExtOf)((0, decompress_1.resolveSource)(set.baseDir, p)) ?? ''] ?? 'plain'));
|
|
76
70
|
return codecs.length === 1 ? codecs[0] : 'mixed';
|
|
77
71
|
}
|
|
78
72
|
/** describe one loaded source for `:version` / diagnostics: a single bundle, a sharded set, or an in-memory source */
|
|
@@ -178,7 +172,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
178
172
|
if (ctx.config.solver.sigdb.warmInBackground) {
|
|
179
173
|
this.startBackgroundWarm();
|
|
180
174
|
}
|
|
181
|
-
if (ctx.config.solver.sigdb.autoSync) {
|
|
175
|
+
if (ctx.config.solver.sigdb.autoSync && !secure_mode_1.SecureMode.isEnabled()) {
|
|
182
176
|
this.startBackgroundSync(ctx);
|
|
183
177
|
}
|
|
184
178
|
if (ctx.config.solver.sigdb.versionSelection === config_1.VersionSelection.System) {
|
|
@@ -285,16 +279,7 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
285
279
|
/* the historical bundle is not asked: a name is hinted so a `library()` can be added for it, and a package
|
|
286
280
|
only that bundle carries is one nothing can attach today */
|
|
287
281
|
const sources = this.loadSources().filter(s => describeLoadedDatabase(s).scope !== 'history');
|
|
288
|
-
const
|
|
289
|
-
const owners = [];
|
|
290
|
-
for (const src of sources) {
|
|
291
|
-
for (const pkg of exportOwners(src, name)) {
|
|
292
|
-
if (!seen.has(pkg) && !this.isSelfPackage(pkg)) {
|
|
293
|
-
seen.add(pkg);
|
|
294
|
-
owners.push(pkg);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
282
|
+
const owners = (0, arrays_1.uniqueArray)(sources.flatMap(src => exportOwners(src, name))).filter(pkg => !this.isSelfPackage(pkg));
|
|
298
283
|
// each source's list is already sorted; a merge of several needs one more pass to be globally ordered
|
|
299
284
|
if (owners.length > 1 && sources.length > 1) {
|
|
300
285
|
/* the comparator runs O(n log n) times, so each package is counted once up front */
|
|
@@ -395,12 +380,8 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
395
380
|
return undefined;
|
|
396
381
|
}
|
|
397
382
|
const target = this.analyzerCtx?.resolvedRVersion ?? (0, config_1.resolveAssumedRVersion)(undefined);
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
if (r_version_1.RVersion.compare(v.str, target) <= 0) {
|
|
401
|
-
chosen = v;
|
|
402
|
-
}
|
|
403
|
-
}
|
|
383
|
+
// versions are ascending; keep the newest core release <= target
|
|
384
|
+
let chosen = versions.findLast(v => r_version_1.RVersion.compare(v.str, target) <= 0);
|
|
404
385
|
if (chosen === undefined) {
|
|
405
386
|
// the assumed R version is older than the earliest recorded core release: fall back to the closest one
|
|
406
387
|
chosen = versions[0];
|
|
@@ -481,24 +462,17 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
481
462
|
if (info && (range === undefined || r_version_1.RRange.satisfies(info.version, range))) {
|
|
482
463
|
return info;
|
|
483
464
|
}
|
|
484
|
-
if (range
|
|
485
|
-
|
|
486
|
-
for (let i = versions.length - 1; i >= 0; i--) {
|
|
487
|
-
if (r_version_1.RRange.satisfies(versions[i], range)) {
|
|
488
|
-
return src.lookup(name, versions[i]);
|
|
489
|
-
}
|
|
490
|
-
}
|
|
465
|
+
if (range === undefined) {
|
|
466
|
+
return undefined;
|
|
491
467
|
}
|
|
492
|
-
|
|
468
|
+
const satisfying = this.availableVersions(src, name).findLast(version => r_version_1.RRange.satisfies(version, range));
|
|
469
|
+
return satisfying === undefined ? undefined : src.lookup(name, satisfying);
|
|
493
470
|
}
|
|
494
471
|
/** Lowest stored version satisfying the constraint (using the store's actual R-form version strings). */
|
|
495
472
|
oldestSatisfying(src, name, range) {
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
return undefined;
|
|
473
|
+
// versions are ascending, so the first satisfying one is the oldest
|
|
474
|
+
const satisfying = this.availableVersions(src, name).find(version => range === undefined || r_version_1.RRange.satisfies(version, range));
|
|
475
|
+
return satisfying === undefined ? undefined : src.lookup(name, satisfying);
|
|
502
476
|
}
|
|
503
477
|
/**
|
|
504
478
|
* The versions the source can answer for a package (dated releases, base-R core releases, and the latest),
|
|
@@ -509,7 +483,9 @@ class FlowrAnalyzerPackageVersionsSigDbPlugin extends flowr_analyzer_package_ver
|
|
|
509
483
|
}
|
|
510
484
|
/** build the resolved {@link Package} (namespace + version) from a source's export view */
|
|
511
485
|
toResolvedPackage(name, info) {
|
|
512
|
-
|
|
486
|
+
/* what the configuration states for the package is part of its interface, even where the database misses it */
|
|
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)]);
|
|
513
489
|
const namespaceInfo = {
|
|
514
490
|
exportedSymbols: exported,
|
|
515
491
|
exportedFunctions: [],
|
|
@@ -27,6 +27,7 @@ const schema_1 = require("./schema");
|
|
|
27
27
|
const index_format_1 = require("./index-format");
|
|
28
28
|
const hash_1 = require("../../util/hash");
|
|
29
29
|
const codec_1 = require("./codec");
|
|
30
|
+
const files_1 = require("../../util/files");
|
|
30
31
|
/** whether a bundle path is a compressed (`.br`/`.zst`/`.gz`) source that must be decompressed to be seekable */
|
|
31
32
|
const isCompressed = (f) => (0, codec_1.isCompressedExt)(f);
|
|
32
33
|
exports.isCompressed = isCompressed;
|
|
@@ -117,7 +118,8 @@ async function readHeaderOf(source) {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
function cachePaths(hash, cacheDir) {
|
|
120
|
-
|
|
121
|
+
// the hash may come from the header of a project-supplied bundle
|
|
122
|
+
const plain = (0, files_1.joinUntrustedSegment)(sigDbCacheDir(cacheDir), `sigdb-${hash}${schema_1.SigDbExt}`);
|
|
121
123
|
return { plain, idx: `${plain}.idx` };
|
|
122
124
|
}
|
|
123
125
|
/** whether a compressed source with the given content hash has already been unpacked into its decompressed cache */
|
|
@@ -18,6 +18,8 @@ const crypto_1 = __importDefault(require("crypto"));
|
|
|
18
18
|
const decompress_1 = require("./decompress");
|
|
19
19
|
const codec_1 = require("./codec");
|
|
20
20
|
const version_1 = require("../../util/version");
|
|
21
|
+
const files_1 = require("../../util/files");
|
|
22
|
+
const secure_mode_1 = require("../../util/secure-mode");
|
|
21
23
|
/** the GitHub `owner/repo` the full-history bundle is published to (see `scripts/publish-sigdb.mjs`) */
|
|
22
24
|
const DefaultRepo = 'flowr-analysis/flowr';
|
|
23
25
|
/** GitHub request headers; the token (used only for the API's rate limit and private repos) is attached only when `withAuth` */
|
|
@@ -39,6 +41,7 @@ class HttpError extends Error {
|
|
|
39
41
|
}
|
|
40
42
|
/** GET following redirects (GitHub asset URLs redirect to a storage host); resolves the final response for streaming */
|
|
41
43
|
function httpGet(url, accept, redirects = 5, withAuth = true) {
|
|
44
|
+
secure_mode_1.SecureMode.guard('network access', url);
|
|
42
45
|
return new Promise((resolve, reject) => {
|
|
43
46
|
const req = (url.startsWith('http:') ? http_1.default : https_1.default).get(url, { headers: ghHeaders(accept, withAuth) }, res => {
|
|
44
47
|
const status = res.statusCode ?? 0;
|
|
@@ -143,9 +146,8 @@ function findRemotePointer() {
|
|
|
143
146
|
return fs_1.default.existsSync(override) ? override : undefined;
|
|
144
147
|
}
|
|
145
148
|
const candidates = [
|
|
146
|
-
|
|
147
|
-
path_1.default.join(
|
|
148
|
-
path_1.default.join(process.cwd(), 'dist/src/data/sigdb', exports.SigDbRemoteFileName),
|
|
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),
|
|
149
151
|
];
|
|
150
152
|
return candidates.find(p => {
|
|
151
153
|
try {
|
|
@@ -238,10 +240,11 @@ function isCached(dest, file) {
|
|
|
238
240
|
async function syncFiles(tag, repo, planned, opts) {
|
|
239
241
|
const progress = opts.onProgress ?? (() => { });
|
|
240
242
|
const start = Date.now();
|
|
241
|
-
|
|
243
|
+
// tag and file names come from the (remote) pointer and release listing
|
|
244
|
+
const dir = (0, files_1.joinUntrustedSegment)(path_1.default.join((0, decompress_1.sigDbCacheDir)(), 'bundles'), tag);
|
|
242
245
|
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
243
246
|
const ordered = [...planned.filter(p => !(0, exports.isManifestFile)(p.name)), ...planned.filter(p => (0, exports.isManifestFile)(p.name))];
|
|
244
|
-
const missing = ordered.filter(p => opts.force || !isCached(
|
|
247
|
+
const missing = ordered.filter(p => opts.force || !isCached((0, files_1.joinUntrustedSegment)(dir, p.name), p));
|
|
245
248
|
const toFetch = missing.reduce((sum, p) => sum + (p.expected?.bytes ?? p.size ?? 0), 0);
|
|
246
249
|
progress(`signature database ${tag} from ${repo}: ${ordered.length} file(s), ${ordered.length - missing.length} up to date, ${missing.length} to fetch (${mb(toFetch)}) into ${dir}`);
|
|
247
250
|
const files = [];
|
|
@@ -249,7 +252,7 @@ async function syncFiles(tag, repo, planned, opts) {
|
|
|
249
252
|
const failed = [];
|
|
250
253
|
let bytes = 0;
|
|
251
254
|
for (const file of ordered) {
|
|
252
|
-
const dest =
|
|
255
|
+
const dest = (0, files_1.joinUntrustedSegment)(dir, file.name);
|
|
253
256
|
if (!missing.includes(file)) {
|
|
254
257
|
files.push(dest);
|
|
255
258
|
continue;
|
|
@@ -18,13 +18,12 @@ function filterLineParser(type) {
|
|
|
18
18
|
function singleCriterionLineParser(type, label, extra) {
|
|
19
19
|
return function (output, line, _config) {
|
|
20
20
|
const criterion = (0, slice_query_parser_1.sliceCriteriaParser)(line[0]);
|
|
21
|
-
const fields = extra?.(line);
|
|
22
21
|
if (!criterion || criterion.length !== 1) {
|
|
23
22
|
output.stderr(output.formatter.format(`Invalid ${label} query format, a single slicing criterion must be given in the form "(criterion1)"`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
|
|
24
23
|
return { query: [] };
|
|
25
24
|
}
|
|
26
25
|
return {
|
|
27
|
-
query: [{ type, criterion: criterion[0], ...
|
|
26
|
+
query: [{ type, criterion: criterion[0], ...extra?.(line) }],
|
|
28
27
|
rCode: (0, slice_query_parser_1.queryLineCode)(line)
|
|
29
28
|
};
|
|
30
29
|
};
|
|
@@ -45,7 +45,7 @@ function absintQueryCompleter(line, startingNewArg, _config) {
|
|
|
45
45
|
return { completions: [] };
|
|
46
46
|
}
|
|
47
47
|
function absintQueryLineParser(output, line, _config) {
|
|
48
|
-
const type = line[0].toLowerCase();
|
|
48
|
+
const type = (line[0] ?? '').toLowerCase();
|
|
49
49
|
if (!record_1.Record.has(exports.AbsintQueryInferences, type)) {
|
|
50
50
|
output.stderr(output.formatter.format(`Invalid inference type "${type}", must be one of ${record_1.Record.keys(exports.AbsintQueryInferences).map(type => `"${type}"`).join(', ')}`, { color: 1 /* Colors.Red */, effect: ansi_1.ColorEffect.Foreground, style: 1 /* FontStyles.Bold */ }));
|
|
51
51
|
return { query: [] };
|
|
@@ -4,6 +4,7 @@ exports.executeConfigQuery = executeConfigQuery;
|
|
|
4
4
|
const log_1 = require("../../../util/log");
|
|
5
5
|
const config_query_format_1 = require("./config-query-format");
|
|
6
6
|
const assert_1 = require("../../../util/assert");
|
|
7
|
+
const config_1 = require("../../../config");
|
|
7
8
|
/**
|
|
8
9
|
* Executes the given configuration queries using the provided analyzer.
|
|
9
10
|
*/
|
|
@@ -17,12 +18,18 @@ function executeConfigQuery({ analyzer }, queries) {
|
|
|
17
18
|
}
|
|
18
19
|
// validate here too (not only in the repl parser), so a programmatic / JSON-API update cannot merge an unknown
|
|
19
20
|
// key or a wrong-typed value; the update then lands via `updateConfig`, which invalidates the analysis cache
|
|
20
|
-
for (const
|
|
21
|
-
const err = (0, config_query_format_1.validateConfigUpdate)(
|
|
21
|
+
for (const given of updates) {
|
|
22
|
+
const err = (0, config_query_format_1.validateConfigUpdate)(given);
|
|
22
23
|
if (err !== undefined) {
|
|
23
24
|
log_1.log.warn(`ignoring invalid config update: ${err}`);
|
|
24
25
|
continue;
|
|
25
26
|
}
|
|
27
|
+
// queries may come from clients of the server, so they must not choose what flowR executes, loads, or downloads
|
|
28
|
+
const update = structuredClone(given);
|
|
29
|
+
const dropped = config_1.FlowrConfig.dropUntrusted(update);
|
|
30
|
+
if (dropped.length > 0) {
|
|
31
|
+
log_1.log.warn(`ignoring untrusted options in config update: ${dropped.join(', ')}`);
|
|
32
|
+
}
|
|
26
33
|
analyzer.updateConfig(update);
|
|
27
34
|
}
|
|
28
35
|
const specialization = analyzer.inspectContext().configSpecialization();
|
|
@@ -10,12 +10,12 @@ async function executeDataflowQuery({ analyzer }, queries) {
|
|
|
10
10
|
log_1.log.warn('Dataflow query expects only up to one query, but got', queries.length);
|
|
11
11
|
}
|
|
12
12
|
const startTime = Date.now();
|
|
13
|
-
const graph =
|
|
13
|
+
const { graph } = await analyzer.dataflow();
|
|
14
14
|
return {
|
|
15
15
|
'.meta': {
|
|
16
16
|
timing: Date.now() - startTime
|
|
17
17
|
},
|
|
18
|
-
graph
|
|
18
|
+
graph: queries.every(q => q.environments === false) ? graph.withoutEnvironments() : graph
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=dataflow-query-executor.js.map
|