Repository navigation
Conversation
OSVDevService.is_version_affected compared the commit hashes of GIT ranges as versions. They failed to parse, so the GIT range matched every version, including fixed ones. last_affected events were ignored, so a range ending in last_affected matched all later versions too, and only the last introduced/fixed pair of an events list was used. Skip GIT ranges, read the events of each range as a sequence of intervals that end at fixed (exclusive) or last_affected (inclusive), and raise APIAccessError if no non-GIT range is left. Refs oracle#1498 Signed-off-by: Dezhen Lu <dezhen.lu@student.uni-tuebingen.de>
|
Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application. When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated. If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes two of the three cases in #1498 for
OSVDevService.is_version_affected(), which the GitHub Actions vulnerability check (mcn_githubactions_vulnerabilities_1) uses:GITranges are no longer compared as versions. Before, their commit hashes failed to parse, the range became "from 0 with no fix", and every version matched, including fixed versions.last_affectedis now an inclusive upper bound. Before, it was ignored and every later version matched.The third case in #1498 (only the first matching
affectedentry is read) is not changed here, see "Not covered".Description of changes
is_version_affected()skips ranges with"type": "GIT". If a record has no other range for the package, it raisesAPIAccessErrorlike the existing "missing ranges" / "missing events" cases, so the check records the analysis as incomplete instead of guessing._is_version_in_events(). Eachintroducedstarts an interval that ends at the nextfixed(exclusive) orlast_affected(inclusive). An interval without an end contains all later versions. A side effect is that an events list with more than oneintroduced/fixedpair now uses all pairs. Before, only the lastintroducedand the lastfixedwere kept.introducedis treated as0, an unparsable end means "no end". This is in a second helper,_parse_event_version().Related issues
Refs #1498
How I found it
I read
is_version_affected()while looking at how the GitHub Actions check matches versions, and then ran it against the current OSV records for the "GitHub Actions" ecosystem to see which record shapes it has to handle. GHSA-5xjx-3w67-w9x9 (pypa/gh-action-pypi-publish) and the compose-lint advisories have aGITrange next to theECOSYSTEMrange, and GHSA-r4fj-r33x-8v88 useslast_affected. For these records the function returnedTruefor versions outside the affected range.Where this can show up in practice
This is my estimate.
GITrange, for examplepypa/gh-action-pypi-publish@v1.14.3, gets a finding for that advisory frommcn_githubactions_vulnerabilities_1, and the recommendation is to upgrade although it is already on the fixed version. This affects every GitHub Actions record with aGITrange. GitHub's newer advisories often have one.last_affectedgets the same kind of finding.mcn_githubactions_vulnerabilities_1fails for the repository, so a pipeline that gates on this check fails until the finding is suppressed.Testing
New cases in
tests/slsa_analyzer/package_registry/test_osv_dev.py. The records are small inline dicts with the same ranges as the real advisories, so the tests do not use the network. Therlespinasse/github-slug-actioncases put two intervals into one events list. That shape is synthetic (I did not find it in the current GitHub Actions records), the real advisory has them in twoaffectedentries.mainECOSYSTEMfixed 1.14.3 +GITrange (pypi-publish)True(fails)FalseTrueTrueECOSYSTEMintroduced 0.2.0, fixed 0.31.0 +GITrange (compose-lint)True(fails)FalseTrue(fails)FalseGITrangeTrue(fails, expectedAPIAccessError)APIAccessErrorTrueTrueTrue(fails)FalseFalse(fails)TrueFalseFalseTrueTrueFalseFalsepytest tests/slsa_analyzer/package_registry/test_osv_dev.py tests/slsa_analyzer/checks/test_github_actions_vulnerability_check.py: 45 passed. Onmainwith the new tests, 6 of them fail (the rows marked "fails").ruff format --check,ruff check,pylint --rcfile pyproject.tomlandmypy --config-file pyproject.tomlon the two changed files pass.False, pypi-publish v1.14.2 and wenxian 0.3.1 still returnTrue.macOS, Python 3.12.
Not covered
affectedentry for the same package (GHSA-7f32-hm4h-w77q forrlespinasse/github-slug-action@v2.0.0, GHSA-2c6m-6gqh-6qg3 foractions/runner). Reading all entries is what the OSV schema says. But GHSA-vqf5-2xx6-9wfm has a second entry forgithub/codeql-actionthat isintroduced: 2.26.11with nofixed, so reading all entries would report it for every current codeql-action release, including the v4 that Macaron's own workflows use. I left this out until it is clear how you want that case handled, and kept it in the issue.versionslist of anaffectedentry is still not used.GITrange are now reported as an incomplete analysis instead of a match. Mapping commit ranges to tags would be a separate change.Checklist
verifiedlabel should appear next to all of your commits on GitHub.OCA pending: I will sign the Oracle Contributor Agreement with the e-mail used in the
Signed-off-byline.