Skip to content

Commit

Permalink
fix: Correct backend lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
laurynasgadl committed Nov 11, 2024
1 parent ddb21c0 commit 944631b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ linters-settings:
dupl:
threshold: 100
exhaustive:
default-signifies-exhaustive: false
default-signifies-exhaustive: true
funlen:
lines: 100
statements: 50
Expand Down
6 changes: 4 additions & 2 deletions http/data.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package http

import (
"errors"
"log"
"net/http"
"strconv"

"github.com/tomasen/realip"

"github.com/filebrowser/filebrowser/v2/errors"
fbErrors "github.com/filebrowser/filebrowser/v2/errors"
"github.com/filebrowser/filebrowser/v2/rules"
"github.com/filebrowser/filebrowser/v2/runner"
"github.com/filebrowser/filebrowser/v2/settings"
Expand Down Expand Up @@ -74,7 +75,8 @@ func handle(fn handleFunc, prefix string, store *storage.Storage, server *settin

if status != 0 {
txt := strconv.Itoa(status) + " " + http.StatusText(status)
if httpErr, ok := err.(*errors.HTTPError); ok {
var httpErr *fbErrors.HTTPError
if errors.As(err, &httpErr) {
txt += " [" + httpErr.Type + "]"
}
http.Error(w, txt, status)
Expand Down
8 changes: 5 additions & 3 deletions http/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,8 @@ func chmodActionHandler(r *http.Request, d *data) error {
return fbErrors.ErrInvalidRequestParams
}

permMode := uint32(mode)

Check failure on line 673 in http/resource.go

View workflow job for this annotation

GitHub Actions / lint-backend

G115: integer overflow conversion uint64 -> uint32 (gosec)

info, err := d.user.Fs.Stat(target)
if err != nil {
return err
Expand All @@ -688,20 +690,20 @@ func chmodActionHandler(r *http.Request, d *data) error {
return !i.IsDir()
}
default:
recFilter = func(i os.FileInfo) bool {
recFilter = func(_ os.FileInfo) bool {
return true
}
}

return afero.Walk(d.user.Fs, target, func(name string, info os.FileInfo, err error) error {
if err == nil {
if recFilter(info) {
err = d.user.Fs.Chmod(name, os.FileMode(mode))
err = d.user.Fs.Chmod(name, os.FileMode(permMode))
}
}
return err
})
}

return d.user.Fs.Chmod(target, os.FileMode(mode))
return d.user.Fs.Chmod(target, os.FileMode(permMode))
}

0 comments on commit 944631b

Please sign in to comment.