Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
3c20890
Add CSAF mirroring task
lawid Sep 23, 2024
03c9778
Inject executor service, add csaf dependency
lawid Oct 29, 2024
68bc93a
Add mirror task interface, enable compiling
lawid Dec 3, 2024
a0e044c
Add base classes for csaf scanner
lawid Dec 9, 2024
44ed60e
Retrieve csaf vulns
lawid Dec 9, 2024
985bec1
Add sample mirroring
lawid Dec 10, 2024
babb05c
Switch to jvm libs, use matching shim
lawid Jan 14, 2025
51da70a
Create protobom transfer object
lawid Jan 23, 2025
4577eee
Formatting
oxisto Feb 14, 2025
703e4c5
Triggering works
oxisto Feb 14, 2025
8f56a7d
Cleanup
oxisto Feb 14, 2025
7c14db2
Filling more vulnerability information
oxisto Feb 14, 2025
c9b2ca1
Added transactional to prepare for database query
oxisto Feb 14, 2025
b541f6f
Actually loading CSAF providers from database
oxisto Feb 15, 2025
836a2e0
Persisting real CSAF documents through mirror task
oxisto Feb 15, 2025
2fc7bc5
Separate csaf sources and documents
lawid Feb 17, 2025
12de8af
Bumped version and checkstyle
oxisto Feb 17, 2025
46f81a7
Added discovery of sources from aggregator
oxisto Feb 17, 2025
c526b3a
Discovery of providers from aggregator should work now
oxisto Feb 17, 2025
1f6d1c9
Trying to set lastFetched, but does not work
oxisto Feb 17, 2025
8cc3fa5
Last fetched as instant
oxisto Feb 18, 2025
2c443d6
Updated lastFetched
oxisto Feb 18, 2025
b6aa085
Compute ID using hash of publisher namespace
oxisto Feb 18, 2025
387eca4
ID renaming
oxisto Feb 18, 2025
37c3f76
ID rename and set last fetched for aggregator
oxisto Feb 18, 2025
5da1254
Merging existing documents with the same ID
oxisto Feb 18, 2025
8987895
Prepare test
oxisto Feb 21, 2025
879dc62
Add CREATE sql
lawid Feb 21, 2025
8c8d2b4
Move psql default counter to ALTER stmt
lawid Feb 21, 2025
e7d63c8
Update schema to generated liquibase migration
lawid Feb 21, 2025
a86c4fb
Corrected schema
oxisto Feb 22, 2025
17e31ae
Mock for test works
oxisto Feb 22, 2025
53b4fa9
Adding test transaction but does not work
oxisto Feb 23, 2025
b4ccb22
Back to bigint ID
oxisto Feb 23, 2025
aa2eecc
Removed unused properties
oxisto Feb 23, 2025
6b6efbf
Moving creation of CSAF documents to api-server
oxisto Feb 23, 2025
da5a53b
Move test source
lawid Feb 23, 2025
eaa2a02
Extended CycloneDX fields from CSAF
oxisto Mar 20, 2025
4ffc0f1
Formatting
oxisto Mar 20, 2025
6fd88cc
Switching to io.csaf namespace
oxisto Apr 22, 2025
0ba7df1
Aggregator domain/url
oxisto Apr 25, 2025
aefc5ff
Fix
oxisto Apr 25, 2025
cbd1ff6
Added domain to SQL
oxisto Apr 25, 2025
df30652
Add doc retrieval
lawid May 18, 2025
9f00b32
Instantiate documents (inefficiently) and try matching components
lawid May 19, 2025
63dfcce
Properly use kotlin json decoder
lawid May 19, 2025
7ccb6f5
Provide hardcoded sample match from scanner
lawid May 19, 2025
c3b0a39
Pass protobom node to csaf-matching-jvm
lawid May 21, 2025
b53f750
Using 0.3.2
oxisto May 22, 2025
a4d410b
Include pbandk runtime
lawid May 26, 2025
a1925dd
Fix style
oxisto Jul 13, 2025
dd7419d
Mirror vulnerabilities from manually added documents
oxisto Jul 18, 2025
e885098
Setting necessary properties for matching
oxisto Jul 19, 2025
9bd0de9
Feeding more information into the matcher
oxisto Jul 19, 2025
3a7e9a2
Checkstyle
oxisto Jul 20, 2025
e83a85b
Merge remote-tracking branch 'origin/main' into csaf
oxisto Sep 16, 2025
edacb1d
Added nullable=false
oxisto Sep 18, 2025
3b570fe
Actually using config values from the database now
oxisto Sep 19, 2025
9c7828a
Services needs to be enabled
oxisto Sep 24, 2025
d16ba7f
Merge remote-tracking branch 'origin/main' into csaf
oxisto Oct 18, 2025
3d9d35c
Migrating to Advisory struct
oxisto Oct 18, 2025
44a9b07
Slightly better logic to fetch documents
oxisto Oct 19, 2025
b6a3785
Adding vendor information to protobom
oxisto Oct 20, 2025
08ac26d
Matching confidence as int
oxisto Oct 23, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.persistence.model;

