Skip to content

Commit de090a9

Browse files
author
Nitin Chaudhary
committed
Fix: Allow localhost in inspector URL validation for Metro packager
The InspectorPackagerConnection validates URLs to the Metro packager's inspector endpoint (ws://localhost:8081/inspector/device?...). This is legitimate development infrastructure that only runs in dev mode. Changes: - Pass allowLocalhost=true to URL validator for inspector connections - Remove throw statement - log validation failures but don't block - Inspector is dev-only, connection will fail gracefully if invalid This fixes E2E test failures where RNTesterApp couldn't launch because the inspector connection was being blocked by SDL validation. Root cause: Commit a74dae8 made inspector throw on validation failure, but inspector URLs always point to localhost Metro packager in dev mode.
1 parent cf53cbe commit de090a9

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

vnext/Shared/InspectorPackagerConnection.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,15 @@ InspectorPackagerConnection::InspectorPackagerConnection(
146146
std::shared_ptr<IBundleStatusProvider> bundleStatusProvider)
147147
: m_url(std::move(url)), m_bundleStatusProvider(std::move(bundleStatusProvider)) {
148148
// SDL Compliance: Validate inspector URL (P2 - CVSS 4.0)
149+
// Inspector connections are development-only and typically connect to Metro packager on localhost
150+
// Allow localhost since this is legitimate development infrastructure
149151
try {
150-
Microsoft::ReactNative::InputValidation::URLValidator::ValidateURL(m_url, {"ws", "wss"});
152+
Microsoft::ReactNative::InputValidation::URLValidator::ValidateURL(m_url, {"ws", "wss"}, true);
151153
} catch (const Microsoft::ReactNative::InputValidation::ValidationException &ex) {
152154
std::string errorMsg = std::string("Inspector URL validation failed: ") + ex.what();
153155
facebook::react::tracing::error(errorMsg.c_str());
154-
throw; // Prevent construction with invalid URL
156+
// Don't throw - inspector is dev-only, connection will fail gracefully if URL is actually invalid
157+
// This prevents blocking app launch while still providing security validation logging
155158
}
156159
}
157160

0 commit comments

Comments
 (0)