Skip to content

Commit 223caaa

Browse files
WIP stack trace censorship using the "sensitive" directive
1 parent 3243025 commit 223caaa

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

spec.html

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8355,6 +8355,17 @@ <h1>ECMAScript Function Objects</h1>
83558355
*true* if this is a strict function, *false* if this is a non-strict function.
83568356
</td>
83578357
</tr>
8358+
<tr>
8359+
<td>
8360+
[[PresentInStackTraces]]
8361+
</td>
8362+
<td>
8363+
Boolean
8364+
</td>
8365+
<td>
8366+
When *false*, this function must not have a corresponding entry in stack traces.
8367+
</td>
8368+
</tr>
83588369
<tr>
83598370
<td>
83608371
[[HasSourceTextAvailable]]
@@ -8514,7 +8525,9 @@ <h1>OrdinaryFunctionCreate ( _functionPrototype_, _sourceText_, _ParameterList_,
85148525
1. Set _F_.[[FormalParameters]] to _ParameterList_.
85158526
1. Set _F_.[[ECMAScriptCode]] to _Body_.
85168527
1. If the source text matching _Body_ is strict mode code, let _Strict_ be *true*; else let _Strict_ be *false*.
8528+
1. Set _F_.[[PresentInStackTraces]] to PresentInStackTraces of _Body_.
85178529
1. Set _F_.[[HasSourceTextAvailable]] to HasSourceTextAvailable of _Body_.
8530+
1. Assert: If _F_.[[PresentInStackTraces]] is *false*, _F_.[[HasSourceTextAvailable]] is *false*.
85188531
1. Set _F_.[[Strict]] to _Strict_.
85198532
1. If _thisMode_ is ~lexical-this~, set _F_.[[ThisMode]] to ~lexical~.
85208533
1. Else if _Strict_ is *true*, set _F_.[[ThisMode]] to ~strict~.
@@ -13638,6 +13651,18 @@ <h1>Static Semantics: AssignmentTargetType</h1>
1363813651
</emu-alg>
1363913652
</emu-clause>
1364013653

13654+
<emu-clause id="sec-callexpression-static-semantics-presentinstacktraces">
13655+
<h1>Static Semantics: PresentInStackTraces</h1>
13656+
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
13657+
<emu-grammar>CallExpression : CoverCallExpressionAndAsyncArrowHead</emu-grammar>
13658+
<emu-alg>
13659+
1. If |CallExpression| occurs within a |ScriptBody|, |ModuleBody|, or |FunctionBody| that has a Directive Prologue that contains a Sensitive Directive, return *false*.
13660+
1. If the source text matched by |CallExpression| is eval code resulting from a direct eval, then
13661+
1. Return PresentInStackTraces of the |CallExpression| whose evaluation is the direct eval.
13662+
1. Return *true*.
13663+
</emu-alg>
13664+
</emu-clause>
13665+
1364113666
<emu-clause id="sec-callexpression-static-semantics-hassourcetextavailable">
1364213667
<h1>Static Semantics: HasSourceTextAvailable</h1>
1364313668
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
@@ -13649,6 +13674,7 @@ <h1>Static Semantics: HasSourceTextAvailable</h1>
1364913674
1. Return *true*.
1365013675
</emu-alg>
1365113676
</emu-clause>
13677+
1365213678
</emu-clause>
1365313679

1365413680
<emu-clause id="sec-property-accessors">
@@ -19452,8 +19478,9 @@ <h2>Syntax</h2>
1945219478
<h1>Directive Prologues</h1>
1945319479
<p>A <dfn id="directive-prologue">Directive Prologue</dfn> is the longest sequence of |ExpressionStatement|s occurring as the initial |StatementListItem|s or |ModuleItem|s of a |FunctionBody|, a |ScriptBody|, or a |ModuleBody| and where each |ExpressionStatement| in the sequence consists entirely of a |StringLiteral| token followed by a semicolon. The semicolon may appear explicitly or may be inserted by automatic semicolon insertion. A Directive Prologue may be an empty sequence.</p>
1945419480
<p>A <dfn id="use-strict-directive">Use Strict Directive</dfn> is an |ExpressionStatement| in a Directive Prologue whose |StringLiteral| is either of the exact code point sequences `"use strict"` or `'use strict'`. A Use Strict Directive may not contain an |EscapeSequence| or |LineContinuation|.</p>
19481+
<p>A <dfn id="sensitive-directive">Sensitive Directive</dfn> is an |ExpressionStatement| in a Directive Prologue whose |StringLiteral| is either of the exact code point sequences `"sensitive"` or `'sensitive'`. A Sensitive Directive may not contain an |EscapeSequence| or |LineContinuation|.</p>
1945519482
<p>A <dfn id="hidden-implementation-directive">Hidden Implementation Directive</dfn> is an |ExpressionStatement| in a Directive Prologue whose |StringLiteral| is either of the exact code point sequences `"hide source"` or `'hide source'`. A Hidden Implementation Directive may not contain an |EscapeSequence| or |LineContinuation|.</p>
19456-
<p>A <dfn id="built-in-directive">Built-in Directive</dfn> is an |ExpressionStatement| in a Directive Prologue that is either a Use Strict Directive, or a Hidden Implementation Directive.</p>
19483+
<p>A <dfn id="built-in-directive">Built-in Directive</dfn> is an |ExpressionStatement| in a Directive Prologue that is either a Use Strict Directive, a Sensitive Directive, or a Hidden Implementation Directive.</p>
1945719484
<p>A Directive Prologue may contain duplicate Built-in Directives. However, an implementation may issue a warning if this occurs.</p>
1945819485
<emu-note>
1945919486
<p>The |ExpressionStatement|s of a Directive Prologue are evaluated normally during evaluation of the containing production. Implementations may define implementation-specific meanings for |ExpressionStatement|s in a Directive Prologue which are not a Built-in Directive. If an appropriate notification mechanism exists, an implementation should issue a warning if it encounters in a Directive Prologue an |ExpressionStatement| that is not a Built-in Directive and which does not have a meaning defined by the implementation.</p>
@@ -19642,6 +19669,19 @@ <h1>Static Semantics: ContainsUseStrict</h1>
1964219669
</emu-alg>
1964319670
</emu-clause>
1964419671

19672+
<emu-clause id="sec-function-definitions-static-semantics-presentinstacktraces">
19673+
<h1>Static Semantics: PresentInStackTraces</h1>
19674+
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
19675+
<emu-grammar>FunctionBody : FunctionStatementList</emu-grammar>
19676+
<emu-alg>
19677+
1. If the Directive Prologue of |FunctionBody| contains a Sensitive Directive, return *false*.
19678+
1. If |FunctionBody| occurs within a |ScriptBody|, |ModuleBody|, or |FunctionBody| that has a Directive Prologue that contains a Sensitive Directive, return *false*.
19679+
1. If the source text matched by |FunctionBody| is eval code resulting from a direct eval, then
19680+
1. Return PresentInStackTraces of the |CallExpression| whose evaluation is the direct eval.
19681+
1. Return *true*.
19682+
</emu-alg>
19683+
</emu-clause>
19684+
1964519685
<emu-clause id="sec-function-definitions-static-semantics-hassourcetextavailable">
1964619686
<h1>Static Semantics: HasSourceTextAvailable</h1>
1964719687
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
@@ -20055,6 +20095,18 @@ <h1>Static Semantics: ContainsUseStrict</h1>
2005520095
</emu-alg>
2005620096
</emu-clause>
2005720097

20098+
<emu-clause id="sec-arrow-function-definitions-static-semantics-presentinstacktraces">
20099+
<h1>Static Semantics: PresentInStackTraces</h1>
20100+
<emu-see-also-para op="PresentInStackTraces"></emu-see-also-para>
20101+
<emu-grammar>ExpressionBody : AssignmentExpression</emu-grammar>
20102+
<emu-alg>
20103+
1. If |ExpressionBody| occurs within a |ScriptBody|, |ModuleBody|, or |FunctionBody| that has a Directive Prologue that contains a Sensitive Directive, return *false*.
20104+
1. If the source text matched by |ExpressionBody| is eval code resulting from a direct eval, then
20105+
1. Return PresentInStackTraces of the |CallExpression| whose evaluation is the direct eval.
20106+
1. Return *true*.
20107+
</emu-alg>
20108+
</emu-clause>
20109+
2005820110
<emu-clause id="sec-arrow-function-definitions-static-semantics-hassourcetextavailable">
2005920111
<h1>Static Semantics: HasSourceTextAvailable</h1>
2006020112
<emu-see-also-para op="HasSourceTextAvailable"></emu-see-also-para>
@@ -26876,7 +26928,7 @@ <h1>Properties of Symbol Instances</h1>
2687626928
<emu-clause id="sec-error-objects">
2687726929
<h1>Error Objects</h1>
2687826930
<p>Instances of Error objects are thrown as exceptions when runtime errors occur. The Error objects may also serve as base objects for user-defined exception classes.</p>
26879-
<p>Stack trace information exposed to the running program through implementation-defined accessors such as the de facto `Error.prototype.stack` must not include any incidental attribution or position information related to functions whose [[HasSourceTextAvailable]] slot has a value of *false*. Examples of incidental attribution information are filenames, module specifiers, and URIs. Examples of incidental position information are line numbers and column numbers.</p>
26931+
<p>Stack trace information exposed to the running program through implementation-defined accessors such as the de facto `Error.prototype.stack` must not indicate the presence of functions whose [[PresentInStackTraces]] slot has a value of *false*. Additionally, stack frames from these accessors which refer to functions whose [[HasSourceTextAvailable]] slot has a value of *false* must not include any incidental attribution or position information related to the function. Examples of incidental attribution information are filenames, module specifiers, and URIs. Examples of incidental position information are line numbers and column numbers.</p>
2688026932

2688126933
<emu-clause id="sec-error-constructor">
2688226934
<h1>The Error Constructor</h1>

0 commit comments

Comments
 (0)