fix(scan): fix nil poiter in needs-restarting (#1767)
This commit is contained in:
		@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -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",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user