From 03f06b00bfe1a23c1d475d33ab56e9bbb6de6f31 Mon Sep 17 00:00:00 2001 From: CJstate <142857225+CJstate@users.noreply.github.com> Date: Thu, 19 Nov 2026 10:25:24 +0800 Subject: [PATCH] fix(output): omit leading space when security module is empty securityLabel concatenated the module and label before sanitizing, so a process with a confined label but no reported module rendered with a leading space. Skip the separator when the module is empty. --- internal/output/standard.go | 6 +++++- internal/output/standard_test.go | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) 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 {