Skip to content

Commit a2eed9e

Browse files
committed
fix zizmor issues
Signed-off-by: abzcoding <[email protected]>
1 parent 3885ff5 commit a2eed9e

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ on:
66
pull_request:
77
branches: [ "master" ]
88

9+
permissions: {}
10+
911
jobs:
1012
build:
1113
runs-on: ubuntu-latest
1214
steps:
1315
- uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false
18+
1419

1520
- name: Set up Go
1621
uses: actions/setup-go@v4

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
permissions: {}
78

89
jobs:
910
goreleaser:
@@ -13,11 +14,13 @@ jobs:
1314
uses: actions/checkout@v4
1415
with:
1516
fetch-depth: 0
17+
persist-credentials: false
1618

1719
- name: Set up Go
1820
uses: actions/setup-go@v4
1921
with:
2022
go-version: '1.24'
23+
cache: false
2124

2225
- name: Run GoReleaser
2326
uses: goreleaser/goreleaser-action@v5

util.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,10 @@ func FolderOf(urlStr string) string {
7575
fullQualifyPath, err := filepath.Abs(filepath.Join(homeDir, dataFolder, cleanPath))
7676
FatalCheck(err)
7777

78-
// Double-check to ensure full qualify path is CHILD of safe path
79-
// to prevent directory traversal attack
80-
relative, err := filepath.Rel(safePath, fullQualifyPath)
81-
FatalCheck(err)
82-
83-
if strings.Contains(relative, "..") {
84-
FatalCheck(errors.New("you may be a victim of directory traversal path attack"))
85-
return "" // Return is redundant because FatalCheck will panic
78+
if !strings.HasPrefix(fullQualifyPath, safePath) {
79+
FatalCheck(errors.New("path traversal attempt detected"))
8680
}
81+
8782
return fullQualifyPath
8883
}
8984

0 commit comments

Comments
 (0)