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

added support to parse labels in dockerfile #3987

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

VarshaUN
Copy link

Fixes #3561

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁

Signed-off-by: Varsha U N varshaun58@gmail.com

Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a 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/__init__.py Outdated Show resolved Hide resolved

import io
from pathlib import Path
from dockerfile_parse import DockerfileParser
Copy link
Member

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 Show resolved Hide resolved
src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
class DockerfileHandler(models.DatafileHandler):
datasource_id = 'dockerfile'
default_package_type = 'docker-image'
path_patterns = ('Dockerfile', 'containerfile', '*.dockerfile')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
src/packagedcode/dockerfileLABEL.py Outdated Show resolved Hide resolved
JonoYang and others added 10 commits December 23, 2024 21:52
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>
@VarshaUN
Copy link
Author

@AyanSinhaMahapatra I have added everything that you told me. Please review it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Treat Dockerfile and Containerfile as "non-assembled" package data, collect OCi labels
3 participants