File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import (
1515 "io"
1616 "log/slog"
1717 "os"
18+ "path/filepath"
1819 "sync"
1920 "sync/atomic"
2021 "time"
@@ -438,7 +439,20 @@ func getBinaryHash() (string, error) {
438439 return "" , err
439440 }
440441
441- file , err := os .Open (execPath )
442+ execPath , err = filepath .EvalSymlinks (execPath )
443+ if err != nil {
444+ return "" , fmt .Errorf ("resolve self path: %w" , err )
445+ }
446+
447+ fi , err := os .Lstat (execPath )
448+ if err != nil {
449+ return "" , err
450+ }
451+ if ! fi .Mode ().IsRegular () {
452+ return "" , fmt .Errorf ("executable is not a regular file" )
453+ }
454+
455+ file , err := os .Open (execPath ) // #nosec G304 -- opening our own executable, not user-supplied
442456 if err != nil {
443457 return "" , err
444458 }
You can’t perform that action at this time.
0 commit comments