summaryrefslogtreecommitdiff
path: root/lib/internal/policy/sri.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/policy/sri.js')
-rw-r--r--lib/internal/policy/sri.js22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/internal/policy/sri.js b/lib/internal/policy/sri.js
index 877c96a6f7..38d7fc9e07 100644
--- a/lib/internal/policy/sri.js
+++ b/lib/internal/policy/sri.js
@@ -2,9 +2,12 @@
// Value of https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute
const {
- Object,
- RegExpPrototype,
- StringPrototype
+ ObjectDefineProperty,
+ ObjectFreeze,
+ ObjectSeal,
+ RegExpPrototypeExec,
+ RegExpPrototypeTest,
+ StringPrototypeSlice,
} = primordials;
// Returns [{algorithm, value (in base64 string), options,}]
@@ -20,10 +23,9 @@ const kHASH_EXPRESSION = `(${kHASH_ALGO})-(${kHASH_VALUE})`;
const kOPTION_EXPRESSION = `(${kVCHAR}*)`;
const kHASH_WITH_OPTIONS = `${kHASH_EXPRESSION}(?:[?](${kOPTION_EXPRESSION}))?`;
const kSRIPattern = RegExp(`(${kWSP}*)(?:${kHASH_WITH_OPTIONS})`, 'g');
-const { freeze } = Object;
-Object.seal(kSRIPattern);
+ObjectSeal(kSRIPattern);
const kAllWSP = RegExp(`^${kWSP}*$`);
-Object.seal(kAllWSP);
+ObjectSeal(kAllWSP);
const BufferFrom = require('buffer').Buffer.from;
@@ -32,7 +34,7 @@ const parse = (str) => {
let prevIndex = 0;
let match;
const entries = [];
- while (match = RegExpPrototype.exec(kSRIPattern, str)) {
+ while (match = RegExpPrototypeExec(kSRIPattern, str)) {
if (match.index !== prevIndex) {
throw new ERR_SRI_PARSE(str, str.charAt(prevIndex), prevIndex);
}
@@ -41,10 +43,10 @@ const parse = (str) => {
}
// Avoid setters being fired
- Object.defineProperty(entries, entries.length, {
+ ObjectDefineProperty(entries, entries.length, {
enumerable: true,
configurable: true,
- value: freeze({
+ value: ObjectFreeze({
__proto__: null,
algorithm: match[2],
value: BufferFrom(match[3], 'base64'),
@@ -55,7 +57,7 @@ const parse = (str) => {
}
if (prevIndex !== str.length) {
- if (!RegExpPrototype.test(kAllWSP, StringPrototype.slice(str, prevIndex))) {
+ if (!RegExpPrototypeTest(kAllWSP, StringPrototypeSlice(str, prevIndex))) {
throw new ERR_SRI_PARSE(str, str.charAt(prevIndex), prevIndex);
}
}