@@ -16,16 +16,16 @@ type TaintAnalyzer struct{}
1616
1717// TaintFinding represents a data-flow vulnerability where tainted data reaches a sink.
1818type 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 {
215215var 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