@procedures/archive 0.6.0 → 0.8.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAoI5B;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,eAAkG,CAAC;eAEhH,aAAa;AAE5B,8CAA8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,eAAe,CAevF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,GAAE,iBAAsC,EAAE,OAAO,GAAE,oBAAyB,GAAG,IAAI,CAEpI"}
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,oBAAoB,CAAC;AAyI5B;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,eAAkG,CAAC;eAEhH,aAAa;AAE5B,8CAA8C;AAC9C,MAAM,WAAW,oBAAoB;IACnC,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,8DAA8D;IAC9D,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,GAAE,oBAAyB,GAAG,eAAe,CAevF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,GAAE,iBAAsC,EAAE,OAAO,GAAE,oBAAyB,GAAG,IAAI,CAEpI"}
package/dist/module.js CHANGED
@@ -83,6 +83,8 @@ function archiveProcedures(settings) {
83
83
  shorts: { source: "s", format: "f" },
84
84
  output: "json",
85
85
  effects: READS_WRITES_FS,
86
+ // A root of the host examines the archive, the source, the base folder and each file
87
+ fsRoot: { cwd: "cwd", paths: ["output", "source"], names: ["files"] },
86
88
  })
87
89
  .handler(async (input) => archiveCreate(input, settings))
88
90
  .build();
@@ -97,6 +99,8 @@ function archiveProcedures(settings) {
97
99
  shorts: { format: "f" },
98
100
  output: "json",
99
101
  effects: READS_WRITES_FS,
102
+ // The checks of the entries keep the extract in the target
103
+ fsRoot: { paths: ["archive", "target"] },
100
104
  })
101
105
  .handler(async (input) => archiveExtract(input, settings))
102
106
  .build();
@@ -111,6 +115,7 @@ function archiveProcedures(settings) {
111
115
  shorts: { format: "f" },
112
116
  output: "json",
113
117
  effects: READS_FS,
118
+ fsRoot: { paths: ["archive"] },
114
119
  })
115
120
  .handler(async (input) => archiveList(input, settings))
116
121
  .build();
