This repository was archived by the owner on Jul 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Implement Electron Security Guidelines #278
Merged
Merged
Changes from 12 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4ccbd2b
init
pmespresso 2227601
update with needed permissions
pmespresso f93b6c1
update with needed permissions
pmespresso c115dc1
nbs
pmespresso 8a4f51f
checklist cheatsheet
pmespresso 0dd937a
set web preferences
pmespresso d7437ed
Merge branch 'master' of https://github.com/paritytech/substrate-ligh…
pmespresso 75d4874
Merge branch 'master' of https://github.com/paritytech/substrate-ligh…
pmespresso 8dc9540
lint
pmespresso 41677e7
feat(csp):use the csp from parity-js shell and fether
pmespresso e21293e
fix: set csp on headers received
pmespresso 7a294f4
fix lint
pmespresso 0d5b0ca
Merge branch 'master' of https://github.com/paritytech/substrate-ligh…
pmespresso e5757b5
fix: font src csp, comment out webview event
pmespresso 7d1fc1c
Improve CSP (#303)
amaury1093 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,5 @@ | ||
| // Copyright 2018-2019 @paritytech/substrate-light-ui authors & contributors | ||
| // This software may be modified and distributed under the terms | ||
| // of the Apache-2.0 license. See the LICENSE file for details. | ||
|
|
||
| export const IS_PROD = process.env.NODE_ENV === 'production'; |
This file contains hidden or 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,59 @@ | ||
| // Copyright 2018-2019 @paritytech/substrate-light-ui authors & contributors | ||
| // This software may be modified and distributed under the terms | ||
| // of the Apache-2.0 license. See the LICENSE file for details. | ||
|
|
||
| import { IS_PROD } from './constants'; | ||
|
|
||
| /* eslint-disable */ | ||
| // References: | ||
| // * https://github.com/parity-js/shell | ||
| // * https://github.com/paritytech/fether | ||
| const CSP_CONFIG = { | ||
| // Disallow mixed content | ||
| blockAllMixedContent: 'block-all-mixed-content;', | ||
| // Disallow framing and web workers. | ||
| // tslint:disable-next-line:quotemark | ||
| childSrc: "child-src 'none';", | ||
| // FIXME - Only allow connecting to WSS and HTTPS servers. | ||
| connectSrc: 'connect-src http: ws:;', | ||
| // Fallback for missing directives. | ||
| // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/default-src | ||
| // | ||
| // Disallow everything as fallback by default for all CSP fetch directives. | ||
| defaultSrc: "default-src 'none';", | ||
| // Disallow fonts. | ||
| fontSrc: "font-src 'none';", // Additionally used in Parity-JS Shell `'self' data: https:` | ||
|
pmespresso marked this conversation as resolved.
Outdated
|
||
| // Disallow submitting any forms | ||
| formAction: "form-action 'none';", | ||
| // Disallow framing. | ||
| frameSrc: "frame-src 'none';", | ||
| imgSrc: !IS_PROD | ||
| ? // Only allow HTTPS for images. Token provider logos must be https:// | ||
| // Allow `data:` `blob:`. | ||
| "img-src 'self' 'unsafe-inline' file: data: blob: https:;" | ||
| : // Only allow HTTPS for images. Token provider logos must be https:// | ||
| // Allow `data:` `blob:`. | ||
| "img-src 'unsafe-inline' file: data: blob: https:;", // Additionally used in Parity-JS Shell `'self'` | ||
| // Disallow manifests. | ||
| manifestSrc: "manifest-src 'none';", | ||
| // Disallow media. | ||
| mediaSrc: "media-src 'none';", | ||
| // Disallow fonts and `<webview>` objects | ||
| objectSrc: "object-src 'none';", | ||
| // Disallow prefetching. | ||
| prefetchSrc: "prefetch-src 'none';", | ||
| scriptSrc: !IS_PROD | ||
| ? // Only allow `http:` and `unsafe-eval` in dev mode (required by create-react-app) | ||
| "script-src 'self' file: http: blob: 'unsafe-inline' 'unsafe-eval';" | ||
| : "script-src file: 'unsafe-inline';", | ||
| styleSrc: !IS_PROD | ||
| ? "style-src 'self' 'unsafe-inline' file: blob:;" // Additionally used in Parity-JS Shell `data: https:` | ||
| : "style-src unsafe-inline' file: blob:;", // Additionally used in Parity-JS Shell `data: https:` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add https in both. Actually tbh I don't think there's need to differentiate between IS_PROD or not here. |
||
| // Allow `blob:` for camera access (worker) | ||
| workerSrc: 'worker-src blob:;' // Additionally used in Parity-JS Shell `'self' https:` | ||
| }; | ||
| /* eslint-enable */ | ||
|
|
||
| const CSP = Object.values(CSP_CONFIG).join(' '); | ||
|
|
||
| export { CSP }; | ||
This file contains hidden or 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 @@ | ||
| declare module 'pino'; |
This file contains hidden or 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,7 @@ | ||
| // Copyright 2018-2019 @paritytech/substrate-light-ui authors & contributors | ||
| // This software may be modified and distributed under the terms | ||
| // of the Apache-2.0 license. See the LICENSE file for details. | ||
|
|
||
| export * from './constants'; | ||
| export * from './csp'; | ||
| export * from './staticPath'; |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.