gitlab.gosec.G601-1

unknown
Download Count*
License

Implicit memory aliasing in for loop.

Run Locally

Run in CI

Defintion

rules:
  - id: gosec.G601-1
    patterns:
      - pattern-either:
          - pattern: |
              for _, $ARG := range $SLICE {
                <... &($ARG) ...>
              }
          - pattern: |
              for _, $ARG := range $SLICE {
                <... func() { <... &$ARG ...> } ...>
              }
          - pattern: |
              for _, $ARG := range $SLICE {
                <... $X(..., <... &$ARG ...>, ...) ...>
              }
      - pattern-not: |
          for _, $ARG := range $SLICE {
            <... *$ARG ...>
          }
      - pattern-not-inside: for _, $ARG := range $SLICE { return ... }
    message: |
      Implicit memory aliasing in for loop.
    metadata:
      cwe: "CWE-118: Incorrect Access of Indexable Resource ('Range Error')"
      primary_identifier: gosec.G601-1
      secondary_identifiers:
        - name: Gosec Rule ID G601
          type: gosec_rule_id
          value: G601
      license: MIT
    severity: WARNING
    languages:
      - go