Skip to content

Commit

Permalink
Add tests for using "this" in a full context
Browse files Browse the repository at this point in the history
  • Loading branch information
dburgener committed Oct 9, 2023
1 parent 1fa976c commit cc76833
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions data/expected_cil/filecon.cil
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
(filecon "/bin/some_bin" file (system_u object_r foo ((s0) (s0))))
(filecon "/bin/some_bin2" file (system_u object_r foo ((s0) (s0))))
(filecon "/bin/some_bin3" file (system_u object_r foo ((s0) (s0))))
(filecon "/bin/some_bin4" file (system_u object_r foo ((s0) (s0))))
(filecon "/dev/sda1" block (system_u object_r foo ((s0) (s0))))
(filecon "/dev/tty.*" char (system_u object_r foo ((s0) (s0))))
(filecon "/etc" any (system_u object_r foo ((s0) (s0))))
Expand Down
1 change: 1 addition & 0 deletions data/expected_cil/fs_context.cil
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
(typeattributeset resource (unlabeled_sid))
(allow domain foo (file (read)))
(fsuse xattr ext3 (system_u object_r foo ((s0) (s0))))
(fsuse xattr hugetblfs (system_u object_r foo ((s0) (s0))))
(fsuse task sockfs (system_u object_r foo ((s0) (s0))))
(fsuse trans tmpfs (system_u object_r foo ((s0) (s0))))
(genfscon cgroup "/" (system_u object_r foo ((s0) (s0))))
Expand Down
7 changes: 6 additions & 1 deletion data/expected_cil/initial_context.cil
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
(type kernel_sid)
(roletype system_r kernel_sid)
(typeattributeset domain (kernel_sid))
(type other_con)
(roletype object_r other_con)
(typeattributeset resource (other_con))
(type security_con)
(roletype object_r security_con)
(typeattributeset resource (security_con))
Expand All @@ -154,8 +157,10 @@
(allow some_dom unlabeled_con (file (read)))
(sid "kernel")
(sidcontext "kernel" (system_u object_r kernel_con ((s0) (s0))))
(sid "other")
(sidcontext "other" (system_u object_r other_con ((s0) (s0))))
(sid "security")
(sidcontext "security" (system_u object_r security_con ((s0) (s0))))
(sid "unlabeled")
(sidcontext "unlabeled" (system_u object_r unlabeled_con ((s0) (s0))))
(sidorder ("kernel" "security" "unlabeled"))
(sidorder ("kernel" "other" "security" "unlabeled"))
1 change: 1 addition & 0 deletions data/expected_cil/networking_rules.cil
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@
(portcon tcp 22 (system_u object_r my_port ((s0) (s0))))
(portcon tcp 1234 (system_u object_r my_port ((s0) (s0))))
(portcon tcp (5000 5010) (system_u object_r my_port ((s0) (s0))))
(portcon tcp 9999 (system_u object_r my_port ((s0) (s0))))
(portcon udp 1235 (system_u object_r my_port ((s0) (s0))))
(portcon dccp 1337 (system_u object_r my_port ((s0) (s0))))
(portcon sctp 43 (system_u object_r my_port ((s0) (s0))))
Expand Down
1 change: 1 addition & 0 deletions data/policies/filecon.cas
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resource foo {
file_context("/bin/some_bin", [file], system_u:object_r:foo:s0);
file_context("/bin/some_bin2", [file], system_u:object_r:foo:s0-s0);
file_context("/bin/some_bin3", [file], system_u:object_r:foo:s0-s0:c0.c255);
file_context("/bin/some_bin4", [file], system_u:object_r:this:s0);
file_context("HOME_ROOT", dir, this);
// Policies must include at least one av rule
allow(domain, foo, file, [read]);
Expand Down
1 change: 1 addition & 0 deletions data/policies/fs_context.cas
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ resource foo {
fs_context("sockfs", task, this);
fs_context("tmpfs", trans, this);
fs_context("tmpfs", trans, this);
fs_context("hugetblfs", xattr, system_u:object_r:this);

fs_context("proc", genfscon, this, "/");
fs_context("proc", genfscon, this, "/");
Expand Down
4 changes: 4 additions & 0 deletions data/policies/initial_context.cas
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ resource security_con {
initial_context("security", this);
}

resource other_con {
initial_context("other", system_u:object_r:this);
}

domain some_dom {
allow(this, unlabeled_con, file, read);
}
1 change: 1 addition & 0 deletions data/policies/networking_rules.cas
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ resource my_port {
portcon("tcp", ssh_port, this);
portcon("dccp", 1337, this);
portcon("sctp", 43, this);
portcon("tcp", 9999, system_u:object_r:this);
}

domain foo {
Expand Down
2 changes: 1 addition & 1 deletion src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ fn filecon_test() {
"(filecon \"/bin\" dir (",
"(filecon \"/etc\" any (",
],
&[],
&["this"],
0,
);
}
Expand Down

0 comments on commit cc76833

Please sign in to comment.