feat(artifacts): support MSIX and AppX packages
This commit is contained in:
@@ -37,6 +37,8 @@ const formatSchema = z.enum([
|
||||
"zip",
|
||||
"ipa",
|
||||
"apk",
|
||||
"msix",
|
||||
"appx",
|
||||
"asar",
|
||||
"dmg",
|
||||
"pkg",
|
||||
|
||||
@@ -52,6 +52,8 @@ const artifactFormatSchema = z.enum([
|
||||
"analysis-database",
|
||||
"ipa",
|
||||
"apk",
|
||||
"msix",
|
||||
"appx",
|
||||
"plist",
|
||||
"entitlements",
|
||||
"directory",
|
||||
|
||||
@@ -14,6 +14,7 @@ import { promisify } from "node:util";
|
||||
|
||||
import { BinaryTargetError } from "./errors.js";
|
||||
import { err, ok, type Result } from "./result.js";
|
||||
import { zipPackageFormatForPath } from "./zipPackageFormat.js";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
@@ -36,6 +37,8 @@ export interface BinaryTarget {
|
||||
| "zip"
|
||||
| "ipa"
|
||||
| "apk"
|
||||
| "msix"
|
||||
| "appx"
|
||||
| "asar"
|
||||
| "dmg"
|
||||
| "pkg"
|
||||
@@ -131,11 +134,7 @@ const detectArtifactFormat = async (
|
||||
[0x03, 0x05, 0x07].includes(magic[2] ?? -1) &&
|
||||
[0x04, 0x06, 0x08].includes(magic[3] ?? -1)
|
||||
) {
|
||||
return lower.endsWith(".ipa")
|
||||
? "ipa"
|
||||
: lower.endsWith(".apk")
|
||||
? "apk"
|
||||
: "zip";
|
||||
return zipPackageFormatForPath(lower) ?? "zip";
|
||||
}
|
||||
const named = namedArtifactFormat(lower);
|
||||
if (named !== undefined) return named;
|
||||
@@ -167,7 +166,7 @@ const namedArtifactFormat = (
|
||||
};
|
||||
|
||||
const isArchiveFormat = (format: BinaryTarget["format"]): boolean =>
|
||||
["zip", "ipa", "apk", "asar", "dmg", "pkg"].includes(format);
|
||||
["zip", "ipa", "apk", "msix", "appx", "asar", "dmg", "pkg"].includes(format);
|
||||
|
||||
const sha256Handle = async (handle: FileHandle): Promise<string> => {
|
||||
const hash = createHash("sha256");
|
||||
|
||||
@@ -29,6 +29,8 @@ const subjectSchema = z.object({
|
||||
"zip",
|
||||
"ipa",
|
||||
"apk",
|
||||
"msix",
|
||||
"appx",
|
||||
"asar",
|
||||
"dmg",
|
||||
"pkg",
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/** ZIP-backed application package families that share the hardened archive reader. */
|
||||
export type ZipPackageFormat = "zip" | "ipa" | "apk" | "msix" | "appx";
|
||||
|
||||
/**
|
||||
* Classify a ZIP-backed package by its complete lower-cased path suffix.
|
||||
*
|
||||
* This is deliberately extension-only. Callers must separately verify ZIP
|
||||
* magic before trusting the classification for a root input.
|
||||
*/
|
||||
export const zipPackageFormatForPath = (
|
||||
path: string,
|
||||
): ZipPackageFormat | undefined => {
|
||||
const lower = path.toLowerCase();
|
||||
if (lower.endsWith(".zip")) return "zip";
|
||||
if (lower.endsWith(".ipa")) return "ipa";
|
||||
if (lower.endsWith(".apk") || lower.endsWith(".aab")) return "apk";
|
||||
if (lower.endsWith(".msix") || lower.endsWith(".msixbundle")) return "msix";
|
||||
if (lower.endsWith(".appx") || lower.endsWith(".appxbundle")) return "appx";
|
||||
return undefined;
|
||||
};
|
||||
Reference in New Issue
Block a user