generated from templates/go-generic
use filepath.Clean to fix gosec G304
This commit is contained in:
parent
62914aca00
commit
87e7c90f1e
1 changed files with 3 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
@ -13,6 +14,8 @@ type Config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConfig(path string) (Config, error) {
|
func NewConfig(path string) (Config, error) {
|
||||||
|
path = filepath.Clean(path)
|
||||||
|
|
||||||
data, err := os.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Config{}, fmt.Errorf(
|
return Config{}, fmt.Errorf(
|
||||||
|
|
Loading…
Reference in a new issue