Skip to content

Commit

Permalink
fix: serialization error directDependencies
Browse files Browse the repository at this point in the history
The "directDependency" String from the response of project/lookup can be
null.
to fix the error, we make this attribute nullable and warn the user in
GetOutdatedDependenciesTask if the project has no direct dependencies.

also fix an issue in the riskScore task, when the sbom analyse failed
and the project then has no direct dependencies.
  • Loading branch information
Patrick Mirwald committed Dec 19, 2023
1 parent 66b39c3 commit 9647309
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/liftric/dtcp/model/DependencyTrack.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ data class Project(
val version: String,
val active: Boolean,
val classifier: String,
val directDependencies: String,
val directDependencies: String? = null,
val lastInheritedRiskScore: Double? = null,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ abstract class GetOutdatedDependenciesTask : DefaultTask() {
else -> throw GradleException("Either projectUUID or projectName and projectVersion must be set")
}

if (project.directDependencies == null) {
throw GradleException("Project does not have direct dependencies")
}

val directDependencies = Json {
ignoreUnknownKeys = true
}.decodeFromString<List<DirectDependency>>(project.directDependencies)
Expand Down

0 comments on commit 9647309

Please sign in to comment.