自定义规则
vArmor 支持用户基于 enforcer 的语法,在 EhanceProtect 模式的 VarmorPolicy 或 VarmorClusterPolicy 对象中自定义访问控制规则。
注:BPF enforcer 支持的语法在持续开发中。
AppArmor enforcer
AppArmor enforcer 支持用户根据 AppArmor 的语法定制策略。
请参见此 文档 在 .spec.policy.enhanceProtect.appArmorRawRules 字段中设置自定义规则。请确保每条规则以 ',' 结尾。
示例:
policy:
enforcer: AppArmor
mode: EnhanceProtect
enhanceProtect:
# Audit the actions that violate the mandatory access control rules.
# Any detected violation will be logged to /var/log/varmor/violations.log file in the host.
# It's disabled by default.
auditViolations: true
attackProtectionRules:
- rules:
- disable-chmod
- rules:
- mitigate-sa-leak
targets:
- "/bin/bash"
- "/bin/dash"
- "/bin/sh"
appArmorRawRules:
- rules: |
audit deny /etc/hosts r,
audit deny /etc/shadow r,
- rules: "audit deny /etc/hostname r,"
targets:
- "/bin/bash"
Seccomp enforcer
Seccomp enforcer 支持用户根据 OCI 规范的语法定制策略。
请参见此 文档 在 .spec.policy.enhanceProtect.syscallRawRules 字段中设置自定义的系统调用规则。
示例:
policy:
enforcer: Seccomp
mode: EnhanceProtect
enhanceProtect:
syscallRawRules:
# disallow chmod +x XXX, chmod 111 XXX, chmod 001 XXX, chmod 010 XXX...
- names:
- fchmodat
action: SCMP_ACT_ERRNO
args:
- index: 2
value: 0x40 # S_IXUSR
valueTwo: 0x40
op: SCMP_CMP_MASKED_EQ
- index: 2
value: 0x8 # S_IXGRP
valueTwo: 0x8
op: SCMP_CMP_MASKED_EQ
- index: 2
value: 1 # S_IXOTH
valueTwo: 1
op: SCMP_CMP_MASKED_EQ