Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: suppress insecure resource warning for more local hostnames #31037

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions lib/renderer/security-warnings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,14 @@ const warnAboutInsecureResources = function () {
return;
}

const isLocal = (url: URL): boolean =>
['localhost', '127.0.0.1', '[::1]', ''].includes(url.hostname);
const isInsecure = (url: URL): boolean =>
['http:', 'ftp:'].includes(url.protocol) && !isLocal(url);

const resources = window.performance
.getEntriesByType('resource')
.filter(({ name }) => /^(http|ftp):/gi.test(name || ''))
.filter(({ name }) => new URL(name).hostname !== 'localhost')
.filter(({ name }) => isInsecure(new URL(name)))
.map(({ name }) => `- ${name}`)
.join('\n');

Expand Down
1 change: 1 addition & 0 deletions spec-main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ app.on('window-all-closed', () => null);

// Use fake device for Media Stream to replace actual camera and microphone.
app.commandLine.appendSwitch('use-fake-device-for-media-stream');
app.commandLine.appendSwitch('host-rules', 'MAP localhost2 127.0.0.1');

global.standardScheme = 'app';
global.zoomScheme = 'zoom';
Expand Down
2 changes: 1 addition & 1 deletion spec-main/security-warnings-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('security warnings', () => {
});
});
}).listen(0, '127.0.0.1', () => {
serverUrl = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
serverUrl = `http://localhost2:${(server.address() as AddressInfo).port}`;
done();
});
});
Expand Down