Fix linting errors

This commit is contained in:
Patrick Pacher
2024-03-27 16:17:58 +01:00
parent 653a365bce
commit 61176af14e
48 changed files with 167 additions and 153 deletions

View File

@@ -3,6 +3,7 @@ package core
import (
"context"
"encoding/hex"
"errors"
"fmt"
"net/http"
"net/url"
@@ -23,6 +24,8 @@ import (
"github.com/safing/portmaster/spn/captain"
)
var errInvalidReadPermission = errors.New("invalid read permission")
func registerAPIEndpoints() error {
if err := api.RegisterEndpoint(api.Endpoint{
Path: "core/shutdown",
@@ -207,10 +210,10 @@ func authorizeApp(ar *api.Request) (interface{}, error) {
// convert the requested read and write permissions to their api.Permission
// value. This ensures only "user" or "admin" permissions can be requested.
if getSavePermission(readPermStr) <= api.NotSupported {
return nil, fmt.Errorf("invalid read permission")
return nil, errInvalidReadPermission
}
if getSavePermission(writePermStr) <= api.NotSupported {
return nil, fmt.Errorf("invalid read permission")
return nil, errInvalidReadPermission
}
proc, err := process.GetProcessByRequestOrigin(ar)
@@ -281,7 +284,7 @@ func authorizeApp(ar *api.Request) (interface{}, error) {
select {
case key := <-ch:
if len(key) == 0 {
return nil, fmt.Errorf("access denied")
return nil, errors.New("access denied")
}
return map[string]interface{}{
@@ -289,6 +292,6 @@ func authorizeApp(ar *api.Request) (interface{}, error) {
"validUntil": validUntil,
}, nil
case <-ar.Context().Done():
return nil, fmt.Errorf("timeout")
return nil, errors.New("timeout")
}
}