Skip to content

Commit 555d652

Browse files
committed
wip
1 parent 7341d10 commit 555d652

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/sink/XssModuleTest.groovy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,45 @@ class XssModuleTest extends IastModuleImplTestBase {
155155
'/==>var<==' | VulnerabilityMarks.SQL_INJECTION_MARK| "/==>var<=="
156156
}
157157
158+
void 'class and method names are truncated when exceeding max length'() {
159+
setup:
160+
final param = mapTainted('/==>value<==', NOT_MARKED)
161+
final clazz = 'c' * 600
162+
final method = 'm' * 600
163+
164+
when:
165+
module.onXss(param, clazz, method)
166+
167+
then:
168+
1 * reporter.report(_, _) >> { args ->
169+
final vuln = args[1] as Vulnerability
170+
assertEvidence(vuln, '/==>value<==')
171+
assert vuln.location.path.length() == 500
172+
assert vuln.location.method.length() == 500
173+
assert vuln.location.path == clazz.substring(0, 500)
174+
assert vuln.location.method == method.substring(0, 500)
175+
}
176+
}
177+
178+
void 'file name is truncated when exceeding max length'() {
179+
setup:
180+
final param = mapTainted('/==>value<==', NOT_MARKED)
181+
final file = 'f' * 600
182+
final line = 42
183+
184+
when:
185+
module.onXss(param as CharSequence, file, line)
186+
187+
then:
188+
1 * reporter.report(_, _) >> { args ->
189+
final vuln = args[1] as Vulnerability
190+
assertEvidence(vuln, '/==>value<==')
191+
assert vuln.location.path.length() == 500
192+
assert vuln.location.line == line
193+
assert vuln.location.path == file.substring(0, 500)
194+
}
195+
}
196+
158197
159198
private String mapTainted(final String value, final int mark) {
160199
final result = addFromTaintFormat(ctx.taintedObjects, value, mark)

dd-smoke-tests/springboot-thymeleaf/src/test/groovy/datadog/smoketest/springboot/IastSpringBootThymeleafSmokeTest.groovy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package datadog.smoketest.springboot
22

33
import datadog.smoketest.AbstractIastServerSmokeTest
44
import okhttp3.Request
5-
import java.net.URLEncoder
65

76
import static datadog.trace.api.config.IastConfig.IAST_DEBUG_ENABLED
87
import static datadog.trace.api.config.IastConfig.IAST_DETECTION_MODE

0 commit comments

Comments
 (0)