Skip to content
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

apparmor: Add AppArmor info at start time #1079

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/mogensen/kubernetes-split-yaml v0.3.0
github.com/nxadm/tail v1.4.8
github.com/openshift/api v0.0.0-20220209124712-b632c5fc10c0
github.com/pjbgf/go-apparmor v0.0.8
github.com/pjbgf/go-apparmor v0.0.9
github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.58.0
github.com/prometheus/client_golang v1.13.0
github.com/prometheus/client_model v0.2.0
Expand Down Expand Up @@ -137,7 +137,7 @@ require (
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/oauth2 v0.0.0-20220524215830-622c5d57e401 // indirect
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20220411224347-583f2d630306 // indirect
Expand Down
7 changes: 4 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1139,8 +1139,8 @@ github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+v
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d/go.mod h1:3OzsM7FXDQlpCiw2j81fOmAwQLnZnLGXVKUzeKQXIAw=
github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI=
github.com/pjbgf/go-apparmor v0.0.8 h1:4pgHE1vdrcd9/VyxEoEqHc5OgGTV/fpsai0Mygv4nks=
github.com/pjbgf/go-apparmor v0.0.8/go.mod h1:W7d9MAttSsMLmuRfrdAMBRQDn7UlR5UN2UWmOMwtXuk=
github.com/pjbgf/go-apparmor v0.0.9 h1:dt5Lnu+F0t2DNPAr4igXKT/k6+zzeeiOZ7dHzKLAZpo=
github.com/pjbgf/go-apparmor v0.0.9/go.mod h1:qIV2HstpRZmfHeer8kPyeFYPU1C5e1ZcAZvH3RljO0E=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down Expand Up @@ -1785,8 +1785,9 @@ golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
Expand Down
32 changes: 32 additions & 0 deletions internal/pkg/daemon/apparmorprofile/apparmorprofile.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

"github.com/crossplane/crossplane-runtime/pkg/event"
"github.com/go-logr/logr"
aa "github.com/pjbgf/go-apparmor/pkg/apparmor"
"github.com/pjbgf/go-apparmor/pkg/hostop"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
Expand Down Expand Up @@ -271,3 +273,33 @@ func (r *Reconciler) handleDeletion(sp *v1alpha1.AppArmorProfile) error {
r.metrics.IncAppArmorProfileDelete()
return nil
}

func (r *Reconciler) logNodeInfo() {
r.log.Info("detecting apparmor support...")

mount := hostop.NewMountHostOp().WithLogger(r.log)
aa := aa.NewAppArmor().WithLogger(r.log)

err := mount.Do(func() error {
enabled, err := aa.Enabled()
r.log.Info(fmt.Sprintf("apparmor enabled: %s", ok(enabled, err)))

fsPath, err := aa.AppArmorFS()
r.log.Info(fmt.Sprintf("apparmor fs: %s (%v)", fsPath, err))

enforceable, err := aa.Enforceable()
r.log.Info(fmt.Sprintf("apparmor enforceable: %s", ok(enforceable, err)))

return nil
})
if err != nil {
r.log.Error(err, "mounting host")
}
}

func ok(ok bool, err error) string {
if ok {
return "OK"
}
return fmt.Sprintf("NOT OK (%v)", err)
}
2 changes: 2 additions & 0 deletions internal/pkg/daemon/apparmorprofile/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ func (r *Reconciler) Setup(
r.metrics = met
r.manager = NewAppArmorProfileManager(r.log)

r.logNodeInfo()

// Register the regular reconciler to manage AppArmorProfiles
return ctrl.NewControllerManagedBy(mgr).
Named("apparmorprofile").
Expand Down
17 changes: 0 additions & 17 deletions vendor/github.com/pjbgf/go-apparmor/pkg/apparmor/apparmor.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions vendor/golang.org/x/sys/AUTHORS

This file was deleted.

3 changes: 0 additions & 3 deletions vendor/golang.org/x/sys/CONTRIBUTORS

This file was deleted.

7 changes: 2 additions & 5 deletions vendor/golang.org/x/sys/cpu/cpu_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/golang.org/x/sys/cpu/cpu_other_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions vendor/golang.org/x/sys/unix/mkall.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading