-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
--policy-integrity #28734
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
--policy-integrity #28734
Changes from 8 commits
c74132c
56256e0
1678f40
949b0bd
a6924e1
3252926
ecb9153
10d47aa
3c00d15
6bee3a9
33b1b90
1d0ad10
f4ed688
17dfaea
32e4619
556907a
8bbd895
de66401
14d04ed
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,6 +426,14 @@ unless either the `--pending-deprecation` command line flag, or the | |
| are used to provide a kind of selective "early warning" mechanism that | ||
| developers may leverage to detect deprecated API usage. | ||
|
|
||
| ### `--policy-integrity=sri` | ||
| <!-- YAML | ||
| added: REPLACEME | ||
| --> | ||
|
|
||
| Instructs Node.js to error prior to running any code if the policy does not have | ||
| the specified integrity. It expects a [Subresource Integrity] string as a parameter. | ||
|
|
||
| ### `--preserve-symlinks` | ||
| <!-- YAML | ||
| added: v6.3.0 | ||
|
|
@@ -959,6 +967,7 @@ Node.js options that are allowed are: | |
| - `--no-warnings` | ||
| - `--openssl-config` | ||
| - `--pending-deprecation` | ||
| - `--policy-integrity` | ||
| - `--preserve-symlinks-main` | ||
| - `--preserve-symlinks` | ||
| - `--prof-process` | ||
|
|
@@ -1171,3 +1180,4 @@ greater than `4` (its current default value). For more information, see the | |
| [experimental ECMAScript Module]: esm.html#esm_resolve_hook | ||
| [libuv threadpool documentation]: http://docs.libuv.org/en/latest/threadpool.html | ||
| [remote code execution]: https://www.owasp.org/index.php/Code_Injection | ||
| [Subresource Integrity]: https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity | ||
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "resources": { | ||
| "./dep.js": { | ||
| "integrity": "sha512-7CMcc2oytFfMnGQaXbJk84gYWF2J7p/fmWPW7dsnJyniD+vgxtK9VAZ/22UxFOA4q5d27RoGLxSqNZ/nGCJkMw==" | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 'use strict'; | ||
| module.exports = 'The Secret Ingredient'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| 'use strict'; | ||
|
|
||
| const common = require('../common'); | ||
| if (!common.hasCrypto) | ||
| common.skip('missing crypto'); | ||
|
|
||
| const fixtures = require('../common/fixtures'); | ||
|
|
||
| const assert = require('assert'); | ||
| const { spawnSync } = require('child_process'); | ||
| const fs = require('fs'); | ||
| const crypto = require('crypto'); | ||
|
|
||
| const depPolicy = fixtures.path('policy', 'dep-policy.json'); | ||
| const dep = fixtures.path('policy', 'dep.js'); | ||
|
|
||
| const emptyHash = crypto.createHash('sha512'); | ||
| emptyHash.update(''); | ||
| const emptySRI = `sha512-${emptyHash.digest('base64')}`; | ||
| const policyHash = crypto.createHash('sha512'); | ||
| policyHash.update(fs.readFileSync(depPolicy)); | ||
| const depPolicySRI = `sha512-${policyHash.digest('base64')}`; | ||
| { | ||
| const { status, stderr } = spawnSync( | ||
| process.execPath, | ||
| [ | ||
| '--policy-integrity', emptySRI, | ||
| '--experimental-policy', depPolicy, dep, | ||
| ] | ||
| ); | ||
|
|
||
| assert.ok(stderr.includes('ERR_MANIFEST_ASSERT_INTEGRITY')); | ||
| assert.strictEqual(status, 1); | ||
| } | ||
| { | ||
| const { status, stderr } = spawnSync( | ||
| process.execPath, | ||
| [ | ||
| '--policy-integrity', '', | ||
| '--experimental-policy', depPolicy, dep, | ||
| ] | ||
| ); | ||
|
|
||
| assert.ok(stderr.includes('--policy-integrity')); | ||
| assert.strictEqual(status, 9); | ||
| } | ||
| { | ||
| const { status } = spawnSync( | ||
| process.execPath, | ||
| [ | ||
| '--policy-integrity', depPolicySRI, | ||
| '--experimental-policy', depPolicy, dep, | ||
| ] | ||
| ); | ||
|
|
||
| assert.strictEqual(status, 0); | ||
bmeck marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.