diff --git a/internal/output/standard.go b/internal/output/standard.go index aed60d15..5b1e7ee6 100644 --- a/internal/output/standard.go +++ b/internal/output/standard.go @@ -651,7 +651,11 @@ func securityLabel(p model.Process) string { if p.SecurityLabel == "" || strings.Contains(p.SecurityLabel, "unconfined") { return "" } - return SanitizeTerminalLine(p.SecurityModule + " " + p.SecurityLabel) + label := p.SecurityLabel + if p.SecurityModule != "" { + label = p.SecurityModule + " " + label + } + return SanitizeTerminalLine(label) } // formatSocket renders one row of the Sockets section as diff --git a/internal/output/standard_test.go b/internal/output/standard_test.go index c499576f..5024de66 100644 --- a/internal/output/standard_test.go +++ b/internal/output/standard_test.go @@ -250,6 +250,7 @@ func TestIntegrityAndSecurityLabel(t *testing.T) { {"SELinux", "system_u:system_r:httpd_t:s0", "SELinux system_u:system_r:httpd_t:s0"}, {"SELinux", "unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023", ""}, {"", "", ""}, + {"", "system_u:system_r:httpd_t:s0", "system_u:system_r:httpd_t:s0"}, } for _, tt := range tests { if got := securityLabel(model.Process{SecurityModule: tt.module, SecurityLabel: tt.label}); got != tt.want {