import jakarta.persistence.Basic;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.io.Serializable;
import java.time.Instant;

/**
* Model for security advisories (CSAF documents).
*/
@Entity
@Table(name = "ADVISORY")
public class Advisory implements Serializable {

@Id
@Column(name = "ID")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;

/**
* A machine-readable name of the CSAF document. This is typically the "document.tracking.id" field.
*/
@Column(name = "NAME")
private String name;

/**
* The version of the CSAF document. This is typically the "document.tracking.version" field.
*/
@Column(name = "VERSION")
private String version;

/**
* The publisher (namespace) of the CSAF document. This is typically the "document.publisher.namespace" field.
*/
@Column(name = "PUBLISHER")
private String publisher;

/**
* A human-readable title for the CSAF document.
*/
@Column(name = "TITLE")
private String title;

/**
* The URL where the CSAF document can be found externally.
*/
@Column(name = "URL")
private String url;

/**
* The format of the document, e.g., "CSAF".
*/
@Column(name = "FORMAT")
private String format;

/**
* The raw content of the CSAF document, typically in JSON format.
*/
@Column(name = "CONTENT", columnDefinition = "CLOB")
@Basic(fetch = FetchType.LAZY)
private String content;

/**
* Whether the document has been marked as "seen" in the UI.
*/
@Column(name = "SEEN")
private boolean seen;

/**
* The time when the document was last fetched from the external source.
*/
@Column(name = "LASTFETCHED")
private Instant lastFetched;

public Advisory() {

Check notice on line 100 in commons-persistence/src/main/java/org/dependencytrack/persistence/model/Advisory.java

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

commons-persistence/src/main/java/org/dependencytrack/persistence/model/Advisory.java#L100

Avoid unnecessary constructors - the compiler will generate these for you
// no args for JPA
}

public long getId() {
return id;
}

public void setId(long id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getVersion() {
return version;
}

public void setVersion(String version) {
this.version = version;
}

public String getPublisher() {
return publisher;
}

public void setPublisher(String publisher) {
this.publisher = publisher;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getUrl() {
return url;
}

public void setUrl(String url) {
this.url = url;
}

public String getFormat() {
return format;
}

public void setFormat(String format) {
this.format = format;
}

public String getContent() {
return content;
}

public void setContent(String content) {
this.content = content;
}

public boolean isSeen() {
return seen;
}

public void setSeen(boolean seen) {
this.seen = seen;
}

public Instant getLastFetched() {
return lastFetched;
}

public void setLastFetched(Instant lastFetched) {
this.lastFetched = lastFetched;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public enum Source {
RETIREJS, // Retire.js
INTERNAL, // Internally-managed (and manually entered) vulnerability
SNYK, // Snyk Purl Vulnerability
OSV // Google OSV Advisories
OSV, // Google OSV Advisories
CSAF // CSAF Advisories
}

@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.persistence.repository;

import io.quarkus.hibernate.orm.panache.PanacheRepositoryBase;
import jakarta.enterprise.context.ApplicationScoped;
import org.dependencytrack.persistence.model.Advisory;

@ApplicationScoped
public class AdvisoryRepository implements PanacheRepositoryBase<Advisory, Long> {


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of Dependency-Track.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) OWASP Foundation. All Rights Reserved.
*/
package org.dependencytrack.persistence.repository;

import io.quarkus.hibernate.orm.panache.PanacheRepository;
import jakarta.enterprise.context.ApplicationScoped;
import org.dependencytrack.persistence.model.Component;

@ApplicationScoped
public class ComponentRepository implements PanacheRepository<Component> {

}
22 changes: 22 additions & 0 deletions commons-persistence/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,28 @@ ALTER TABLE public."CONFIGPROPERTY" ALTER COLUMN "ID" ADD GENERATED BY DEFAULT A
CACHE 1
);

CREATE TABLE public."ADVISORY" (
"ID" bigint NOT NULL,
"NAME" character varying(255) NOT NULL,
"VERSION" character varying(255),
"PUBLISHER" character varying(1024),
"TITLE" character varying(1024),
"URL" character varying(255),
"FORMAT" character varying(50),
"CONTENT" text,
"SEEN" boolean,
"LASTFETCHED" timestamp with time zone
);

ALTER TABLE public."ADVISORY" ALTER COLUMN "ID" ADD GENERATED BY DEFAULT AS IDENTITY (
SEQUENCE NAME public."ADVISORY_ID_seq"
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1
);

CREATE TABLE public."DEPENDENCYMETRICS" (
"COMPONENT_ID" bigint NOT NULL,
"CRITICAL" integer NOT NULL,
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,14 @@ services:
volumes:
- "postgres-data:/var/lib/postgresql/data"
restart: unless-stopped
pgadmin:
image: dpage/pgadmin4
container_name: dt-pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: [email protected]
PGADMIN_DEFAULT_PASSWORD: admin
ports:
- "5431:80"

redpanda:
image: docker.redpanda.com/redpandadata/redpanda:v24.2.17
Expand Down
9 changes: 8 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
<quarkus.wiremock.version>1.3.3</quarkus.wiremock.version>
<lib.brotli.version>0.1.2</lib.brotli.version>
<lib.versatile.version>0.7.0</lib.versatile.version>
<lib.csaf-matching-jvm.version>0.4.1</lib.csaf-matching-jvm.version>

<!-- Plugin Versions -->
<plugin.jacoco.version>0.8.13</plugin.jacoco.version>
Expand Down Expand Up @@ -222,7 +223,7 @@
<artifactId>json</artifactId>
<version>${lib.org-json.version}</version>
</dependency>

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
Expand Down Expand Up @@ -381,6 +382,12 @@
<artifactId>versatile</artifactId>
<version>${lib.versatile.version}</version>
</dependency>

<dependency>
<groupId>io.csaf</groupId>
<artifactId>csaf-matching-jvm</artifactId>
<version>${lib.csaf-matching-jvm.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
20 changes: 20 additions & 0 deletions proto/src/main/proto/org/dependencytrack/mirror/v1/csaf_data.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

import "google/protobuf/timestamp.proto";

// Public API for DependencyTrack mirroring data.
package org.dependencytrack.mirror.v1;

option java_multiple_files = true;
option java_package = "org.dependencytrack.proto.mirror.v1";

message CsafDocumentItem {
string publisher_namespace = 1;
string tracking_id = 2;
string tracking_version = 3;
string name = 4;
optional string url = 5;
optional google.protobuf.Timestamp last_fetched = 6;
bytes json_content = 7;
bool seen = 8;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ enum Scanner {
SCANNER_INTERNAL = 2;
SCANNER_OSSINDEX = 3;
SCANNER_SNYK = 4;
SCANNER_CSAF = 5;
}

message ScanCommand {
Expand Down Expand Up @@ -66,6 +67,9 @@ message ScannerResult {

// Bov identified in the scan.
org.cyclonedx.v1_6.Bom bom = 5;

// Confidence of the match per vulnerability ID.
map<string, int32> matching_confidence = 6;
}

message ScanResult {
Expand Down
9 changes: 9 additions & 0 deletions vulnerability-analyzer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-logging-json</artifactId>
</dependency>
<dependency>
<groupId>io.csaf</groupId>
<artifactId>csaf-matching-jvm</artifactId>
</dependency>
<dependency>
<groupId>pro.streem.pbandk</groupId>
<artifactId>pbandk-runtime-jvm</artifactId>
<version>0.16.0</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
Expand Down
Loading
Loading