Skip to content

Commit 01b4532

Browse files
committed
Fix gosec security findings in Go package
- Tighten directory permissions from 0755 to 0750 (G301) - Handle db.Close() error return (G104) - Cap exponential backoff shift to prevent overflow (G115) - Scope gosec CI to production code (exclude examples/cmd)
1 parent 720ce32 commit 01b4532

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

.github/workflows/release-go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
run: |
6767
cd go
6868
go install github.com/securego/gosec/v2/cmd/gosec@latest
69-
gosec ./...
69+
gosec -exclude-dir=examples -exclude-dir=cmd ./pkg/... ./internal/... ./tests/...
7070
7171
- name: Build CLI tools
7272
run: |

go/pkg/pinning/pinning.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func NewKeyPinning(dbPath string, mode PinningMode, handler interactive.Interact
7676
}
7777

7878
// Ensure directory exists
79-
if err := os.MkdirAll(filepath.Dir(dbPath), 0755); err != nil {
79+
if err := os.MkdirAll(filepath.Dir(dbPath), 0750); err != nil {
8080
return nil, fmt.Errorf("failed to create database directory: %w", err)
8181
}
8282

@@ -97,7 +97,7 @@ func NewKeyPinning(dbPath string, mode PinningMode, handler interactive.Interact
9797
return nil
9898
})
9999
if err != nil {
100-
db.Close()
100+
_ = db.Close()
101101
return nil, err
102102
}
103103

go/pkg/utils/utils.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func RetryVerification(ctx context.Context, workflow *SchemaVerificationWorkflow
468468

469469
if attempt < maxRetries {
470470
// Exponential backoff: 1s, 2s, 4s, 8s, etc.
471-
backoff := time.Duration(1<<uint(attempt)) * time.Second
471+
backoff := time.Duration(1<<min(uint(attempt), 30)) * time.Second // #nosec G115 -- attempt is bounded by maxRetries
472472
select {
473473
case <-ctx.Done():
474474
return nil, ctx.Err()

0 commit comments

Comments
 (0)