fix(native): inspect plists containing data, dates, and non-finite reals

`inspect_plist` converted every plist with `plutil -convert json`, which
rejects plists containing `<data>`, `<date>`, or non-finite `<real>`
values. Such valid plists (including Stocks.app's Info.plist) failed with
a cause-free `execution_failure`.

When the JSON conversion exits nonzero, decode `plutil -convert xml1`
instead. Data and dates use the `$plist_type` objects the keyed-archive
reader already emits; non-finite reals become an explicit unknown because
the XML decoder reports NaN and infinity alike. Provenance records both
conversions and limitations explain the representation. Plists that JSON
can express keep the unchanged single-conversion path.

The projection moves to `src/domain/plistValue.ts` and is shared with the
keyed-archive reader, which keeps rejecting non-finite reals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Iwakurakaoru0822
2026-10-06 20:54:23 -07:00
co-authored by Claude Opus 5.5
parent be3cfbffdf
commit 5ead2cfbc4
6 changed files with 260 additions and 56 deletions
+29 -11
View File
@@ -45,7 +45,7 @@ import {
import { parseCodeSignature } from "./parsers/codesign.js";
import { parseDemangledSymbols } from "./parsers/demangle.js";
import { parseLipoArchitectures } from "./parsers/lipo.js";
import { parsePlistJson } from "./parsers/plist.js";
import { parsePlistJson, parsePlistXml } from "./parsers/plist.js";
import {
architectureLocations,
inspectNativeMacho,
@@ -460,33 +460,51 @@ class NativeMacOSClient implements AnalysisClient {
{ signal },
);
if (!classified.ok) return classified;
const capture = await this.#run(
const json = await this.#run(
"inspect_plist",
"plutil",
["-convert", "json", "-o", "-", "--", plist.value],
{ signal },
{ signal, acceptNonZero: true },
);
if (!capture.ok) return capture;
const parsed = parsePlistJson(capture.value.stdout);
if (!json.ok) return json;
// JSON cannot express data, dates, or non-finite reals; plutil rejects
// such plists, so decode its lossless XML conversion instead.
const xml =
json.value.exitCode === 0
? undefined
: await this.#run(
"inspect_plist",
"plutil",
["-convert", "xml1", "-o", "-", "--", plist.value],
{ signal },
);
if (xml !== undefined && !xml.ok) return xml;
const parsed =
xml === undefined
? parsePlistJson(json.value.stdout)
: parsePlistXml(xml.value.stdout);
if (!parsed.ok) return parsed;
const provenance = [classified.value, capture.value].map((item) =>
invocation(item, plist.value, "$PLIST"),
);
const provenance = [
classified.value,
json.value,
...(xml === undefined ? [] : [xml.value]),
].map((item) => invocation(item, plist.value, "$PLIST"));
const result = inspectPlistSchema.parse({
format: /binary property list/iu.test(classified.value.stdout)
? "binary"
: /XML|text/iu.test(classified.value.stdout)
? "xml"
: "unknown",
...parsed.value,
value: parsed.value.value,
bundle: parsed.value.bundle,
source_path: plist.value,
provenance,
limitations: [],
limitations: parsed.value.limitations,
});
return ok({
result: jsonValueSchema.parse(result),
provenance,
limitations: [],
limitations: parsed.value.limitations,
locations: [{ kind: "artifact-path", path: plist.value }],
});
}