dgryski.semgrep-go.contextcancelable.cancelable-context-not-systematically-cancelled

profile photo of dgryskidgryski
Author
unknown
Download Count*
License

it is good practice to call context cancellation function, $X(), in any case

Run Locally

Run in CI

Defintion

rules:
  - id: cancelable-context-not-systematically-cancelled
    patterns:
      - pattern: $_, $X := context.$CANCELABLE(...)
      - pattern-not-inside: |
          $_, $X := context.$CANCELABLE(...)
          ...
          defer $X()
      - pattern-not-inside: |
          $_, $X := context.$CANCELABLE(...)
          ...
          $X()
      - pattern-not-inside: |
          $_, $X := context.$CANCELABLE(...)
          ...
          t.Cleanup($X)
      - metavariable-regex:
          metavariable: $CANCELABLE
          regex: (WithDeadline|WithTimeout)
    message: it is good practice to call context cancellation function, $X(), in any
      case
    languages:
      - go
    severity: WARNING
    metadata:
      license: MIT