Skip to content

Commit 5b9a331

Browse files
authored
move stackId from vulnerability to Location (#8384)
What Does This Do Move stackId from Vulnerability to Location Motivation The RFC specifies that Location In order to link the stack with the vulnerability, we will add a stack field to the vulnerability’s location, containing the stack id in the vulnerabilities section of stacks of the span. However, this stackId was incorrectly added to the vulnerability instead of to the Location.
1 parent 0111818 commit 5b9a331

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

dd-java-agent/agent-iast/src/main/java/com/datadog/iast/Reporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ private void reportVulnerability(
8181
String stackId =
8282
addVulnerabilityStackTrace(span, String.valueOf(batch.getVulnerabilities().size()));
8383
if (stackId != null) {
84-
vulnerability.setStackId(stackId);
84+
vulnerability.getLocation().setStackId(stackId);
8585
}
8686
}
8787
}

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

+11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public final class Location {
1515

1616
@Nullable private transient String serviceName;
1717

18+
private @Nullable String stackId;
19+
1820
private Location(
1921
@Nullable final Long spanId,
2022
@Nullable final String path,
@@ -86,6 +88,15 @@ public void updateSpan(@Nullable final AgentSpan span) {
8688
}
8789
}
8890

91+
@Nullable
92+
public String getStackId() {
93+
return stackId;
94+
}
95+
96+
public void setStackId(@Nullable String stackId) {
97+
this.stackId = stackId;
98+
}
99+
89100
@Nullable
90101
private static Long spanId(@Nullable AgentSpan span) {
91102
return span != null ? span.getSpanId() : null;

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

-11
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ public final class Vulnerability {
1212

1313
private final @Nullable Evidence evidence;
1414

15-
private @Nullable String stackId;
16-
1715
private long hash;
1816

1917
public Vulnerability(@Nonnull final VulnerabilityType type, @Nonnull final Location location) {
@@ -45,15 +43,6 @@ public Evidence getEvidence() {
4543
return evidence;
4644
}
4745

48-
@Nullable
49-
public String getStackId() {
50-
return stackId;
51-
}
52-
53-
public void setStackId(@Nullable String stackId) {
54-
this.stackId = stackId;
55-
}
56-
5746
public long getHash() {
5847
return hash;
5948
}

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,9 @@ class ReporterTest extends DDSpecification {
7878
"spanId":123456,
7979
"line":1,
8080
"path": "foo",
81-
"method": "foo"
81+
"method": "foo",
82+
"stackId":"1"
8283
},
83-
"stackId":"1",
8484
"type":"WEAK_HASH"
8585
}
8686
]
@@ -187,9 +187,9 @@ class ReporterTest extends DDSpecification {
187187
"spanId":123456,
188188
"line":1,
189189
"path":"foo",
190-
"method": "foo"
190+
"method": "foo",
191+
"stackId":"1"
191192
},
192-
"stackId":"1",
193193
"type":"WEAK_HASH"
194194
},
195195
{
@@ -199,9 +199,9 @@ class ReporterTest extends DDSpecification {
199199
"spanId":123456,
200200
"line":2,
201201
"path":"foo",
202-
"method": "foo"
202+
"method": "foo",
203+
"stackId":"2"
203204
},
204-
"stackId":"2",
205205
"type":"WEAK_HASH"
206206
}
207207
]
@@ -578,7 +578,7 @@ class ReporterTest extends DDSpecification {
578578
StackTraceEvent currentStackTrace = null
579579
for (int i = 0; i < vulnerabilities.size(); i++) {
580580
for (StackTraceEvent event : batch.get("vulnerability")) {
581-
if(event.getId() == vulnerabilities[i].getStackId()) {
581+
if(event.getId() == vulnerabilities[i].getLocation().getStackId()) {
582582
currentStackTrace = event
583583
break
584584
}

0 commit comments

Comments
 (0)