Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
debug windows
  • Loading branch information
bmeck committed Jan 15, 2019
commit 29ee2aae98cef792e6140f2d19636a24b60d285c
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ function startup() {
const manifestURL = new URL(experimentalPolicy, cwdURL);
const fs = NativeModule.require('fs');
const src = fs.readFileSync(manifestURL, 'utf8');
NativeModule.require('internal/process/policy').setup(src, manifestURL);
NativeModule.require('internal/process/policy').setup(src, manifestURL.href);
}

const browserGlobals = !process._noBrowserGlobals;
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/policy/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
ERR_MANIFEST_INTEGRITY_MISMATCH,
ERR_MANIFEST_UNKNOWN_ONERROR,
} = require('internal/errors').codes;
const debug = require('util').debuglog('policy');
const SRI = require('internal/policy/sri');
const { SafeWeakMap } = require('internal/safe_globals');
const crypto = require('crypto');
Expand Down Expand Up @@ -60,6 +61,7 @@ class Manifest {
let url = manifestEntries[i][0];
const integrity = manifestEntries[i][1].integrity;
if (integrity != null) {
debug(`Manifest contains integrity for url ${url}`);
if (RegExpTest(kRelativeURLStringPattern, url)) {
url = new URL(url, manifestURL).href;
}
Expand Down Expand Up @@ -95,6 +97,7 @@ class Manifest {
Object.freeze(this);
}
assertIntegrity(url, content) {
debug(`Checking integrity of ${url}`);
const integrities = kIntegrities.get(this);
const realIntegrities = new Map();
if (integrities && url in integrities) {
Expand Down
8 changes: 6 additions & 2 deletions test/parallel/test-policy-integrity.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const policyToDepRelativeURLString = `./${
fs.writeFileSync(parentFilepath, parentBody);
fs.writeFileSync(depFilepath, depBody);

const tmpdirURL = pathToFileURL(tmpdir.path);
if (!tmpdirURL.pathname.endsWith('/')) {
tmpdirURL.pathname += '/';
}
function test({
shouldFail = false,
entry,
Expand All @@ -57,13 +61,13 @@ function test({
manifest.resources[url] = {
integrity: `sha256-${hash('sha256', match ? body : body + '\n')}`
};
fs.writeFileSync(new URL(url, pathToFileURL(tmpdir.path) + '/'), body);
fs.writeFileSync(new URL(url, tmpdirURL.href), body);
}
fs.writeFileSync(policyFilepath, JSON.stringify(manifest, null, 2));
const { status } = spawnSync(process.execPath, [
'--experimental-policy', policyFilepath, entry
], {
stdio: 'pipe'
stdio: 'inherit'
});
if (shouldFail) {
assert.notStrictEqual(status, 0);
Expand Down