-
-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: CBOM support #933
Open
san-zrl
wants to merge
8
commits into
DependencyTrack:main
Choose a base branch
from
san-zrl:cbom_support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: CBOM support #933
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
febbbe6
feat: load, persist and export CBOM 1.6 data
san-zrl 26ec12e
fix: tests
san-zrl 3580ede
fix: refresh tests
san-zrl f6b2d0d
fix: MetricsMaintenanceTaskTest
san-zrl 2daae1b
fix: added tests for new model classes
san-zrl 0a578df
fix: even more tests
san-zrl 279450c
fix: coding style glitches
san-zrl 850eab9
Dropped Occurrences, added tests for crypto BOM ingestion, replaced j…
san-zrl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* 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.model; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
import javax.jdo.annotations.Column; | ||
import javax.jdo.annotations.Element; | ||
import javax.jdo.annotations.Extension; | ||
import javax.jdo.annotations.IdGeneratorStrategy; | ||
import javax.jdo.annotations.Join; | ||
import javax.jdo.annotations.Order; | ||
import javax.jdo.annotations.PersistenceCapable; | ||
import javax.jdo.annotations.Persistent; | ||
import javax.jdo.annotations.PrimaryKey; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnore; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
@PersistenceCapable(table = "CIPHER_SUITE") | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class CipherSuite implements Serializable { | ||
|
||
private static final long serialVersionUID = 8548267900098588016L; | ||
|
||
@PrimaryKey | ||
@Persistent(valueStrategy = IdGeneratorStrategy.NATIVE) | ||
@JsonIgnore | ||
private long id; | ||
|
||
@Persistent | ||
@Column(name = "NAME", jdbcType = "VARCHAR", length=64) | ||
private String name; | ||
|
||
@Persistent(table = "CIPHER_SUITE_ALGORITHM", defaultFetchGroup = "true") | ||
@Join(column = "CIPHER_SUITE_ID") | ||
@Element(column = "ALGORITHM", dependent = "true") | ||
@Order(extensions = @Extension(vendorName = "datanucleus", key = "list-ordering", value = "id ASC")) | ||
private List<String> algorithms; | ||
|
||
@Persistent(table = "CIPHER_SUITE_IDENTIFIER", defaultFetchGroup = "true") | ||
@Join(column = "CIPHER_SUITE_ID") | ||
@Element(column = "IDENTIFIER", dependent = "true") | ||
@Order(extensions = @Extension(vendorName = "datanucleus", key = "list-ordering", value = "id ASC")) | ||
private List<String> identifiers; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public List<String> getAlgorithms() { | ||
return algorithms; | ||
} | ||
|
||
public void setAlgorithms(List<String> algorithms) { | ||
this.algorithms = algorithms; | ||
} | ||
|
||
public List<String> getIdentifiers() { | ||
return identifiers; | ||
} | ||
|
||
public void setIdentifiers(List<String> identifiers) { | ||
this.identifiers = identifiers; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,5 +36,6 @@ public enum Classifier { | |
PLATFORM, | ||
DEVICE_DRIVER, | ||
MACHINE_LEARNING_MODEL, | ||
DATA | ||
DATA, | ||
CRYPTOGRAPHIC_ASSET | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at a few example CBOMs, and it strikes me that there's very little overlap of fields between "normal" components and crypto components. CycloneDX uses the same object model for both, but I'm wondering if it makes sense for us to follow that approach.
I asked about this in the CycloneDX Slack as well: https://cyclonedx.slack.com/archives/C05E2FLUTNH/p1737221163931089
A few downsides I'm seeing currently:
purl
,swidTagId
, ...), which is a bit confusing. The UI also offers users to modify those fields.cryptographic-asset
only have crypto-related fields set, and that "normal" components do not have any crypto-related fields set. The object model itself allows for invalid states, and we would have to constantly work around preventing those.IMO keeping
Component
and, say,CryptoComponent
separate would make a lot of things more clear, and it would also perform better. TheFetchGroup
issue would be easier to resolve as well. WDYT?CC @n1ckl0sk0rtge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nscuro - Thanks a lot for your comments and sorry for the late response. I'm currently caught up in some other projects so it may take a little while before I will come back with some code. Without having a deep insight yet, here is my preliminary answer on your thoughts.
Agree. As a first step, I will change the ref fields to Component references (for the time being - see below) and add a post-processing step to resolve the refs when the BOM has been loaded.
Makes sense. The CycloneDX Reference specifies components similarly to a union with a type selector. Except the name, components of type
cryptographic-asset
have not much in common with other component types. Their characteristics are specified incryptoProperties
which don't exist for other types. I'll look into this as a 2nd step.These are component ids. I guess there are so many of them because the spec authors didn't quite know if there is a unique id for components and what this would be. We plan to use the purl as id for a crypto component.