Repository navigation
fix(linter): Make make lint run and pass again - #1202
Conversation
👷 Deploy request for urunc pending review.Visit the deploys page to approve it
|
The lint workflow moved to golangci-lint v2.15 with the Go v1.27.2 update in ee1476e, but the Makefile stayed at v2.9, which can't load a go1.27.3 module, so make lint stopped before linting. Fixes: urunc-dev#1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com>
21f8d4e to
5e4a334
Compare
cmainas
left a comment
There was a problem hiding this comment.
Thank you @martijnhoekstra for the PR.
A couple generic comments:
- I do not really see the value of using
OpenRootforXDG_RUNTIME_DIR. If this is for symlinks protection a malicious user must be already able to plant a symlink or change theXDG_RUNTIME_DIR. If this is the case, then the attacker has control over the host, which urunc considers trusted. Also, because of howprepareXDGRuntimeDiris used there is also the case of TOCTOU. So for this particular case, it would better to follow runc https://github.com/opencontainers/runc/blob/fa3163705ba9e45ca04739d89a0ef8958cab159e/main.go#L100. - The unit tests at
cmd/urunc/utils_test.gohave not been added in the Makefile or the CI and they will never get executed. Check how other unit tests are added https://github.com/urunc-dev/urunc/blob/main/Makefile#L242.
Other than that PR looks good, just a nit for a constant. Please let me know your opinion for the OpenRoot change.
There was a problem hiding this comment.
Since, we perform this change. Can we also move this const in the solo5.go file?
There was a problem hiding this comment.
Yes, but it triggers a new dupl linter warning, and wants to unify hvt and spt for solo5 into a solo5 tender if we do.
I'd suggest moving and suppressing on the file(s), or keeping it where it's now, but not merging hvt and spt into a single tender. What's your pref?
There was a problem hiding this comment.
Eventually, we should merge hvt/spt. Let's go with your suggestion. I will also open an issue to merge them in a follow up.
|
For the openRoot, it's a question of whether we add the lint suppression or do what it wants despite questionable usefulness. IMO doing what it wants is at worst harmless, and lint suppression is the more dangerous route, but it's definitely questionable, which is why I already left it as a separate commit. If we drop 5e4a334 we get the suppression back. I don't really have a strong pref Let me know your preference, and either I'll add the tests to the makefile when the openRoot stays, or I'll remove them altogether when it goes. |
The hvt and spt tenders take the same command line, and their BuildExecCmd bodies were identical, which dupl reported. Build it in one solo5ExecCmd. What is left of hvt.go and spt.go is the same thin wrapper, so dupl skips those two files. Fixes: urunc-dev#1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com>
Statfs_t.Flags is an int64 on amd64 and arm64, and the ST_* constants are untyped, so keep them as int64 instead of converting the flags to uintptr, which gosec reported as G115. Fixes: urunc-dev#1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com>
runcExec hands non-unikernel containers to runc with urunc's own arguments, and prepareXDGRuntimeDir only creates $XDG_RUNTIME_DIR/urunc for a rootless user, so G702 and G703 do not apply there. Fixes: urunc-dev#1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com>
|
I agree that suppressions should be avoided and always justified. However, the changes in |
3805f23 to
642bac1
Compare
cmainas
left a comment
There was a problem hiding this comment.
Thank you @martijnhoekstra for the fix.
The lint workflow moved to golangci-lint v2.15 with the Go v1.27.2 update in ee1476e, but the Makefile stayed at v2.9, which can't load a go1.27.3 module, so make lint stopped before linting. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
The hvt and spt tenders take the same command line, and their BuildExecCmd bodies were identical, which dupl reported. Build it in one solo5ExecCmd. What is left of hvt.go and spt.go is the same thin wrapper, so dupl skips those two files. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Statfs_t.Flags is an int64 on amd64 and arm64, and the ST_* constants are untyped, so keep them as int64 instead of converting the flags to uintptr, which gosec reported as G115. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
runcExec hands non-unikernel containers to runc with urunc's own arguments, and prepareXDGRuntimeDir only creates $XDG_RUNTIME_DIR/urunc for a rootless user, so G702 and G703 do not apply there. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
The lint workflow moved to golangci-lint v2.15 with the Go v1.27.2 update in ee1476e, but the Makefile stayed at v2.9, which can't load a go1.27.3 module, so make lint stopped before linting. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
The hvt and spt tenders take the same command line, and their BuildExecCmd bodies were identical, which dupl reported. Build it in one solo5ExecCmd. What is left of hvt.go and spt.go is the same thin wrapper, so dupl skips those two files. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Statfs_t.Flags is an int64 on amd64 and arm64, and the ST_* constants are untyped, so keep them as int64 instead of converting the flags to uintptr, which gosec reported as G115. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
runcExec hands non-unikernel containers to runc with urunc's own arguments, and prepareXDGRuntimeDir only creates $XDG_RUNTIME_DIR/urunc for a rootless user, so G702 and G703 do not apply there. PR: #1202 Fixes: #1201 Signed-off-by: Martijn <martijn.hoekstra@kiteworks.com> Reviewed-by: Charalampos Mainas <cmainas@nubificus.co.uk> Approved-by: Charalampos Mainas <cmainas@nubificus.co.uk>
Description
make lintpins golangci-lint v2.9, which can't load a go1.27.3 module, so it stops before linting. The lint workflow moved to v2.15 with the Go v1.27.2 update in ee1476e; the Makefile stayed behind. With v2.15, six findings show up that CI doesn't report because ofonly-new-issues. This PR updates the Makefile and fixes or annotates those findings, one commit each:dupl: the hvt and sptBuildExecCmdbodies were identical; both now call onesolo5ExecCmd, which also holds the separator const.duplskipshvt.goandspt.go, which are now the same thin wrapper.gosecG115 ingetUnprivilegedMountFlags: the ST_* flags are compared as int64, the type ofStatfs_t.Flagson amd64 and arm64, instead of converting the flags to uintptr.gosecG702 and G703 incmd/urunc/utils.goare annotated as false positives:runcExechands non-unikernel containers to runc with urunc's own arguments, andprepareXDGRuntimeDironly creates$XDG_RUNTIME_DIR/uruncfor a rootless user.Related issues
How was this tested?
make lint's command (golangci-lint run -v --timeout=5m) reports 0 issues.test_unikontainersas a non-root user).go build ./...passes for amd64;pkg/unikontainersalso builds and vets for arm64.make staticand Firecracker v1.7.0: all 14 specs the test machine can run pass, including the four hvt and spt Mirage specs. Skipped because the machine lacks devmapper, virtiofsd and Hyperlight: the two rumprun specs,Qemu-linux-read-file-virtiofsandHyperlight-unikraft-hello.LLM usage
Claude Opus 5.5 (
claude-opus-5-5) helped write the changes and this description, and ran the tests above. I reviewed the changes and the results.Checklist
make lint).make test_ctr,make test_nerdctl,make test_docker,make test_crictl).