mirror of
https://github.com/morluto/rea.git
synced 2026-11-23 15:05:51 +00:00
refactor(inspector): own the Node discovery path rule in one module (#10680)
Node Inspector discovery reports a target as `file://` plus the pathname, with quotes and backslashes replaced by underscores. Whether such a pathname is identifiable was decided twice: inline in authorizeRuntimeTargetLocation and again as NODE_DISCOVERY_AMBIGUOUS in the createNodeDiscoveryTempDirectory fixture. The copies could drift, and the fixture could not import the product rule without loading JavaScriptRuntimeScope and its Electron file-scope chain. Move the rule to src/inspector/nodeDiscoveryPath.ts, a module with no imports, and use it from both places. Behavior is unchanged. A unit test covers the Windows branch, which Linux CI cannot reach through the boundary tests. Validation: nodeDiscoveryPath and cancellation tests 12/12; javascriptRuntimeTargetLocations and javascriptRuntimeObservation 42/42 with TMPDIR containing an underscore (exercises the /tmp fallback); check:fast passes. Refs morluto/rea#9996
This commit is contained in:
1 parent
7b856fa5a1
commit
559956cf6b
4 files changed
+47
-21
No files matched your search
@@ -15,6 +15,7 @@ import type {
|
||||
JavaScriptRuntimeTargetLocation,
|
||||
} from "../domain/javascript/javascriptRuntimeObservation.js";
|
||||
import { cancelledBy } from "../domain/analysisErrorCore.js";
|
||||
import { isLosslessNodeDiscoveryPath } from "./nodeDiscoveryPath.js";
|
||||
import {
|
||||
authorizedElectronFile,
|
||||
type ElectronFileScope,
|
||||
@@ -150,20 +151,15 @@ export const authorizeRuntimeTargetLocation = async (
|
||||
files,
|
||||
);
|
||||
|
||||
// Node concatenates the pathname, then replaces quotes and backslashes with
|
||||
// underscores. A remaining underscore cannot prove which pathname was used.
|
||||
// The runtime runs on this host and reports one of this host's paths.
|
||||
if (HOST_PLATFORM.platform !== "win32" && !/[_"\\]/u.test(reportedPath)) {
|
||||
if (reportedPath.startsWith("/")) {
|
||||
const decision = await authorizeRuntimeLocation(
|
||||
pathToFileURL(reportedPath).href,
|
||||
signal,
|
||||
operation,
|
||||
asarHeaderAdmission,
|
||||
files,
|
||||
);
|
||||
if (decision.allowed) return decision;
|
||||
}
|
||||
if (isLosslessNodeDiscoveryPath(reportedPath, HOST_PLATFORM.platform)) {
|
||||
const decision = await authorizeRuntimeLocation(
|
||||
pathToFileURL(reportedPath).href,
|
||||
signal,
|
||||
operation,
|
||||
asarHeaderAdmission,
|
||||
files,
|
||||
);
|
||||
if (decision.allowed) return decision;
|
||||
}
|
||||
return {
|
||||
allowed: true,
|
||||
|
||||
Reference in new issue
Block a user