forked from Taritsyn/JavaScriptEngineSwitcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSecurityTests.cs
More file actions
40 lines (33 loc) · 780 Bytes
/
SecurityTests.cs
File metadata and controls
40 lines (33 loc) · 780 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Xunit;
namespace JavaScriptEngineSwitcher.Tests.Node
{
public class SecurityTests : TestsBase
{
protected override string EngineName
{
get { return "NodeJsEngine"; }
}
[Fact]
public void AccessingToProcess()
{
// Arrange
const string input1 = @"typeof process === 'undefined';";
const string input2 = @"let process = this.constructor.constructor('return this.process;')();
typeof process === 'undefined';";
// Act
bool output1 = false;
bool output2 = false;
using (var jsEngine = CreateJsEngine())
{
output1 = jsEngine.Evaluate<bool>(input1);
}
using (var jsEngine = CreateJsEngine())
{
output2 = jsEngine.Evaluate<bool>(input2);
}
// Assert
Assert.True(output1);
Assert.True(output2);
}
}
}