-
Notifications
You must be signed in to change notification settings - Fork 64
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
Bump Go version, CI deps, fix some linter issues... #218
base: main
Are you sure you want to change the base?
Conversation
fcc7c0e
to
e2f9e99
Compare
Oops, apparently most tests are skipped (because, of course, Ubuntu does not have selinux).
Need to switch to a hosted Fedora or something like that. But that's a separate issue. Let this be draft for now. |
Of course we knew it for a long time, we just forgot :) And since actions/runner-images#2307 is quite old, I filed a new one: actions/runner-images#10802 |
LGTM, Are the SELinux tests running on Ubuntu now? |
No :( We need to switch to Fedora, I filed #220 for that. This PR still makes sense but with or without it we actually don't test much :( |
@kolyshkin wondering, would this be something that could be provided through those "actuated.dev" runners? (perhaps the "actuated.com" runners could provide a configuration with SELinux installed?) |
Current generations of arm64 servers available via cloud do not have working nested virtualisation. It may come in the future, where a standard runner could pivot into a RPM-based distro. So whilst that's not available, and GitHub may not have it on their radar to support SELinux, we could provide SELinux based runners with fedora or a fedora-like distro like Alma for x86_64 and arm64. Feel free to reach out to me to discuss options if you know of an end-user company willing to sponsor it. |
Ubuntu 20.04 is being deprecated. Signed-off-by: Kir Kolyshkin <[email protected]>
Fix the following gosec warnings in tests by using uint32 everywhere, so we don't have to do a single cast: pkg/pwalk/pwalk_test.go:29:20: G115: integer overflow conversion int -> uint32 (gosec) if count != uint32(total) { ^ pkg/pwalk/pwalk_test.go:73:15: G115: integer overflow conversion int -> uint32 (gosec) max := uint32(total / 2) ^ pkg/pwalk/pwalk_test.go:86:21: G115: integer overflow conversion int -> uint32 (gosec) if count != uint32(total) { ^ pkg/pwalkdir/pwalkdir_test.go:32:20: G115: integer overflow conversion int -> uint32 (gosec) if count != uint32(total) { ^ pkg/pwalkdir/pwalkdir_test.go:76:15: G115: integer overflow conversion int -> uint32 (gosec) max := uint32(total / 2) ^ pkg/pwalkdir/pwalkdir_test.go:89:21: G115: integer overflow conversion int -> uint32 (gosec) if count != uint32(total) { ^ While at it, - switch from atomic op (atomic.AddUint32) to atomic type (atomic.Int32) with methods, which is more error-prone; - rename max to maxFiles as the former is now a built-in function. Signed-off-by: Kir Kolyshkin <[email protected]>
Currently supported go versions are 1.22 and 1.23. Drop min and max functions now, as Go 1.21 has built-in ones. Signed-off-by: Kir Kolyshkin <[email protected]>
Most of parseLevelItem users will cast its result to int. On a 32-bit platform this means we may end up with a negative number. So, let's limit bitSize to 31 in a call to ParseUint, and return int so there are less typecasts in the code. Also, change MLS level to use int, for the same reason (less typecasts). This fixes the following gosec warnings: go-selinux/selinux_linux.go:505:30: G115: integer overflow conversion uint -> int (gosec) bitset.SetBit(bitset, int(i), 1) ^ go-selinux/selinux_linux.go:512:29: G115: integer overflow conversion uint -> int (gosec) bitset.SetBit(bitset, int(cat), 1) ^ go-selinux/selinux_linux.go:626:31: G115: integer overflow conversion uint -> int (gosec) low := "s" + strconv.Itoa(int(m.low.sens)) ^ go-selinux/selinux_linux.go:635:32: G115: integer overflow conversion uint -> int (gosec) high := "s" + strconv.Itoa(int(m.high.sens)) ^ Signed-off-by: Kir Kolyshkin <[email protected]>
Gosec doesn't like this code: go-selinux/selinux_linux.go:141:11: G115: integer overflow conversion int64 -> uint32 (gosec) if uint32(buf.Type) != uint32(unix.SELINUX_MAGIC) { ^ But it is correct because - buf.Type is int64 or int32, depending on the platform; - unix.SELINUX_MAGIC is untyped int which overflows int32 (i.e. it becomes negative). So the best type to use here is uint32. Signed-off-by: Kir Kolyshkin <[email protected]>
Gosec complains: go-selinux/selinux_linux.go:587:14: G115: integer overflow conversion uint -> int (gosec) for i := int(c.TrailingZeroBits()); i < c.BitLen(); i++ { ^ This is indeed a valid concern in case TrailingZeroBits returns a value which uses a highest bit (i.e. more than MaxInt32 or MaxInt64, depending on the platform). But I think this is highly unlikely. Signed-off-by: Kir Kolyshkin <[email protected]>
While at it, fix naked returns. Signed-off-by: Kir Kolyshkin <[email protected]>
d3c4054
to
0594972
Compare
The new version produces the following warnings: WARN [config_reader] The configuration option `linters.govet.check-shadowing` is deprecated. Please enable `shadow` instead, if you are not using `enable-all`. WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar. WARN The linter 'tenv' is deprecated (since v1.64.0) due to: Duplicate feature another linter. Replaced by usetesting. so fix the configuration accordingly. Note we do not enable copyloopvar since it requires Go 1.22 and we're currently have it set to Go 1.21 in go.mod. Also, remove "cache: false" from actions/setup-go@v5 since golangci-lint-action@v6 now relies on setup-go caching. Also, rename "deadline" to "timeout" as the former is no longer supported. Signed-off-by: Kir Kolyshkin <[email protected]>
and drop Go 1.22 as it is no longer supported. Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
The sole reason is to simplify branch protection rules, requiring just this one to be passed. I tried but could not find a way to list all other jobs, so had to add all of them manually. Signed-off-by: Kir Kolyshkin <[email protected]>
Use the oldest tagged version here, because all the functionality this package needs is in there already. Signed-off-by: Kir Kolyshkin <[email protected]>
@rhatdan @thaJeztah PTAL (the lack of selinux testing is now addressed by #221). |
This started as a bump of some CI deps but quickly got out of hand 😬
See individual commits for details. High level overview:
all-done
job;golang.org/x/sys v0.1.0
.