Skip to content

Commit 84b7738

Browse files
committed
chore(security): try to fix snyk security issues
Even after the fix, Snyk seems to be reporting false positives. Signed-off-by: Marc Nuri <[email protected]>
1 parent e403f47 commit 84b7738

File tree

1 file changed

+10
-2
lines changed
  • internal/tools/update-readme

1 file changed

+10
-2
lines changed

internal/tools/update-readme/main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"maps"
77
"os"
8+
"path/filepath"
89
"slices"
910
"strings"
1011

@@ -25,7 +26,14 @@ func (o *OpenShift) IsOpenShift(ctx context.Context) bool {
2526
var _ internalk8s.Openshift = (*OpenShift)(nil)
2627

2728
func main() {
28-
readme, err := os.ReadFile(os.Args[1])
29+
// Snyk reports false positive unless we flow the args through filepath.Clean and filepath.Localize in this specific order
30+
var err error
31+
localReadmePath := filepath.Clean(os.Args[1])
32+
localReadmePath, err = filepath.Localize(localReadmePath)
33+
if err != nil {
34+
panic(err)
35+
}
36+
readme, err := os.ReadFile(localReadmePath)
2937
if err != nil {
3038
panic(err)
3139
}
@@ -81,7 +89,7 @@ func main() {
8189
toolsetTools.String(),
8290
)
8391

84-
if err := os.WriteFile(os.Args[1], []byte(updated), 0o644); err != nil {
92+
if err := os.WriteFile(localReadmePath, []byte(updated), 0o644); err != nil {
8593
panic(err)
8694
}
8795
}

0 commit comments

Comments
 (0)