-
Notifications
You must be signed in to change notification settings - Fork 38
twoliter: add check-advisories task to lint BRSAs #467
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
base: develop
Are you sure you want to change the base?
Conversation
I'll update to a newer nightly rust compiler in an additional commit to this PR |
^ added a commit for updating nightly rust toolchain to e: working through
now. This is strange because as far as I can tell, |
f93c95f
to
64b8cad
Compare
^ force push adds a check to ensure that each versioned directory under |
twoliter/embedded/Makefile.toml
Outdated
grep v$(basename ${version})$ <(PAGER= git tag) | ||
if [ "$?" -ne 0 ]; then |
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.
This implies a dependency on the project this check runs against having all tags fetched. Curious for feedback on either:
- fetching tags in this check
- or, removing this as a default check and running this check as a new GitHub CI step on projects. Those projects will set
fetch-tags: true
in respectiveactions/checkout
steps
64b8cad
to
9c32cf6
Compare
^ force push handles return code from |
9c32cf6
to
1018ea5
Compare
^ force push pins |
e0c189c
to
cf07a98
Compare
^ force push based on some offline feedback from @cbgbt . We should only be linting on structured data, which in this case is a CVE or GHSA ID. Adjusted the lint to validate those IDs rather than lint entire advisory files for non-ASCII chars Also updated to latest rust nightly toolchain now that cargo-deny 0.18.1 is released with a fix for EmbarkStudios/krates#100 |
f0abf30
to
e631461
Compare
Lint BRSAs for non-ASCII characters that may be included in advisory information in a new task, check-advisories. Also ensure that each directory under "advisories" in a project has an associated tag on the project Add this to the list in the meta task "check" Signed-off-by: Gavin Inglis <[email protected]>
Update rust toolchain to the latest nightly release. Address lints and license clarifications as a result. Signed-off-by: Gavin Inglis <[email protected]>
Signed-off-by: Gavin Inglis <[email protected]>
e631461
to
276d91a
Compare
^ force push links against musl in CI for
Indicated that builds were failing due to an older glibc coming from the bottlerocket-sdk https://github.com/bottlerocket-os/bottlerocket-sdk/blob/7b29868e87346b1538403509a79c22a67a463bce/Dockerfile#L186 |
script_runner = "bash" | ||
script = [ | ||
''' | ||
if find advisories -name '*.toml' -type f >/dev/null 2>&1 ; then |
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.
if find advisories -name '*.toml' -type f >/dev/null 2>&1 ; then | |
if find ${BUILDSYS_ROOT_DIR}/advisories -name '*.toml' -type f >/dev/null 2>&1 ; then |
We should use full filepaths in case the current working directory is not set as expected. There are a few cases in here that refer to the advisories
directory that require this.
cve_regex="^cve\s+=\s+\"CVE-\d{4}-(0\d{3}|[1-9]\d{3,})\"" | ||
# Find all non-matching CVE lines and report | ||
cve_found="$(grep -L --include '*.toml' -R -P ${cve_regex} advisories | xargs awk '/cve/')" |
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.
If I understand right, these checks will fail if an advisory document contains the string cve
or ghsa
but does not contain a valid CVE or GHSA line.
I think what we actually want to do is semantically parse the advisory TOML document and check that the CVE and GHSA lines are valid, right? I think parsing with regexes like this leads to a lot of potential for surprising and valid inputs to get caught in the crossfire.
Can we at least constrain the mismatch checks to lines that start with cve
/ghsa
rather than the entirety of the document? That way we don't misfire on freeform text e.g. in an advisory description that happens to have the character string cve
in it.
In general I want to see code like this in Twoliter hoisted into Rust so that we can get unit test coverage and a higher ability to take advantage of software libraries like a toml parser. We don't really have a "recommended" way to do that. In a pinch we could probably have Twoliter provide a helper binary (oneliter
?) under tools/
to run some of these tasks, but in the longer term we probably want to express the task graph currently in Makefile.toml inside Twoliter and drop cargo-make as a dependency.
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.
Can we at least constrain the mismatch checks to lines that start with cve/ghsa rather than the entirety of the document? That way we don't misfire on freeform text e.g. in an advisory description that happens to have the character string cve in it.
You're right, the awk
half of this pipeline would break down on any inclusion of "cve"/"ghsa", including advisory descriptions. I'll modify those respective checks to match on line start.
In general I want to see code like this in Twoliter hoisted into Rust so that we can get unit test coverage and a higher ability to take advantage of software libraries like a toml parser.
I totally agree; that along with including advisory types, tools, and models in twoliter are a more robust long term effort
Chatted offline with @cbgbt . I'm going to take this approach - add a new |
Issue number:
Closes #466
Description of changes:
Lint BRSAs for CVE / GHSA IDs in a new task, check-advisories. Also ensure that each directory under "advisories" in a project has an associated tag on the project.
Add this to the list in the meta task "check"
Testing done:
[x] Run against kernel-kit with bad CVE IDs
Fixed in bottlerocket-os/bottlerocket-kernel-kit#55
[x] Run against kernel-kit with bad GHSA ID (mocked advisory)
[x] Run in a Twoliter project without an
advisories
subdirectoryAfter ASCII fixes, run against kernel-kit:
Test case of unexpected directory under
advisories/
:Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.