Skip to content
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

Running snyk code test? #21

Open
vnickolov opened this issue Aug 31, 2022 · 1 comment
Open

Running snyk code test? #21

vnickolov opened this issue Aug 31, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@vnickolov
Copy link

vnickolov commented Aug 31, 2022

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
Copy link

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.

@bmvermeer bmvermeer self-assigned this Oct 21, 2024
@bmvermeer bmvermeer added the enhancement New feature or request label Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants