Skip to content

Commit ca0d440

Browse files
pfaffeDevtools-frontend LUCI CQ
authored andcommitted
[extensions] Fail-open determining if extensions may see a (file) URL
We prevent language extensions from learning about file URLs unless they already have file access. If a URL string fails to parse we should allow it, since even if it's a relative URL we also validate the base. Fixed: 396169337 Change-Id: I11f8a6f0c6f3b7c67c73c61dcdf9511137bbca04 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6263086 Auto-Submit: Philip Pfaffe <[email protected]> Commit-Queue: Danil Somsikov <[email protected]> Reviewed-by: Danil Somsikov <[email protected]>
1 parent 19ea45c commit ca0d440

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

front_end/models/extensions/LanguageExtensionEndpoint.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ for (const allowFileAccess of [true, false]) {
5858
assert.lengthOf(endpointProxyStub.getCalls(), allowFileAccess ? 3 : 1);
5959
await endpoint.addRawModule('', '', {url: 'http://example.com'});
6060
assert.lengthOf(endpointProxyStub.getCalls(), allowFileAccess ? 4 : 2);
61+
await endpoint.addRawModule('', 'wasm.debug.wasm', {url: 'http://example.com'});
62+
assert.lengthOf(endpointProxyStub.getCalls(), allowFileAccess ? 5 : 3);
6163
});
6264
});
6365
}

front_end/models/extensions/LanguageExtensionEndpoint.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ export class LanguageExtensionEndpoint implements Bindings.DebuggerLanguagePlugi
5757
try {
5858
return !url || this.allowFileAccess || new URL(url).protocol !== 'file:';
5959
} catch {
60-
return false;
60+
// If the URL isn't valid, it also isn't a valid file url and it's safe to tell the extensions about it.
61+
return true;
6162
}
6263
}
6364

0 commit comments

Comments
 (0)