-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mini-browser,webview: warn if unsecure
Add security warnings to the mini-browser and webviews when modifying the host patterns. You can disable those warnings by setting `warnOnPotentiallyInsecureHostPattern: false` in your application's `package.json` file, as frontend/backend configurations.
- Loading branch information
1 parent
c92e822
commit a073736
Showing
15 changed files
with
307 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/mini-browser/src/browser/mini-browser-frontend-security-warnings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { MessageService } from '@theia/core'; | ||
import { FrontendApplicationContribution } from '@theia/core/lib/browser'; | ||
import { FrontendApplicationConfigProvider } from '@theia/core/lib/browser/frontend-application-config-provider'; | ||
import { inject, injectable } from '@theia/core/shared/inversify'; | ||
import { MiniBrowserEnvironment } from './environment/mini-browser-environment'; | ||
import { MiniBrowserEndpoint } from '../common/mini-browser-endpoint'; | ||
|
||
@injectable() | ||
export class MiniBrowserFrontendSecurityWarnings implements FrontendApplicationContribution { | ||
|
||
@inject(MessageService) | ||
protected messageService: MessageService; | ||
|
||
@inject(MiniBrowserEnvironment) | ||
protected miniBrowserEnvironment: MiniBrowserEnvironment; | ||
|
||
initialize(): void { | ||
this.checkHostPattern(); | ||
} | ||
|
||
protected async checkHostPattern(): Promise<void> { | ||
if (FrontendApplicationConfigProvider.get()['warnOnPotentiallyInsecureHostPattern'] === false) { | ||
return; | ||
} | ||
const hostPattern = await this.miniBrowserEnvironment.hostPatternPromise; | ||
if (hostPattern !== MiniBrowserEndpoint.HOST_PATTERN_DEFAULT) { | ||
this.messageService.warn(`\ | ||
The mini-browser endpoint's host pattern has been changed to \`${hostPattern}\`, changing this pattern can lead to security vulnerabilities. \ | ||
See \`@theia/mini-browser/README.md\` for more information.` | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
packages/mini-browser/src/node/mini-browser-backend-security-warnings.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2021 Ericsson and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { BackendApplicationContribution } from '@theia/core/lib/node'; | ||
import { BackendApplicationConfigProvider } from '@theia/core/lib/node/backend-application-config-provider'; | ||
import { injectable } from '@theia/core/shared/inversify'; | ||
import { MiniBrowserEndpoint } from '../common/mini-browser-endpoint'; | ||
|
||
@injectable() | ||
export class MiniBrowserBackendSecurityWarnings implements BackendApplicationContribution { | ||
|
||
initialize(): void { | ||
this.checkHostPattern(); | ||
} | ||
|
||
protected async checkHostPattern(): Promise<void> { | ||
if (BackendApplicationConfigProvider.get()['warnOnPotentiallyInsecureHostPattern'] === false) { | ||
return; | ||
} | ||
const envHostPattern = process.env[MiniBrowserEndpoint.HOST_PATTERN_ENV]; | ||
if (envHostPattern && envHostPattern !== MiniBrowserEndpoint.HOST_PATTERN_DEFAULT) { | ||
console.warn(`\ | ||
MINI BROWSER SECURITY WARNING | ||
Changing the @theia/mini-browser host pattern can lead to security vulnerabilities. | ||
Current pattern: "${envHostPattern}" | ||
Please read @theia/mini-browser/README.md for more information. | ||
` | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.