-
Notifications
You must be signed in to change notification settings - Fork 24
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: adds support for enhanced continuous scanning #46
feat: adds support for enhanced continuous scanning #46
Conversation
Thanks for this PR! It's a long-overdue enhancement. One concern I have is that this PR duplicates key code paths to handle differences in basic & enhanced scan message formats. Why don't we drop basic scan support? This action has history of breaking backwards compatibility on the |
Yeah, I'm disappointed AWS made them have different JSON structures. Makes this more complicated than it really needs to be. I could remove the basic scanning support and you could bump to version 3.0. People looking for basic scanning support could still use v2.0.1 and enhanced scanners can use v3.0. Is that what you would like to do? |
Yes please! |
My first thought was to make it a setting and assume "Basic" until a "useEnhancedScan" feature flag is set to true. Having said that, I don't use this workflow any more... whatever works best for the people using it :) |
I saw this AWS announcement, basic scanning will get some new responses soon anyway. Seems like a good time to drop support:
|
Makes sense. I'll try and finish up the PR this week. I've been pretty busy. |
BREAKING CHANGE: removes support for ECR basic scanning. Only enhanced scanning is supported.
@alexjurkiewicz I found some time today to update it. Basic scanning dependent code was removed. Let me know what you think. |
index.js
Outdated
if (err.code === 'ScanNotFoundException') { return null } | ||
throw err | ||
}) | ||
|
||
return { | ||
marker: findings.nextToken, | ||
results: findings.imageScanFindings.findings, | ||
results: findings.imageScanFindings.findings || findings.imageScanFindings.enhancedFindings, |
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.
Great stuff!
I see that you've put a friendly message for basic scanning results further into the call stack. Good idea, especially since this is a breaking change 👍
To simplify, we can pull the error check up, and only pass in enhanced findings to the action's "real logic".
Something like:
// ...existing code
}).promise().catch(
(err) => {
core.debug(`Error: ${err}`);
if (err.code === 'ScanNotFoundException') { return null }
throw err
})
// new code
if (!findings.imageScanFindings.enhancedFindings) {
throw new Error(`Basic scan not supported. Please enable enhanced scanning in ECR.`)
}
return {
marker: findings.nextToken,
results: findings.imageScanFindings.enhancedFindings,
// ...
Then you can simplify further down, like removing isEnhancedScan
and inlining getEnhancedScanFindings
.
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.
Let me know if the changes I made are what you're looking for. I moved the code to getFindings
because we have 2 functions and getFindings
is called first so that's where the enhancedScan
check should happen. The getAllFindings
is paginated which makes changing that one a little more challenging.
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.
Thank you! This looks great. If you comments from @pzi , I'll merge and cut a release ASAP
No need to wait for me. Get cutting :) |
Having said that... does the README need updating at all to make it clear it now relies on the enhanced scan and it will fail if that's not used? Might as well be upfront and not wait until people complain :) |
I've added a README update. Let me know if you think this is sufficient. |
LGTM, thanks for that! |
Sorry for the big delays. You know... life. This is merged and let's wait for bug reports from people pinned to |
Adding support for enhanced continuous scanning in ECR. This setting returns a different JSON structure which breaks the action.
This PR resolves #45
The changes are as follows:
COMPLETE
andACTIVE
are now acceptable.ACTIVE
is the status given for enhanced continuous scans.imageScanFindings.enhancedFindings
orimageScanFindings.findings
imageScanFindings.enhancedFindings.[].packageVulnerabilityDetails.vulnerabilityId
for enhanced scans.imageScanFindings.enhancedFindings.[].packageVulnerabilityDetails.vulnerablePackages
andimageScanFindings.enhancedFindings.[].packageVulnerabilityDetails.cvss