fix(native): keep integral plist reals beyond the JSON range as reals (#860)

plutil's JSON spells an integral <real> such as 9007199254740992 like an
<integer>, so the JSON path labeled it an exact integer. When the JSON
holds an unsafe integral number, read element types from plutil's XML
conversion; numbers whose origin stays ambiguous are reported as decoded
with an explicit limitation.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kaoru0822
2026-10-07 13:01:26 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 8b9940a7b5
commit 3b92a2bced
4 changed files with 199 additions and 65 deletions
+13 -4
View File
@@ -50,7 +50,11 @@ import {
import { parseCodeSignature } from "./parsers/codesign.js";
import { parseDemangledSymbols } from "./parsers/demangle.js";
import { parseLipoArchitectures } from "./parsers/lipo.js";
import { parsePlistJson, parsePlistXml } from "./parsers/plist.js";
import {
parsePlistJson,
parsePlistXml,
plistJsonNeedsNumberTypes,
} from "./parsers/plist.js";
import {
architectureLocations,
inspectNativeMacho,
@@ -431,9 +435,12 @@ class NativeMacOSClient implements AnalysisClient {
);
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.
// such plists, so decode its lossless XML conversion instead. JSON also
// prints an integral <real> like an <integer>, so a number beyond the
// exact JSON range takes its element type from the XML conversion.
const jsonDecoded = json.value.exitCode === 0;
const xml =
json.value.exitCode === 0
jsonDecoded && !plistJsonNeedsNumberTypes(json.value.stdout)
? undefined
: await this.#run(
"inspect_plist",
@@ -445,7 +452,9 @@ class NativeMacOSClient implements AnalysisClient {
const parsed =
xml === undefined
? parsePlistJson(json.value.stdout)
: parsePlistXml(xml.value.stdout);
: jsonDecoded
? parsePlistJson(json.value.stdout, xml.value.stdout)
: parsePlistXml(xml.value.stdout);
if (!parsed.ok) return parsed;
const provenance = [
classified.value,