@solaqua/gji 0.12.3 → 0.12.4
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/dist/gji-bundle.mjs +22 -2
- package/dist/uv-validation.js +24 -2
- package/man/man1/gji-back.1 +1 -1
- package/man/man1/gji-clean.1 +1 -1
- package/man/man1/gji-completion.1 +1 -1
- package/man/man1/gji-config.1 +1 -1
- package/man/man1/gji-doctor.1 +1 -1
- package/man/man1/gji-done.1 +1 -1
- package/man/man1/gji-go.1 +1 -1
- package/man/man1/gji-history.1 +1 -1
- package/man/man1/gji-init.1 +1 -1
- package/man/man1/gji-ls.1 +1 -1
- package/man/man1/gji-new.1 +1 -1
- package/man/man1/gji-open.1 +1 -1
- package/man/man1/gji-pr.1 +1 -1
- package/man/man1/gji-remove.1 +1 -1
- package/man/man1/gji-root.1 +1 -1
- package/man/man1/gji-run-hook.1 +1 -1
- package/man/man1/gji-status.1 +1 -1
- package/man/man1/gji-sync-files.1 +1 -1
- package/man/man1/gji-sync.1 +1 -1
- package/man/man1/gji-task.1 +1 -1
- package/man/man1/gji-undo.1 +1 -1
- package/man/man1/gji-warp.1 +1 -1
- package/man/man1/gji.1 +1 -1
- package/package.json +1 -1
package/dist/gji-bundle.mjs
CHANGED
|
@@ -18883,11 +18883,12 @@ import { execFile as execFile5 } from "node:child_process";
|
|
|
18883
18883
|
import { constants as constants5 } from "node:fs";
|
|
18884
18884
|
import { lstat as lstat3, open as open3, readdir, realpath as realpath2 } from "node:fs/promises";
|
|
18885
18885
|
import { basename as basename6, dirname as dirname8, isAbsolute as isAbsolute3, join as join11, resolve as resolve8, sep as sep2 } from "node:path";
|
|
18886
|
-
import { promisify as promisify6 } from "node:util";
|
|
18886
|
+
import { promisify as promisify6, TextDecoder } from "node:util";
|
|
18887
18887
|
var execFileAsync5 = promisify6(execFile5);
|
|
18888
18888
|
var UV_VALIDATION_MAX_ENTRIES = 1e4;
|
|
18889
18889
|
var UV_VALIDATION_MAX_FILE_BYTES = 1024 * 1024;
|
|
18890
18890
|
var UV_VALIDATION_MAX_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
18891
|
+
var UV_VALIDATION_TEXT_PROBE_BYTES = 4 * 1024;
|
|
18891
18892
|
function virtualEnvironmentPrefixes(text) {
|
|
18892
18893
|
const prefixes = [];
|
|
18893
18894
|
for (const line of text.split(/\r?\n/u)) {
|
|
@@ -19052,6 +19053,14 @@ async function readBoundedUvTextFile(path9, remainingBytes) {
|
|
|
19052
19053
|
try {
|
|
19053
19054
|
const stats = await handle.stat();
|
|
19054
19055
|
if (!stats.isFile()) return void 0;
|
|
19056
|
+
const probeBytes = Math.min(UV_VALIDATION_TEXT_PROBE_BYTES, stats.size);
|
|
19057
|
+
if (probeBytes > remainingBytes) {
|
|
19058
|
+
throw new Error("uv launchers exceed the total validation size limit");
|
|
19059
|
+
}
|
|
19060
|
+
const probe = await readFilePrefix(handle, probeBytes);
|
|
19061
|
+
if (!looksLikeUtf8Text(probe, probe.byteLength === stats.size)) {
|
|
19062
|
+
return { bytes: probe.byteLength };
|
|
19063
|
+
}
|
|
19055
19064
|
if (stats.size > UV_VALIDATION_MAX_FILE_BYTES) {
|
|
19056
19065
|
throw new Error(`uv launcher exceeds the validation size limit: ${path9}`);
|
|
19057
19066
|
}
|
|
@@ -19067,11 +19076,22 @@ async function readBoundedUvTextFile(path9, remainingBytes) {
|
|
|
19067
19076
|
throw new Error("uv launchers exceed the total validation size limit");
|
|
19068
19077
|
}
|
|
19069
19078
|
const text = contents.toString("utf8");
|
|
19070
|
-
return
|
|
19079
|
+
return looksLikeUtf8Text(contents, true) ? { bytes: contents.byteLength, text } : { bytes: contents.byteLength };
|
|
19071
19080
|
} finally {
|
|
19072
19081
|
await handle.close();
|
|
19073
19082
|
}
|
|
19074
19083
|
}
|
|
19084
|
+
function looksLikeUtf8Text(contents, complete) {
|
|
19085
|
+
if (contents.includes(0)) return false;
|
|
19086
|
+
try {
|
|
19087
|
+
new TextDecoder("utf-8", { fatal: true }).decode(contents, {
|
|
19088
|
+
stream: !complete
|
|
19089
|
+
});
|
|
19090
|
+
return true;
|
|
19091
|
+
} catch {
|
|
19092
|
+
return false;
|
|
19093
|
+
}
|
|
19094
|
+
}
|
|
19075
19095
|
async function readFilePrefix(handle, maxBytes) {
|
|
19076
19096
|
const contents = Buffer.allocUnsafe(maxBytes);
|
|
19077
19097
|
let offset = 0;
|
package/dist/uv-validation.js
CHANGED
|
@@ -2,12 +2,13 @@ import { execFile } from "node:child_process";
|
|
|
2
2
|
import { constants } from "node:fs";
|
|
3
3
|
import { lstat, open, readdir, realpath } from "node:fs/promises";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, resolve, sep } from "node:path";
|
|
5
|
-
import { promisify } from "node:util";
|
|
5
|
+
import { promisify, TextDecoder } from "node:util";
|
|
6
6
|
import { isNotFoundError } from "./fs-utils.js";
|
|
7
7
|
const execFileAsync = promisify(execFile);
|
|
8
8
|
const UV_VALIDATION_MAX_ENTRIES = 10_000;
|
|
9
9
|
const UV_VALIDATION_MAX_FILE_BYTES = 1024 * 1024;
|
|
10
10
|
const UV_VALIDATION_MAX_TOTAL_BYTES = 16 * 1024 * 1024;
|
|
11
|
+
const UV_VALIDATION_TEXT_PROBE_BYTES = 4 * 1024;
|
|
11
12
|
function virtualEnvironmentPrefixes(text) {
|
|
12
13
|
const prefixes = [];
|
|
13
14
|
for (const line of text.split(/\r?\n/u)) {
|
|
@@ -168,6 +169,14 @@ async function readBoundedUvTextFile(path, remainingBytes) {
|
|
|
168
169
|
const stats = await handle.stat();
|
|
169
170
|
if (!stats.isFile())
|
|
170
171
|
return undefined;
|
|
172
|
+
const probeBytes = Math.min(UV_VALIDATION_TEXT_PROBE_BYTES, stats.size);
|
|
173
|
+
if (probeBytes > remainingBytes) {
|
|
174
|
+
throw new Error("uv launchers exceed the total validation size limit");
|
|
175
|
+
}
|
|
176
|
+
const probe = await readFilePrefix(handle, probeBytes);
|
|
177
|
+
if (!looksLikeUtf8Text(probe, probe.byteLength === stats.size)) {
|
|
178
|
+
return { bytes: probe.byteLength };
|
|
179
|
+
}
|
|
171
180
|
if (stats.size > UV_VALIDATION_MAX_FILE_BYTES) {
|
|
172
181
|
throw new Error(`uv launcher exceeds the validation size limit: ${path}`);
|
|
173
182
|
}
|
|
@@ -183,7 +192,7 @@ async function readBoundedUvTextFile(path, remainingBytes) {
|
|
|
183
192
|
throw new Error("uv launchers exceed the total validation size limit");
|
|
184
193
|
}
|
|
185
194
|
const text = contents.toString("utf8");
|
|
186
|
-
return
|
|
195
|
+
return looksLikeUtf8Text(contents, true)
|
|
187
196
|
? { bytes: contents.byteLength, text }
|
|
188
197
|
: { bytes: contents.byteLength };
|
|
189
198
|
}
|
|
@@ -191,6 +200,19 @@ async function readBoundedUvTextFile(path, remainingBytes) {
|
|
|
191
200
|
await handle.close();
|
|
192
201
|
}
|
|
193
202
|
}
|
|
203
|
+
function looksLikeUtf8Text(contents, complete) {
|
|
204
|
+
if (contents.includes(0))
|
|
205
|
+
return false;
|
|
206
|
+
try {
|
|
207
|
+
new TextDecoder("utf-8", { fatal: true }).decode(contents, {
|
|
208
|
+
stream: !complete,
|
|
209
|
+
});
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
194
216
|
async function readFilePrefix(handle, maxBytes) {
|
|
195
217
|
const contents = Buffer.allocUnsafe(maxBytes);
|
|
196
218
|
let offset = 0;
|
package/man/man1/gji-back.1
CHANGED
package/man/man1/gji-clean.1
CHANGED
package/man/man1/gji-config.1
CHANGED
package/man/man1/gji-doctor.1
CHANGED
package/man/man1/gji-done.1
CHANGED
package/man/man1/gji-go.1
CHANGED
package/man/man1/gji-history.1
CHANGED
package/man/man1/gji-init.1
CHANGED
package/man/man1/gji-ls.1
CHANGED
package/man/man1/gji-new.1
CHANGED
package/man/man1/gji-open.1
CHANGED
package/man/man1/gji-pr.1
CHANGED
package/man/man1/gji-remove.1
CHANGED
package/man/man1/gji-root.1
CHANGED
package/man/man1/gji-run-hook.1
CHANGED
package/man/man1/gji-status.1
CHANGED
package/man/man1/gji-sync.1
CHANGED
package/man/man1/gji-task.1
CHANGED
package/man/man1/gji-undo.1
CHANGED
package/man/man1/gji-warp.1
CHANGED
package/man/man1/gji.1
CHANGED