📦 deps(thirdparty): update snapshots
This commit is contained in:
+30
-10
@@ -54,6 +54,12 @@ function privateModeUnsafe(stat) {
|
||||
return process.platform !== "win32" && (stat.mode & 0o077) !== 0;
|
||||
}
|
||||
|
||||
function ownershipUnsafe(stat) {
|
||||
return process.platform !== "win32"
|
||||
&& typeof process.getuid === "function"
|
||||
&& stat.uid !== process.getuid();
|
||||
}
|
||||
|
||||
function publicRuntimeIdentity(identity) {
|
||||
return Object.freeze({
|
||||
package: identity.package,
|
||||
@@ -187,23 +193,37 @@ function runtimeRecords(entries, version) {
|
||||
return { records, assets, closureDigest: sha256(canonicalJson({ digestVersion: DIGEST_VERSION, assets })) };
|
||||
}
|
||||
|
||||
async function ensureRealDirectory(directoryPath, created) {
|
||||
async function ensureRealDirectory(directoryPath, created, cacheRoot) {
|
||||
const boundary = path.resolve(cacheRoot);
|
||||
const resolved = path.resolve(directoryPath);
|
||||
if (resolved !== boundary && !resolved.startsWith(`${boundary}${path.sep}`)) {
|
||||
throw cacheError("AAS_RUNTIME_DIRECTORY_UNSAFE", "runtime cache path escaped the configured cache root");
|
||||
}
|
||||
try {
|
||||
const stat = await fsp.lstat(directoryPath);
|
||||
if (!stat.isDirectory() || stat.isSymbolicLink() || privateModeUnsafe(stat)) {
|
||||
const stat = await fsp.lstat(resolved);
|
||||
if (!stat.isDirectory() || stat.isSymbolicLink() || privateModeUnsafe(stat) || ownershipUnsafe(stat)) {
|
||||
throw cacheError("AAS_RUNTIME_DIRECTORY_UNSAFE", "runtime cache path is not a private real directory");
|
||||
}
|
||||
} catch (error) {
|
||||
if (error.code !== "ENOENT") throw error;
|
||||
const parent = path.dirname(directoryPath);
|
||||
if (parent !== directoryPath) await ensureRealDirectory(parent, created);
|
||||
const parent = path.dirname(resolved);
|
||||
if (resolved === boundary) {
|
||||
const parentStat = await fsp.lstat(parent);
|
||||
if (!parentStat.isDirectory() || parentStat.isSymbolicLink()
|
||||
|| ownershipUnsafe(parentStat)
|
||||
|| (process.platform !== "win32" && (parentStat.mode & 0o022) !== 0)) {
|
||||
throw cacheError("AAS_RUNTIME_DIRECTORY_UNSAFE", "runtime cache parent is not a real directory");
|
||||
}
|
||||
} else {
|
||||
await ensureRealDirectory(parent, created, boundary);
|
||||
}
|
||||
try {
|
||||
await fsp.mkdir(directoryPath, { mode: 0o700 });
|
||||
created.push(directoryPath);
|
||||
await fsp.mkdir(resolved, { mode: 0o700 });
|
||||
created.push(resolved);
|
||||
} catch (mkdirError) {
|
||||
if (mkdirError.code !== "EEXIST") throw mkdirError;
|
||||
const stat = await fsp.lstat(directoryPath);
|
||||
if (!stat.isDirectory() || stat.isSymbolicLink() || privateModeUnsafe(stat)) {
|
||||
const stat = await fsp.lstat(resolved);
|
||||
if (!stat.isDirectory() || stat.isSymbolicLink() || privateModeUnsafe(stat) || ownershipUnsafe(stat)) {
|
||||
throw cacheError("AAS_RUNTIME_DIRECTORY_UNSAFE", "runtime cache path is not a private real directory");
|
||||
}
|
||||
}
|
||||
@@ -299,7 +319,7 @@ async function promoteRuntime({ cacheRoot, release, parsed }) {
|
||||
let stagePath;
|
||||
let promoted = false;
|
||||
try {
|
||||
await ensureRealDirectory(versionDirectory, created);
|
||||
await ensureRealDirectory(versionDirectory, created, cacheRoot);
|
||||
stagePath = path.join(versionDirectory, `.stage-${process.pid}-${crypto.randomBytes(12).toString("hex")}`);
|
||||
await fsp.mkdir(stagePath, { mode: 0o700 });
|
||||
const directories = new Set([stagePath]);
|
||||
|
||||
@@ -17,9 +17,6 @@ const CATALOG_ASSET_PATHS = Object.freeze([
|
||||
"data/aas-v1/skill-content-index.v1.json",
|
||||
"data/aas-v1/skill-content.v1.ndjson",
|
||||
"data/catalog.json",
|
||||
"data/plugin-compatibility.json",
|
||||
"tools/lib/aas-v1/metadata-reviews.v1.json",
|
||||
"tools/lib/aas-v1/metadata-overrides.v1.json",
|
||||
"tools/lib/aas-v1/ontology.v1.json",
|
||||
]);
|
||||
|
||||
@@ -68,7 +65,8 @@ function validateCatalogManifest(bytes, version) {
|
||||
const text = bytes.toString("utf8");
|
||||
const manifest = JSON.parse(text);
|
||||
if (`${canonicalJson(manifest)}\n` !== text || manifest.schemaVersion !== 1 || manifest.digestVersion !== 1
|
||||
|| manifest.package !== PACKAGE_NAME || manifest.packageVersion !== version || manifest.skillCount !== 1965
|
||||
|| manifest.package !== PACKAGE_NAME || manifest.packageVersion !== version
|
||||
|| !Number.isSafeInteger(manifest.skillCount) || manifest.skillCount <= 0
|
||||
|| !/^sha256-[a-f0-9]{64}$/.test(manifest.catalogDigest) || !Array.isArray(manifest.assets)) {
|
||||
throw cacheError("AAS_UPDATE_CATALOG_MANIFEST_INVALID", "catalog manifest is invalid or incompatible");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user