Running `snyk code test`?
vnickolov opened this issue ยท 1 comments
vnickolov commented
Hello ๐
Is there a way to configure the plugin to run equivalent of snyk code test
which is the command for scanning the code under development rather than its depencencies?
So far we've achieved this by adding a handcrafted task, but we think it's more hack than a solution.
tasks.register('snyk-code-test', Exec) {
dependsOn ':snyk-check-binary'
workingDir rootProject.projectDir
commandLine 'snyk', 'code', 'test'
}
Thank you in advance,
Ves
Direwolfik commented
To anyone it might concern - it might be a bit better to run it like this
open class SnykCodeTask : SnykTask() {
@TaskAction
fun doCodeTestTask() {
log.debug("Snyk Test Task")
authentication()
val output = runSnykCommand("code test")
log.lifecycle(output.output)
if (output.exitcode > 0) {
throw GradleException("Snyk Test failed")
}
}
}
tasks.register<SnykCodeTask>("snyk-code-test")
this utilizes functions available in parent SnykTask
and correctly propagates all arguments provided in snyk
block.
Anyway I agree that it would be nice to have it supported out of the box.