Skip to content

Commit 0786e3e

Browse files
committed
Extend vulnerability location data
1 parent b9533be commit 0786e3e

File tree

1 file changed

+17
-7
lines changed
  • dd-java-agent/agent-iast/src/main/java/com/datadog/iast/model

1 file changed

+17
-7
lines changed

dd-java-agent/agent-iast/src/main/java/com/datadog/iast/model/Location.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,50 @@ public final class Location {
1515

1616
@Nullable private transient String serviceName;
1717

18+
@Nullable private String className;
19+
1820
private Location(
1921
@Nullable final Long spanId,
2022
@Nullable final String path,
2123
final int line,
2224
@Nullable final String method,
23-
@Nullable final String serviceName) {
25+
@Nullable final String serviceName,
26+
@Nullable final String className) {
2427
this.spanId = spanId;
2528
this.path = path;
2629
this.line = line;
2730
this.method = method;
2831
this.serviceName = serviceName;
32+
this.className = className;
2933
}
3034

3135
public static Location forSpanAndStack(
3236
@Nullable final AgentSpan span, final StackTraceElement stack) {
3337
return new Location(
3438
spanId(span),
35-
stack.getClassName(),
39+
stack.getFileName(),
3640
stack.getLineNumber(),
3741
stack.getMethodName(),
38-
serviceName(span));
42+
serviceName(span),
43+
stack.getClassName());
3944
}
4045

4146
public static Location forSpanAndClassAndMethod(
4247
@Nullable final AgentSpan span, final String clazz, final String method) {
43-
return new Location(spanId(span), clazz, -1, method, serviceName(span));
48+
return new Location(spanId(span), null, -1, method, serviceName(span), clazz);
4449
}
4550

4651
public static Location forSpanAndFileAndLine(
4752
@Nullable final AgentSpan span, final String file, final int line) {
48-
return new Location(spanId(span), file, line, null, serviceName(span));
53+
return new Location(spanId(span), file, line, null, serviceName(span), null);
4954
}
5055

5156
public static Location forSpan(@Nullable final AgentSpan span) {
52-
return new Location(spanId(span), null, -1, null, serviceName(span));
57+
return new Location(spanId(span), null, -1, null, serviceName(span), null);
5358
}
5459

5560
public static Location forClassAndMethodAndLine(String clazz, String method, int currentLine) {
56-
return new Location(null, clazz, currentLine, method, null);
61+
return new Location(null, null, currentLine, method, null, clazz);
5762
}
5863

5964
public long getSpanId() {
@@ -79,6 +84,11 @@ public String getServiceName() {
7984
return serviceName;
8085
}
8186

87+
@Nullable
88+
public String getClassName() {
89+
return className;
90+
}
91+
8292
public void updateSpan(@Nullable final AgentSpan span) {
8393
if (span != null) {
8494
this.spanId = span.getSpanId();

0 commit comments

Comments
 (0)