Skip to content

Commit a978914

Browse files
authored
Merge pull request #360 from lunasec-io/do-not-open-non-existant-files-from-symlinks
Broken symlinks no longer stop scanning Former-commit-id: 998c69d Former-commit-id: 01e330a42371d858afe52ceae45107d51270c496
2 parents 038b814 + c0f0192 commit a978914

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

tools/log4shell/constants/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
//
1515
package constants
1616

17-
const Version = "1.4.0"
17+
const Version = "1.4.1"

tools/log4shell/scan/scan.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func (s *Log4jDirectoryScanner) Scan(
9090
// overwrite path and info with the resolved symlink file values
9191
path, info, err = util.ResolveSymlinkFilePathAndInfo(path)
9292
if err != nil {
93-
return
93+
return nil
9494
}
9595
}
9696

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
a

tools/log4shell/util/fs.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,22 @@ func ResolveSymlinkFilePathAndInfo(symlinkPath string) (path string, info os.Fil
4747
path, err = filepath.EvalSymlinks(symlinkPath)
4848
if err != nil {
4949
log.Warn().
50-
Str("path", path).
50+
Str("symlinkPath", symlinkPath).
5151
Err(err).
5252
Msg("unable to read symlink to file")
5353
return
5454
}
5555

56+
_, err = os.Stat(path)
57+
if err != nil {
58+
log.Warn().
59+
Str("path", path).
60+
Str("symlinkPath", symlinkPath).
61+
Err(err).
62+
Msg("unable to read evaluated path")
63+
return
64+
}
65+
5666
// use file info of the resolved file
5767
info, err = os.Lstat(path)
5868
if err != nil {

0 commit comments

Comments
 (0)