Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/main/java/org/dependencytrack/parser/snyk/SnykParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ public Vulnerability parse(JSONArray data, QueryManager qm, String purl, int cou
if (vulnAttributes != null && vulnAttributes.optString("type").equalsIgnoreCase("package_vulnerability")) {
// get the references of the data record (vulnerability)
final JSONObject slots = vulnAttributes.optJSONObject("slots");
if (slots != null && slots.optJSONArray("references") != null) {
vulnerability.setReferences(addReferences(slots));
if (slots != null) {
var publishedTime = jsonStringToTimestamp(slots.optString("publication_time"));
if (publishedTime != null) {
vulnerability.setPublished(Date.from(publishedTime.toInstant()));
}
if (slots.optJSONArray("references") != null) {
vulnerability.setReferences(addReferences(slots));
}
}
vulnerability.setTitle(vulnAttributes.optString("title", null));
vulnerability.setDescription(vulnAttributes.optString("description", null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ public void testAnalyzeWithRateLimiting() {
assertThat(vulnerability.getSeverity()).isEqualTo(Severity.HIGH);
assertThat(vulnerability.getCreated()).isInSameDayAs("2022-10-31");
assertThat(vulnerability.getUpdated()).isInSameDayAs("2022-11-26");
assertThat(vulnerability.getPublished()).isInSameDayAs("2022-10-31");
assertThat(vulnerability.getRecommendation()).contains("Upgrade the package version to 5.0.4,6.0.4 to fix this vulnerability");
assertThat(vulnerability.getAliases()).satisfiesExactly(
alias -> {
Expand Down