Skip to content

Commit bfdb1d5

Browse files
committed
style: apply gofumpt formatting
1 parent f38e0b7 commit bfdb1d5

2 files changed

Lines changed: 39 additions & 39 deletions

File tree

internal/output/output.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ func FormatJSON(findings []Finding) (string, error) {
150150
// SARIF 2.1.0 output types (package-level so they can reference each other).
151151

152152
type outputSarifLog struct {
153-
Version string `json:"version"`
154-
Schema string `json:"$schema"`
155-
Runs []outputSarifRun `json:"runs"`
153+
Version string `json:"version"`
154+
Schema string `json:"$schema"`
155+
Runs []outputSarifRun `json:"runs"`
156156
}
157157

158158
type outputSarifRun struct {
@@ -165,21 +165,21 @@ type outputSarifTool struct {
165165
}
166166

167167
type outputSarifDriver struct {
168-
Name string `json:"name"`
169-
Version string `json:"version"`
170-
InformationURI string `json:"informationUri,omitempty"`
171-
Rules []outputSarifRule `json:"rules,omitempty"`
168+
Name string `json:"name"`
169+
Version string `json:"version"`
170+
InformationURI string `json:"informationUri,omitempty"`
171+
Rules []outputSarifRule `json:"rules,omitempty"`
172172
}
173173

174174
type outputSarifRule struct {
175-
ID string `json:"id"`
176-
Name string `json:"name,omitempty"`
175+
ID string `json:"id"`
176+
Name string `json:"name,omitempty"`
177177
ShortDescription outputSarifMessage `json:"shortDescription"`
178178
}
179179

180180
type outputSarifResult struct {
181-
RuleID string `json:"ruleId"`
182-
Level string `json:"level"`
181+
RuleID string `json:"ruleId"`
182+
Level string `json:"level"`
183183
Message outputSarifMessage `json:"message"`
184184
Locations []outputSarifLocation `json:"locations,omitempty"`
185185
}

taint_analysis.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ type TaintAnalyzer struct{}
1616

1717
// TaintFinding represents a data-flow vulnerability where tainted data reaches a sink.
1818
type TaintFinding struct {
19-
Source string // description of the taint source
20-
Sink string // description of the sink
21-
SinkType string // category: "sql_injection", "command_injection", "path_traversal", "log_leak"
22-
Variable string // the tainted variable name
23-
File string
24-
Line int
25-
Severity string
26-
CWE string
27-
Message string
28-
Fix string
19+
Source string // description of the taint source
20+
Sink string // description of the sink
21+
SinkType string // category: "sql_injection", "command_injection", "path_traversal", "log_leak"
22+
Variable string // the tainted variable name
23+
File string
24+
Line int
25+
Severity string
26+
CWE string
27+
Message string
28+
Fix string
2929
}
3030

3131
// NewTaintAnalyzer creates a TaintAnalyzer ready for use.
@@ -215,44 +215,44 @@ type taintSink struct {
215215
var goTaintSinks = []taintSink{
216216
// SQL injection — match any .Query(), .QueryRow(), .Exec() call
217217
{
218-
Name: "SQL query execution",
219-
CWE: "CWE-89",
220-
Fix: "Use parameterized queries with db.Query(sql, args...) instead of string concatenation",
218+
Name: "SQL query execution",
219+
CWE: "CWE-89",
220+
Fix: "Use parameterized queries with db.Query(sql, args...) instead of string concatenation",
221221
Pattern: regexp.MustCompile(`(?:\.Query|\.QueryRow|\.Exec)\s*\(`),
222222
},
223223
// Command injection
224224
{
225-
Name: "command execution",
226-
CWE: "CWE-78",
227-
Fix: "Validate and sanitize input before passing to exec.Command; use an allowlist of commands",
225+
Name: "command execution",
226+
CWE: "CWE-78",
227+
Fix: "Validate and sanitize input before passing to exec.Command; use an allowlist of commands",
228228
Pattern: regexp.MustCompile(`exec\.Command\s*\(`),
229229
},
230230
// Path traversal — os.Open, os.Create, os.ReadFile, os.WriteFile
231231
{
232-
Name: "file operation",
233-
CWE: "CWE-22",
234-
Fix: "Use filepath.Clean() and validate the path is within the expected directory",
232+
Name: "file operation",
233+
CWE: "CWE-22",
234+
Fix: "Use filepath.Clean() and validate the path is within the expected directory",
235235
Pattern: regexp.MustCompile(`os\.(?:Open|Create|ReadFile|WriteFile|Remove|MkdirAll)\s*\(`),
236236
},
237237
// HTTP response writing with tainted data
238238
{
239-
Name: "HTTP response write",
240-
CWE: "CWE-79",
241-
Fix: "Sanitize output before writing to HTTP response to prevent XSS",
239+
Name: "HTTP response write",
240+
CWE: "CWE-79",
241+
Fix: "Sanitize output before writing to HTTP response to prevent XSS",
242242
Pattern: regexp.MustCompile(`(?:w|rw|resp|response)\.(?:Write|WriteHeader)\s*\(`),
243243
},
244244
// Log output
245245
{
246-
Name: "log output",
247-
CWE: "CWE-532",
248-
Fix: "Avoid logging sensitive user data; redact or mask before logging",
246+
Name: "log output",
247+
CWE: "CWE-532",
248+
Fix: "Avoid logging sensitive user data; redact or mask before logging",
249249
Pattern: regexp.MustCompile(`(?:log\.|slog\.|logger\.|fmt\.Print)(?:Println|Printf|Info|Debug|Warn|Error|Fatal|Sprintf|Sprintln)`),
250250
},
251251
// Template execution (XSS)
252252
{
253-
Name: "template execution",
254-
CWE: "CWE-79",
255-
Fix: "Use html/template instead of text/template; sanitize user input before template rendering",
253+
Name: "template execution",
254+
CWE: "CWE-79",
255+
Fix: "Use html/template instead of text/template; sanitize user input before template rendering",
256256
Pattern: regexp.MustCompile(`\.Execute\s*\(`),
257257
},
258258
}

0 commit comments

Comments
 (0)