Skip to content

Commit

Permalink
Merge pull request #360 from lunasec-io/do-not-open-non-existant-file…
Browse files Browse the repository at this point in the history
…s-from-symlinks

Broken symlinks no longer stop scanning

Former-commit-id: 998c69d
Former-commit-id: 01e330a42371d858afe52ceae45107d51270c496
  • Loading branch information
breadchris committed Dec 18, 2021
2 parents 038b814 + c0f0192 commit a978914
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/log4shell/constants/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
//
package constants

const Version = "1.4.0"
const Version = "1.4.1"
2 changes: 1 addition & 1 deletion tools/log4shell/scan/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *Log4jDirectoryScanner) Scan(
// overwrite path and info with the resolved symlink file values
path, info, err = util.ResolveSymlinkFilePathAndInfo(path)
if err != nil {
return
return nil
}
}

Expand Down
12 changes: 11 additions & 1 deletion tools/log4shell/util/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,22 @@ func ResolveSymlinkFilePathAndInfo(symlinkPath string) (path string, info os.Fil
path, err = filepath.EvalSymlinks(symlinkPath)
if err != nil {
log.Warn().
Str("path", path).
Str("symlinkPath", symlinkPath).
Err(err).
Msg("unable to read symlink to file")
return
}

_, err = os.Stat(path)
if err != nil {
log.Warn().
Str("path", path).
Str("symlinkPath", symlinkPath).
Err(err).
Msg("unable to read evaluated path")
return
}

// use file info of the resolved file
info, err = os.Lstat(path)
if err != nil {
Expand Down

0 comments on commit a978914

Please sign in to comment.