From 2eeb44f3facb58dacbcb2f270d4f169a2c81ee08 Mon Sep 17 00:00:00 2001 From: Bradley Farias Date: Wed, 5 Jun 2019 13:33:07 -0500 Subject: [PATCH] policy: add policy-integrity to mitigate policy tampering PR-URL: https://github.com/nodejs/node/pull/28734 Reviewed-By: Gus Caplan Reviewed-By: Richard Lau Reviewed-By: Guy Bedford Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- doc/api/cli.md | 13 ++++ doc/api/policy.md | 9 +++ doc/node.1 | 3 + lib/internal/bootstrap/pre_execution.js | 27 ++++++++ src/node_options.cc | 16 +++++ src/node_options.h | 2 + test/fixtures/policy/dep-policy.json | 7 +++ test/fixtures/policy/dep.js | 2 + test/parallel/test-policy-integrity-flag.js | 69 +++++++++++++++++++++ 9 files changed, 148 insertions(+) create mode 100644 test/fixtures/policy/dep-policy.json create mode 100644 test/fixtures/policy/dep.js create mode 100644 test/parallel/test-policy-integrity-flag.js diff --git a/doc/api/cli.md b/doc/api/cli.md index d63749819eb10b..5e60b509e310a0 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -457,6 +457,17 @@ 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` + + +> Stability: 1 - Experimental + +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`