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

Support to exclude scope for Maven Projects like compile, runtime, provided or test in Syft #3130

Open
arkajnag23 opened this issue Aug 15, 2024 · 3 comments
Labels
enhancement New feature or request good-first-issue Good for newcomers

Comments

@arkajnag23
Copy link

What happened: Not able to find any support to decide or exclude what scope to be included for scanning.

What you expected to happen:
Support like how we have in Maven arguments -DincludeCompileScope=true -DincludeProvidedScope=false -DincludeRuntimeScope=true -DincludeTestScope=false

Steps to reproduce the issue:

Anything else we need to know?:

Environment:

  • Output of syft version: release tag='v1.11.0' version='1.11.0' os='linux' arch='amd64'
  • OS (e.g: cat /etc/os-release or similar):
@arkajnag23 arkajnag23 added the bug Something isn't working label Aug 15, 2024
@kzantow
Copy link
Contributor

kzantow commented Aug 28, 2024

I think this is a great idea and there are a couple paths forward.

One path is more complicated: capture java relationships for these dependencies (we are going to do this, anyway) but capture additional information including the dependency scope, and post-process relationships to exclude "development" scoped dependencies. This has the benefit that NPM has a similar issue where devDependencies often want to be excluded and could share some general logic to exclude these development-only dependencies. But there are plenty of questions with this approach, and I don't think it's going to be done in this manner especially soon.

Another path is fairly simple: we have some maven configuration (and the CLI configuration), we could simply add a MavenExcludeScopes []string property, which would map to environment variable SYFT_JAVA_MAVEN_EXCLUDE_SCOPES and when syft reads the dependencies, check the scope and exclude them and you could accomplish this more-or-less like:

SYFT_JAVA_MAVEN_EXCLUDE_SCOPES=test,runtime syft ...

Does this sound like something that would work for you?

@kzantow kzantow added enhancement New feature or request good-first-issue Good for newcomers and removed bug Something isn't working labels Aug 28, 2024
@arkajnag23
Copy link
Author

Yes @kzantow this sounds good with the second approach... It's not only scope exclusion, but providing support to exclude groups or artifacts IDs , is a great benefit to Maven Users.

@albert0815
Copy link

I would like to add my point of view to this issue. For me it would be useful to be able to differentiate between direct test dependencies and the test dependencies of the direct dependencies. I am actually interested in my test dependencies (e.g. in terms of identifying vulnerabilities or to be able to check for updates for those test dependencies). But I am not interested in the test dependencies of the transitive dependencies because I will not be in touch with them, they are not part of my build process or of my runtime environment. My direct test dependencies are part of my build process so I want to be able to report them without having the test dependencies of the transitive dependencies.

Just excluding certain scopes would not fully allow for this use case. Please consider a solution which would allow for reporting all direct and only transitive compile dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good-first-issue Good for newcomers
Projects
Status: Ready
Development

No branches or pull requests

3 participants