[quality] test: unit coverage for .github/scripts/check-k0s-version.py (read, scalar, expand, main fail-closed branches) - #62
Merged
Conversation
Adds tests/unit/test_check_k0s_version.py: 42 pytest cases covering read(), scalar(), expand(), fail(), SAFE_VERSION_RE, LITERAL_VERSION_RE and every fail-closed branch of main() in .github/scripts/check-k0s-version.py. The script gates 'just validate' and the check-k0s-version pre-commit hook, but had no direct test: tests/unit/test_k0s_version.py only asserts the repository's current file contents and never executes the script, so any of its rejection paths could regress to fail-open unnoticed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: sec-check[bot] <sec-check[bot]@users.noreply.github.com>
Collaborator
|
Quality pass review: verified 42 unit test cases covering |
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.
Test Improvement
Adds
tests/unit/test_check_k0s_version.py— 42 pytest cases for.github/scripts/check-k0s-version.py.Claimed ground (files / functions)
tests/unit/test_check_k0s_version.py(only file touched — no production code).github/scripts/check-k0s-version.pyread(),scalar(),expand(),fail(),main(), plusSAFE_VERSION_REandLITERAL_VERSION_REinclude/k0s.yml->elements/k0s/k0s-bin.bst,elements/oci/k0s-sysext.bst,files/k0s/sysext/extension-release.k0s,files/os/sysupdate.d/70-k0s.transfer)Why
The script is a gate:
Justfilevalidateruns it and.pre-commit-config.yamlregisters it as thecheck-k0s-versionhook. It had no direct test.tests/unit/test_k0s_version.pyonly asserts the repository files current contents and never executes the script, so any of its ~12 fail-closed rejection paths could regress to fail-open unnoticed and the k0s sysext would silently stop updating.Coverage added
read()— contents returned; missing file exits with a repo-relative pathscalar()— double- and single-quoted values, unquoted value rejected, missing name exitsexpand()— literal passthrough, nested substitution, undefined reference, circular referencefail()— problem and fix both surfaced%{...}reference is not treated as a literal versionmain()passing path, and the comment-line exemption in the literal-version scanmain()rejections: non-filename-safe version; missing sourceurl:; hardcoded upstream tag in the URL; missingFNAME;FNAMEon the OS%{release-version}axis;FNAMEnot derived from%{k0s-version}; missing generatedVERSION_ID=; hardcodedVERSION_ID=inextension-release.k0s(flush and indented); literal k0s version in each of the three consumers; missingMatchPattern;MatchPatternwithout the.zstsuffix; prefix, suffix and over-capture drift betweenFNAMEand the sysupdate@vwildcardVerification
python3 -m pytest tests/unit -q-> 170 passed, 1 xfailed (42 new).Disjointness
Checked against the open-PR snapshot. The only open server PR is #27 (
[scanner] fix: enable PXE DDI downloads), which touches the installer/PXE export path, not the k0s version gate ortests/unit/. No other open PR namescheck-k0s-version.pyortests/unit/test_check_k0s_version.py.Filed by quality agent (hold-gated mode). Human review required — do not merge without review.
— hive: agent=quality backend=copilot model=claude-opus-5