rules:
  - id: bash-tls-version-too-old
    patterns:
      - pattern-either:
          - pattern: openssl s_client -tls1 ...
          - pattern: openssl s_client -tls1_1 ...
          - pattern: openssl s_client -ssl3 ...
          - pattern: openssl s_client -ssl2 ...
          - pattern: curl --tlsv1.0 ...
          - pattern: curl --tlsv1.1 ...
          - pattern: curl --sslv3 ...
          - pattern: wget --secure-protocol=TLSv1 ...
          - pattern: wget --secure-protocol=SSLv3 ...
    message: >-
      TLS 1.0/1.1 use broken cipher suites (RC4, 3DES, EXPORT) and are prohibited by RFC 8996. Upgrade to
      TLS 1.3.
    severity: ERROR
    languages: [bash]
    metadata:
      category: security
      technology: [bash, shell, openssl, curl, tls, post-quantum]
      cwe:
        - "CWE-326: Inadequate Encryption Strength"
      owasp:
        - A02:2021 - Cryptographic Failures
      confidence: HIGH
      likelihood: HIGH
      impact: HIGH
      quantum_vulnerable: true
      quantum_attack: "Blocks PQC migration"
      quantum_risk_score: 8

  - id: bash-tls-cert-validation-disabled
    patterns:
      - pattern-either:
          - pattern: curl -k ...
          - pattern: curl --insecure ...
          - pattern: wget --no-check-certificate ...
          - pattern: openssl s_client -noverify ...
    message: >-
      SECURITY VULNERABILITY: TLS certificate validation is disabled. This allows man-in-the-middle
      attacks and completely defeats TLS security.
    severity: ERROR
    languages: [bash]
    metadata:
      category: security
      technology: [bash, shell, curl, wget, tls]
      cwe:
        - "CWE-295: Improper Certificate Validation"
      owasp:
        - A02:2021 - Cryptographic Failures
      confidence: HIGH
      likelihood: HIGH
      impact: CRITICAL
      quantum_vulnerable: false
      quantum_risk_score: 9

  - id: bash-tls-weak-cipher-suite
    patterns:
      - pattern-either:
          - pattern: openssl s_client -cipher RC4-SHA ...
          - pattern: openssl s_client -cipher DES-CBC-SHA ...
          - pattern: openssl s_client -cipher NULL-SHA ...
          - pattern: curl --ciphers RC4-SHA ...
          - pattern: curl --ciphers DES-CBC-SHA ...
    message: >-
      DES has a 56-bit key -- completely broken classically and trivially quantum-vulnerable. Migrate to
      AES-256-GCM.
    severity: ERROR
    languages: [bash]
    metadata:
      category: security
      technology: [bash, shell, openssl, tls, post-quantum]
      cwe:
        - "CWE-327: Use of a Broken or Risky Cryptographic Algorithm"
      owasp:
        - A02:2021 - Cryptographic Failures
      confidence: HIGH
      likelihood: MEDIUM
      impact: HIGH
      quantum_vulnerable: true
      quantum_attack: "Blocks PQC migration"
      quantum_risk_score: 8
