Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a600da9

Browse files
committed
profiles/apparmor, seccomp: migrate to separate module
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 0c60a0e commit a600da9

27 files changed

+516
-2318
lines changed

daemon/apparmor_default.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"fmt"
77

88
"github.com/containerd/containerd/v2/pkg/apparmor"
9-
aaprofile "github.com/docker/docker/profiles/apparmor"
9+
aaprofile "github.com/moby/profiles/apparmor"
1010
)
1111

1212
// Define constants for native driver

daemon/seccomp_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/containerd/log"
1010
dconfig "github.com/docker/docker/daemon/config"
1111
"github.com/docker/docker/daemon/container"
12-
"github.com/docker/docker/profiles/seccomp"
12+
"github.com/moby/profiles/seccomp"
1313
"github.com/opencontainers/runtime-spec/specs-go"
1414
)
1515

daemon/seccomp_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"github.com/docker/docker/daemon/container"
99
"github.com/docker/docker/oci"
1010
"github.com/docker/docker/pkg/sysinfo"
11-
"github.com/docker/docker/profiles/seccomp"
1211
containertypes "github.com/moby/moby/api/types/container"
12+
"github.com/moby/profiles/seccomp"
1313
"github.com/opencontainers/runtime-spec/specs-go"
1414
"gotest.tools/v3/assert"
1515
)

integration-cli/docker_cli_run_unix_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"github.com/docker/docker/pkg/sysinfo"
2323
"github.com/docker/docker/testutil"
2424
"github.com/moby/moby/client"
25+
"github.com/moby/profiles/seccomp"
2526
"github.com/moby/sys/mount"
2627
"gotest.tools/v3/assert"
2728
is "gotest.tools/v3/assert/cmp"
@@ -1319,7 +1320,16 @@ func (s *DockerCLIRunSuite) TestRunApparmorProcDirectory(c *testing.T) {
13191320
func (s *DockerCLIRunSuite) TestRunSeccompWithDefaultProfile(c *testing.T) {
13201321
testRequires(c, testEnv.IsLocalDaemon, seccompEnabled)
13211322

1322-
out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp=../profiles/seccomp/default.json", "debian:bookworm-slim", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
1323+
// write the default profile to a file
1324+
b, err := json.MarshalIndent(seccomp.DefaultProfile(), "", "\t")
1325+
assert.NilError(c, err)
1326+
1327+
tmpDir := c.TempDir()
1328+
fileName := filepath.Join(tmpDir, "default.json")
1329+
err = os.WriteFile(fileName, b, 0o644)
1330+
assert.NilError(c, err)
1331+
1332+
out, _, err := dockerCmdWithError("run", "--security-opt", "seccomp="+fileName, "debian:bookworm-slim", "unshare", "--map-root-user", "--user", "sh", "-c", "whoami")
13231333
assert.ErrorContains(c, err, "", out)
13241334
assert.Equal(c, strings.TrimSpace(out), "unshare: unshare failed: Operation not permitted")
13251335
}

oci/seccomp_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"os"
88
"testing"
99

10-
"github.com/docker/docker/profiles/seccomp"
10+
"github.com/moby/profiles/seccomp"
1111
)
1212

1313
func TestSeccompLoadProfile(t *testing.T) {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//go:build linux
2+
3+
package apparmor
4+
5+
import "github.com/moby/profiles/apparmor"
6+
7+
// InstallDefault generates a default profile in a temp directory determined by
8+
// os.TempDir(), then loads the profile into the kernel using 'apparmor_parser'.
9+
//
10+
// Deprecated: use [apparmor.InstallDefault].
11+
func InstallDefault(name string) error {
12+
return apparmor.InstallDefault(name)
13+
}
14+
15+
// IsLoaded checks if a profile with the given name has been loaded into the
16+
// kernel.
17+
//
18+
// Deprecated: use [apparmor.IsLoaded].
19+
func IsLoaded(name string) (bool, error) {
20+
return apparmor.IsLoaded(name)
21+
}

profiles/apparmor/apparmor_linux_test.go

Lines changed: 0 additions & 197 deletions
This file was deleted.

profiles/seccomp/fixtures/conditional_include.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)