diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index aeefcb6e..e31e941f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -94,7 +94,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Install promu run: | diff --git a/.github/workflows/step_build.yml b/.github/workflows/step_build.yml index c46601bc..a37410f7 100644 --- a/.github/workflows/step_build.yml +++ b/.github/workflows/step_build.yml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Install promu run: | diff --git a/.github/workflows/step_cross-build.yml b/.github/workflows/step_cross-build.yml index 708b87e9..2235776a 100644 --- a/.github/workflows/step_cross-build.yml +++ b/.github/workflows/step_cross-build.yml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Install promu run: | diff --git a/.github/workflows/step_packaging.yml b/.github/workflows/step_packaging.yml index 0837f9ab..6b4f5aac 100644 --- a/.github/workflows/step_packaging.yml +++ b/.github/workflows/step_packaging.yml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Install nfpm run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest diff --git a/.github/workflows/step_tests-e2e.yml b/.github/workflows/step_tests-e2e.yml index 953823ec..4ac6d7e1 100644 --- a/.github/workflows/step_tests-e2e.yml +++ b/.github/workflows/step_tests-e2e.yml @@ -15,7 +15,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Setup clang 18 run: ./scripts/install_clang.sh @@ -36,7 +36,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Setup clang 18 run: ./scripts/install_clang.sh diff --git a/.github/workflows/step_tests-lint.yml b/.github/workflows/step_tests-lint.yml index 0487bfa5..338ef889 100644 --- a/.github/workflows/step_tests-lint.yml +++ b/.github/workflows/step_tests-lint.yml @@ -16,7 +16,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Create a sample object file run: | @@ -28,5 +28,5 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v9 with: - version: v2.13.2 + version: v2.15.0 args: --timeout=5m diff --git a/.github/workflows/step_tests-unit.yml b/.github/workflows/step_tests-unit.yml index 8609086b..72007df8 100644 --- a/.github/workflows/step_tests-unit.yml +++ b/.github/workflows/step_tests-unit.yml @@ -22,7 +22,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Setup clang run: ./scripts/install_clang.sh @@ -118,7 +118,7 @@ jobs: - name: Install Go uses: actions/setup-go@v7 with: - go-version: 1.26.x + go-version: 1.27.x - name: Setup clang run: ./scripts/install_clang.sh diff --git a/.promu/.promu-cgo-test.yml b/.promu/.promu-cgo-test.yml index d22d2ee8..bbc8ef48 100644 --- a/.promu/.promu-cgo-test.yml +++ b/.promu/.promu-cgo-test.yml @@ -2,7 +2,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu-cgo.yml should also be updated. - version: 1.26 + version: 1.27 cgo: true repository: path: github.com/ceems-dev/ceems diff --git a/.promu/.promu-cgo.yml b/.promu/.promu-cgo.yml index 640453fd..9c88ec87 100644 --- a/.promu/.promu-cgo.yml +++ b/.promu/.promu-cgo.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu.yml should also be updated. - version: 1.26 + version: 1.27 cgo: true repository: path: github.com/ceems-dev/ceems diff --git a/.promu/.promu-go-test.yml b/.promu/.promu-go-test.yml index d789dc82..9840656b 100644 --- a/.promu/.promu-go-test.yml +++ b/.promu/.promu-go-test.yml @@ -2,7 +2,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu-cgo.yml should also be updated. - version: 1.26 + version: 1.27 repository: path: github.com/ceems-dev/ceems build: diff --git a/.promu/.promu-go.yml b/.promu/.promu-go.yml index 653f6937..f0b5b933 100644 --- a/.promu/.promu-go.yml +++ b/.promu/.promu-go.yml @@ -1,7 +1,7 @@ go: # Whenever the Go version is updated here, .circle/config.yml and # .promu-cgo.yml should also be updated. - version: 1.26 + version: 1.27 repository: path: github.com/ceems-dev/ceems build: diff --git a/cmd/ceems_k8s_admission_controller/http/handlers_test.go b/cmd/ceems_k8s_admission_controller/http/handlers_test.go index 736bc364..fcf0c483 100644 --- a/cmd/ceems_k8s_admission_controller/http/handlers_test.go +++ b/cmd/ceems_k8s_admission_controller/http/handlers_test.go @@ -14,7 +14,6 @@ import ( "github.com/stretchr/testify/require" v1 "k8s.io/api/admission/v1" "k8s.io/api/admission/v1beta1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" ) @@ -42,11 +41,9 @@ func TestHandler(t *testing.T) { method: http.MethodPost, url: mutatePath, req: &v1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1", - }, - Response: &v1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1", + Response: &v1.AdmissionResponse{}, Request: &v1.AdmissionRequest{ Name: "name", Namespace: "ns", @@ -62,11 +59,9 @@ func TestHandler(t *testing.T) { method: http.MethodPost, url: mutatePath, req: &v1beta1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1beta1", - }, - Response: &v1beta1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1beta1", + Response: &v1beta1.AdmissionResponse{}, Request: &v1beta1.AdmissionRequest{ Name: "name", Namespace: "ns", @@ -89,11 +84,9 @@ func TestHandler(t *testing.T) { method: http.MethodPost, url: mutatePath, req: &v1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1", - }, - Response: &v1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1", + Response: &v1.AdmissionResponse{}, }, handler: handler.Serve(podsMutation), code: 400, @@ -103,11 +96,9 @@ func TestHandler(t *testing.T) { method: http.MethodPost, url: mutatePath, req: &v1beta1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1beta1", - }, - Response: &v1beta1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1beta1", + Response: &v1beta1.AdmissionResponse{}, }, handler: handler.Serve(podsMutation), code: 400, @@ -118,11 +109,9 @@ func TestHandler(t *testing.T) { url: mutatePath, handler: handler.Serve(podsValidation), req: &v1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1", - }, - Response: &v1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1", + Response: &v1.AdmissionResponse{}, Request: &v1.AdmissionRequest{ Name: "name", Namespace: "ns", @@ -137,11 +126,9 @@ func TestHandler(t *testing.T) { url: mutatePath, handler: handler.Serve(podsValidation), req: &v1beta1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1beta1", - }, - Response: &v1beta1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1beta1", + Response: &v1beta1.AdmissionResponse{}, Request: &v1beta1.AdmissionRequest{ Name: "name", Namespace: "ns", @@ -155,11 +142,9 @@ func TestHandler(t *testing.T) { method: http.MethodPost, url: mutatePath, req: &v1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1", - }, - Response: &v1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1", + Response: &v1.AdmissionResponse{}, Request: &v1.AdmissionRequest{ Name: "name", Namespace: "ns", @@ -175,11 +160,9 @@ func TestHandler(t *testing.T) { method: http.MethodPost, url: mutatePath, req: &v1beta1.AdmissionReview{ - TypeMeta: metav1.TypeMeta{ - Kind: "AdmissionReview", - APIVersion: "admission.k8s.io/v1beta1", - }, - Response: &v1beta1.AdmissionResponse{}, + Kind: "AdmissionReview", + APIVersion: "admission.k8s.io/v1beta1", + Response: &v1beta1.AdmissionResponse{}, Request: &v1beta1.AdmissionRequest{ Name: "name", Namespace: "ns", diff --git a/go.mod b/go.mod index c67f359b..224e5012 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/ceems-dev/ceems -go 1.26.0 +go 1.27.1 require ( connectrpc.com/connect v1.21.1 @@ -20,12 +20,12 @@ require ( github.com/iancoleman/strcase v0.3.0 github.com/jedib0t/go-pretty/v6 v6.8.3 github.com/jellydator/ttlcache/v3 v3.4.1 - github.com/mattn/go-sqlite3 v1.14.52 + github.com/mattn/go-sqlite3 v1.14.53 github.com/prometheus/client_golang v1.25.0 github.com/prometheus/common v0.73.1 github.com/prometheus/exporter-toolkit v0.20.0 github.com/prometheus/procfs v0.23.0 - github.com/prometheus/prometheus v0.315.1 + github.com/prometheus/prometheus v0.316.0 github.com/steiler/acls v0.1.6 github.com/stmcginnis/gofish v0.27.0 github.com/stretchr/testify v1.12.1 @@ -34,7 +34,7 @@ require ( github.com/wneessen/go-fileperm v0.2.1 github.com/zeebo/xxh3 v1.1.0 golang.org/x/crypto v0.58.0 - golang.org/x/sys v0.49.0 + golang.org/x/sys v0.50.0 google.golang.org/grpc v1.85.0 google.golang.org/protobuf v1.36.12 gopkg.in/yaml.v3 v3.0.1 @@ -60,33 +60,33 @@ require ( github.com/fxamacker/cbor/v2 v2.9.1 // indirect github.com/go-logfmt/logfmt v0.6.1 // indirect github.com/go-logr/logr v1.4.4 // indirect - github.com/go-openapi/jsonpointer v1.0.0 // indirect - github.com/go-openapi/jsonreference v1.0.0 // indirect - github.com/go-openapi/spec v0.22.9 // indirect - github.com/go-openapi/swag v0.28.0 // indirect - github.com/go-openapi/swag/cmdutils v0.28.0 // indirect - github.com/go-openapi/swag/conv v0.28.0 // indirect - github.com/go-openapi/swag/fileutils v0.28.0 // indirect - github.com/go-openapi/swag/jsonutils v0.28.0 // indirect - github.com/go-openapi/swag/loading v0.28.0 // indirect - github.com/go-openapi/swag/mangling v0.28.0 // indirect - github.com/go-openapi/swag/netutils v0.28.0 // indirect - github.com/go-openapi/swag/pools v0.28.0 // indirect - github.com/go-openapi/swag/stringutils v0.28.0 // indirect - github.com/go-openapi/swag/typeutils v0.28.0 // indirect - github.com/go-openapi/swag/yamlutils v0.28.0 // indirect + github.com/go-openapi/jsonpointer v1.0.2 // indirect + github.com/go-openapi/jsonreference v1.0.2 // indirect + github.com/go-openapi/spec v1.0.1 // indirect + github.com/go-openapi/swag v0.29.2 // indirect + github.com/go-openapi/swag/cmdutils v0.29.2 // indirect + github.com/go-openapi/swag/conv v0.29.2 // indirect + github.com/go-openapi/swag/fileutils v0.29.2 // indirect + github.com/go-openapi/swag/jsonutils v0.29.2 // indirect + github.com/go-openapi/swag/loading v0.29.2 // indirect + github.com/go-openapi/swag/mangling v0.29.2 // indirect + github.com/go-openapi/swag/netutils v0.29.2 // indirect + github.com/go-openapi/swag/pools v0.29.2 // indirect + github.com/go-openapi/swag/stringutils v0.29.2 // indirect + github.com/go-openapi/swag/typeutils v0.29.2 // indirect + github.com/go-openapi/swag/yamlutils v0.29.2 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/golang-jwt/jwt/v5 v5.3.1 // indirect github.com/google/gnostic v0.7.1 // indirect github.com/google/gnostic-models v0.7.1 // indirect - github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe // indirect + github.com/google/pprof v0.0.0-20261016150608-1facf8f91b50 // indirect github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect github.com/grafana/regexp v0.0.0-20250905093917-f7b3be9d1853 // indirect github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect github.com/ianlancetaylor/demangle v0.0.0-20251118225945-96ee0021ea0f // indirect github.com/jpillora/backoff v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.20.1 // indirect + github.com/klauspost/compress v1.20.3 // indirect github.com/klauspost/cpuid/v2 v2.2.10 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mdlayher/socket v0.6.0 // indirect @@ -120,9 +120,9 @@ require ( golang.org/x/sync v0.24.0 // indirect golang.org/x/term v0.47.0 // indirect golang.org/x/text v0.43.0 // indirect - golang.org/x/time v0.15.0 // indirect + golang.org/x/time v0.16.0 // indirect golang.org/x/tools v0.51.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect k8s.io/klog/v2 v2.140.0 // indirect diff --git a/go.sum b/go.sum index 3db9ef97..cdd399f9 100644 --- a/go.sum +++ b/go.sum @@ -56,42 +56,42 @@ github.com/go-logfmt/logfmt v0.6.1 h1:4hvbpePJKnIzH1B+8OR/JPbTx37NktoI9LE2QZBBkv github.com/go-logfmt/logfmt v0.6.1/go.mod h1:EV2pOAQoZaT1ZXZbqDl5hrymndi4SY9ED9/z6CO0XAk= github.com/go-logr/logr v1.4.4 h1:tG4xh9yMsRCAiodLVTxyrkzSZ9+o0L1Kg/+cPVcbP/8= github.com/go-logr/logr v1.4.4/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-openapi/jsonpointer v1.0.0 h1:kR9tHqY0CtZaOPVFm622dPVNhrvYpwr4uCxgL3h1H8s= -github.com/go-openapi/jsonpointer v1.0.0/go.mod h1:Z3rw7dWu1p9IgitXCFamSlA5lmDiklEB6vkaxcNZW5Y= -github.com/go-openapi/jsonreference v1.0.0 h1:jlmTr6torcd1YgDQvSfNmRtKzYDO4FGBkrAdlAVWnpY= -github.com/go-openapi/jsonreference v1.0.0/go.mod h1:jtwdyGbJk0Xhe5Y+rwtglQP6Sb1WZST4rT32LWB+sv0= -github.com/go-openapi/spec v0.22.9 h1:/vKIFDcGKp0ktZWGbym/tJEWbk6/XOEmAVU0kqKMH+w= -github.com/go-openapi/spec v0.22.9/go.mod h1:b/mNUYIOQOyIiUzUzXEE8xzyZqf93KvM9hQGP91yfl0= -github.com/go-openapi/swag v0.28.0 h1:xkgbOSKj6DZziNpyqRRAOt3GJGtgjgsd2RoyT30VWuw= -github.com/go-openapi/swag v0.28.0/go.mod h1:4qYnT3Cqr1p1VknOdPo70evN4rgQnAg6jwApHyxSGIg= -github.com/go-openapi/swag/cmdutils v0.28.0 h1:7TOeNtkYru1SG8Y34tDh9WBbLsMqGnptuxWiHREPZ4Q= -github.com/go-openapi/swag/cmdutils v0.28.0/go.mod h1:Sm1MVFMkF6guJJ+pQqHnQA3N0j9qALV3NxzDSv6bETM= -github.com/go-openapi/swag/conv v0.28.0 h1:GtqqbyFe7vR5Y7ehxG9W6/OvrSFdf1OLeTGp40TqxH8= -github.com/go-openapi/swag/conv v0.28.0/go.mod h1:mbUE+mzctnhxi864m0Q07SpN8OowD9JhxmxuYvZZD/k= -github.com/go-openapi/swag/fileutils v0.28.0 h1:Z04XWQD7R8Eq+7GnOrjovBxPPmZzsS4gt2H2GPGIViU= -github.com/go-openapi/swag/fileutils v0.28.0/go.mod h1:VvJFZLTZS0AI854gEQz5tk7dBESdLjiNUMSZ/th2ry8= -github.com/go-openapi/swag/jsonutils v0.28.0 h1:YIch6FwO7RXzeAnbO8Tu7dWBZeUEH+4nA0HXltVTnv4= -github.com/go-openapi/swag/jsonutils v0.28.0/go.mod h1:CYM3WlTUcagR2ZoHdz54di/cbBqt82tuxuXgAjxw+mg= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.28.0 h1:qV+VVUAx5Oro8WjVWpZeql7YReTKhT4smR4zhcOQZr0= -github.com/go-openapi/swag/jsonutils/fixtures_test v0.28.0/go.mod h1:mofwUWx70wvskwESqRJ//k/9kURmCgyJl5m5Ppoh5kY= -github.com/go-openapi/swag/loading v0.28.0 h1:td8QZdZC9MIYGGSnSPKShKiK22I2tU5UQvuUhIBPRLU= -github.com/go-openapi/swag/loading v0.28.0/go.mod h1:rXB0QiQX5mMveXEA7ouM4KiiM9jVJe4K6BVbwhD1M4k= -github.com/go-openapi/swag/mangling v0.28.0 h1:pH8eyeNO9SLYsTMWJrurnNfKmDa28XrlA+HePVD53VM= -github.com/go-openapi/swag/mangling v0.28.0/go.mod h1:jtBE2+V+3pILxOR7Vgce+Cwp6A2PgZbvVqfNntbVs0w= -github.com/go-openapi/swag/netutils v0.28.0 h1:YXN6TALEi2pzts8/8GNm6T61HTAZsieukGZidap989k= -github.com/go-openapi/swag/netutils v0.28.0/go.mod h1:J+WYyFMLtvtCGqa6jLv+YNUmIKI3ZRQRrvfNDMoQoEQ= -github.com/go-openapi/swag/pools v0.28.0 h1:HPMZWSAfce3rdVTFcjFiCIBtDg9h4x2QlRrHipwhxeU= -github.com/go-openapi/swag/pools v0.28.0/go.mod h1:kVQefhSK5RWuRe7BXsL8htgBPAMpN7HDGpGEknqugeE= -github.com/go-openapi/swag/stringutils v0.28.0 h1:ixsc9iYgDPubHL/8nSkbnryEHpD2VRlBMLKpQyPXcDU= -github.com/go-openapi/swag/stringutils v0.28.0/go.mod h1:lzRN95CxXmA03XcDWHLOb6nOMcxCqR5rGY0lOgsfRoM= -github.com/go-openapi/swag/typeutils v0.28.0 h1:nRBKSBXjDgf01VDPB3fWeD9nQuhCOVeIYAkUx2tbkyY= -github.com/go-openapi/swag/typeutils v0.28.0/go.mod h1:Srm0xFNRZ1Y+vCxJclo5qzx8aj+1pAKda/YfFPrG0dQ= -github.com/go-openapi/swag/yamlutils v0.28.0 h1:TV3JXH6DS46KUroDtMLAYHGkdWf5VDq3wVWFirmzROY= -github.com/go-openapi/swag/yamlutils v0.28.0/go.mod h1:x0q/yndZHEgk9Rx3DyDqzFUmHy55KTvIZldvF2dTJXs= -github.com/go-openapi/testify/enable/yaml/v2 v2.6.0 h1:gGHwAJ0R/5jU8BEGDbfRNR3hL68dAVi84WuOApp29B0= -github.com/go-openapi/testify/enable/yaml/v2 v2.6.0/go.mod h1:tY+St1SGq4NFl0QIqdTY4aEdbChAHxhyB77XQi9iJCo= -github.com/go-openapi/testify/v2 v2.6.0 h1:5PKH2HE7YJ/LuRPQGvSxBRlFXNQhSetBLlGAgUEu3ug= -github.com/go-openapi/testify/v2 v2.6.0/go.mod h1:SgsVHtfooshd0tublTtJ50FPKhujf47YRqauXXOUxfw= +github.com/go-openapi/jsonpointer v1.0.2 h1:NbW7xT2b+l7x+JefiPGDsZWsrLk1ogrz4AHK1TTzMt8= +github.com/go-openapi/jsonpointer v1.0.2/go.mod h1:N0rI4MbNKD7xAFTiHtB+5Nhrg2j/wwYg7m7Fmb4/jk8= +github.com/go-openapi/jsonreference v1.0.2 h1:oS4et8FOf3p3UQxEo4Xt0esijmBUM+F259Xl72OSZsc= +github.com/go-openapi/jsonreference v1.0.2/go.mod h1:TbUNSOo+fcorZjFaNoiSDSoaNnnZtqJtLGR1PuvE/Cs= +github.com/go-openapi/spec v1.0.1 h1:lj2vdGpNDcVgwRc6qXdw6qt/KQpCtSa9tnUH6vpDPDk= +github.com/go-openapi/spec v1.0.1/go.mod h1:M//GWQGtDUAjnP37gE6fInLgaczB+FatoipV3H1fYw8= +github.com/go-openapi/swag v0.29.2 h1:9n8frkcsuQRA0INU31VbxNxt1zBaHxrHYGEf5BUjFi4= +github.com/go-openapi/swag v0.29.2/go.mod h1:RkCiX1gCVXWgLOavDXE3ALJrQ/VO2ziiIzOUs3z10xo= +github.com/go-openapi/swag/cmdutils v0.29.2 h1:cXEzX/nWCODon251f+1HgL75/R4XXML5IZxgLCWMoro= +github.com/go-openapi/swag/cmdutils v0.29.2/go.mod h1:XziaSVzYqkDvpWXzASfWajw2YvJrLscq610O2XiyqJw= +github.com/go-openapi/swag/conv v0.29.2 h1:8c9shoB8l0QRSR6ymq1llHdBWDqpIgJfjTGHx3Vuhm0= +github.com/go-openapi/swag/conv v0.29.2/go.mod h1:AZS0YigTNf8qNtD6WqJz/N4RUNmpr76SyjFGkq4+p6Q= +github.com/go-openapi/swag/fileutils v0.29.2 h1:mdUL+Vw5ah1fO1AvFCoHeIyv7YZsCz2MN3KNqd/lLVI= +github.com/go-openapi/swag/fileutils v0.29.2/go.mod h1:7QKmmodjAebaq61lGVJa8ldLdGeMF4DSgYv8tXOGGo0= +github.com/go-openapi/swag/jsonutils v0.29.2 h1:uZNSD2/rJDYAfvsLYkykTzXuyxM3QpDKV9jhRHrMu6k= +github.com/go-openapi/swag/jsonutils v0.29.2/go.mod h1:ONTdNvj3Y+IXRzfa17E+Rgt2ns/qiSOYjIo2K7v2yDs= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2 h1:w+Fd6EBOMGlC74GYGHqCLGyb3Bpams8TtNrgM/SG4jo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.29.2/go.mod h1:HC2egPORFzbj/gf05Zrfgz8Mgplx3oW7hgGi7pjZVhM= +github.com/go-openapi/swag/loading v0.29.2 h1:QU1ry24e6r6Shoxe380Nx0X5iKkpRO+hJffsyJ2dVlY= +github.com/go-openapi/swag/loading v0.29.2/go.mod h1:DqilDjuiJKETecsS4TRopWG1acUDsfqN39ZmQhPu6uI= +github.com/go-openapi/swag/mangling v0.29.2 h1:ltdo3K0tTP4P6zWhVVWDU9D37/YYBuMJRdZxiS2Dtog= +github.com/go-openapi/swag/mangling v0.29.2/go.mod h1:RjDi4TnItAenS3cgCXSpIl1kKbjG7il6pnmQVl/8bp8= +github.com/go-openapi/swag/netutils v0.29.2 h1:dBli6jyUa93sDS/XYWShJzf4+nnVfFKfvY9SLUaUzB8= +github.com/go-openapi/swag/netutils v0.29.2/go.mod h1:1pM6Xg/Um8E1eps3umWl8Hme3ByWXOtHsvFC0CULHUE= +github.com/go-openapi/swag/pools v0.29.2 h1:PlGoDRF8WtSyXkedZZkpW3f9wDhFf3u8KtaBcmgmh8c= +github.com/go-openapi/swag/pools v0.29.2/go.mod h1:V3lhxVT4qDYRqc2MRSSbLsTYIYV/2HlHafhyEkmzLIc= +github.com/go-openapi/swag/stringutils v0.29.2 h1:lcnBxwAaysT3bMUVBfn9V/PkfVqkurpqufKU6rTUMGk= +github.com/go-openapi/swag/stringutils v0.29.2/go.mod h1:i9cdh7sGaa0nm3CqIvH5IM5h2QClk1wns2ktKeILvRI= +github.com/go-openapi/swag/typeutils v0.29.2 h1:O7aVvkTs3pXwikgtrPLenigEMdQFgONKRooQA9pgf2I= +github.com/go-openapi/swag/typeutils v0.29.2/go.mod h1:7+GDG+uz9Ke+eVt4rClZg7wklSDp8hT/mKNh/pC26TE= +github.com/go-openapi/swag/yamlutils v0.29.2 h1:IFKFFeDnuIwzfsuWRQU+rI8iL3g4XyAYjV/RlnlxPLM= +github.com/go-openapi/swag/yamlutils v0.29.2/go.mod h1:7MGqtcrK73sxQ4ceiyIf8qiXS/s09JLMdR5esK5euYQ= +github.com/go-openapi/testify/enable/yaml/v2 v2.7.0 h1:wPW6YRgx3+SID1yUy/Xwa17L8kFEaEKod2VRbJDZNUs= +github.com/go-openapi/testify/enable/yaml/v2 v2.7.0/go.mod h1:mI1M88etYbc3PhgHsWQK2kwvNwW5aGFqMPbmib+SGIs= +github.com/go-openapi/testify/v2 v2.8.0 h1:19QDx5b57p8KjO2E4sgs/woL4Akp+FGLRlVm2xn0Rho= +github.com/go-openapi/testify/v2 v2.8.0/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak= github.com/go-quicktest/qt v1.101.1-0.20240301121107-c6c8733fa1e6 h1:teYtXy9B7y5lHTp8V9KPxpYRAVA7dozigQcMiBust1s= github.com/go-quicktest/qt v1.101.1-0.20240301121107-c6c8733fa1e6/go.mod h1:p4lGIVX+8Wa6ZPNDvqcxq36XpUDLh42FLetFU7odllI= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= @@ -113,8 +113,8 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= -github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe h1:QAinXoAFJdGQYztXn3VpFey7KCwpedbZ/EkzbplQ0cY= -github.com/google/pprof v0.0.0-20260906184651-6331bc6350fe/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk= +github.com/google/pprof v0.0.0-20261016150608-1facf8f91b50 h1:PlNWJRxu5APSV0pWqfIsZ0qt9OOGHSWfZQ4zvx+WgWs= +github.com/google/pprof v0.0.0-20261016150608-1facf8f91b50/go.mod h1:yUo1AMMpsPIDFGuwDK8nLcf8+vvAd5l2O6JDZ6hpwrM= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= @@ -145,8 +145,8 @@ github.com/jsimonetti/rtnetlink/v2 v2.0.1 h1:xda7qaHDSVOsADNouv7ukSuicKZO7GgVUCX github.com/jsimonetti/rtnetlink/v2 v2.0.1/go.mod h1:7MoNYNbb3UaDHtF8udiJo/RH6VsTKP1pqKLUTVCvToE= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/klauspost/compress v1.20.1 h1:T7kKElXUMXrUJ2E9QhQhxFtcK5rPyLdsGZvdbLMPdiQ= -github.com/klauspost/compress v1.20.1/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= +github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4= +github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI= github.com/klauspost/cpuid/v2 v2.2.10 h1:tBs3QSyvjDyFTq3uoc/9xFpCuOsJQFNPiAhYdw2skhE= github.com/klauspost/cpuid/v2 v2.2.10/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -161,8 +161,8 @@ github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/mattn/go-sqlite3 v1.14.52 h1:wVbm2Qnf4OXkqhBTSPuCRZDRnxfbVrrmiCEroVdog8U= -github.com/mattn/go-sqlite3 v1.14.52/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w= +github.com/mattn/go-sqlite3 v1.14.53 h1:mnTM0owzUMrKuLo+0w51NUiB0ir2Fo7kFXlPt/l3BGs= +github.com/mattn/go-sqlite3 v1.14.53/go.mod h1:6JTjA44L93a0QCyJef5YvlPoKXntQPjzWv5gtm9sB6w= github.com/mdlayher/netlink v1.7.2 h1:/UtM3ofJap7Vl4QWCPDGXY8d3GIY2UGSDbK+QWmY8/g= github.com/mdlayher/netlink v1.7.2/go.mod h1:xraEF7uJbxLhc5fpHL4cPe221LI2bdttWlU+ZGLfQSw= github.com/mdlayher/socket v0.6.0 h1:ScZPaAGyO1icQnbFrhPM8mnXyMu9qukC1K4ZoM2IQKU= @@ -205,8 +205,8 @@ github.com/prometheus/exporter-toolkit v0.20.0 h1:hz3g2aPcq3mXlQSt1MGjj2rwVk1wtR github.com/prometheus/exporter-toolkit v0.20.0/go.mod h1:gIIY0Mw0ci1wgYscdeMqVh6FUPYJca549eOkE39nU64= github.com/prometheus/procfs v0.23.0 h1:ad+S6FTkzwaMgacKLM5h6bNKExS+DMH0YiUwXItH/o4= github.com/prometheus/procfs v0.23.0/go.mod h1:3AVXO0FqLafyYFU/V/IQRZlC8Rgqz8Dm/x6pKLK+RIk= -github.com/prometheus/prometheus v0.315.1 h1:ZXaNKyUO5szJhhw7gKiP6b2jpx1QkS0S3CI1R1bPqIA= -github.com/prometheus/prometheus v0.315.1/go.mod h1:6ISUXTjRxj9U2d8ssng8khR1b2dDJ+MpftZD190149I= +github.com/prometheus/prometheus v0.316.0 h1:f1GRFerhTMKQma+awCoC9T820ecWeGSdF+xAlMHzZzM= +github.com/prometheus/prometheus v0.316.0/go.mod h1:nd2m0IehYLgxV4yAmoQDsvV45I9Xerh+uTUeCioEMis= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -276,20 +276,20 @@ golang.org/x/sync v0.24.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= -golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/term v0.47.0 h1:cpyOwQkr2Nzxe2p6KnrTG7Ei2wtzjsuSjhpXXepZ/BM= golang.org/x/term v0.47.0/go.mod h1:efAfAuG6RKABvg1ArGebRkvX6LXul14SM67o2e4mUCY= golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= -golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= -golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE= +golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s= golang.org/x/tools v0.51.0 h1:k4Xc/1Om9jwkBJBo4NVLMSARBoWtK10mx+W5BnXCeAI= golang.org/x/tools v0.51.0/go.mod h1:9eEncMayCV6zRMGhR5eZEC2iBx98qWcF1HZ9Z7wJOoA= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5 h1:1VUiZAXyC+zmiFYi+WLtBzr68Cj8wOofHjjrA/kkizc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260825221802-da73d73af1c5/go.mod h1:DjtHYE8FKJLivXcBEjGwndXfIC23G0VpXiXKqG179uA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 h1:QG6hS4zFplRZvOQedzei4t2pT/zkQc3VR1u+S9/rcAw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= diff --git a/internal/security/exec.go b/internal/security/exec.go index 8101453e..1f77d711 100644 --- a/internal/security/exec.go +++ b/internal/security/exec.go @@ -8,7 +8,7 @@ import ( "time" "github.com/ceems-dev/ceems/internal/osexec" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) // Custom errors. @@ -20,7 +20,7 @@ var ( type SCConfig struct { Logger *slog.Logger Func func(any) error - Caps []cap.Value + Caps []libcap.Value Name string // Execute function natively without a security context. @@ -33,10 +33,10 @@ type SCConfig struct { // safely executed with required privileges on a thread locked to OS. type SecurityContext struct { logger *slog.Logger - launcher *cap.Launcher + launcher *libcap.Launcher f func(any) error - caps []cap.Value - capSet *cap.Set + caps []libcap.Value + capSet *libcap.Set execNatively bool Name string } @@ -48,13 +48,13 @@ func NewSecurityContext(c *SCConfig) (*SecurityContext, error) { logger: c.Logger, caps: c.Caps, Name: c.Name, - capSet: cap.NewSet(), + capSet: libcap.NewSet(), execNatively: c.ExecNatively, f: c.Func, } // Create a new Launcher after embedding the function inside enclave - s.launcher = cap.FuncLauncher(s.targetFunc) + s.launcher = libcap.FuncLauncher(s.targetFunc) return s, nil } @@ -82,12 +82,12 @@ func (s *SecurityContext) raiseCaps() error { return nil } - err := s.capSet.SetFlag(cap.Permitted, true, s.caps...) + err := s.capSet.SetFlag(libcap.Permitted, true, s.caps...) if err != nil { return fmt.Errorf("raising: error setting permitted capabilities: %w", err) } - err = s.capSet.SetFlag(cap.Effective, true, s.caps...) + err = s.capSet.SetFlag(libcap.Effective, true, s.caps...) if err != nil { return fmt.Errorf("raising: error setting effective capabilities: %w", err) } @@ -107,7 +107,7 @@ func (s *SecurityContext) dropCaps() error { return nil } - err := s.capSet.SetFlag(cap.Effective, false, s.caps...) + err := s.capSet.SetFlag(libcap.Effective, false, s.caps...) if err != nil { return fmt.Errorf("dropping: error setting effective capabilities: %w", err) } @@ -131,10 +131,10 @@ func (s *SecurityContext) targetFunc(data any) error { // for the error is lack of privileges. err := s.raiseCaps() if err != nil { - s.logger.Error("Failed to raise capabilities", "name", s.Name, "caps", cap.GetProc().String(), "err", err) + s.logger.Error("Failed to raise capabilities", "name", s.Name, "caps", libcap.GetProc().String(), "err", err) } - s.logger.Debug("Executing in security context", "name", s.Name, "caps", cap.GetProc().String()) + s.logger.Debug("Executing in security context", "name", s.Name, "caps", libcap.GetProc().String()) // Execute function err = s.f(data) @@ -142,7 +142,7 @@ func (s *SecurityContext) targetFunc(data any) error { // Attempt to drop capabilities and ignore any errors capsErr := s.dropCaps() if capsErr != nil { - s.logger.Warn("Failed to drop capabilities", "name", s.Name, "caps", cap.GetProc().String(), "err", capsErr) + s.logger.Warn("Failed to drop capabilities", "name", s.Name, "caps", libcap.GetProc().String(), "err", capsErr) } return err @@ -153,7 +153,7 @@ func (s *SecurityContext) targetFunc(data any) error { // Ignore any errors err = s.dropCaps() if err != nil { - s.logger.Warn("Failed to drop capabilities", "name", s.Name, "caps", cap.GetProc().String(), "err", err) + s.logger.Warn("Failed to drop capabilities", "name", s.Name, "caps", libcap.GetProc().String(), "err", err) } return nil diff --git a/internal/security/exec_test.go b/internal/security/exec_test.go index 14a90e90..ee2fa665 100644 --- a/internal/security/exec_test.go +++ b/internal/security/exec_test.go @@ -8,7 +8,7 @@ import ( "github.com/ceems-dev/ceems/internal/osexec" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) var noOpLogger = slog.New(slog.DiscardHandler) @@ -38,10 +38,10 @@ func TestNewSecurityLauncher(t *testing.T) { skipUnprivileged(t) // target caps - var values []cap.Value + var values []libcap.Value for _, c := range []string{"cap_setuid", "cap_setgid"} { - value, err := cap.FromName(c) + value, err := libcap.FromName(c) require.NoError(t, err) values = append(values, value) diff --git a/internal/security/manager.go b/internal/security/manager.go index 652215f8..8d45979c 100644 --- a/internal/security/manager.go +++ b/internal/security/manager.go @@ -17,7 +17,7 @@ import ( "github.com/ceems-dev/ceems/internal/osexec" "github.com/steiler/acls" "github.com/wneessen/go-fileperm" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) const ( @@ -32,10 +32,10 @@ type deleteACLEntriesCtxData struct { } type Config struct { - RunAsUser string // Change to this user if app is started as root - Caps []cap.Value // Capabilities necessary for the app - ReadPaths []string // Paths that "RunAsUser" user able to read - ReadWritePaths []string // Paths that "RunAsUser" user able to read/write + RunAsUser string // Change to this user if app is started as root + Caps []libcap.Value // Capabilities necessary for the app + ReadPaths []string // Paths that "RunAsUser" user able to read + ReadWritePaths []string // Paths that "RunAsUser" user able to read/write } type acl struct { @@ -48,7 +48,7 @@ type Manager struct { logger *slog.Logger runAsUser *user.User currentUser *user.User - caps []cap.Value + caps []libcap.Value acls []acl securityContexts map[string]*SecurityContext systemctlBinPath string @@ -193,14 +193,14 @@ func NewManager(c *Config, logger *slog.Logger) (*Manager, error) { manager.securityContexts = make(map[string]*SecurityContext) // If there is no FOWNER cap already in caps, add it - if !slices.Contains(manager.caps, cap.FOWNER) { - manager.caps = append(manager.caps, cap.FOWNER) + if !slices.Contains(manager.caps, libcap.FOWNER) { + manager.caps = append(manager.caps, libcap.FOWNER) } // Create a new security context cfg := &SCConfig{ Name: deleteACLCtx, - Caps: []cap.Value{cap.FOWNER}, + Caps: []libcap.Value{libcap.FOWNER}, Func: deleteACLEntries, Logger: logger, } @@ -223,7 +223,7 @@ func NewManager(c *Config, logger *slog.Logger) (*Manager, error) { // environments. func (m *Manager) DropPrivileges(enableEffective bool) error { if syscall.Geteuid() != 0 { - existing := cap.GetProc() + existing := libcap.GetProc() // Get if the current process has any capabilities at all // by comparing against a new capability set @@ -351,7 +351,7 @@ func (m *Manager) changeUser() error { // Note this is not the regular SetUID! Look at the 'cap' package docs for it, it preserves // capabilities post-SetUID, which we use to lock things down immediately - err = cap.SetUID(localUserUID) + err = libcap.SetUID(localUserUID) if err != nil { return fmt.Errorf("could not setuid to %d: %w", localUserUID, err) } @@ -378,13 +378,13 @@ func (m *Manager) pathsReachable() error { // defaultCaps returns default capabilities a process should have. As of systemd >= 254, // desktop environments will have cap_wake_alarm=i by default. // Ref: https://github.com/systemd/systemd/issues/41386 -func (m *Manager) defaultCaps() *cap.Set { +func (m *Manager) defaultCaps() *libcap.Set { // Get systemd version output, err := osexec.ExecuteWithTimeout(m.systemctlBinPath, []string{"--version"}, 2, nil) if err != nil { m.logger.Warn("Failed to get systemd version", "err", err) - return cap.NewSet() + return libcap.NewSet() } // Find matches @@ -403,17 +403,17 @@ func (m *Manager) defaultCaps() *cap.Set { // Ref: https://superuser.com/questions/1074068/what-is-the-difference-between-desktop-session-xdg-session-desktop-and-xdg-cur/1643180#1643180 // Ref: https://www.freedesktop.org/software/systemd/man/latest/pam_systemd.html if val >= 254 && os.Getenv("XDG_SESSION_DESKTOP") != "" { - capSet, err := cap.FromText("cap_wake_alarm=i") + capSet, err := libcap.FromText("cap_wake_alarm=i") if err == nil { return capSet } - return cap.NewSet() + return libcap.NewSet() } } } - return cap.NewSet() + return libcap.NewSet() } // DropCapabilities drops any existing capabilities on the process. @@ -439,25 +439,25 @@ func GetDefaultRunAsUser() (string, error) { // It only add the capabilities to `permitted` set and it is responsible of the // functions that need privileges to enable `effective` set before perfoming // privileged action and then dropping them off straight after. -func setCapabilities(caps []cap.Value, enableEffective bool) error { +func setCapabilities(caps []libcap.Value, enableEffective bool) error { // Start with an empty capability set - newcaps := cap.NewSet() + newcaps := libcap.NewSet() // Permitted makes the permission possible to get, effective makes it 'active' for _, c := range caps { - err := newcaps.SetFlag(cap.Permitted, true, c) + err := newcaps.SetFlag(libcap.Permitted, true, c) if err != nil { return fmt.Errorf("error setting permitted setcap: %w", err) } // Only enable effective set before performing a privileged operation - err = newcaps.SetFlag(cap.Effective, enableEffective, c) + err = newcaps.SetFlag(libcap.Effective, enableEffective, c) if err != nil { return fmt.Errorf("error setting effective setcap: %w", err) } // We do not want these capabilities to be inherited by subprocesses - err = newcaps.SetFlag(cap.Inheritable, false, c) + err = newcaps.SetFlag(libcap.Inheritable, false, c) if err != nil { return fmt.Errorf("error setting inheritable setcap: %w", err) } diff --git a/internal/security/manager_test.go b/internal/security/manager_test.go index abe5df9d..8375a96d 100644 --- a/internal/security/manager_test.go +++ b/internal/security/manager_test.go @@ -11,7 +11,7 @@ import ( "github.com/steiler/acls" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) func skipUnprivileged(t *testing.T) { @@ -104,17 +104,17 @@ func TestDefaultCaps(t *testing.T) { tmpDir := t.TempDir() // Expected in case of systemd >= 254 and in desktop env - capSet, err := cap.FromText("cap_wake_alarm=i") + capSet, err := libcap.FromText("cap_wake_alarm=i") require.NoError(t, err) // Empty capset - emptyCapSet := cap.NewSet() + emptyCapSet := libcap.NewSet() tests := []struct { name string cmdOut string desktopEnv bool - expected *cap.Set + expected *libcap.Set }{ { name: "systemd > 254 in Desktop env", @@ -258,7 +258,7 @@ func TestGetDefaultRunAsUserPriv(t *testing.T) { // skipUnprivileged(t) // // Target a cap -// value, err := cap.FromName("cap_sys_admin") +// value, err := libcap.FromName("cap_sys_admin") // require.NoError(t, err) // // Make test config @@ -269,7 +269,7 @@ func TestGetDefaultRunAsUserPriv(t *testing.T) { // // test finishes. // cfg := Config{ // RunAsUser: "root", -// Caps: []cap.Value{value}, +// Caps: []libcap.Value{value}, // } // // Drop all privileges @@ -277,16 +277,16 @@ func TestGetDefaultRunAsUserPriv(t *testing.T) { // require.NoError(t, err) // // Check process do not have any privileges -// capName := cap.GetProc().String() +// capName := libcap.GetProc().String() // require.NoError(t, err) // assert.EqualValues(t, "cap_sys_admin=p", capName) // // Get current caps -// current := cap.GetProc() +// current := libcap.GetProc() // // Setback current caps -// err = current.SetFlag(cap.Effective, true, value) +// err = current.SetFlag(libcap.Effective, true, value) // require.NoError(t, err) // err = current.SetProc() diff --git a/pkg/api/cli/cli.go b/pkg/api/cli/cli.go index 7e95fcad..6d65cd28 100644 --- a/pkg/api/cli/cli.go +++ b/pkg/api/cli/cli.go @@ -32,7 +32,7 @@ import ( "github.com/prometheus/common/promslog/flag" "github.com/prometheus/common/version" "github.com/prometheus/exporter-toolkit/web" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) // CEEMSAPIAppConfig contains the configuration of CEEMS API server. @@ -412,10 +412,10 @@ func (b *CEEMSServer) Main() error { // // So, we keep the privileges only as a insurance and once we confirm with resource manager // we decide to either keep them or drop them. - var allCaps []cap.Value + var allCaps []libcap.Value for _, name := range []string{"cap_setuid", "cap_setgid"} { - value, err := cap.FromName(name) + value, err := libcap.FromName(name) if err != nil { logger.Error("Error parsing capability %s: %w", name, err) diff --git a/pkg/api/resource/slurm/cli.go b/pkg/api/resource/slurm/cli.go index d5213c96..3eb91afb 100644 --- a/pkg/api/resource/slurm/cli.go +++ b/pkg/api/resource/slurm/cli.go @@ -19,7 +19,7 @@ import ( "github.com/ceems-dev/ceems/internal/security" "github.com/ceems-dev/ceems/pkg/api/base" "github.com/ceems-dev/ceems/pkg/api/models" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) var ( @@ -72,9 +72,9 @@ func preflightsCLI(slurm *slurmScheduler) error { // Check if current capabilities have required caps haveCaps := true - currentCaps := cap.GetProc().String() - for _, cap := range requiredCaps { - if !strings.Contains(currentCaps, cap) { + currentCaps := libcap.GetProc().String() + for _, c := range requiredCaps { + if !strings.Contains(currentCaps, c) { haveCaps = false break @@ -87,12 +87,12 @@ func preflightsCLI(slurm *slurmScheduler) error { slurm.cmdExecMode = capabilityMode slurm.logger.Info("Current user/process have enough privileges to execute SLURM commands", "user", currentUser.Username) - var caps []cap.Value + var caps []libcap.Value var err error for _, name := range requiredCaps { - value, err := cap.FromName(name) + value, err := libcap.FromName(name) if err != nil { slurm.logger.Error("Error parsing capability %s: %w", name, err) diff --git a/pkg/collector/cli.go b/pkg/collector/cli.go index ab47c225..8e173f20 100644 --- a/pkg/collector/cli.go +++ b/pkg/collector/cli.go @@ -18,7 +18,7 @@ import ( "github.com/prometheus/common/promslog/flag" "github.com/prometheus/common/version" "github.com/prometheus/exporter-toolkit/web" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) // CEEMSExporter represents the `ceems_exporter` cli. @@ -37,9 +37,9 @@ var CEEMSExporterApp = *kingpin.New( ) var ( - appCaps = make([]cap.Value, 0) // Unique slice of all required caps of currently enabled collectors - appReadPaths = make([]string, 0) // Slice of paths that exporter needs read access - appReadWritePaths = make([]string, 0) // Slice of paths that exporter needs read write access + appCaps = make([]libcap.Value, 0) // Unique slice of all required caps of currently enabled collectors + appReadPaths = make([]string, 0) // Slice of paths that exporter needs read access + appReadWritePaths = make([]string, 0) // Slice of paths that exporter needs read write access ) // Placeholders that will be replaced with node labels. diff --git a/pkg/collector/gpu_test.go b/pkg/collector/gpu_test.go index 97758d11..07534195 100644 --- a/pkg/collector/gpu_test.go +++ b/pkg/collector/gpu_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/fake" ) @@ -216,23 +215,19 @@ func TestNewGPUSMIWithK8s(t *testing.T) { gpuPods := []runtime.Object{ &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod11", - UID: "uid11", - Namespace: "nvidia-gpu-operator", - Labels: map[string]string{ - "app": "gpu-feature-discovery", - }, + Name: "pod11", + UID: "uid11", + Namespace: "nvidia-gpu-operator", + Labels: map[string]string{ + "app": "gpu-feature-discovery", }, }, &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod12", - UID: "uid12", - Namespace: "amd-gpu-operator", - Labels: map[string]string{ - "app.kubernetes.io/name": "metrics-exporter", - }, + Name: "pod12", + UID: "uid12", + Namespace: "amd-gpu-operator", + Labels: map[string]string{ + "app.kubernetes.io/name": "metrics-exporter", }, }, } diff --git a/pkg/collector/helper.go b/pkg/collector/helper.go index 2a152e94..660009f4 100644 --- a/pkg/collector/helper.go +++ b/pkg/collector/helper.go @@ -19,7 +19,7 @@ import ( "github.com/go-kit/log" "github.com/go-kit/log/level" "github.com/prometheus/procfs" - "kernel.org/pub/linux/libs/security/libcap/cap" + libcap "kernel.org/pub/linux/libs/security/libcap/cap" ) var ( @@ -118,18 +118,18 @@ func SanitizeMetricName(metricName string) string { } // setupAppCaps sets up the required capabilities for the app. -func setupAppCaps(capabilities []string) ([]cap.Value, error) { +func setupAppCaps(capabilities []string) ([]libcap.Value, error) { // If there is nothing to setup, return if len(capabilities) == 0 { return nil, nil } - var caps []cap.Value + var caps []libcap.Value var errs error for _, name := range capabilities { - value, err := cap.FromName(name) + value, err := libcap.FromName(name) if err != nil { errs = errors.Join(errs, err) } @@ -138,9 +138,9 @@ func setupAppCaps(capabilities []string) ([]cap.Value, error) { } // Add to global caps - for _, cap := range caps { - if !slices.Contains(appCaps, cap) { - appCaps = append(appCaps, cap) + for _, c := range caps { + if !slices.Contains(appCaps, c) { + appCaps = append(appCaps, c) } } diff --git a/pkg/k8s/client_test.go b/pkg/k8s/client_test.go index d0242c4d..9ee5a878 100644 --- a/pkg/k8s/client_test.go +++ b/pkg/k8s/client_test.go @@ -30,44 +30,36 @@ var noOpLogger = slog.New(slog.DiscardHandler) var ( testPods = []runtime.Object{ &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod11", - UID: "uid11", - Namespace: "ns1", - Labels: map[string]string{ - "label1": "value1", - }, + Name: "pod11", + UID: "uid11", + Namespace: "ns1", + Labels: map[string]string{ + "label1": "value1", }, }, &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod12", - UID: "uid12", - Namespace: "ns1", - Labels: map[string]string{ - "label1": "value1", - }, + Name: "pod12", + UID: "uid12", + Namespace: "ns1", + Labels: map[string]string{ + "label1": "value1", }, }, &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pod21", - UID: "uid21", - Namespace: "ns2", - Labels: map[string]string{ - "label2": "value2", - }, + Name: "pod21", + UID: "uid21", + Namespace: "ns2", + Labels: map[string]string{ + "label2": "value2", }, }, } testRoleBindings = []runtime.Object{ &rbacv1.RoleBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "rb1", - UID: "rb1", - Namespace: "foo", - }, + Name: "rb1", + UID: "rb1", + Namespace: "foo", Subjects: []rbacv1.Subject{ { Kind: "User", @@ -92,11 +84,9 @@ var ( }, }, &rbacv1.RoleBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "rb2", - UID: "rb2", - Namespace: "foo", - }, + Name: "rb2", + UID: "rb2", + Namespace: "foo", Subjects: []rbacv1.Subject{ { Kind: "User", @@ -106,11 +96,9 @@ var ( }, }, &rbacv1.RoleBinding{ - ObjectMeta: metav1.ObjectMeta{ - Name: "rb3", - UID: "rb3", - Namespace: "bar", - }, + Name: "rb3", + UID: "rb3", + Namespace: "bar", Subjects: []rbacv1.Subject{ { Kind: "User", @@ -482,12 +470,10 @@ func TestConfigMap(t *testing.T) { fakeClientset := fake.NewClientset( []runtime.Object{ &v1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: "cm", - UID: "cm", - Namespace: "default", - }, - Data: expectedData, + Name: "cm", + UID: "cm", + Namespace: "default", + Data: expectedData, }, }..., ) diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index 423796c1..e813bee7 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -13,7 +13,7 @@ const website = "ceems.dev" // Global variables that will be replaced // in markdown files let globalVars = { - goVersion: "1.26.x", // Everytime Go version is updated, this needs to be updated as well + goVersion: "1.27.x", // Everytime Go version is updated, this needs to be updated as well ceemsVersion: "", ceemsOrg: organizationName, ceemsContOrg: "ceems",