From 4253550c999d27fac802f616dbe50dd884e93f51 Mon Sep 17 00:00:00 2001 From: MaineK00n Date: Fri, 23 Jun 2023 16:08:49 +0900 Subject: [PATCH] chore(scanner): do not show logs when lsof: no Internet files located (#1688) --- scanner/base.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scanner/base.go b/scanner/base.go index ef491dd8f1..5321af00ac 100644 --- a/scanner/base.go +++ b/scanner/base.go @@ -1305,10 +1305,15 @@ func (l *base) parseGrepProcMap(stdout string) (soPaths []string) { return soPaths } +var errLSOFNoInternetFiles = xerrors.New("no Internet files located") + func (l *base) lsOfListen() (string, error) { - cmd := `lsof -i -P -n` + cmd := `lsof -i -P -n -V` r := l.exec(util.PrependProxyEnv(cmd), sudo) if !r.isSuccess() { + if strings.TrimSpace(r.Stdout) == "lsof: no Internet files located" { + return "", xerrors.Errorf("Failed to lsof: %w", errLSOFNoInternetFiles) + } return "", xerrors.Errorf("Failed to lsof: %s", r) } return r.Stdout, nil @@ -1364,7 +1369,7 @@ func (l *base) pkgPs(getOwnerPkgs func([]string) ([]string, error)) error { pidListenPorts := map[string][]models.PortStat{} stdout, err = l.lsOfListen() - if err != nil { + if err != nil && !xerrors.Is(err, errLSOFNoInternetFiles) { // warning only, continue scanning l.log.Warnf("Failed to lsof: %+v", err) }