Skip to content

Commit

Permalink
Bug 1905239 - Add new parameters to HostEnsureCanCompileStrings hook.…
Browse files Browse the repository at this point in the history
… r=tschuster

Currently, we do this via isRuntimeCodeGenEnabled whose single argument
is equivalent to codeString in "Dynamic Code Brand Checks" spec [1]. We
extend this hook to accept new parameters from that spec and adjust
PerformEval and CreateDynamicFunction accordingly. We don't change the
behavior for PerformShadowRealmEval [2] and WASM, i.e. we keep dummy
parameters.

[1] https://tc39.es/proposal-dynamic-code-brand-checks
[2] tc39/proposal-shadowrealm#414

Differential Revision: https://phabricator.services.mozilla.com/D229588

UltraBlame original commit: a282ae3a55f7f97440b424de73e66a3b39faee92
  • Loading branch information
marco-c committed Dec 13, 2024
1 parent 4d71ca4 commit ce54c28
Show file tree
Hide file tree
Showing 12 changed files with 2,184 additions and 43 deletions.
113 changes: 103 additions & 10 deletions caps/nsScriptSecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,24 @@ ColumnNumber
h
"
#
include
"
js
/
GCVector
.
h
"
#
include
"
js
/
Value
.
h
"
#
define
WEBAPPS_PERM_NAME
"
Expand Down Expand Up @@ -2061,7 +2079,67 @@ Handle
JSString
*
>
aCode
aCodeString
JS
:
:
CompilationType
aCompilationType
JS
:
:
Handle
<
JS
:
:
StackGCVector
<
JSString
*
>
>
aParameterStrings
JS
:
:
Handle
<
JSString
*
>
aBodyString
JS
:
:
Handle
<
JS
:
:
StackGCVector
<
JS
:
:
Value
>
>
aParameterArgs
JS
:
:
Handle
<
JS
:
:
Value
>
aBodyArg
bool
*
aOutCanCompileStrings
)
{
MOZ_ASSERT
Expand Down Expand Up @@ -2149,7 +2227,7 @@ scriptSample
init
(
cx
aCode
aCodeString
)
)
)
Expand Down Expand Up @@ -2177,9 +2255,14 @@ scriptSample
)
)
{
return
*
aOutCanCompileStrings
=
false
;
return
true
;
}
}
nsCOMPtr
Expand Down Expand Up @@ -2270,6 +2353,11 @@ if
csp
)
{
*
aOutCanCompileStrings
=
true
;
return
true
;
Expand Down Expand Up @@ -2378,6 +2466,11 @@ allowsEval
"
)
;
*
aOutCanCompileStrings
=
true
;
return
true
;
Expand Down Expand Up @@ -2497,16 +2590,11 @@ scriptSample
init
(
cx
aCode
aCodeString
)
)
)
{
JS_ClearPendingException
(
cx
)
;
return
false
;
Expand Down Expand Up @@ -2566,9 +2654,14 @@ _ns
)
;
}
return
*
aOutCanCompileStrings
=
evalOK
;
return
true
;
}
bool
nsScriptSecurityManager
Expand Down
70 changes: 67 additions & 3 deletions caps/nsScriptSecurityManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ enum
class
RuntimeCode
;
enum
class
CompilationType
;
}
#
define
Expand Down Expand Up @@ -286,12 +290,12 @@ ContentSecurityPolicyPermitsJSAction
(
JSContext
*
cx
aCx
JS
:
:
RuntimeCode
kind
aKind
JS
:
:
Expand All @@ -300,7 +304,67 @@ Handle
JSString
*
>
aCode
aCodeString
JS
:
:
CompilationType
aCompilationType
JS
:
:
Handle
<
JS
:
:
StackGCVector
<
JSString
*
>
>
aParameterStrings
JS
:
:
Handle
<
JSString
*
>
aBodyString
JS
:
:
Handle
<
JS
:
:
StackGCVector
<
JS
:
:
Value
>
>
aParameterArgs
JS
:
:
Handle
<
JS
:
:
Value
>
aBodyArg
bool
*
aOutCanCompileStrings
)
;
static
Expand Down
Loading

0 comments on commit ce54c28

Please sign in to comment.