Skip to content

Commit f92b205

Browse files
committed
Fix copilot review comments from blockdev mounts PR
Addresses the following comments: microsoft#2762 (comment) microsoft#2762 (comment) microsoft#2762 (comment) microsoft#2762 (comment) microsoft#2762 (comment) microsoft#2762 (comment) Assisted-by: GitHub Copilot:claude-opus-4.7 copilot-review Signed-off-by: Tingmao Wang <tingmaowang@microsoft.com>
1 parent f2c6219 commit f92b205

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

pkg/securitypolicy/regopolicy_linux_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,7 +2151,7 @@ func Test_Rego_EnforceCreateContainer_Capabilities_Drop_NoMatches(t *testing.T)
21512151
}
21522152
}
21532153

2154-
func Test_Regi_EnforceCreateContainer_RequireNoDevices(t *testing.T) {
2154+
func Test_Rego_EnforceCreateContainer_RequireNoDevices(t *testing.T) {
21552155
f := func(p *generatedConstraints) bool {
21562156
tc, err := setupSimpleRegoCreateContainerTest(p)
21572157
if err != nil {
@@ -2180,7 +2180,7 @@ func Test_Regi_EnforceCreateContainer_RequireNoDevices(t *testing.T) {
21802180
}
21812181

21822182
if err := quick.Check(f, &quick.Config{MaxCount: 50, Rand: testRand}); err != nil {
2183-
t.Errorf("Test_Regi_EnforceCreateContainer_RequireNoDevices: %v", err)
2183+
t.Errorf("Test_Rego_EnforceCreateContainer_RequireNoDevices: %v", err)
21842184
}
21852185
}
21862186

pkg/securitypolicy/securitypolicyenforcer_rego.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,13 @@ func appendMountData(mountData []interface{}, mounts []oci.Mount) []interface{}
842842
return mountData
843843
}
844844

845+
func uint32ptrtoany(i *uint32) interface{} {
846+
if i == nil {
847+
return nil
848+
}
849+
return *i
850+
}
851+
845852
func appendDeviceData(deviceData []interface{}, devices []oci.LinuxDevice) []interface{} {
846853
for _, device := range devices {
847854
deviceData = append(deviceData, inputData{
@@ -850,8 +857,8 @@ func appendDeviceData(deviceData []interface{}, devices []oci.LinuxDevice) []int
850857
"major": device.Major,
851858
"minor": device.Minor,
852859
"fileMode": device.FileMode,
853-
"uid": device.UID,
854-
"gid": device.GID,
860+
"uid": uint32ptrtoany(device.UID),
861+
"gid": uint32ptrtoany(device.GID),
855862
})
856863
}
857864

0 commit comments

Comments
 (0)