rules:
- id: openuri-request
  message: >-
    Checks for requests to http and ftp (unencrypted) sites using OpenURI.
  severity: WARNING
  metadata:
    likelihood: MEDIUM
    impact: MEDIUM
    confidence: MEDIUM
    category: security
    cwe: 'CWE-319: Cleartext Transmission of Sensitive Information'
    owasp: 'A03:2017 - Sensitive Data Exposure'
    references:
    - https://ruby-doc.org/stdlib-2.6.3/libdoc/open-uri/rdoc/OpenURI.html
    subcategory:
    - vuln
    technology:
    - open-uri
    vulnerability: Insecure Transport
  languages:
  - ruby
  pattern-either:
  - pattern: |
      URI.open('=~/[hH][tT][tT][pP]://.*/', ...)
  - pattern: |
      $URI = URI.parse('=~/[hH][tT][tT][pP]://.*/', ...)
      ...
      $URI.open
  - pattern: |
      URI.open('=~/^[fF][tT][pP]://.*/', ...)
  - pattern: |
      $URI = URI.parse('=~/^[fF][tT][pP]://.*/', ...)
      ...
      $URI.open
