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

Possiblity to run Syft on a Dockerfile #1074

Closed
vargenau opened this issue Jun 29, 2022 · 7 comments
Closed

Possiblity to run Syft on a Dockerfile #1074

vargenau opened this issue Jun 29, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@vargenau
Copy link
Contributor

What would you like to be added:

It would be nice to be able to run Syft on a Dockerfile.

Why is this needed:

Additional context:

Tern allows this.

@vargenau vargenau added the enhancement New feature or request label Jun 29, 2022
@spiffcs spiffcs added this to OSS Jun 29, 2022
@joshbressers
Copy link
Contributor

@vargenau Do you know how tern accomplishes this?

@bureado
Copy link
Contributor

bureado commented Jul 6, 2022

In case it helps, https://github.com/tern-tools/tern/blob/main/tern/analyze/default/dockerfile/run.py

But also see moby/buildkit#2773

I would love to hear more about the use cases here. Is this something that should sit between hadolint and docker sbom? If so, why? Build tool independence? Fast inner loop? Honestly interested.

@vargenau
Copy link
Contributor Author

vargenau commented Jul 6, 2022

@vargenau Do you know how tern accomplishes this?

I do not really know. I am testing both Syft and Tern and comparing features and results.

@spiffcs spiffcs moved this to Triage (Comments or Progress Made) in OSS Jul 7, 2022
@joshbressers
Copy link
Contributor

In case it helps, https://github.com/tern-tools/tern/blob/main/tern/analyze/default/dockerfile/run.py

That process looks very heavy and error prone. I think it would make more sense given the state of all tooling to just build a dockerfile then scan it rather than having Syft try to untangle the layers

@bureado
Copy link
Contributor

bureado commented Jul 18, 2022

In case it helps, https://github.com/tern-tools/tern/blob/main/tern/analyze/default/dockerfile/run.py

That process looks very heavy and error prone. I think it would make more sense given the state of all tooling to just build a dockerfile then scan it rather than having Syft try to untangle the layers

I tend to agree.

I'm still curious about the use cases but IMHO static analysis will be extremely limited for the SBOM use case, and anything related to packages/dependencies at that level can probably be handled (if it isn't already) by linters.

There's a spectrum of dynamic analysis options (like the buildkit one mentioned above, another one that comes to mind is docker-slim) that all basically involve building the image anyway at which point running syft over the built image yields the best results.

In general, I think trying to produce an SBOM from an otherwise non-annotated Dockerfile can only yield an "envelope" SBOM, e.g., reference the base file, reference it's part of a larger codebase but not actually get into component substance without dynamic introspection at which point the OCI image has already materialized somewhere syft can catalog it.

@bureado
Copy link
Contributor

bureado commented Jul 20, 2022

@willmurphyscode
Copy link
Contributor

It looks like tern is just building the image and then analyzing it: https://github.com/tern-tools/tern/blob/717ea47be7310d055b86fb1b80d39fb472c0ddbf/tern/analyze/default/dockerfile/run.py#L177

We're closing this as "not planned" because we don't think it's correct for Syft to execute docker build on a user's behalf, and we don't think there's any great way to know what a Dockerfile will do before building it. Users who need to scan a Dockerfile they trust can docker build it, and then point Syft at the resulting image.

The reason we're taking a sort of firm stance here is this: Syft is a security tool, and it doesn't trust the artifacts it's pointed at, and building a Dockerfile requires trusting it.

@willmurphyscode willmurphyscode closed this as not planned Won't fix, can't repro, duplicate, stale Oct 17, 2024
@github-project-automation github-project-automation bot moved this to Done in OSS Oct 17, 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
Archived in project
Development

No branches or pull requests

5 participants