-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
added support to parse labels in dockerfile #3987
base: develop
Are you sure you want to change the base?
Conversation
edd1a8d
to
c90069a
Compare
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.
@VarshaUN Thanks++
Looking good, need another round of changes and a lot more tests here for the added functionality, and this should be much better.
src/packagedcode/dockerfileLABEL.py
Outdated
|
||
import io | ||
from pathlib import Path | ||
from dockerfile_parse import DockerfileParser |
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.
https://pypi.org/project/dockerfile-parse/ is nice to use, also note that we use this at container inspector https://github.com/aboutcode-org/container-inspector/blob/main/src/container_inspector/dockerfile.py#L14C8-L14C24 as we parse dockerfiles there too. container-inspector
is also a scancode dependency, so we have to think about whether to move this code there. But overall I think this is fine here, as packagedata creation/datafile handlers should be in scancode.
I don't see this used anywhere else in scancode-toolkit, we have this in the requirements at https://github.com/aboutcode-org/scancode-toolkit/blob/develop/requirements.txt#L18 to pin the version when we import container-inspector. But we need to add dockerfile-parse here: https://github.com/aboutcode-org/scancode-toolkit/blob/develop/setup.cfg#L73 as this is not constrained at https://github.com/aboutcode-org/container-inspector/blob/main/setup.cfg#L62
src/packagedcode/dockerfileLABEL.py
Outdated
class DockerfileHandler(models.DatafileHandler): | ||
datasource_id = 'dockerfile' | ||
default_package_type = 'docker-image' | ||
path_patterns = ('Dockerfile', 'containerfile', '*.dockerfile') |
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.
We need to test the is_datafile()
here with examples from here:
- https://github.com/search?q=org.opencontainers.image+path%3A**%2FDockerfile&type=code&ref=advsearch
- https://github.com/search?q=org.opencontainers.image+path%3A**%2F*containerfile*&type=code&ref=advsearch
- https://github.com/search?q=org.opencontainers.image+path%3A**%2F*.dockerfile&type=code&ref=advsearch
Also have these as tests for parsers, choosing from more popular repos/more diverse examples of usage.
See for example other tests like this: https://github.com/aboutcode-org/scancode-toolkit/blob/develop/tests/packagedcode/test_npm.py#L445
Signed-off-by: Varsha U N <[email protected]>
Co-authored-by: Ayan Sinha Mahapatra <[email protected]> Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Co-authored-by: Ayan Sinha Mahapatra <[email protected]> Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
Signed-off-by: Varsha U N <[email protected]>
d60d0c8
to
328639b
Compare
Fixes #3561
Tasks
Signed-off-by: Varsha U N [email protected]