@@ -1 +1 @@
1
- {"version":3,"file":"module.js","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,UAAU,GAKX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAA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the archive procedures: one folder that confines each path (roadmap R33).
3
3
  *
4
- * The rules are the rules of `root.ts` of `@procedures/fs` (`createFsModule({ root })`):
4
+ * The rules are the rules of `@procedures/fs/root`, the rules of `createFsModule({ root })`:
5
5
  * - A relative path starts at the root, not at the working folder of the process.
6
6
  * - A path outside the root gives `FORBIDDEN` with the reason `outside-root`. This includes a
7
7
  * path that goes up with `..`, an absolute path outside the root, a path on another drive, and
@@ -10,39 +10,14 @@
10
10
  * uses the real path of the nearest existing ancestor. So a symlinked parent folder cannot
11
11
  * lead a write or a `mkdir` out of the root.
12
12
  *
13
- * On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same.
13
+ * On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same. This
14
+ * file adds only `placesOf()`, the paths of one call of an archive procedure.
14
15
  */
15
- import { InvocationError, type ProcedurePath } from "@procedures/client";
16
- /** The reason of the `FORBIDDEN` error for a path outside the root. */
17
- export declare const OUTSIDE_ROOT = "outside-root";
18
- /**
19
- * This function tells if `path` is `folder` or a path in `folder`. The two paths are absolute.
20
- * On Windows, the case of the letters is not significant.
21
- */
22
- export declare function isInside(folder: string, path: string): boolean;
23
- /**
24
- * This function gives the real path of an absolute path. For a path that does not exist, it
25
- * gives the real path of the nearest existing ancestor and the rest of the path. A symlink whose
26
- * target does not exist leads to its target, because a write follows it.
27
- */
28
- export declare function realPathOf(path: string, links?: number): Promise<string>;
29
- /** A root: the absolute path that the host gave, and its real path. */
30
- export interface ResolvedRoot {
31
- folder: string;
32
- real: string;
33
- }
34
- /** This function gives the absolute path and the real path of a root. The root must exist. */
16
+ import type { ProcedurePath } from "@procedures/client";
17
+ import { type ResolvedRoot } from "@procedures/fs/root";
18
+ export { OUTSIDE_ROOT, inRoot, isInside, isOutsideRoot, outsideRoot, realPathIsInside, realPathOf, type ResolvedRoot } from "@procedures/fs/root";
19
+ /** This function gives the absolute path and the real path of a root of the archive procedures. The root must exist. */
35
20
  export declare function resolveRoot(root: string): Promise<ResolvedRoot>;
36
- /** The `FORBIDDEN` error for a path outside the root. */
37
- export declare function outsideRoot(procedure: ProcedurePath, message: string): InvocationError;
38
- /** True for the `FORBIDDEN` error of a path outside the root. */
39
- export declare function isOutsideRoot(error: unknown): boolean;
40
- /**
41
- * This function gives the absolute path of `path` in the root. A relative path starts at the
42
- * root. The real path decides: a path whose real path is outside the real path of the root gives
43
- * `FORBIDDEN` with the reason `outside-root`.
44
- */
45
- export declare function inRoot(root: ResolvedRoot, path: string, procedure: ProcedurePath): Promise<string>;
46
21
  /** The paths of one call of a procedure. */
47
22
  export interface Places {
48
23
  /** The root of the call, or undefined for a module without a root. */
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,eAAe,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEzE,uEAAuE;AACvE,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAK3C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAG9D;AAoBD;;;;GAIG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAwBzE;AAED,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,8FAA8F;AAC9F,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAUrE;AAED,yDAAyD;AACzD,wBAAgB,WAAW,CAAC,SAAS,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,GAAG,eAAe,CAEtF;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAErD;AAED;;;;GAIG;AAC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CAAC,CAIlG"}
package/dist/root.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The root of the archive procedures: one folder that confines each path (roadmap R33).
3
3
  *
4
- * The rules are the rules of `root.ts` of `@procedures/fs` (`createFsModule({ root })`):
4
+ * The rules are the rules of `@procedures/fs/root`, the rules of `createFsModule({ root })`:
5
5
  * - A relative path starts at the root, not at the working folder of the process.
6
6
  * - A path outside the root gives `FORBIDDEN` with the reason `outside-root`. This includes a
7
7
  * path that goes up with `..`, an absolute path outside the root, a path on another drive, and
@@ -10,113 +10,15 @@
10
10
  * uses the real path of the nearest existing ancestor. So a symlinked parent folder cannot
11
11
  * lead a write or a `mkdir` out of the root.
12
12
  *
13
- * On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same.
13
+ * On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same. This
14
+ * file adds only `placesOf()`, the paths of one call of an archive procedure.
14
15
  */
15
- import { readlink, realpath } from "node:fs/promises";
16
- import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
17
- import { InvocationError } from "@procedures/client";
18
- /** The reason of the `FORBIDDEN` error for a path outside the root. */
19
- export const OUTSIDE_ROOT = "outside-root";
20
- /** The maximum number of symlinks that one check follows. After it, the check fails with `ELOOP`. */
21
- const MAX_LINKS = 40;
22
- /**
23
- * This function tells if `path` is `folder` or a path in `folder`. The two paths are absolute.
24
- * On Windows, the case of the letters is not significant.
25
- */
26
- export function isInside(folder, path) {
27
- const rel = relative(folder, path);
28
- return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`));
29
- }
30
- /** True for the error of a path that does not exist. */
31
- function isMissing(error) {
32
- const code = error.code;
33
- return code === "ENOENT" || code === "ENOTDIR";
34
- }
35
- /** The target of a symlink, or undefined when the path is not a symlink or does not exist. */
36
- async function linkTarget(path) {
37
- try {
38
- return await readlink(path);
39
- }
40
- catch (error) {
41
- // EINVAL: the path is not a symlink
42
- const code = error.code;
43
- if (code === "EINVAL" || isMissing(error))
44
- return undefined;
45
- throw error;
46
- }
47
- }
48
- /**
49
- * This function gives the real path of an absolute path. For a path that does not exist, it
50
- * gives the real path of the nearest existing ancestor and the rest of the path. A symlink whose
51
- * target does not exist leads to its target, because a write follows it.
52
- */
53
- export async function realPathOf(path, links = 0) {
54
- const rest = [];
55
- let current = path;
56
- for (;;) {
57
- try {
58
- return join(await realpath(current), ...rest);
59
- }
60
- catch (error) {
61
- if (!isMissing(error))
62
- throw error;
63
- }
64
- const target = await linkTarget(current);
65
- if (target !== undefined) {
66
- if (links >= MAX_LINKS) {
67
- const loop = new Error(`Too many symlinks in the path ${path}`);
68
- loop.code = "ELOOP";
69
- throw loop;
70
- }
71
- return join(await realPathOf(resolve(dirname(current), target), links + 1), ...rest);
72
- }
73
- const parent = dirname(current);
74
- // No ancestor exists, for example a drive that is not there
75
- if (parent === current)
76
- return join(current, ...rest);
77
- rest.unshift(basename(current));
78
- current = parent;
79
- }
80
- }
81
- /** This function gives the absolute path and the real path of a root. The root must exist. */
82
- export async function resolveRoot(root) {
83
- const folder = resolve(root);
84
- try {
85
- return { folder, real: await realpath(folder) };
86
- }
87
- catch (error) {
88
- if (!isMissing(error))
89
- throw error;
90
- const missing = new Error(`The root of the archive procedures does not exist: ${folder}`);
91
- missing.code = "ENOENT";
92
- throw missing;
93
- }
94
- }
95
- /** The `FORBIDDEN` error for a path outside the root. */
96
- export function outsideRoot(procedure, message) {
97
- return new InvocationError("FORBIDDEN", `${procedure.join(".")}: ${message}`, procedure, OUTSIDE_ROOT);
98
- }
99
- /** True for the `FORBIDDEN` error of a path outside the root. */
100
- export function isOutsideRoot(error) {
101
- return error instanceof InvocationError && error.code === "FORBIDDEN" && error.reason === OUTSIDE_ROOT;
102
- }
103
- /**
104
- * This function gives the absolute path of `path` in the root. A relative path starts at the
105
- * root. The real path decides: a path whose real path is outside the real path of the root gives
106
- * `FORBIDDEN` with the reason `outside-root`.
107
- */
108
- export async function inRoot(root, path, procedure) {
109
- const absolute = resolve(root.folder, path);
110
- const real = await realPathOf(absolute);
111
- // A path counts as inside by its given form or by its real form. On Windows, the two forms of a
112
- // folder can differ by more than the links: a short 8.3 name (RUNNER~1) has a long real name.
113
- if (!isInside(root.folder, absolute) && !isInside(root.real, absolute) && !isInside(root.real, real)) {
114
- throw outsideRoot(procedure, `the path ${JSON.stringify(path)} is outside the root ${root.folder}`);
115
- }
116
- if (!isInside(root.real, real)) {
117
- throw outsideRoot(procedure, `the path ${JSON.stringify(path)} leads out of the root ${root.folder} through a symlink`);
118
- }
119
- return absolute;
16
+ import { resolve } from "node:path";
17
+ import { inRoot, resolveRoot as resolveFsRoot } from "@procedures/fs/root";
18
+ export { OUTSIDE_ROOT, inRoot, isInside, isOutsideRoot, outsideRoot, realPathIsInside, realPathOf } from "@procedures/fs/root";
19
+ /** This function gives the absolute path and the real path of a root of the archive procedures. The root must exist. */
20
+ export function resolveRoot(root) {
21
+ return resolveFsRoot(root, "the archive procedures");
120
22
  }
121
23
  /** This function gives the paths of one call. With a root, the root must exist when the call starts. */
122
24
  export async function placesOf(root, procedure) {
package/dist/root.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"root.js","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxF,OAAO,EAAE,eAAe,EAAsB,MAAM,oBAAoB,CAAC;AAEzE,uEAAuE;AACvE,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAE3C,qGAAqG;AACrG,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAc,EAAE,IAAY;IACnD,MAAM,GAAG,G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AC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;AAChF,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@procedures/archive",
4
- "version": "0.6.0",
4
+ "version": "0.8.0",
5
5
  "description": "Archives as procedures: make, list and extract tar.gz and zip, with a check of each path against zip slip and links out of the target.",
6
6
  "keywords": [
7
7
  "procedures",
@@ -62,7 +62,8 @@
62
62
  "procedures": "./dist/register.js"
63
63
  },
64
64
  "dependencies": {
65
- "@procedures/client": "0.6.0",
65
+ "@procedures/client": "0.8.0",
66
+ "@procedures/fs": "0.8.0",
66
67
  "tar": "^7.5.0",
67
68
  "zod": "^4.6.5"
68
69
  },
package/src/module.ts CHANGED
@@ -115,6 +115,8 @@ function archiveProcedures(settings: ArchiveSettings): AnyProcedure[] {
115
115
  shorts: { source: "s", format: "f" },
116
116
  output: "json",
117
117
  effects: READS_WRITES_FS,
118
+ // A root of the host examines the archive, the source, the base folder and each file
119
+ fsRoot: { cwd: "cwd", paths: ["output", "source"], names: ["files"] },
118
120
  })
119
121
  .handler(async (input: ArchiveCreateInput): Promise<ArchiveCreateOutput> => archiveCreate(input, settings))
120
122
  .build();
@@ -130,6 +132,8 @@ function archiveProcedures(settings: ArchiveSettings): AnyProcedure[] {
130
132
  shorts: { format: "f" },
131
133
  output: "json",
132
134
  effects: READS_WRITES_FS,
135
+ // The checks of the entries keep the extract in the target
136
+ fsRoot: { paths: ["archive", "target"] },
133
137
  })
134
138
  .handler(async (input: ArchiveExtractInput): Promise<ArchiveExtractOutput> => archiveExtract(input, settings))
135
139
  .build();
@@ -145,6 +149,7 @@ function archiveProcedures(settings: ArchiveSettings): AnyProcedure[] {
145
149
  shorts: { format: "f" },
146
150
  output: "json",
147
151
  effects: READS_FS,
152
+ fsRoot: { paths: ["archive"] },
148
153
  })
149
154
  .handler(async (input: ArchiveListInput): Promise<ArchiveListOutput> => archiveList(input, settings))
150
155
  .build();
package/src/root.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The root of the archive procedures: one folder that confines each path (roadmap R33).
3
3
  *
4
- * The rules are the rules of `root.ts` of `@procedures/fs` (`createFsModule({ root })`):
4
+ * The rules are the rules of `@procedures/fs/root`, the rules of `createFsModule({ root })`:
5
5
  * - A relative path starts at the root, not at the working folder of the process.
6
6
  * - A path outside the root gives `FORBIDDEN` with the reason `outside-root`. This includes a
7
7
  * path that goes up with `..`, an absolute path outside the root, a path on another drive, and
@@ -10,123 +10,19 @@
10
10
  * uses the real path of the nearest existing ancestor. So a symlinked parent folder cannot
11
11
  * lead a write or a `mkdir` out of the root.
12
12
  *
13
- * On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same.
13
+ * On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same. This
14
+ * file adds only `placesOf()`, the paths of one call of an archive procedure.
14
15
  */
15
16
 
16
- import { readlink, realpath } from "node:fs/promises";
17
- import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
18
- import { InvocationError, type ProcedurePath } from "@procedures/client";
17
+ import { resolve } from "node:path";
18
+ import type { ProcedurePath } from "@procedures/client";
19
+ import { inRoot, resolveRoot as resolveFsRoot, type ResolvedRoot } from "@procedures/fs/root";
19
20
 
20
- /** The reason of the `FORBIDDEN` error for a path outside the root. */
21
- export const OUTSIDE_ROOT = "outside-root";
21
+ export { OUTSIDE_ROOT, inRoot, isInside, isOutsideRoot, outsideRoot, realPathIsInside, realPathOf, type ResolvedRoot } from "@procedures/fs/root";
22
22
 
23
- /** The maximum number of symlinks that one check follows. After it, the check fails with `ELOOP`. */
24
- const MAX_LINKS = 40;
25
-
26
- /**
27
- * This function tells if `path` is `folder` or a path in `folder`. The two paths are absolute.
28
- * On Windows, the case of the letters is not significant.
29
- */
30
- export function isInside(folder: string, path: string): boolean {
31
- const rel = relative(folder, path);
32
- return rel === "" || (!isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`));
33
- }
34
-
35
- /** True for the error of a path that does not exist. */
36
- function isMissing(error: unknown): boolean {
37
- const code = (error as NodeJS.ErrnoException).code;
38
- return code === "ENOENT" || code === "ENOTDIR";
39
- }
40
-
41
- /** The target of a symlink, or undefined when the path is not a symlink or does not exist. */
42
- async function linkTarget(path: string): Promise<string | undefined> {
43
- try {
44
- return await readlink(path);
45
- } catch (error) {
46
- // EINVAL: the path is not a symlink
47
- const code = (error as NodeJS.ErrnoException).code;
48
- if (code === "EINVAL" || isMissing(error)) return undefined;
49
- throw error;
50
- }
51
- }
52
-
53
- /**
54
- * This function gives the real path of an absolute path. For a path that does not exist, it
55
- * gives the real path of the nearest existing ancestor and the rest of the path. A symlink whose
56
- * target does not exist leads to its target, because a write follows it.
57
- */
58
- export async function realPathOf(path: string, links = 0): Promise<string> {
59
- const rest: string[] = [];
60
- let current = path;
61
- for (;;) {
62
- try {
63
- return join(await realpath(current), ...rest);
64
- } catch (error) {
65
- if (!isMissing(error)) throw error;
66
- }
67
- const target = await linkTarget(current);
68
- if (target !== undefined) {
69
- if (links >= MAX_LINKS) {
70
- const loop = new Error(`Too many symlinks in the path ${path}`) as NodeJS.ErrnoException;
71
- loop.code = "ELOOP";
72
- throw loop;
73
- }
74
- return join(await realPathOf(resolve(dirname(current), target), links + 1), ...rest);
75
- }
76
- const parent = dirname(current);
77
- // No ancestor exists, for example a drive that is not there
78
- if (parent === current) return join(current, ...rest);
79
- rest.unshift(basename(current));
80
- current = parent;
81
- }
82
- }
83
-
84
- /** A root: the absolute path that the host gave, and its real path. */
85
- export interface ResolvedRoot {
86
- folder: string;
87
- real: string;
88
- }
89
-
90
- /** This function gives the absolute path and the real path of a root. The root must exist. */
91
- export async function resolveRoot(root: string): Promise<ResolvedRoot> {
92
- const folder = resolve(root);
93
- try {
94
- return { folder, real: await realpath(folder) };
95
- } catch (error) {
96
- if (!isMissing(error)) throw error;
97
- const missing = new Error(`The root of the archive procedures does not exist: ${folder}`) as NodeJS.ErrnoException;
98
- missing.code = "ENOENT";
99
- throw missing;
100
- }
101
- }
102
-
103
- /** The `FORBIDDEN` error for a path outside the root. */
104
- export function outsideRoot(procedure: ProcedurePath, message: string): InvocationError {
105
- return new InvocationError("FORBIDDEN", `${procedure.join(".")}: ${message}`, procedure, OUTSIDE_ROOT);
106
- }
107
-
108
- /** True for the `FORBIDDEN` error of a path outside the root. */
109
- export function isOutsideRoot(error: unknown): boolean {
110
- return error instanceof InvocationError && error.code === "FORBIDDEN" && error.reason === OUTSIDE_ROOT;
111
- }
112
-
113
- /**
114
- * This function gives the absolute path of `path` in the root. A relative path starts at the
115
- * root. The real path decides: a path whose real path is outside the real path of the root gives
116
- * `FORBIDDEN` with the reason `outside-root`.
117
- */
118
- export async function inRoot(root: ResolvedRoot, path: string, procedure: ProcedurePath): Promise<string> {
119
- const absolute = resolve(root.folder, path);
120
- const real = await realPathOf(absolute);
121
- // A path counts as inside by its given form or by its real form. On Windows, the two forms of a
122
- // folder can differ by more than the links: a short 8.3 name (RUNNER~1) has a long real name.
123
- if (!isInside(root.folder, absolute) && !isInside(root.real, absolute) && !isInside(root.real, real)) {
124
- throw outsideRoot(procedure, `the path ${JSON.stringify(path)} is outside the root ${root.folder}`);
125
- }
126
- if (!isInside(root.real, real)) {
127
- throw outsideRoot(procedure, `the path ${JSON.stringify(path)} leads out of the root ${root.folder} through a symlink`);
128
- }
129
- return absolute;
23
+ /** This function gives the absolute path and the real path of a root of the archive procedures. The root must exist. */
24
+ export function resolveRoot(root: string): Promise<ResolvedRoot> {
25
+ return resolveFsRoot(root, "the archive procedures");
130
26
  }
131
27
 
132
28
  /** The paths of one call of a procedure. */