Skip to content

Commit bfe0b67

Browse files
committed
Isolate a failing assert
1 parent 1951e6f commit bfe0b67

File tree

1 file changed

+29
-28
lines changed

1 file changed

+29
-28
lines changed

dd-java-agent/instrumentation/freemarker/freemarker-2.3.24/src/test/groovy/datadog/trace/instrumentation/freemarker/StringUtilCallSiteTest.groovy

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,49 +13,50 @@ class StringUtilCallSiteTest extends AgentTestRunner {
1313
injectSysConfig("dd.iast.enabled", "true")
1414
}
1515

16-
void 'test #method'() {
17-
given:
18-
final module = Mock(PropagationModule)
19-
InstrumentationBridge.registerIastModule(module)
20-
21-
when:
22-
final result = TestStringUtilSuite.&"$method".call(args)
23-
24-
then:
25-
result == expected
26-
1 * module.taintStringIfTainted(_ as String, args[0], false, VulnerabilityMarks.XSS_MARK)
27-
0 * _
28-
29-
where:
30-
method | args | expected
31-
'HTMLEnc' | ['<htmlTag>"escape this < </htmlTag>'] | '&lt;htmlTag&gt;&quot;escape this &lt; &lt;/htmlTag&gt;'
32-
'XMLEnc' | ['<xmlTag>"escape this < </xmlTag>'] | '&lt;xmlTag&gt;&quot;escape this &lt; &lt;/xmlTag&gt;'
33-
'XHTMLEnc' | ['<htmlTag>"escape this < </htmlTag>'] | '&lt;htmlTag&gt;&quot;escape this &lt; &lt;/htmlTag&gt;'
34-
'javaStringEnc' | ['<script>function a(){console.log("escape this < ")}<script>'] | '<script>function a(){console.log(\\"escape this < \\")}<script>'
35-
'javaScriptStringEnc' | ['<script>function a(){console.log("escape this < ")}<script>'] | '<script>function a(){console.log(\\"escape this < \\")}<script>'
36-
'jsonStringEnc' | ['["a":{"b":2}]'] | '[\\"a\\":{\\"b\\":2}]'
37-
}
16+
// void 'test #method'() {
17+
// given:
18+
// final module = Mock(PropagationModule)
19+
// InstrumentationBridge.registerIastModule(module)
20+
//
21+
// when:
22+
// final result = TestStringUtilSuite.&"$method".call(args)
23+
//
24+
// then:
25+
// result == expected
26+
// 1 * module.taintStringIfTainted(_ as String, args[0], false, VulnerabilityMarks.XSS_MARK)
27+
// 0 * _
28+
//
29+
// where:
30+
// method | args | expected
31+
// 'HTMLEnc' | ['<htmlTag>"escape this < </htmlTag>'] | '&lt;htmlTag&gt;&quot;escape this &lt; &lt;/htmlTag&gt;'
32+
// 'XMLEnc' | ['<xmlTag>"escape this < </xmlTag>'] | '&lt;xmlTag&gt;&quot;escape this &lt; &lt;/xmlTag&gt;'
33+
// 'XHTMLEnc' | ['<htmlTag>"escape this < </htmlTag>'] | '&lt;htmlTag&gt;&quot;escape this &lt; &lt;/htmlTag&gt;'
34+
// 'javaStringEnc' | ['<script>function a(){console.log("escape this < ")}<script>'] | '<script>function a(){console.log(\\"escape this < \\")}<script>'
35+
// 'javaScriptStringEnc' | ['<script>function a(){console.log("escape this < ")}<script>'] | '<script>function a(){console.log(\\"escape this < \\")}<script>'
36+
// 'jsonStringEnc' | ['["a":{"b":2}]'] | '[\\"a\\":{\\"b\\":2}]'
37+
// }
3838

3939
void 'test #method with null args'() {
4040
given:
4141
final module = Mock(PropagationModule)
4242
InstrumentationBridge.registerIastModule(module)
4343

4444
when:
45+
System.out.println("---running failing test---")
4546
TestStringUtilSuite.&"$method".call(null)
4647

4748
then:
4849
def thrownException = thrown (Exception)
49-
assert thrownException.stackTrace[0].getClassName().startsWith('freemarker')
50+
assert thrownException.stackTrace[0].getClassName().startsWith('Xfreemarker')
5051
0 * _
5152

5253
where:
5354
method | ex
5455
'HTMLEnc' | _
55-
'XMLEnc' | _
56-
'XHTMLEnc' | _
57-
'javaStringEnc' | _
58-
'javaScriptStringEnc' | _
59-
'jsonStringEnc' | _
56+
// 'XMLEnc' | _
57+
// 'XHTMLEnc' | _
58+
// 'javaStringEnc' | _
59+
// 'javaScriptStringEnc' | _
60+
// 'jsonStringEnc' | _
6061
}
6162
}

0 commit comments

Comments
 (0)