Skip to content

Commit

Permalink
chore(scanner): do not show logs when lsof: no Internet files located (
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n authored Jun 23, 2023
1 parent 97cf033 commit 4253550
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scanner/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 4253550

Please sign in to comment.