|
| 1 | +# BACO preset — Go |
| 2 | +[project] |
| 3 | +name = "go" |
| 4 | +languages = ["go"] |
| 5 | + |
| 6 | +[scanner] |
| 7 | +max_file_size_kb = 512 |
| 8 | +exclude_paths = [ |
| 9 | + "vendor/*", |
| 10 | + "node_modules/*", |
| 11 | + "tests/*", |
| 12 | + "test/*", |
| 13 | + "spec/*", |
| 14 | + "cypress/*", |
| 15 | + "playwright/*", |
| 16 | + "*.min.js", |
| 17 | + "*.min.css", |
| 18 | + "*.map", |
| 19 | +] |
| 20 | + |
| 21 | +[scanner.semgrep] |
| 22 | +rulesets = ["p/go"] |
| 23 | +custom_rules = [''' |
| 24 | +rules: |
| 25 | + - id: go-template-html-high |
| 26 | + languages: [go] |
| 27 | + severity: ERROR |
| 28 | + message: > |
| 29 | + template.HTML conversion without escaping, XSS risk if user input flows here. |
| 30 | + metadata: |
| 31 | + cwe: |
| 32 | + - "CWE-79: Improper Neutralization of Input During Web Page Generation" |
| 33 | + pattern: template.HTML($VAR) |
| 34 | +
|
| 35 | + - id: go-weak-hash-md5-medium |
| 36 | + languages: [go] |
| 37 | + severity: WARNING |
| 38 | + message: > |
| 39 | + MD5 hash used for security purposes, cryptographically broken. |
| 40 | + metadata: |
| 41 | + cwe: |
| 42 | + - "CWE-327: Use of a Broken or Risky Cryptographic Algorithm" |
| 43 | + pattern-either: |
| 44 | + - pattern: md5.New() |
| 45 | + - pattern: md5.Sum($VAR) |
| 46 | +
|
| 47 | + - id: go-exec-command-high |
| 48 | + languages: [go] |
| 49 | + severity: ERROR |
| 50 | + message: > |
| 51 | + exec.Command() with variable input, command injection risk. |
| 52 | + metadata: |
| 53 | + cwe: |
| 54 | + - "CWE-78: Improper Neutralization of Special Elements used in an OS Command" |
| 55 | + pattern-either: |
| 56 | + - pattern: exec.Command($CMD) |
| 57 | + - pattern: exec.CommandContext($CTX, $CMD) |
| 58 | +
|
| 59 | + - id: go-taint-sqli-high |
| 60 | + languages: [go] |
| 61 | + mode: taint |
| 62 | + severity: ERROR |
| 63 | + message: > |
| 64 | + User input flows into database query without sanitization, SQL injection risk. |
| 65 | + metadata: |
| 66 | + cwe: |
| 67 | + - "CWE-89: Improper Neutralization of Special Elements used in an SQL Command" |
| 68 | + pattern-sources: |
| 69 | + - pattern: r.URL.Query().Get($KEY) |
| 70 | + - pattern: r.FormValue($KEY) |
| 71 | + - pattern: r.PostFormValue($KEY) |
| 72 | + pattern-sinks: |
| 73 | + - pattern: db.Query($SQL) |
| 74 | + - pattern: db.Exec($SQL) |
| 75 | + - pattern: db.QueryRow($SQL) |
| 76 | + - pattern: db.Prepare($SQL) |
| 77 | +
|
| 78 | + - id: go-taint-cmdi-high |
| 79 | + languages: [go] |
| 80 | + mode: taint |
| 81 | + severity: ERROR |
| 82 | + message: > |
| 83 | + User input flows into command execution without sanitization, command injection risk. |
| 84 | + metadata: |
| 85 | + cwe: |
| 86 | + - "CWE-78: Improper Neutralization of Special Elements used in an OS Command" |
| 87 | + pattern-sources: |
| 88 | + - pattern: r.URL.Query().Get($KEY) |
| 89 | + pattern-sinks: |
| 90 | + - pattern: exec.Command($CMD) |
| 91 | +
|
| 92 | + - id: go-taint-path-traversal-high |
| 93 | + languages: [go] |
| 94 | + mode: taint |
| 95 | + severity: ERROR |
| 96 | + message: > |
| 97 | + User input flows into file operations without validation, path traversal risk. |
| 98 | + metadata: |
| 99 | + cwe: |
| 100 | + - "CWE-22: Improper Limitation of a Pathname to a Restricted Directory" |
| 101 | + pattern-sources: |
| 102 | + - pattern: r.URL.Query().Get($KEY) |
| 103 | + pattern-sinks: |
| 104 | + - pattern: os.Open($PATH) |
| 105 | + - pattern: os.ReadFile($PATH) |
| 106 | + - pattern: os.Create($PATH) |
| 107 | + - pattern: os.Remove($PATH) |
| 108 | +'''] |
| 109 | + |
| 110 | +[scanner.performance] |
| 111 | +enable_variant_search = true |
| 112 | +enable_cve_bootstrap = true |
| 113 | + |
| 114 | +[llm] |
| 115 | +temperature = 0.2 |
| 116 | +max_concurrent = 4 |
| 117 | +enable_llm_cache = true |
| 118 | + |
| 119 | +[llm.phases.discovery] |
| 120 | +models = ["mistral-small"] |
| 121 | + |
| 122 | +[llm.phases.verification] |
| 123 | +model = "mistral-medium" |
| 124 | + |
| 125 | +[llm.phases.aggregation] |
| 126 | +model = "mistral-medium" |
| 127 | + |
| 128 | +[triage] |
| 129 | +enabled = true |
| 130 | +model = "mistral-small" |
| 131 | +batch_size = 8 |
| 132 | +suspicion_threshold = 0.30 |
| 133 | + |
| 134 | +[priority] |
| 135 | +entry_point_patterns = [ |
| 136 | + "http.HandleFunc", |
| 137 | + "router.", |
| 138 | + "gin.", |
| 139 | + "echo.", |
| 140 | + "main.go", |
| 141 | + "cmd/", |
| 142 | + "handlers/", |
| 143 | + "controllers/", |
| 144 | +] |
| 145 | +sink_patterns = [ |
| 146 | + "template.HTML(", |
| 147 | + "md5.New(", |
| 148 | + "md5.Sum(", |
| 149 | + "exec.Command(", |
| 150 | + "exec.CommandContext(", |
| 151 | + "db.Query(", |
| 152 | + "db.Exec(", |
| 153 | + "os.Open(", |
| 154 | + "os.ReadFile(", |
| 155 | +] |
| 156 | + |
| 157 | +[budget] |
| 158 | +enabled = true |
| 159 | +max_llm_calls = 250 |
| 160 | + |
| 161 | +[knowledge.fp_patterns] |
| 162 | +"CWE-79" = [ |
| 163 | + "template.HTMLEscapeString(", |
| 164 | + "template.HTMLAttr(", |
| 165 | + "html.EscapeString(", |
| 166 | + "HTMLEscapeString(", |
| 167 | +] |
| 168 | +"CWE-89" = [ |
| 169 | + "?", |
| 170 | + "$1", |
| 171 | + "sql.Named(", |
| 172 | +] |
| 173 | +"CWE-352" = [ |
| 174 | + "csrf", |
| 175 | + "CSRF", |
| 176 | + "token", |
| 177 | + "nonce", |
| 178 | +] |
| 179 | +"CWE-862" = [ |
| 180 | + "Auth(", |
| 181 | + "Authenticate(", |
| 182 | + "IsAuthenticated(", |
| 183 | + "CheckAuth(", |
| 184 | + "RequireAuth(", |
| 185 | +] |
| 186 | + |
| 187 | +[knowledge.required_security_primitives] |
| 188 | +"go" = ["template.HTMLEscapeString", "template.HTMLAttr", "html.EscapeString", "HTMLEscapeString"] |
| 189 | + |
| 190 | +[agent] |
| 191 | +enabled = false |
0 commit comments