2024-09-17 10:17:36 +02:00
|
|
|
== Why is this an issue?
|
|
|
|
|
2024-09-20 13:48:02 +02:00
|
|
|
include::../rationale.adoc[]
|
2024-09-17 10:17:36 +02:00
|
|
|
|
2024-09-20 13:48:02 +02:00
|
|
|
include::../impact.adoc[]
|
2024-09-17 10:17:36 +02:00
|
|
|
|
|
|
|
== How to fix it
|
|
|
|
|
|
|
|
=== Code examples
|
|
|
|
|
|
|
|
==== Noncompliant code example
|
|
|
|
|
|
|
|
Setting the `sandbox` property of `webPreferences` to false or setting
|
|
|
|
`nodeIntegration` to true will result in a configuration that will not be sandboxed.
|
|
|
|
|
|
|
|
[source,javascript,diff-id=1,diff-type=noncompliant]
|
|
|
|
----
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
webPreferences: {
|
|
|
|
sandbox: false // Noncompliant
|
|
|
|
}
|
|
|
|
})
|
|
|
|
----
|
|
|
|
|
|
|
|
[source,javascript,diff-id=2,diff-type=noncompliant]
|
|
|
|
----
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: true // Noncompliant
|
|
|
|
}
|
|
|
|
})
|
|
|
|
----
|
|
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
|
|
|
|
[source,javascript,diff-id=1,diff-type=compliant]
|
|
|
|
----
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
webPreferences: {
|
|
|
|
sandbox: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
----
|
|
|
|
|
|
|
|
[source,javascript,diff-id=2,diff-type=compliant]
|
|
|
|
----
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: false
|
|
|
|
}
|
|
|
|
})
|
|
|
|
----
|
|
|
|
|
|
|
|
=== How does this work?
|
|
|
|
|
|
|
|
In the compliant examples `sandbox` or `nodeIntegration` are explicitly
|
|
|
|
set to their secure value. It is also sufficient to not set any of these
|
|
|
|
properties since they will default to secure values.
|
|
|
|
|
|
|
|
//=== Pitfalls
|
|
|
|
|
|
|
|
//=== Going the extra mile
|
|
|
|
|
|
|
|
|
|
|
|
== Resources
|
2024-09-20 13:48:02 +02:00
|
|
|
|
|
|
|
include::../common/resources/docs.adoc[]
|
2024-09-17 10:17:36 +02:00
|
|
|
|
|
|
|
//=== Articles & blog posts
|
|
|
|
//=== Conference presentations
|
|
|
|
//=== Standards
|
|
|
|
//=== External coding guidelines
|
|
|
|
//=== Benchmarks
|
2024-09-20 13:48:02 +02:00
|
|
|
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Implementation Specification
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
include::../message.adoc[]
|
|
|
|
|
|
|
|
=== Highlighting
|
|
|
|
Highlight the new BrowserWindow() call.
|
|
|
|
|
|
|
|
'''
|
|
|
|
== Comments And Links
|
|
|
|
(visible only on this page)
|
|
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|