Skip to content

Commit 56bc14a

Browse files
authored
fix G107 G304 gosec warnings (#24)
Signed-off-by: someshkoli <kolisomesh27@gmail.com>
1 parent 4c8941d commit 56bc14a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

model/unmarshal_json.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const prefix = "file:/"
2828

2929
func getBytesFromFile(s string) (b []byte, err error) {
3030

31+
// #nosec
3132
if resp, err := http.Get(s); err == nil {
3233
defer resp.Body.Close()
3334
buf := new(bytes.Buffer)
@@ -43,7 +44,7 @@ func getBytesFromFile(s string) (b []byte, err error) {
4344
return nil, err
4445
}
4546
}
46-
if b, err = ioutil.ReadFile(s); err != nil {
47+
if b, err = ioutil.ReadFile(filepath.Clean(s)); err != nil {
4748
return nil, err
4849
}
4950
return b, nil

parser/parser.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ package parser
1717
import (
1818
"encoding/json"
1919
"fmt"
20-
"github.com/serverlessworkflow/sdk-go/model"
2120
"io/ioutil"
2221
"os"
23-
"sigs.k8s.io/yaml"
22+
"path/filepath"
2423
"strings"
24+
25+
"github.com/serverlessworkflow/sdk-go/model"
26+
"sigs.k8s.io/yaml"
2527
)
2628

2729
const (
@@ -55,7 +57,7 @@ func FromFile(path string) (*model.Workflow, error) {
5557
if err := checkFilePath(path); err != nil {
5658
return nil, err
5759
}
58-
fileBytes, err := ioutil.ReadFile(path)
60+
fileBytes, err := ioutil.ReadFile(filepath.Clean(path))
5961
if err != nil {
6062
return nil, err
6163
}

0 commit comments

Comments
 (0)