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

Add support for Windows containers #181

Merged
merged 30 commits into from
Aug 4, 2021
Merged

Add support for Windows containers #181

merged 30 commits into from
Aug 4, 2021

Conversation

pombredanne
Copy link
Contributor

No description provided.

@@ -61,23 +61,23 @@ def extract_layers_from_images(project, images):
Return the `errors` that may have happen during the extraction.
"""
errors = []

# FIXME: use container-inspector extract instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you provide some context and reason about this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

@JonoYang Could you enter a new issue with some details of the problem? This would have more chance to be worked on than a comment in the code.
Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tdruez there are some issues that @JonoYang uncovered in how code is being extracted AFAIRC.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pombredanne I would prefer a ticket nonetheless as those # FIXME tend to never get dealt with.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, #251 added

@@ -24,14 +24,14 @@ redis==3.5.3
gunicorn==20.1.0

# Docker
container_inspector>=3.1.2
container_inspector>=21.5.25
Copy link
Contributor

@tdruez tdruez May 27, 2021

Choose a reason for hiding this comment

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

Using >= with CalVer is problematic for API changes, see 7b7fc2b
One that would run the install at the moment would encounter issues running the docker pipeline:

'Image' object has no attribute 'base_location'

We should revert back to exact versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a container-inspector issue ... and that's my making: this ship has sailed there now and I cannot see how I can revert there.
Note that the API for this container-inspector library is fast evolving but I will thrive to keep it backward compatible as much as possible.

etc/requirements/base.txt Outdated Show resolved Hide resolved
scanpipe/pipelines/docker.py Outdated Show resolved Hide resolved
scanpipe/pipelines/windows_docker.py Outdated Show resolved Hide resolved
@tdruez
Copy link
Contributor

tdruez commented Jul 16, 2021

@JonoYang we need docstrings for all pipeline steps and pipes as parts of the documentation are automatically generated from that content.

@JonoYang
Copy link
Contributor

@tdruez Thanks for the review. I added/updated docstrings to the functions that were missing it.

scanpipe/pipes/docker.py Outdated Show resolved Hide resolved
pombredanne and others added 10 commits August 2, 2021 10:29
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
    * The windows_helper module from scancode is not available on pypi

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Create Windows specific tag_uninteresting_windows_codebase_resources function

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Change name of Docker step from "find_images_linux_distro" to "find_images_os_and_distro"

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update docstrings
    * Pin fetchcode dep

Signed-off-by: Jono Yang <jyang@nexb.com>
JonoYang and others added 13 commits August 2, 2021 10:31
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Add more file names and file extensions to be ignored
    * Update expected test results

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Create issue to track extraction issue

See #251

Signed-off-by: Philippe Ombredanne <pombredanne@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Modify regex used for Windows container analysis so it can be used outside the context of a Windows Docker image
    * Update tests

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Create pipes that ignore media files and data files with no clues
    * Update test results

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Jono Yang <jyang@nexb.com>
    * Use InstalledWindowsProgram object instead of Package

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update tests with more paths to test regex patterns

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Thomas Druez <tdruez@nexb.com>
Copy link
Contributor

@tdruez tdruez left a comment

Choose a reason for hiding this comment

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

@JonoYang good work, looks like we're almost there for the merge.
I've made a round of adjustments in a48eb4c

See my comments for a last round of code improvements.

`mimes` and `types` are taken from TypeCode:
https://github.com/nexB/typecode/blob/main/src/typecode/contenttype.py#L528
"""
mimes = (
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be directly imported from typecode.
It would require to make https://github.com/nexB/typecode/blob/main/src/typecode/contenttype.py#L528 available as a module variable.
In the short term, we can keep it as-is and enter a ticket on the typecode side.

Copy link
Contributor

Choose a reason for hiding this comment

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

@tdruez On the other hand, what if we added the is_media field from the license scan to the CodebaseResource model?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, that sounds good.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've added the is_media field to CodebaseResource, removed the part that excludes is_media from unsupported_fields in scanpipe.pipes.scancode.get_resource_info, and updated the tests results.

from scanpipe.pipes import windows


class WindowsDocker(Docker):
Copy link
Contributor

Choose a reason for hiding this comment

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

What about DockerWindows and docker_windows instead? This would keep all Docker based pipeline grouped in the UI.
I'm not sure about this though, what's your take?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it makes sense to rename the pipeline to DockerWindows for grouping.

qs.filter(lookups).update(status="ignored-not-interesting")


def tag_installed_package_files(project, root_dir_pattern, package, q_objects=[]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do not use mutable default arguments.


openjdk_versions_by_path = {}
for openjdk_codebase_resource in qs.filter(rootfs_path__regex=openjdk_root_pattern):
_, openjdk_root_path, _, _, _, openjdk_version, _, _, _ = re.split(
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

This applies to the 3 re.split() of the PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

I replaced all useage of re.split() with re.match()

    * Use re.match instead of re.split
    * Rename WindowsDocker pipeline to DockerWindows
    * Set the default value of the q_objects argument for tag_installed_package_files to be a tuple

Signed-off-by: Jono Yang <jyang@nexb.com>
    * Update test results

Signed-off-by: Jono Yang <jyang@nexb.com>
JonoYang and others added 2 commits August 3, 2021 12:38
    * Update test

Signed-off-by: Jono Yang <jyang@nexb.com>
Signed-off-by: Thomas Druez <tdruez@nexb.com>
@tdruez tdruez merged commit a7e3897 into main Aug 4, 2021
@tdruez tdruez deleted the windows-containers branch August 4, 2021 07:10
@tdruez
Copy link
Contributor

tdruez commented Aug 4, 2021

@JonoYang nice work, PR merged!
See 2645864#diff-30934e49c9b2107144b0ea45fd86cb0693bf7544f0195a3caec127e0118720a1R96 for a better fix for empty list as default parameter.

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.

3 participants