|
| 1 | +run: |
| 2 | + skip-dirs: |
| 3 | + - vendor |
| 4 | + - tests |
| 5 | + - scripts |
| 6 | + skip-files: |
| 7 | + - .*/zz_generated.deepcopy.go |
| 8 | + - .*/mock/*.go |
| 9 | + tests: false |
| 10 | + timeout: 10m |
| 11 | +linters-settings: |
| 12 | + funlen: |
| 13 | + lines: 500 |
| 14 | + statements: 200 |
| 15 | + gocyclo: |
| 16 | + min-complexity: 40 |
| 17 | + gosimple: |
| 18 | + checks: ["S1019", "S1002"] |
| 19 | + staticcheck: |
| 20 | + checks: ["SA4006"] |
| 21 | + govet: |
| 22 | + enable: |
| 23 | + - asmdecl |
| 24 | + - assign |
| 25 | + - atomic |
| 26 | + - atomicalign |
| 27 | + - bools |
| 28 | + - buildtag |
| 29 | + - cgocall |
| 30 | + - copylocks |
| 31 | + - deepequalerrors |
| 32 | + - errorsas |
| 33 | + - findcall |
| 34 | + - framepointer |
| 35 | + - httpresponse |
| 36 | + - ifaceassert |
| 37 | + - lostcancel |
| 38 | + - nilfunc |
| 39 | + - nilness |
| 40 | + - reflectvaluecompare |
| 41 | + - shift |
| 42 | + - sigchanyzer |
| 43 | + - sortslice |
| 44 | + - stdmethods |
| 45 | + - stringintconv |
| 46 | + - testinggoroutine |
| 47 | + - tests |
| 48 | + - unmarshal |
| 49 | + - unreachable |
| 50 | + - unsafeptr |
| 51 | + - unusedresult |
| 52 | + - printf |
| 53 | + disable: |
| 54 | + - composites |
| 55 | + - loopclosure |
| 56 | + - fieldalignment |
| 57 | + - shadow |
| 58 | + - structtag |
| 59 | + - unusedwrite |
| 60 | + errcheck: |
| 61 | + exclude-functions: |
| 62 | + - flag.Set |
| 63 | + - os.Setenv |
| 64 | + - os.Unsetenv |
| 65 | + - logger.Sync |
| 66 | + - fmt.Fprintf |
| 67 | + - fmt.Fprintln |
| 68 | + - (io.Closer).Close |
| 69 | + - (io.ReadCloser).Close |
| 70 | + - (k8s.io/client-go/tools/cache.SharedInformer).AddEventHandler |
| 71 | + nestif: |
| 72 | + # 复杂度大于32的认为阻塞 |
| 73 | + min-complexity: 32 |
| 74 | + goconst: |
| 75 | + # Minimal length of string constant. |
| 76 | + # Default: 3 |
| 77 | + min-len: 3 |
| 78 | + # Minimum occurrences of constant string count to trigger issue. |
| 79 | + # Default: 3 |
| 80 | + min-occurrences: 3 |
| 81 | + # Ignore test files. |
| 82 | + # Default: false |
| 83 | + ignore-tests: true |
| 84 | + match-constant: false |
| 85 | + numbers: true |
| 86 | + min: 2 |
| 87 | + max: 10 |
| 88 | + ignore-calls: true |
| 89 | + gosec: |
| 90 | + includes: |
| 91 | + - G101 # Look for hard coded credentials |
| 92 | + - G102 # Bind to all interfaces |
| 93 | + - G103 # Audit the use of unsafe block |
| 94 | + - G104 # Audit errors not checked |
| 95 | + - G106 # Audit the use of ssh.InsecureIgnoreHostKey |
| 96 | + - G107 # Url provided to HTTP request as taint input |
| 97 | + - G108 # Profiling endpoint automatically exposed on /debug/pprof |
| 98 | + - G109 # Potential Integer overflow made by strconv.Atoi result conversion to int16/32 |
| 99 | + - G110 # Potential DoS vulnerability via decompression bomb |
| 100 | + - G111 # Potential directory traversal |
| 101 | + - G112 # Potential slowloris attack |
| 102 | + - G113 # Usage of Rat.SetString in math/big with an overflow (CVE-2022-23772) |
| 103 | + # - G114 # Use of net/http serve function that has no support for setting timeouts |
| 104 | + - G201 # SQL query construction using format string |
| 105 | + - G202 # SQL query construction using string concatenation |
| 106 | + - G203 # Use of unescaped data in HTML templates |
| 107 | + #- G204 # Audit use of command execution |
| 108 | + - G301 # Poor file permissions used when creating a directory |
| 109 | + - G302 # Poor file permissions used with chmod |
| 110 | + - G303 # Creating tempfile using a predictable path |
| 111 | + - G304 # File path provided as taint input |
| 112 | + - G305 # File traversal when extracting zip/tar archive |
| 113 | + - G306 # Poor file permissions used when writing to a new file |
| 114 | + - G307 # Deferring a method which returns an error |
| 115 | + #- G401 # Detect the usage of DES, RC4, MD5 or SHA1 |
| 116 | + - G402 # Look for bad TLS connection settings |
| 117 | + - G403 # Ensure minimum RSA key length of 2048 bits |
| 118 | + - G404 # Insecure random number source (rand) |
| 119 | + #- G501 # Import blocklist: crypto/md5 |
| 120 | + - G502 # Import blocklist: crypto/des |
| 121 | + - G503 # Import blocklist: crypto/rc4 |
| 122 | + - G504 # Import blocklist: net/http/cgi |
| 123 | + - G505 # Import blocklist: crypto/sha1 |
| 124 | + - G601 # Implicit memory aliasing of items from a range statement |
| 125 | + # Exclude generated files |
| 126 | + # Default: false |
| 127 | + exclude-generated: true |
| 128 | + # Filter out the issues with a lower severity than the given value. |
| 129 | + # Valid options are: low, medium, high. |
| 130 | + # Default: low |
| 131 | + severity: medium |
| 132 | + # Filter out the issues with a lower confidence than the given value. |
| 133 | + # Valid options are: low, medium, high. |
| 134 | + # Default: low |
| 135 | + confidence: medium |
| 136 | + # Concurrency value. |
| 137 | + # Default: the number of logical CPUs usable by the current process. |
| 138 | + concurrency: 12 |
| 139 | + # To specify the configuration of rules. |
| 140 | + config: |
| 141 | + # Globals are applicable to all rules. |
| 142 | + global: |
| 143 | + nosec: true |
| 144 | + show-ignored: true |
| 145 | + audit: true |
| 146 | + G101: |
| 147 | + # Regexp pattern for variables and constants to find. |
| 148 | + # Default: "(?i)passwd|pass|password|pwd|secret|token|pw|apiKey|bearer|cred" |
| 149 | + pattern: "(?i)example" |
| 150 | + # If true, complain about all cases (even with low entropy). |
| 151 | + # Default: false |
| 152 | + ignore_entropy: false |
| 153 | + # Maximum allowed entropy of the string. |
| 154 | + # Default: "80.0" |
| 155 | + entropy_threshold: "80.0" |
| 156 | + per_char_threshold: "3.0" |
| 157 | + truncate: "32" |
| 158 | + G104: |
| 159 | + fmt: |
| 160 | + - Fscanf |
| 161 | + G111: |
| 162 | + # Regexp pattern to find potential directory traversal. |
| 163 | + # Default: "http\\.Dir\\(\"\\/\"\\)|http\\.Dir\\('\\/'\\)" |
| 164 | + pattern: "custom\\.Dir\\(\\)" |
| 165 | + # Maximum allowed permissions mode for os.Mkdir and os.MkdirAll |
| 166 | + # Default: "0750" |
| 167 | + G301: "0750" |
| 168 | + # Maximum allowed permissions mode for os.OpenFile and os.Chmod |
| 169 | + # Default: "0600" |
| 170 | + G302: "0600" |
| 171 | + # Maximum allowed permissions mode for os.WriteFile and ioutil.WriteFile |
| 172 | + # Default: "0600" |
| 173 | + G306: "0600" |
| 174 | + nilnil: |
| 175 | + checked-types: |
| 176 | + - ptr |
| 177 | + - map |
| 178 | + - chan |
| 179 | + depguard: |
| 180 | + rules: |
| 181 | + prevent_unmaintained_packages: |
| 182 | + list-mode: lax # allow unless explicitely denied |
| 183 | + files: |
| 184 | + - $all |
| 185 | + - "!$test" |
| 186 | + allow: |
| 187 | + - $gostd |
| 188 | + - path/filepath |
| 189 | + deny: |
| 190 | + - pkg: io/ioutil |
| 191 | + desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil" |
| 192 | + - pkg: path |
| 193 | + desc: "replaced by cross-platform package path/filepath" |
| 194 | + gci: |
| 195 | + # Section configuration to compare against. |
| 196 | + # Section names are case-insensitive and may contain parameters in (). |
| 197 | + # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, |
| 198 | + # If `custom-order` is `true`, it follows the order of `sections` option. |
| 199 | + # Default: ["standard", "default"] |
| 200 | + sections: |
| 201 | + - standard # Standard section: captures all standard packages. |
| 202 | + - default # Default section: contains all imports that could not be matched to another section type.: |
| 203 | + - prefix(github.com/org/project) # Custom section: groups all imports with the specified Prefix. |
| 204 | + - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. |
| 205 | + - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. |
| 206 | + - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. |
| 207 | + # Skip generated files. |
| 208 | + # Default: true |
| 209 | + skip-generated: true |
| 210 | + # Enable custom order of sections. |
| 211 | + # If `true`, make the section order the same as the order of `sections`. |
| 212 | + # Default: false |
| 213 | + custom-order: true |
| 214 | + # Drops lexical ordering for custom sections. |
| 215 | + # Default: false |
| 216 | + no-lex-order: true |
| 217 | + forbidigo: |
| 218 | + forbid: |
| 219 | + # Forbid spew Dump, whether it is called as function or method. |
| 220 | + # Depends on analyze-types below. |
| 221 | + - ^spew\.(ConfigState\.)?Dump$ |
| 222 | + # The package name might be ambiguous. |
| 223 | + # The full import path can be used as additional criteria. |
| 224 | + # Depends on analyze-types below. |
| 225 | + - p: ^v1.Dump$ |
| 226 | + pkg: ^example.com/pkg/api/v1$ |
| 227 | + |
| 228 | +linters: |
| 229 | + enable: |
| 230 | + - asasalint |
| 231 | + - asciicheck |
| 232 | + - bidichk |
| 233 | + - bodyclose |
| 234 | + # - cyclop |
| 235 | + - decorder |
| 236 | + - depguard |
| 237 | + - errcheck |
| 238 | + # - errchkjson |
| 239 | + - errorlint |
| 240 | + - forbidigo |
| 241 | + # - forcetypeassert |
| 242 | + - funlen |
| 243 | + - ineffassign |
| 244 | + - gocognit |
| 245 | + - gocyclo |
| 246 | + - goheader |
| 247 | + - gomodguard |
| 248 | + - goprintffuncname |
| 249 | + - gosimple |
| 250 | + - gosec |
| 251 | + - grouper |
| 252 | + - importas |
| 253 | + - maintidx |
| 254 | + - misspell |
| 255 | + - nakedret |
| 256 | + - nilerr |
| 257 | + - nilnil |
| 258 | + # - noctx |
| 259 | + - nosprintfhostport |
| 260 | + - paralleltest |
| 261 | + - predeclared |
| 262 | + # - promlinter |
| 263 | + - reassign |
| 264 | + - sqlclosecheck |
| 265 | + - staticcheck |
| 266 | + - tenv |
| 267 | + - testpackage |
| 268 | + - tparallel |
| 269 | + # del |
| 270 | + # - typecheck |
| 271 | + - usestdlibvars |
| 272 | + - nestif |
| 273 | + - unused |
| 274 | + - makezero |
| 275 | + - govet |
| 276 | + - goconst |
| 277 | + - gci |
| 278 | + # - rowserrcheck |
| 279 | + # 1.59 version no new lints |
| 280 | + # 1.58 version new lints |
| 281 | + # - fatcontext |
| 282 | + - canonicalheader |
| 283 | + # 1.57 version new lints |
| 284 | + - copyloopvar |
| 285 | + - intrange |
| 286 | + # 1.56 version new lints |
| 287 | + - spancheck |
| 288 | + # 1.55 version new lints |
| 289 | + - gochecksumtype |
| 290 | + - perfsprint |
| 291 | + - sloglint |
| 292 | + - testifylint |
| 293 | + - mirror |
| 294 | + - zerologlint |
| 295 | + # 1.51 version new lints |
| 296 | + - gocheckcompilerdirectives |
| 297 | + # 1.50 version new lints |
| 298 | + - testableexamples |
| 299 | + |
| 300 | +issues: |
| 301 | + # Note: path identifiers are regular expressions, hence the \.go suffixes. |
| 302 | + exclude-rules: |
| 303 | + - path: main\.go |
| 304 | + linters: |
| 305 | + - forbidigo |
| 306 | + - path: _test\.go |
| 307 | + linters: |
| 308 | + - dogsled |
| 309 | + - errcheck |
| 310 | + - goconst |
| 311 | + - gosec |
| 312 | + - ineffassign |
| 313 | + - maintidx |
| 314 | + - typecheck |
| 315 | + - path: \.go$ |
| 316 | + text: "should have a package comment" |
| 317 | + - path: \.go$ |
| 318 | + text: 'exported (.+) should have comment( \(or a comment on this block\))? or be unexported' |
| 319 | + - path: \.go$ |
| 320 | + text: "fmt.Sprintf can be replaced with string concatenation" |
0 commit comments