From a8b29b452720a992f446e3702cb5f99b85861a0b Mon Sep 17 00:00:00 2001 From: Karim Kanso Date: Tue, 10 Mar 2020 14:17:37 +0000 Subject: [PATCH] Increase width of uid field from 4 chars to 5 to allow for range of 16-bit uids. --- internal/psscanner/psscanner.go | 4 ++-- internal/psscanner/psscanner_test.go | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/psscanner/psscanner.go b/internal/psscanner/psscanner.go index 7f7ba14..44def17 100644 --- a/internal/psscanner/psscanner.go +++ b/internal/psscanner/psscanner.go @@ -26,11 +26,11 @@ func (evt PSEvent) String() string { } if evt.PPID == -1 { - return fmt.Sprintf("UID=%-4s PID=%-6d | %s", uid, evt.PID, evt.CMD) + return fmt.Sprintf("UID=%-5s PID=%-6d | %s", uid, evt.PID, evt.CMD) } return fmt.Sprintf( - "UID=%-4s PID=%-6d PPID=%-6d | %s", uid, evt.PID, evt.PPID, evt.CMD) + "UID=%-5s PID=%-6d PPID=%-6d | %s", uid, evt.PID, evt.PPID, evt.CMD) } func NewPSScanner(ppid bool) *PSScanner { diff --git a/internal/psscanner/psscanner_test.go b/internal/psscanner/psscanner_test.go index 98dc76b..7e8c4f3 100644 --- a/internal/psscanner/psscanner_test.go +++ b/internal/psscanner/psscanner_test.go @@ -16,9 +16,9 @@ func TestRun(t *testing.T) { events []string }{ {pids: []int{1, 2, 3}, events: []string{ - "UID=??? PID=3 | the-command", - "UID=??? PID=2 | the-command", - "UID=??? PID=1 | the-command", + "UID=??? PID=3 | the-command", + "UID=??? PID=2 | the-command", + "UID=??? PID=1 | the-command", }}, } @@ -423,7 +423,7 @@ func TestPSEvent(t *testing.T) { pid: 123, ppid: 321, cmd: "some cmd", - expected: "UID=999 PID=123 PPID=321 | some cmd", + expected: "UID=999 PID=123 PPID=321 | some cmd", }, { name: "nominal-without-ppid", @@ -431,7 +431,7 @@ func TestPSEvent(t *testing.T) { pid: 123, ppid: -1, cmd: "some cmd", - expected: "UID=999 PID=123 | some cmd", + expected: "UID=999 PID=123 | some cmd", }, { name: "nocmd-without-ppid", @@ -439,7 +439,7 @@ func TestPSEvent(t *testing.T) { pid: 123, ppid: -1, cmd: "", - expected: "UID=999 PID=123 | ", + expected: "UID=999 PID=123 | ", }, { name: "nocmd-with-ppid", @@ -447,7 +447,7 @@ func TestPSEvent(t *testing.T) { pid: 123, ppid: 321, cmd: "", - expected: "UID=999 PID=123 PPID=321 | ", + expected: "UID=999 PID=123 PPID=321 | ", }, { name: "nouid", @@ -455,7 +455,7 @@ func TestPSEvent(t *testing.T) { pid: 123, ppid: 321, cmd: "some cmd", - expected: "UID=??? PID=123 PPID=321 | some cmd", + expected: "UID=??? PID=123 PPID=321 | some cmd", }, }