chore(aa-log): cleanup test data.

This commit is contained in:
Alexandre Pujol 2023-10-01 19:04:43 +01:00
parent fd46022d5b
commit 4798b2d04a
Failed to generate hash of commit
2 changed files with 40 additions and 93 deletions

View file

@ -6,11 +6,15 @@ package aa
var ( var (
// Include // Include
includeLocal1 = &Include{ include1 = &Include{IsMagic: true, Path: "abstraction/base"}
IfExists: true, include2 = &Include{IsMagic: false, Path: "abstraction/base"}
IsMagic: true, include3 = &Include{IfExists: true, IsMagic: true, Path: "abstraction/base"}
Path: "local/foo", includeLocal1 = &Include{IfExists: true, IsMagic: true, Path: "local/foo"}
}
// Rlimit
rlimit1 = &Rlimit{Key: "nproc", Op: "<=", Value: "200"}
rlimit2 = &Rlimit{Key: "cpu", Op: "<=", Value: "2"}
rlimit3 = &Rlimit{Key: "nproc", Op: "<", Value: "2"}
// Capability // Capability
capability1Log = map[string]string{ capability1Log = map[string]string{
@ -38,15 +42,8 @@ var (
"denied_mask": "create", "denied_mask": "create",
"comm": "sddm-greeter", "comm": "sddm-greeter",
} }
network1 = &Network{ network1 = &Network{Domain: "netlink", Type: "raw", Protocol: "15"}
Domain: "netlink", network2 = &Network{Domain: "inet", Type: "dgram"}
Type: "raw",
Protocol: "15",
}
network2 = &Network{
Domain: "inet",
Type: "dgram",
}
// Mount // Mount
mount1Log = map[string]string{ mount1Log = map[string]string{
@ -84,6 +81,11 @@ var (
MountPoint: "/var/lib/docker/overlay2/metacopy-check906831159/merged/", MountPoint: "/var/lib/docker/overlay2/metacopy-check906831159/merged/",
} }
// Change Profile
changeprofile1 = &ChangeProfile{ExecMode: "Px", Exec: "/bin/bash", ProfileName: "brwap//default"}
changeprofile2 = &ChangeProfile{ExecMode: "Px", Exec: "/bin/bash", ProfileName: "brwap"}
changeprofile3 = &ChangeProfile{ExecMode: "safe", Exec: "/bin/foo", ProfileName: "brwap//default"}
// Signal // Signal
signal1Log = map[string]string{ signal1Log = map[string]string{
"apparmor": "ALLOWED", "apparmor": "ALLOWED",
@ -127,16 +129,8 @@ var (
"denied_mask": "readby", "denied_mask": "readby",
"peer": "systemd-journald", "peer": "systemd-journald",
} }
ptrace1 = &Ptrace{ ptrace1 = &Ptrace{Access: "read", Peer: "nautilus"}
Qualifier: Qualifier{}, ptrace2 = &Ptrace{Access: "readby", Peer: "systemd-journald"}
Access: "read",
Peer: "nautilus",
}
ptrace2 = &Ptrace{
Qualifier: Qualifier{},
Access: "readby",
Peer: "systemd-journald",
}
// Unix // Unix
unix1Log = map[string]string{ unix1Log = map[string]string{
@ -205,6 +199,11 @@ var (
Bus: "session", Bus: "session",
Name: "org.gnome.evolution.dataserver.Sources5", Name: "org.gnome.evolution.dataserver.Sources5",
} }
dbus3 = &Dbus{
Access: "bind",
Bus: "session",
Name: "org.gnome.evolution.dataserver",
}
// File // File
file1Log = map[string]string{ file1Log = map[string]string{
@ -236,15 +235,10 @@ var (
"OUID": "user", "OUID": "user",
"error": "-1", "error": "-1",
} }
file1 = &File{ file1 = &File{Path: "/usr/share/poppler/cMap/Identity-H", Access: "r"}
Path: "/usr/share/poppler/cMap/Identity-H",
Access: "r",
Target: "",
}
file2 = &File{ file2 = &File{
Qualifier: Qualifier{Owner: true, NoNewPrivs: true}, Qualifier: Qualifier{Owner: true, NoNewPrivs: true},
Path: "@{PROC}/4163/cgroup", Path: "@{PROC}/4163/cgroup",
Access: "r", Access: "r",
Target: "",
} }
) )

View file

@ -45,30 +45,13 @@ func TestAppArmorProfile_String(t *testing.T) {
name: "foo", name: "foo",
p: &AppArmorProfile{ p: &AppArmorProfile{
Preamble: Preamble{ Preamble: Preamble{
Abi: []Abi{ Abi: []Abi{{IsMagic: true, Path: "abi/4.0"}},
{ Includes: []Include{{IsMagic: true, Path: "tunables/global"}},
IsMagic: true, Aliases: []Alias{{Path: "/mnt/usr", RewrittenPath: "/usr"}},
Path: "abi/4.0", Variables: []Variable{{
},
},
Includes: []Include{
{
IsMagic: true,
Path: "tunables/global",
},
},
Aliases: []Alias{
{
Path: "/mnt/usr",
RewrittenPath: "/usr",
},
},
Variables: []Variable{
{
Name: "exec_path", Name: "exec_path",
Values: []string{"@{bin}/foo", "@{lib}/foo"}, Values: []string{"@{bin}/foo", "@{lib}/foo"},
}, }},
},
}, },
Profile: Profile{ Profile: Profile{
Name: "foo", Name: "foo",
@ -76,29 +59,13 @@ func TestAppArmorProfile_String(t *testing.T) {
Attributes: map[string]string{"security.tagged": "allowed"}, Attributes: map[string]string{"security.tagged": "allowed"},
Flags: []string{"complain", "attach_disconnected"}, Flags: []string{"complain", "attach_disconnected"},
Rules: []ApparmorRule{ Rules: []ApparmorRule{
&Include{ &Include{IsMagic: true, Path: "abstractions/base"},
IsMagic: true, &Include{IsMagic: true, Path: "abstractions/nameservice-strict"},
Path: "abstractions/base", rlimit1,
},
&Include{
IsMagic: true,
Path: "abstractions/nameservice-strict",
},
&Rlimit{
Key: "nproc",
Op: "<=",
Value: "200",
},
&Capability{Name: "dac_read_search"}, &Capability{Name: "dac_read_search"},
&Capability{Name: "dac_override"}, &Capability{Name: "dac_override"},
&Network{ &Network{Domain: "inet", Type: "stream"},
Domain: "inet", &Network{Domain: "inet6", Type: "stream"},
Type: "stream",
},
&Network{
Domain: "inet6",
Type: "stream",
},
&Mount{ &Mount{
MountConditions: MountConditions{ MountConditions: MountConditions{
FsType: "fuse.portal", FsType: "fuse.portal",
@ -116,11 +83,7 @@ func TestAppArmorProfile_String(t *testing.T) {
Set: "term", Set: "term",
Peer: "at-spi-bus-launcher", Peer: "at-spi-bus-launcher",
}, },
&Ptrace{Access: "read", Peer: "nautilus"},
&Ptrace{
Access: "read",
Peer: "nautilus",
},
&Unix{ &Unix{
Access: "send receive", Access: "send receive",
Type: "stream", Type: "stream",
@ -142,19 +105,9 @@ func TestAppArmorProfile_String(t *testing.T) {
Member: "AddMatch", Member: "AddMatch",
Label: "power-profiles-daemon", Label: "power-profiles-daemon",
}, },
&File{ &File{Path: "/opt/intel/oneapi/compiler/*/linux/lib/*.so./*", Access: "rm"},
Path: "/opt/intel/oneapi/compiler/*/linux/lib/*.so./*", &File{Path: "@{PROC}/@{pid}/task/@{tid}/comm", Access: "rw"},
Access: "rm", &File{Path: "@{sys}/devices/pci[0-9]*/**/class", Access: "r"},
},
&File{
Path: "@{PROC}/@{pid}/task/@{tid}/comm",
Access: "rw",
},
&File{
Path: "@{sys}/devices/pci[0-9]*/**/class",
Access: "r",
},
includeLocal1, includeLocal1,
}, },
}, },