mirror of
https://github.com/roddhjav/apparmor.d.git
synced 2025-02-06 18:25:05 +01:00
fix: go linter issue & not defined variables.
This commit is contained in:
parent
0f382a4d5d
commit
bc216176a3
7 changed files with 14 additions and 19 deletions
|
@ -6,7 +6,7 @@ abi <abi/3.0>,
|
||||||
|
|
||||||
include <tunables/global>
|
include <tunables/global>
|
||||||
|
|
||||||
profile default-sudo @{exec_path} {
|
profile default-sudo {
|
||||||
include <abstractions/base>
|
include <abstractions/base>
|
||||||
include <abstractions/app/sudo>
|
include <abstractions/app/sudo>
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ abi <abi/3.0>,
|
||||||
|
|
||||||
include <tunables/global>
|
include <tunables/global>
|
||||||
|
|
||||||
profile systemd-service @{exec_path} flags=(attach_disconnected) {
|
profile systemd-service flags=(attach_disconnected) {
|
||||||
include <abstractions/base>
|
include <abstractions/base>
|
||||||
include <abstractions/consoles>
|
include <abstractions/consoles>
|
||||||
include <abstractions/nameservice-strict>
|
include <abstractions/nameservice-strict>
|
||||||
|
|
|
@ -14,7 +14,7 @@ profile aa-status @{exec_path} {
|
||||||
capability dac_read_search,
|
capability dac_read_search,
|
||||||
capability sys_ptrace,
|
capability sys_ptrace,
|
||||||
|
|
||||||
ptrace (read),
|
ptrace read,
|
||||||
|
|
||||||
@{exec_path} mr,
|
@{exec_path} mr,
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ var (
|
||||||
// Include
|
// Include
|
||||||
include1 = &Include{IsMagic: true, Path: "abstraction/base"}
|
include1 = &Include{IsMagic: true, Path: "abstraction/base"}
|
||||||
include2 = &Include{IsMagic: false, Path: "abstraction/base"}
|
include2 = &Include{IsMagic: false, Path: "abstraction/base"}
|
||||||
include3 = &Include{IfExists: true, IsMagic: true, Path: "abstraction/base"}
|
|
||||||
includeLocal1 = &Include{IfExists: true, IsMagic: true, Path: "local/foo"}
|
includeLocal1 = &Include{IfExists: true, IsMagic: true, Path: "local/foo"}
|
||||||
|
|
||||||
// Variable
|
// Variable
|
||||||
|
@ -326,8 +325,7 @@ var (
|
||||||
}
|
}
|
||||||
|
|
||||||
// Link
|
// Link
|
||||||
link3LogStr = `apparmor="ALLOWED" operation="link" class="file" profile="dolphin" name="@{user_config_dirs}/kiorc" comm="dolphin" requested_mask="l" denied_mask="l" fsuid=1000 ouid=1000 target="@{user_config_dirs}/#3954"`
|
link1Log = map[string]string{
|
||||||
link1Log = map[string]string{
|
|
||||||
"apparmor": "ALLOWED",
|
"apparmor": "ALLOWED",
|
||||||
"operation": "link",
|
"operation": "link",
|
||||||
"class": "file",
|
"class": "file",
|
||||||
|
|
|
@ -10,12 +10,6 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
tokALLOW = "allow"
|
|
||||||
tokAUDIT = "audit"
|
|
||||||
tokDENY = "deny"
|
|
||||||
)
|
|
||||||
|
|
||||||
type requirement map[string][]string
|
type requirement map[string][]string
|
||||||
|
|
||||||
type constraint uint
|
type constraint uint
|
||||||
|
@ -126,9 +120,9 @@ func (r Rules) Filter(filter Kind) Rules {
|
||||||
func (r Rules) GetVariables() []*Variable {
|
func (r Rules) GetVariables() []*Variable {
|
||||||
res := make([]*Variable, 0)
|
res := make([]*Variable, 0)
|
||||||
for _, rule := range r {
|
for _, rule := range r {
|
||||||
switch rule.(type) {
|
switch rule := rule.(type) {
|
||||||
case *Variable:
|
case *Variable:
|
||||||
res = append(res, rule.(*Variable))
|
res = append(res, rule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
@ -137,9 +131,9 @@ func (r Rules) GetVariables() []*Variable {
|
||||||
func (r Rules) GetIncludes() []*Include {
|
func (r Rules) GetIncludes() []*Include {
|
||||||
res := make([]*Include, 0)
|
res := make([]*Include, 0)
|
||||||
for _, rule := range r {
|
for _, rule := range r {
|
||||||
switch rule.(type) {
|
switch rule := rule.(type) {
|
||||||
case *Include:
|
case *Include:
|
||||||
res = append(res, rule.(*Include))
|
res = append(res, rule)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -303,13 +303,13 @@ func TestAppArmorLogs_ParseToProfiles(t *testing.T) {
|
||||||
Rules: aa.Rules{
|
Rules: aa.Rules{
|
||||||
&aa.Unix{
|
&aa.Unix{
|
||||||
RuleBase: aa.RuleBase{FileInherit: true},
|
RuleBase: aa.RuleBase{FileInherit: true},
|
||||||
Access: []string{"receive", "send"},
|
Access: []string{"send", "receive"},
|
||||||
Type: "stream",
|
Type: "stream",
|
||||||
Protocol: "0",
|
Protocol: "0",
|
||||||
},
|
},
|
||||||
&aa.Unix{
|
&aa.Unix{
|
||||||
RuleBase: aa.RuleBase{FileInherit: true},
|
RuleBase: aa.RuleBase{FileInherit: true},
|
||||||
Access: []string{"receive", "send"},
|
Access: []string{"send", "receive"},
|
||||||
Type: "stream",
|
Type: "stream",
|
||||||
Protocol: "0",
|
Protocol: "0",
|
||||||
},
|
},
|
||||||
|
|
|
@ -42,7 +42,10 @@ func (d Exec) Apply(opt *Option, profileRaw string) (string, error) {
|
||||||
for name := range opt.ArgMap {
|
for name := range opt.ArgMap {
|
||||||
profiletoTransition := util.MustReadFile(cfg.RootApparmord.Join(name))
|
profiletoTransition := util.MustReadFile(cfg.RootApparmord.Join(name))
|
||||||
dstProfile := aa.DefaultTunables()
|
dstProfile := aa.DefaultTunables()
|
||||||
dstProfile.Parse(profiletoTransition)
|
err := dstProfile.Parse(profiletoTransition)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
for _, variable := range dstProfile.Preamble.GetVariables() {
|
for _, variable := range dstProfile.Preamble.GetVariables() {
|
||||||
if variable.Name == "exec_path" {
|
if variable.Name == "exec_path" {
|
||||||
for _, v := range variable.Values {
|
for _, v := range variable.Values {
|
||||||
|
|
Loading…
Reference in a new issue