seccomp.go 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package types
  2. // Seccomp represents the config for a seccomp profile for syscall restriction.
  3. type Seccomp struct {
  4. DefaultAction Action `json:"defaultAction"`
  5. // Architectures is kept to maintain backward compatibility with the old
  6. // seccomp profile.
  7. Architectures []Arch `json:"architectures,omitempty"`
  8. ArchMap []Architecture `json:"archMap,omitempty"`
  9. Syscalls []*Syscall `json:"syscalls"`
  10. }
  11. // Architecture is used to represent an specific architecture
  12. // and its sub-architectures
  13. type Architecture struct {
  14. Arch Arch `json:"architecture"`
  15. SubArches []Arch `json:"subArchitectures"`
  16. }
  17. // Arch used for architectures
  18. type Arch string
  19. // Additional architectures permitted to be used for system calls
  20. // By default only the native architecture of the kernel is permitted
  21. const (
  22. ArchX86 Arch = "SCMP_ARCH_X86"
  23. ArchX86_64 Arch = "SCMP_ARCH_X86_64"
  24. ArchX32 Arch = "SCMP_ARCH_X32"
  25. ArchARM Arch = "SCMP_ARCH_ARM"
  26. ArchAARCH64 Arch = "SCMP_ARCH_AARCH64"
  27. ArchMIPS Arch = "SCMP_ARCH_MIPS"
  28. ArchMIPS64 Arch = "SCMP_ARCH_MIPS64"
  29. ArchMIPS64N32 Arch = "SCMP_ARCH_MIPS64N32"
  30. ArchMIPSEL Arch = "SCMP_ARCH_MIPSEL"
  31. ArchMIPSEL64 Arch = "SCMP_ARCH_MIPSEL64"
  32. ArchMIPSEL64N32 Arch = "SCMP_ARCH_MIPSEL64N32"
  33. ArchPPC Arch = "SCMP_ARCH_PPC"
  34. ArchPPC64 Arch = "SCMP_ARCH_PPC64"
  35. ArchPPC64LE Arch = "SCMP_ARCH_PPC64LE"
  36. ArchS390 Arch = "SCMP_ARCH_S390"
  37. ArchS390X Arch = "SCMP_ARCH_S390X"
  38. )
  39. // Action taken upon Seccomp rule match
  40. type Action string
  41. // Define actions for Seccomp rules
  42. const (
  43. ActKill Action = "SCMP_ACT_KILL"
  44. ActTrap Action = "SCMP_ACT_TRAP"
  45. ActErrno Action = "SCMP_ACT_ERRNO"
  46. ActTrace Action = "SCMP_ACT_TRACE"
  47. ActAllow Action = "SCMP_ACT_ALLOW"
  48. )
  49. // Operator used to match syscall arguments in Seccomp
  50. type Operator string
  51. // Define operators for syscall arguments in Seccomp
  52. const (
  53. OpNotEqual Operator = "SCMP_CMP_NE"
  54. OpLessThan Operator = "SCMP_CMP_LT"
  55. OpLessEqual Operator = "SCMP_CMP_LE"
  56. OpEqualTo Operator = "SCMP_CMP_EQ"
  57. OpGreaterEqual Operator = "SCMP_CMP_GE"
  58. OpGreaterThan Operator = "SCMP_CMP_GT"
  59. OpMaskedEqual Operator = "SCMP_CMP_MASKED_EQ"
  60. )
  61. // Arg used for matching specific syscall arguments in Seccomp
  62. type Arg struct {
  63. Index uint `json:"index"`
  64. Value uint64 `json:"value"`
  65. ValueTwo uint64 `json:"valueTwo"`
  66. Op Operator `json:"op"`
  67. }
  68. // Filter is used to conditionally apply Seccomp rules
  69. type Filter struct {
  70. Caps []string `json:"caps,omitempty"`
  71. Arches []string `json:"arches,omitempty"`
  72. }
  73. // Syscall is used to match a group of syscalls in Seccomp
  74. type Syscall struct {
  75. Name string `json:"name,omitempty"`
  76. Names []string `json:"names,omitempty"`
  77. Action Action `json:"action"`
  78. Args []*Arg `json:"args"`
  79. Comment string `json:"comment"`
  80. Includes Filter `json:"includes"`
  81. Excludes Filter `json:"excludes"`
  82. }