Skip to content

Commit 764c79d

Browse files
committed
fix: resolve gosec lint warnings in proxysql provider
- Config file permissions tightened from 0644 to 0600 (G306) - Script WriteFile 0755 annotated with nolint (scripts must be executable) - exec.Command annotated with nolint (paths from trusted sandbox dirs)
1 parent a4e6878 commit 764c79d

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

providers/proxysql/proxysql.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (p *ProxySQLProvider) CreateSandbox(config providers.SandboxConfig) (*provi
9393

9494
cfgContent := GenerateConfig(proxyCfg)
9595
cfgPath := filepath.Join(config.Dir, "proxysql.cnf")
96-
if err := os.WriteFile(cfgPath, []byte(cfgContent), 0644); err != nil {
96+
if err := os.WriteFile(cfgPath, []byte(cfgContent), 0600); err != nil {
9797
return nil, fmt.Errorf("writing config: %w", err)
9898
}
9999

@@ -116,7 +116,7 @@ func (p *ProxySQLProvider) CreateSandbox(config providers.SandboxConfig) (*provi
116116

117117
for name, content := range scripts {
118118
scriptPath := filepath.Join(config.Dir, name)
119-
if err := os.WriteFile(scriptPath, []byte(content), 0755); err != nil {
119+
if err := os.WriteFile(scriptPath, []byte(content), 0755); err != nil { //nolint:gosec // scripts must be executable
120120
return nil, fmt.Errorf("writing script %s: %w", name, err)
121121
}
122122
}
@@ -129,7 +129,7 @@ func (p *ProxySQLProvider) CreateSandbox(config providers.SandboxConfig) (*provi
129129
}
130130

131131
func (p *ProxySQLProvider) StartSandbox(dir string) error {
132-
cmd := exec.Command("bash", filepath.Join(dir, "start"))
132+
cmd := exec.Command("bash", filepath.Join(dir, "start")) //nolint:gosec // path is from trusted sandbox directory
133133
output, err := cmd.CombinedOutput()
134134
if err != nil {
135135
return fmt.Errorf("start failed: %s: %w", string(output), err)
@@ -138,7 +138,7 @@ func (p *ProxySQLProvider) StartSandbox(dir string) error {
138138
}
139139

140140
func (p *ProxySQLProvider) StopSandbox(dir string) error {
141-
cmd := exec.Command("bash", filepath.Join(dir, "stop"))
141+
cmd := exec.Command("bash", filepath.Join(dir, "stop")) //nolint:gosec // path is from trusted sandbox directory
142142
output, err := cmd.CombinedOutput()
143143
if err != nil {
144144
return fmt.Errorf("stop failed: %s: %w", string(output), err)

0 commit comments

Comments
 (0)