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

feat: Glob processor for Docker images. #100

Merged
merged 1 commit into from
Aug 13, 2019
Merged

Conversation

mladkau
Copy link
Contributor

@mladkau mladkau commented Aug 9, 2019

The manifestGlobs which can be defined in the inspect() options are now interpreted. This PR adds the ability to scan a given docker images for specific files and return their content.

lsu.iterateFiles(root, (f) => {
const filepath = fspath.join(f.path, f.name);
let exclude = false;
exclusionGlobs.forEach((g) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using a for loop and break when exclude is set to true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer a function here. Normally you are right - we should break out of a loop as soon as possible. In this case the looping effort is insignificant. We'll only expect a few exclude patterns (<10) and the expensive minimatch is no longer executed once the exclude flag has been set. I prefer iterators to loops in JavaScript as variables have function score and not block scope - as such iterator functions are an effective way to avoid polluting the variable scope of the enclosing function with loop variables.


/**
* Return a subdirectory of a given DiscoveredDirectory. Create
* parent directories of the subdirectory if necessary.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I miss something but where is a parent directory is created if necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Line 84/85. In the code it is a subdir as we go bottom-up however in the comment I write from the perspective of a subdirectory - so its parents are created (hence I write "parent directories of the subdirectory")...

@mladkau mladkau self-assigned this Aug 13, 2019
@mladkau mladkau merged commit 9e4577a into master Aug 13, 2019
@mladkau mladkau deleted the feat/glob-for-docker-images branch August 13, 2019 09:33
@snyksec
Copy link

snyksec commented Aug 13, 2019

🎉 This PR is included in version 1.30.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

3 participants