-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Closed
Closed
--policy-integrity #28734
Changes from 3 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c74132c
policy: add policy-integrity to mitigate policy tampering
bmeck 56256e0
Update test/parallel/test-policy-integrity-flag.js
bmeck 1678f40
update cli.md and node.1 with policy-integrity flag
bmeck 949b0bd
Update doc/api/cli.md
bmeck a6924e1
Update doc/node.1
bmeck 3252926
Update doc/node.1
bmeck ecb9153
Update doc/api/cli.md
bmeck 10d47aa
explain parameter for policy-integrity
bmeck 3c00d15
Update doc/api/cli.md
bmeck 6bee3a9
Update doc/node.1
bmeck 33b1b90
nits
bmeck 1d0ad10
doc flag as experimental
bmeck f4ed688
stderr dump from CI
bmeck 17dfaea
Update test/parallel/test-policy-integrity-flag.js
bmeck 32e4619
error in CI went away
bmeck 556907a
win32 investigation continues
bmeck 8bbd895
investigating win32
bmeck de66401
add multiple integrity values for diff line endings
bmeck 14d04ed
lint-fixup
Trott 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 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"resources": { | ||
"./dep.js": { | ||
"integrity": "sha512-7CMcc2oytFfMnGQaXbJk84gYWF2J7p/fmWPW7dsnJyniD+vgxtK9VAZ/22UxFOA4q5d27RoGLxSqNZ/nGCJkMw==" | ||
} | ||
} | ||
} |
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,2 @@ | ||
'use strict'; | ||
module.exports = 'The Secret Ingredient'; |
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,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.
Show resolved
Hide resolved
|
||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be
--policy-integrity=checksum
with some explanation about the expected format of the argument (checksum
or a more appropriate word if the argument isn't actually a checksum).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it is an SRI string so we could link to that somewhere but the SRI spec is kind of not great for explaining that, would linking to mdn be fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think linking to mdn should be ok. (and rename my suggested parameter name to
sri
instead ofchecksum
).