11package datadog.trace.instrumentation.java.lang
22
3- import datadog.environment.JavaVirtualMachine
43import datadog.trace.agent.test.AgentTestRunner
54import datadog.trace.api.iast.InstrumentationBridge
65import datadog.trace.api.iast.sink.CommandInjectionModule
76import foo.bar.TestRuntimeSuite
8- import groovy.transform.CompileDynamic
9- import spock.lang.IgnoreIf
107
11- @CompileDynamic
12- @IgnoreIf (reason = " TODO: Fix for Java 25." , value = {
13- JavaVirtualMachine .isJavaVersionAtLeast(25 )
14- })
8+ import static org.mockito.Mockito.mock
9+
1510class RuntimeCallSiteTest extends AgentTestRunner {
1611
1712 @Override
@@ -21,7 +16,7 @@ class RuntimeCallSiteTest extends AgentTestRunner {
2116
2217 def ' test exec with command string' () {
2318 setup :
24- final runtime = Mock (Runtime )
19+ final runtime = mock (Runtime )
2520 CommandInjectionModule iastModule = Mock (CommandInjectionModule )
2621 final command = ' ls'
2722 InstrumentationBridge . registerIastModule(iastModule)
@@ -31,13 +26,12 @@ class RuntimeCallSiteTest extends AgentTestRunner {
3126
3227 then :
3328 1 * iastModule. onRuntimeExec(command)
34- 1 * runtime. exec(command)
3529 0 * _
3630 }
3731
3832 def ' test exec with command string and env array' () {
3933 setup :
40- final runtime = Mock (Runtime )
34+ final runtime = mock (Runtime )
4135 CommandInjectionModule iastModule = Mock (CommandInjectionModule )
4236 final command = ' ls'
4337 final env = [' DD_TRACE_DEBUG=true' ] as String []
@@ -48,13 +42,12 @@ class RuntimeCallSiteTest extends AgentTestRunner {
4842
4943 then :
5044 1 * iastModule. onRuntimeExec(env, command)
51- 1 * runtime. exec(command, env)
5245 0 * _
5346 }
5447
5548 def ' test exec with command string array' () {
5649 setup :
57- final runtime = Mock (Runtime )
50+ final runtime = mock (Runtime )
5851 CommandInjectionModule iastModule = Mock (CommandInjectionModule )
5952 final command = [' ls' , ' -lah' ] as String []
6053 InstrumentationBridge . registerIastModule(iastModule)
@@ -64,13 +57,12 @@ class RuntimeCallSiteTest extends AgentTestRunner {
6457
6558 then :
6659 1 * iastModule. onRuntimeExec(command)
67- 1 * runtime. exec(command)
6860 0 * _
6961 }
7062
7163 def ' test exec with command string array and env array' () {
7264 setup :
73- final runtime = Mock (Runtime )
65+ final runtime = mock (Runtime )
7466 CommandInjectionModule iastModule = Mock (CommandInjectionModule )
7567 final command = [' ls' , ' -lah' ] as String []
7668 final env = [' DD_TRACE_DEBUG=true' ] as String []
@@ -81,13 +73,12 @@ class RuntimeCallSiteTest extends AgentTestRunner {
8173
8274 then :
8375 1 * iastModule. onRuntimeExec(env, command)
84- 1 * runtime. exec(command, env)
8576 0 * _
8677 }
8778
8879 def ' test exec with command string and env array and dir' () {
8980 setup :
90- final runtime = Mock (Runtime )
81+ final runtime = mock (Runtime )
9182 CommandInjectionModule iastModule = Mock (CommandInjectionModule )
9283 final command = ' ls'
9384 final env = [' DD_TRACE_DEBUG=true' ] as String []
@@ -99,13 +90,12 @@ class RuntimeCallSiteTest extends AgentTestRunner {
9990
10091 then :
10192 1 * iastModule. onRuntimeExec(env, command)
102- 1 * runtime. exec(command, env, file)
10393 0 * _
10494 }
10595
10696 def ' test exec with command string array and env array and dir' () {
10797 setup :
108- final runtime = Mock (Runtime )
98+ final runtime = mock (Runtime )
10999 CommandInjectionModule iastModule = Mock (CommandInjectionModule )
110100 final command = [' ls' , ' -lah' ] as String []
111101 final env = [' DD_TRACE_DEBUG=true' ] as String []
@@ -117,7 +107,6 @@ class RuntimeCallSiteTest extends AgentTestRunner {
117107
118108 then :
119109 1 * iastModule. onRuntimeExec(env, command)
120- 1 * runtime. exec(command, env, file)
121110 0 * _
122111 }
123112}
0 commit comments