Skip to content

Commit

Permalink
fix(scan): fix nil poiter in needs-restarting (#1767)
Browse files Browse the repository at this point in the history
  • Loading branch information
kotakanbe authored Oct 17, 2023
1 parent 48ff519 commit 57264e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion scanner/redhatbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ func (o *redhatBase) parseNeedsRestarting(stdout string) (procs []models.NeedRes
}

path := ss[1]
if !strings.HasPrefix(path, "/") {
if path != "" && !strings.HasPrefix(path, "/") {
path = strings.Fields(path)[0]
// [ec2-user@ip-172-31-11-139 ~]$ sudo needs-restarting
// 2024 : auditd
Expand Down
6 changes: 6 additions & 0 deletions scanner/redhatbase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,14 @@ func TestParseNeedsRestarting(t *testing.T) {
}{
{
`1 : /usr/lib/systemd/systemd --switched-root --system --deserialize 21kk
30170 :
437 : /usr/sbin/NetworkManager --no-daemon`,
[]models.NeedRestartProcess{
{
PID: "30170",
Path: "",
HasInit: true,
},
{
PID: "437",
Path: "/usr/sbin/NetworkManager --no-daemon",
Expand Down

0 comments on commit 57264e1

Please sign in to comment.