Skip to content

Commit 8f0c31a

Browse files
committed
refactor(ses): hostEvaluators assertions to failures
1 parent 4651175 commit 8f0c31a

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

packages/ses/src/lockdown.js

+6-12
Original file line numberDiff line numberDiff line change
@@ -279,22 +279,16 @@ export const repairIntrinsics = (options = {}) => {
279279
const noEvaluators = !evalAllowed && !functionAllowed; // eval() itself and the Function() constructor are not allowed to execute.
280280

281281
hostEvaluators === 'all' &&
282-
assert(
283-
!noEvaluators,
284-
"'hostEvaluators' was set to 'all', but the Function() constructor and eval() are not allowed to execute (SES_DIRECT_EVAL)",
285-
);
282+
noEvaluators &&
283+
Fail`'hostEvaluators' was set to 'all', but the Function() constructor and eval() are not allowed to execute (SES_DIRECT_EVAL)`;
286284

287285
hostEvaluators === 'none' &&
288-
assert(
289-
noEvaluators,
290-
"'hostEvaluators' was set to 'none', but the Function() constructor and eval() are allowed to execute (SES_DIRECT_EVAL)",
291-
);
286+
!noEvaluators &&
287+
Fail`'hostEvaluators' was set to 'none', but the Function() constructor and eval() are allowed to execute (SES_DIRECT_EVAL)`;
292288

293289
hostEvaluators === 'no-direct' &&
294-
assert(
295-
!directEvalAllowed,
296-
`'hostEvaluators' was set to 'no-direct', but ${directEvalAllowed === true ? 'direct eval is functional' : 'the Function() constructor and eval() are not allowed to execute'} (SES_DIRECT_EVAL)`,
297-
);
290+
directEvalAllowed &&
291+
Fail`'hostEvaluators' was set to 'no-direct', but ${directEvalAllowed === true ? 'direct eval is functional' : 'the Function() constructor and eval() are not allowed to execute'} (SES_DIRECT_EVAL)`;
298292

299293
// TODO: Remove '_legacy' when 'all' introduced as the new default option (breaking change).
300294
// For backwards compatibility under '_legacy', we do not error with a strict CSP, since directEvalAllowed remains undefined.

0 commit comments

Comments
 (0)