github.com/jasoet/gopki@v1.15.0/.golangci.yml (about)

     1  # GoPKI golangci-lint configuration
     2  # Optimized for cryptographic library with focus on security and performance
     3  
     4  run:
     5    timeout: 5m
     6    tests: true
     7  
     8  output:
     9    formats:
    10      - format: colored-line-number
    11    print-issued-lines: true
    12    print-linter-name: true
    13  
    14  linters-settings:
    15    # Security-focused settings
    16    gosec:
    17      # Security rules for crypto libraries
    18      severity: "medium"
    19      confidence: "medium"
    20      excludes:
    21        - G501  # Allow MD5 for non-security purposes (like checksums)
    22      includes:
    23        - G101  # Look for hardcoded credentials
    24        - G102  # Bind to all interfaces
    25        - G103  # Audit the use of unsafe block
    26        - G104  # Audit errors not checked
    27        - G106  # Audit the use of ssh.InsecureIgnoreHostKey
    28        - G107  # Url provided to HTTP request as taint input
    29        - G108  # Profiling endpoint automatically exposed
    30        - G109  # Potential Integer overflow made by strconv.Atoi result conversion
    31        - G110  # Potential DoS vulnerability via decompression bomb
    32  
    33    # Code quality settings
    34    govet:
    35      enable-all: true
    36      disable:
    37        - fieldalignment  # Struct field alignment can be relaxed for clarity
    38        - shadow         # Enable predeclared linter separately
    39  
    40    gocyclo:
    41      min-complexity: 15  # Allow moderate complexity for crypto operations
    42  
    43    gofmt:
    44      simplify: true
    45  
    46    goimports:
    47      local-prefixes: github.com/jasoet/gopki
    48  
    49    goconst:
    50      min-len: 3
    51      min-occurrences: 3
    52      ignore-tests: true
    53  
    54    misspell:
    55      locale: US
    56      ignore-words:
    57        - keypair
    58        - keypairs
    59  
    60    lll:
    61      line-length: 120  # Reasonable for complex crypto function signatures
    62  
    63    unused:
    64      check-exported: false  # Public API may have unused exported functions
    65  
    66    staticcheck:
    67      checks: ["all"]
    68  
    69    errcheck:
    70      check-type-assertions: true
    71      check-blank: true
    72      exclude-functions:
    73        - io/ioutil.ReadFile
    74        - io.Copy(*bytes.Buffer)
    75        - io.Copy(os.Stdout)
    76  
    77    # Performance settings
    78    prealloc:
    79      simple: true
    80      range-loops: true
    81      for-loops: false
    82  
    83    # Style settings
    84    revive:
    85      rules:
    86        - name: var-naming
    87          severity: warning
    88          disabled: false
    89          arguments:
    90            - ["ID", "URL", "HTTP", "JSON", "API", "PKI", "CA", "RSA", "ECDSA", "Ed25519", "X509", "PEM", "DER", "PKCS", "CMS", "OID"] # Allow crypto acronyms
    91        - name: exported
    92          severity: warning
    93          disabled: false
    94          arguments:
    95            - "checkPrivateReceivers"
    96            - "sayRepetitiveInsteadOfStutters"
    97  
    98  linters:
    99    enable:
   100      # Code quality
   101      - govet
   102      - errcheck
   103      - staticcheck
   104      - unused
   105      - gosimple
   106      - ineffassign
   107      - typecheck
   108      - predeclared
   109  
   110      # Security (critical for crypto library)
   111      - gosec
   112  
   113      # Performance
   114      - prealloc
   115      - unconvert
   116  
   117      # Style and maintainability
   118      - gofmt
   119      - goimports
   120      - misspell
   121      - lll
   122      - goconst
   123      - gocyclo
   124      - revive
   125  
   126      # Bug prevention
   127      - bodyclose
   128      - noctx
   129      - rowserrcheck
   130      - sqlclosecheck
   131  
   132      # Additional useful linters
   133      - asciicheck
   134      - gofumpt
   135      - whitespace
   136      - wsl
   137  
   138    disable:
   139      # Disabled linters with reasons
   140      - dupl         # Crypto code may have similar patterns legitimately
   141      - funlen       # Crypto functions can be long due to security checks
   142      - gocognit     # Cognitive complexity can be high in crypto code
   143      - nestif       # Deep nesting acceptable for security validations
   144      - cyclop       # Duplicate of gocyclo
   145      - exhaustive   # Not all enum cases need handling in crypto contexts
   146      - forbidigo    # May conflict with necessary crypto operations
   147      - forcetypeassert # Type assertions are sometimes necessary in crypto
   148      - godot        # Comment formatting can be relaxed
   149      - godox        # Allow TODOs in development
   150      - gomnd        # Magic numbers acceptable in crypto (key sizes, etc.)
   151      - gomoddirectives # Module directives are project-specific
   152      - gomodguard   # Module restrictions not needed
   153      - importas     # Import aliasing flexibility needed
   154      - maintidx     # Maintainability index can be relaxed for crypto
   155      - nlreturn     # Newline returns formatting is subjective
   156      - paralleltest # Crypto tests may need sequential execution
   157      - testpackage  # Tests can be in same package for access to internals
   158      - wrapcheck    # Error wrapping patterns can vary
   159  
   160  issues:
   161    exclude-dirs:
   162      - vendor
   163      - examples  # Examples may have API mismatches during development
   164      - encryption  # Temporarily excluded due to API updates
   165      - pkcs12     # Temporarily excluded due to API updates
   166  
   167    exclude-files:
   168      - ".*\\.pb\\.go$"  # Exclude generated protobuf files
   169  
   170    exclude-rules:
   171      # Exclude some linters from running on tests files
   172      - path: _test\.go
   173        linters:
   174          - gosec        # Security checks can be relaxed in tests
   175          - goconst      # Test constants can be repeated
   176          - lll          # Test lines can be longer
   177          - dupl         # Test code duplication is acceptable
   178  
   179      # Exclude specific issues
   180      - text: "weak cryptographic primitive"
   181        linters:
   182          - gosec
   183        # Allow weak crypto in examples or specific documented cases
   184  
   185      # Allow long functions in signer/verifier (complex crypto operations)
   186      - path: (signer|verifier)\.go
   187        linters:
   188          - funlen
   189          - gocyclo
   190  
   191      # Allow complexity in format implementations
   192      - path: formats/.*\.go
   193        linters:
   194          - gocyclo
   195          - goconst
   196  
   197    max-issues-per-linter: 0
   198    max-same-issues: 0
   199    new: false
   200  
   201  severity:
   202    default-severity: error
   203    case-sensitive: false
   204    rules:
   205      - linters:
   206          - revive
   207        severity: warning
   208      - linters:
   209          - gosec
   210        severity: error  # Security issues are always errors