mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
portlist: normalise space delimited process names (#5634)
This commit is contained in:
parent
9c6bdae556
commit
81574a5c8d
@ -26,6 +26,9 @@ func argvSubject(argv ...string) string {
|
|||||||
ret = filepath.Base(argv[1])
|
ret = filepath.Base(argv[1])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle space separated argv
|
||||||
|
ret, _, _ = strings.Cut(ret, " ")
|
||||||
|
|
||||||
// Remove common noise.
|
// Remove common noise.
|
||||||
ret = strings.TrimSpace(ret)
|
ret = strings.TrimSpace(ret)
|
||||||
ret = strings.TrimSuffix(ret, ".exe")
|
ret = strings.TrimSuffix(ret, ".exe")
|
||||||
|
@ -31,6 +31,22 @@ func TestArgvSubject(t *testing.T) {
|
|||||||
in: []string{"/bin/mono", "/sbin/exampleProgram.bin"},
|
in: []string{"/bin/mono", "/sbin/exampleProgram.bin"},
|
||||||
want: "exampleProgram.bin",
|
want: "exampleProgram.bin",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: []string{"/usr/bin/sshd_config [listener] 1 of 10-100 startups"},
|
||||||
|
want: "sshd_config",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: []string{"/usr/bin/sshd [listener] 0 of 10-100 startups"},
|
||||||
|
want: "sshd",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: []string{"/opt/aws/bin/eic_run_authorized_keys %u %f -o AuthorizedKeysCommandUser ec2-instance-connect [listener] 0 of 10-100 startups"},
|
||||||
|
want: "eic_run_authorized_keys",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
in: []string{"/usr/bin/nginx worker"},
|
||||||
|
want: "nginx",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
Loading…
Reference in New Issue
Block a user