DependencyTrack / DependencyTrack/dependency-track
OpenAPI PUT api/v1/component/project/{project_uuid} - Adding functionality to define dependencies
- Dominant language
- Java
- Stars
- 4.2k
- Forks
- 811
- Avg merge
- 8h 39m
- Merged PRs (30d)
- 237
Description
### Current Behavior
When doing a bom-Upload, references between components are defined and are present in inventory-download. Example for a Spring-Component, which have been added via bom-upload (`GET api/v1/component/b2cdaf9f-65a1-42b6-9ba7-eab392081ea3`):
```json
{
"uuid": "b2cdaf9f-65a1-42b6-9ba7-eab392081ea3",
"publisher": "Spring IO",
"group": "org.springframework",
"name": "spring-core",
"directDependencies": "[{\"name\":\"spring-jcl\",\"purl\":\"pkg:maven/org.springframework/spring-jcl@5.3.39?type=jar\",\"uuid\":\"001f3a52-3456-4e42-9090-c410f7335394\",\"version\":\"5.3.39\",\"group\":\"org.springframework\",\"purlCoordinates\":\"pkg:maven/org.springframework/spring-jcl@5.3.39\",\"objectType\":\"COMPONENT\"}]"
}
```
When adding components to a different project via `PUT api/v1/component/project/{uuid}`, this dependency could not be defined.
### Adding the dependent component:
- REQUEST `PUT /api/v1/component/project/61107858-af3d-4d30-892c-cd0125abb3c6`
```json
{
"publisher": "Spring IO",
"group": "org.springframework",
"name": "spring-jcl",
"version": "5.3.39",
"purl": "pkg:maven/org.springframework/spring-jcl@5.3.39?type=jar",
"classifier": "LIBRARY"
}
```
- RESPONSE (removed empty or false fields)
```json
{
"publisher": "Spring IO",
"group": "org.springframework",
"name": "spring-jcl",
"version": "5.3.39",
"classifier": "LIBRARY",
"purl": "pkg:maven/org.springframework/spring-jcl@5.3.39?type=jar",
"project": {
"name": "Test",
"version": "1.0.0",
"classifier": "APPLICATION",
"collectionLogic": "NONE",
"uuid": "61107858-af3d-4d30-892c-cd0125abb3c6",
"active": true
},
"uuid": "81b120ae-2e3f-4d95-bff4-0e7722f61f90"
}
```
### Adding the component with dependencies to first one:
- REQUEST `PUT /api/v1/component/project/61107858-af3d-4d30-892c-cd0125abb3c6`
```json
{
"publisher": "Spring IO",
"group": "org.springframework",
"name": "spring-core",
"version": "5.3.39",
"purl": "pkg:maven/org.springframework/spring-core@5.3.39?type=jar",
"classifier": "LIBRARY",
"directDependencies": "[{\"name\":\"spring-jcl\",\"purl\":\"pkg:maven/org.springframework/spring-jcl@5.3.39?type=jar\",\"81b120ae-2e3f-4d95-bff4-0e7722f61f90\":\"\",\"version\":\"5.3.39\",\"group\":\"org.springframework\",\"purlCoordinates\":\"pkg:maven/org.springframework/spring-jcl@5.3.39\",\"objectType\":\"COMPONENT\"}]"
}
```
- RESPONSE (removed empty or false fields)
```json
{
"publisher": "Spring IO",
"group": "org.springframework",
"name": "spring-core",
"version": "5.3.39",
"classifier": "LIBRARY",
"purl": "pkg:maven/org.springframework/spring-core@5.3.39?type=jar",
"project": {
"name": "Test",
"version": "1.0.0",
"classifier": "APPLICATION",
"collectionLogic": "NONE",
"uuid": "61107858-af3d-4d30-892c-cd0125abb3c6",
"active": true
},
"uuid": "f4a18bda-7c72-4f2e-8f7e-498859ad8ad7"
}
```
### Asking for component-information
- REQUEST `GET /api/v1/component/f4a18bda-7c72-4f2e-8f7e-498859ad8ad7`
- RESPONSE
```json
{
"publisher": "Spring IO",
"group": "org.springframework",
"name": "spring-core",
"version": "5.3.39",
"classifier": "LIBRARY",
"purl": "pkg:maven/org.springframework/spring-core@5.3.39?type=jar",
"project": {
"name": "Test",
"version": "1.0.0",
"classifier": "APPLICATION",
"collectionLogic": "NONE",
"uuid": "61107858-af3d-4d30-892c-cd0125abb3c6",
"active": true
},
"uuid": "f4a18bda-7c72-4f2e-8f7e-498859ad8ad7"
}
```
### Proposed Behavior
There should be a way to define component-dependencies via `PUT /api/v1/component/project/{project_uuid}`, so that the field directDependencies in loading the component with `GET /api/v1/component/{component_uuid}` is filled. And so that the inventory download contains not only both dependencies, but their connection too.
### Checklist
- [x] I have read and understand the [contributing guidelines](https://github.com/DependencyTrack/dependency-track/blob/master/CONTRIBUTING.md#filing-issues)
- [x] I have checked the [existing issues](https://github.com/DependencyTrack/dependency-track/issues) for whether this enhancement was already requested
Contributor guide
Assessment
This issue has not been assessed yet.