-
-
Notifications
You must be signed in to change notification settings - Fork 562
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
d60d0c8
to
328639b
Compare
Signed-off-by: Jono Yang <jyang@nexb.com> Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Co-authored-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com> Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Co-authored-by: Ayan Sinha Mahapatra <ayansmahapatra@gmail.com> Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
Signed-off-by: Varsha U N <varshamaddur2006@gmail.com>
e82bc6c
to
7a785ea
Compare
@AyanSinhaMahapatra I have added everything that you told me. Please review it. |
Fixes #3561
Tasks
Signed-off-by: Varsha U N varshaun58@gmail.com