-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: Decoupling Project Analysis from Risk Score Check #12
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35f25df
chore(RiskScoreTask): remove project analyzing
af22e3b
feat(tasks): add AnalyzeProjectTask
aa8e816
feat(plugin): add analyzeProject task
77c0707
chore(plugin): remove riskScore Task from runDepTrackWorkflow
298f46c
chore(README): add analyzeProject instruction
b680857
Merge branch 'main' into refactor/riskScore_task
nvima 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
53 changes: 53 additions & 0 deletions
53
src/main/kotlin/com/liftric/dtcp/tasks/AnalyzeProjectTask.kt
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,53 @@ | ||
package com.liftric.dtcp.tasks | ||
|
||
import com.liftric.dtcp.service.DependencyTrack | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.GradleException | ||
import org.gradle.api.provider.Property | ||
import org.gradle.api.tasks.TaskAction | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
|
||
abstract class AnalyzeProjectTask : DefaultTask() { | ||
@get:Input | ||
abstract val apiKey: Property<String> | ||
|
||
@get:Input | ||
abstract val url: Property<String> | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val projectUUID: Property<String> | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val projectName: Property<String> | ||
|
||
@get:Input | ||
@get:Optional | ||
abstract val projectVersion: Property<String> | ||
|
||
@TaskAction | ||
fun analyzeProjectTask() { | ||
val apiKeyValue = apiKey.get() | ||
val urlValue = url.get() | ||
|
||
val projectUUIDValue = projectUUID.orNull | ||
val projectNameValue = projectName.orNull | ||
val projectVersionValue = projectVersion.orNull | ||
|
||
val dt = DependencyTrack(apiKeyValue, urlValue) | ||
|
||
val uuid = when { | ||
projectUUIDValue != null -> projectUUIDValue | ||
projectNameValue != null && projectVersionValue != null -> dt.getProject( | ||
projectNameValue, | ||
projectVersionValue | ||
).uuid | ||
|
||
else -> throw GradleException("Either projectUUID or projectName and projectVersion must be set") | ||
} | ||
|
||
dt.analyzeProjectFindings(uuid) | ||
} | ||
} |
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.
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.
Is the logic here
UUID || (projectName && projectVersion)
or is it(UUID && projectVersion) || (projectName && projectVersion)
?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.
It's "UUID || (projectName && projectVersion)"