Skip to content
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
11 changes: 7 additions & 4 deletions server/pkg/macrules/macrules.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,15 @@ func IsRiskyPermissiveDomain(name string) bool {

// cilAllowedStatements are the top-level CIL statements a Bor module may
// use: rules, type and attribute declarations, booleans, file and port
// contexts, login mappings, and the containers CIL sources are organised
// in. Statements that restructure the base policy (classes, sids, users
// and roles, MLS, policy capabilities, kernel object contexts) are not
// contexts, login mappings, constraints, and the containers CIL sources
// are organised in. Constraints are accepted because they are the only
// way to take a permission away from the unconfined domains, which hold
// allow rules for everything; a bad one is undone by removing the module.
// Statements that restructure the base policy (classes, sids, users and
// roles, MLS, policy capabilities, kernel object contexts) are not
// accepted.
var cilAllowedStatements = map[string]struct{}{
"allow": {}, "auditallow": {}, "dontaudit": {}, "neverallow": {},
"allow": {}, "auditallow": {}, "dontaudit": {}, "neverallow": {}, "constrain": {},
"allowx": {}, "auditallowx": {}, "dontauditx": {}, "neverallowx": {}, "permissionx": {},
"type": {}, "typealias": {}, "typealiasactual": {}, "typeattribute": {}, "typeattributeset": {},
"typetransition": {}, "typechange": {}, "typemember": {}, "typebounds": {}, "typepermissive": {},
Expand Down
2 changes: 2 additions & 0 deletions server/pkg/macrules/macrules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ func TestCheckCIL(t *testing.T) {
"(optional corp (allow a_t b_t (file (read))))",
"(block corp (type corp_t) (roletype system_r corp_t))",
"(booleanif deny_ptrace (true (allow a_t b_t (process (ptrace)))))",
"(constrain (process (signal sigkill sigstop)) (or (neq t2 corp_t) (eq t1 init_t)))",
}
for _, v := range valid {
if err := CheckCIL(v); err != nil {
Expand All @@ -116,6 +117,7 @@ func TestCheckCIL(t *testing.T) {
"sid": "(sid kernel)",
"user": "(user corp_u)",
"policycap": "(policycap open_perms)",
"mls": "(mlsconstrain (process (sigkill)) (dom h1 h2))",
"nul": "(allow a_t b_t (file (read)))\x00",
"unterminated": `(filecon "/opt any (system_u object_r bin_t ((s0) (s0))))`,
"too big": "(" + strings.Repeat("allow a_t b_t (file (read))\n", 4000) + ")",
Expand Down
Loading