You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After some research this seems to be caused by Java Type erasure, specifically:
The FindingsQueryManager.getFindings method (used by the export endpoint) set the vulnerabilityAliases on the Findings object directly by placing a List in the Map<String, Object> vulnerability of the Findings object. (see line 279 in FindingsQueryManager.
Because the VulnerabilityAlias list object is set into the Object part of the MAP which loses the Type specific data and annotations (such as @JsonIgnore).
I also wrote a a quick Test function to test this: @test
public void serialises_VulnerabilityAlias() throws JsonProcessingException {
var alias = new VulnerabilityAlias();
alias.setCveId("someCveId");
alias.setSonatypeId("someSonatypeId");
alias.setGhsaId("someGhsaId");
alias.setOsvId("someOsvId");
alias.setSnykId("someSnykId");
alias.setGsdId("someGsdId");
alias.setVulnDbId("someVulnDbId");
alias.setInternalId("someInternalId");
alias.setUuid(null);
var list = new ArrayList();
list.add(alias);
Map<String, Object> vulnerability = new LinkedHashMap<String, Object>();
vulnerability.put("aliases",list);
final JSONObject root = new JSONObject();
root.put("vuln", vulnerability);
String output = root.toString();
Assert.assertTrue(output.contains("allBySource"));
}
Current Behavior
Currently if you export the findings or a project, for example over the findings /export endpoint the following JSON is generated:
Steps to Reproduce
1.call the export findings endpoint: /v1/finding/project/c6d2b597-c538-41fb-ba91-...../export
2. look at the JSON
Expected Behavior
As discussed with @nscuro on Slack: https://owasp.slack.com/archives/C6R3R32H4/p1675805664776859 it seems the allBySource element and id element should not have been included in the JSON.
After some research this seems to be caused by Java Type erasure, specifically:
The FindingsQueryManager.getFindings method (used by the export endpoint) set the vulnerabilityAliases on the Findings object directly by placing a List in the Map<String, Object> vulnerability of the Findings object. (see line 279 in FindingsQueryManager.
Because the VulnerabilityAlias list object is set into the Object part of the MAP which loses the Type specific data and annotations (such as @JsonIgnore).
I also wrote a a quick Test function to test this:
@test
public void serialises_VulnerabilityAlias() throws JsonProcessingException {
var alias = new VulnerabilityAlias();
alias.setCveId("someCveId");
alias.setSonatypeId("someSonatypeId");
alias.setGhsaId("someGhsaId");
alias.setOsvId("someOsvId");
alias.setSnykId("someSnykId");
alias.setGsdId("someGsdId");
alias.setVulnDbId("someVulnDbId");
alias.setInternalId("someInternalId");
alias.setUuid(null);
var list = new ArrayList();
list.add(alias);
Dependency-Track Version
4.7.0
Dependency-Track Distribution
Container Image
Database Server
PostgreSQL
Database Server Version
No response
Browser
Google Chrome
Checklist
The text was updated successfully, but these errors were encountered: