Skip to content

Commit 4253550

Browse files
authoredJun 23, 2023
chore(scanner): do not show logs when lsof: no Internet files located (#1688)
1 parent 97cf033 commit 4253550

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed
 

‎scanner/base.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,15 @@ func (l *base) parseGrepProcMap(stdout string) (soPaths []string) {
13051305
return soPaths
13061306
}
13071307

1308+
var errLSOFNoInternetFiles = xerrors.New("no Internet files located")
1309+
13081310
func (l *base) lsOfListen() (string, error) {
1309-
cmd := `lsof -i -P -n`
1311+
cmd := `lsof -i -P -n -V`
13101312
r := l.exec(util.PrependProxyEnv(cmd), sudo)
13111313
if !r.isSuccess() {
1314+
if strings.TrimSpace(r.Stdout) == "lsof: no Internet files located" {
1315+
return "", xerrors.Errorf("Failed to lsof: %w", errLSOFNoInternetFiles)
1316+
}
13121317
return "", xerrors.Errorf("Failed to lsof: %s", r)
13131318
}
13141319
return r.Stdout, nil
@@ -1364,7 +1369,7 @@ func (l *base) pkgPs(getOwnerPkgs func([]string) ([]string, error)) error {
13641369

13651370
pidListenPorts := map[string][]models.PortStat{}
13661371
stdout, err = l.lsOfListen()
1367-
if err != nil {
1372+
if err != nil && !xerrors.Is(err, errLSOFNoInternetFiles) {
13681373
// warning only, continue scanning
13691374
l.log.Warnf("Failed to lsof: %+v", err)
13701375
}

0 commit comments

Comments
 (0)
Failed to load comments.