Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Re-block running insecure content #3808

Merged
merged 4 commits into from
Sep 9, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/extensions/brave/locales/en-US/app.properties
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ phone=Phone
email=Email
editAddress=Edit Address
editCreditCard=Edit Credit Card
denyRunInsecureContent=Stay Secure
dismissAllowRunInsecureContent=Stay Secure
allowRunInsecureContent=Load Unsafe Scripts
dismissDenyRunInsecureContent=Stay Insecure
denyRunInsecureContent=Stop Loading Unsafe Scripts
runInsecureContentWarning=This page is trying to load scripts from insecure sources. If you allow this content to run it will not be encrypted and it may transmit unencrypted data to other sites.
denyRunInsecureContentWarning=This page is currently loading scripts from insecure sources.
5 changes: 4 additions & 1 deletion docs/appActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ Change a hostPattern's config



### removeSiteSetting(hostPattern, key)
### removeSiteSetting(hostPattern, key, temp)

Removes a site setting

Expand All @@ -250,6 +250,9 @@ Removes a site setting

**key**: `string`, The config key to update

**temp**: `boolean`, Whether to change temporary or persistent
settings. defaults to false (persistent).



### updateLedgerInfo(ledgerInfo)
Expand Down
3 changes: 2 additions & 1 deletion docs/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ AppStore
httpsEverywhere: boolean,
fingerprintingProtection: boolean,
flash: (number|boolean), // approval expiration time if allowed, false if never allow
ledgerPayments: boolean // False if site should not be paid by the ledger. Defaults to true.
ledgerPayments: boolean, // False if site should not be paid by the ledger. Defaults to true.
runInsecureContent: boolean // Allow active mixed content
}
},
temporarySiteSettings: {
Expand Down
7 changes: 5 additions & 2 deletions js/actions/appActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,15 @@ const appActions = {
* Removes a site setting
* @param {string} hostPattern - The host pattern to update the config for
* @param {string} key - The config key to update
* @param {boolean} temp - Whether to change temporary or persistent
* settings. defaults to false (persistent).
*/
removeSiteSetting: function (hostPattern, key) {
removeSiteSetting: function (hostPattern, key, temp) {
AppDispatcher.dispatch({
actionType: AppConstants.APP_REMOVE_SITE_SETTING,
hostPattern,
key
key,
temporary: temp || false
})
},

Expand Down
3 changes: 3 additions & 0 deletions js/components/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ class Frame extends ImmutableComponent {
})
this.webview.addEventListener('did-finish-load', () => {
loadEnd(true)
if (this.runInsecureContent()) {
appActions.removeSiteSetting(this.origin, 'runInsecureContent', this.props.isPrivate)
}
})
this.webview.addEventListener('did-navigate-in-page', (e) => {
windowActions.setNavigated(e.url, this.props.frameKey, true)
Expand Down
39 changes: 34 additions & 5 deletions js/components/siteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,29 @@ class SiteInfo extends ImmutableComponent {
constructor () {
super()
this.onAllowRunInsecureContent = this.onAllowRunInsecureContent.bind(this)
this.onDenyRunInsecureContent = this.onDenyRunInsecureContent.bind(this)
}
onAllowRunInsecureContent () {
appActions.changeSiteSetting(siteUtil.getOrigin(this.isBlockedRunInsecureContent), 'runInsecureContent', true)
appActions.changeSiteSetting(siteUtil.getOrigin(this.isBlockedRunInsecureContent),
'runInsecureContent', true, this.isPrivate)
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.isBlockedRunInsecureContent)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the code above can also use this.location instead of this.isBlockedRunInsecureContent

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but that is more of a refactor issue so this looks good to merge now. :)

this.props.onHide()
}
onDenyRunInsecureContent () {
appActions.removeSiteSetting(siteUtil.getOrigin(this.location),
'runInsecureContent', this.isPrivate)
ipc.emit(messages.SHORTCUT_ACTIVE_FRAME_LOAD_URL, {}, this.location)
this.props.onHide()
}
get isExtendedValidation () {
return this.props.frameProps.getIn(['security', 'isExtendedValidation'])
}
get isSecure () {
return this.props.frameProps.getIn(['security', 'isSecure'])
}
get isPrivate () {
return this.props.frameProps.getIn(['isPrivate'])
}
get runInsecureContent () {
return this.props.frameProps.getIn(['security', 'runInsecureContent'])
}
Expand All @@ -37,6 +48,9 @@ class SiteInfo extends ImmutableComponent {
get partitionNumber () {
return this.props.frameProps.getIn(['partitionNumber'])
}
get location () {
return this.props.frameProps.getIn(['location'])
}
render () {
let secureIcon
if (this.isSecure && !this.runInsecureContent) {
Expand All @@ -63,19 +77,34 @@ class SiteInfo extends ImmutableComponent {
<span data-l10n-args={JSON.stringify(l10nArgs)} data-l10n-id='sessionInfo' /></li>
}

let runInsecureContentWarning = null
let runInsecureContentInfo = null
if (this.isBlockedRunInsecureContent) {
runInsecureContentWarning =
runInsecureContentInfo =
<li>
<ul>
<li><span className='runInsecureContentWarning' data-l10n-id='runInsecureContentWarning' /></li>
<li>
<Button l10nId='allowRunInsecureContent' className='secondaryAltButton allowRunInsecureContentButton' onClick={this.onAllowRunInsecureContent} />
<Button l10nId='denyRunInsecureContent' className='primaryButton denyRunInsecureContentButton' onClick={this.props.onHide} />
<Button l10nId='dismissAllowRunInsecureContent' className='primaryButton dismissAllowRunInsecureContentButton' onClick={this.props.onHide} />
</li>
</ul>
</li>
} else if (this.runInsecureContent) {
runInsecureContentInfo =
<li>
<ul>
<li><span className='denyRunInsecureContentWarning' data-l10n-id='denyRunInsecureContentWarning' /></li>
<li>
<Button l10nId='denyRunInsecureContent' className='primaryButton denyRunInsecureContentButton' onClick={this.onDenyRunInsecureContent} />
<Button l10nId='dismissDenyRunInsecureContent' className='secondaryAltButton dismissDenyRunInsecureContentButton' onClick={this.props.onHide} />
</li>
</ul>
</li>
}
// Disable in private mode for now
if (this.isPrivate) {
runInsecureContentInfo = null
}

return <Dialog onHide={this.props.onHide} className='siteInfo' isClickDismiss>
<ul onClick={(e) => e.stopPropagation()}>
Expand All @@ -86,7 +115,7 @@ class SiteInfo extends ImmutableComponent {
partitionInfo
}
{
runInsecureContentWarning
runInsecureContentInfo
}
</ul>
</Dialog>
Expand Down
1 change: 1 addition & 0 deletions js/state/contentSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ const getContentSettingsFromSiteSettings = (appState) => {
addContentSettings(contentSettings.referer, hostPattern, '*', 'allow')
}
}

return { content_settings: contentSettings }
}

Expand Down
21 changes: 13 additions & 8 deletions js/stores/appStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,15 +487,20 @@ const handleAppAction = (action) => {
handleChangeSettingAction(action.key, action.value)
break
case AppConstants.APP_CHANGE_SITE_SETTING:
let propertyName = action.temporary ? 'temporarySiteSettings' : 'siteSettings'
appState = appState.set(propertyName,
siteSettings.mergeSiteSetting(appState.get(propertyName), action.hostPattern, action.key, action.value))
break
{
let propertyName = action.temporary ? 'temporarySiteSettings' : 'siteSettings'
appState = appState.set(propertyName,
siteSettings.mergeSiteSetting(appState.get(propertyName), action.hostPattern, action.key, action.value))
break
}
case AppConstants.APP_REMOVE_SITE_SETTING:
let newSiteSettings = siteSettings.removeSiteSetting(appState.get('siteSettings'),
action.hostPattern, action.key)
appState = appState.set('siteSettings', newSiteSettings)
break
{
let propertyName = action.temporary ? 'temporarySiteSettings' : 'siteSettings'
let newSiteSettings = siteSettings.removeSiteSetting(appState.get(propertyName),
action.hostPattern, action.key)
appState = appState.set(propertyName, newSiteSettings)
break
}
case AppConstants.APP_UPDATE_LEDGER_INFO:
appState = appState.set('ledgerInfo', Immutable.fromJS(action.ledgerInfo))
break
Expand Down
Loading