Uploaded image for project: 'Red Hat 3scale API Management'
  1. Red Hat 3scale API Management
  2. THREESCALE-10934

Batcher policy does not accept the same chars specified in Porta regex for app_id, app_key & user_key

XMLWordPrintable

    • False
    • None
    • False
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • Not Started
    • RHOAM Sprint 56, RHOAM Sprint 57

      When batcher policy retrieving the reports from the cached, it will return the following error if user_key is base64 encoded.

      reports_batcher.lua:99: get_all(): failed to get report for key service_id:12,user_key:ZXhhbXBsZV91c2VyX2tleQo=,metric:Hits err: credentials not found, context: ngx.timer, client: 10.10.10.1, server: 0.0.0.0:8080 

      The above error is due to the batcher's policy allowing only user_key contains characters

      local regexes_report_key = {
        [[service_id:(?<service_id>[\w-]+),user_key:(?<user_key>[\S-]+),metric:(?<metric>[\S-]+)]],
        [[service_id:(?<service_id>[\w-]+),access_token:(?<access_token>[\w-]+),metric:(?<metric>[\S-]+)]],
        [[service_id:(?<service_id>[\w-]+),app_id:(?<app_id>[\w-]+),app_key:(?<app_key>[\w-]+),metric:(?<metric>[\S-]+)]],
        [[service_id:(?<service_id>[\w-]+),app_id:(?<app_id>[\w-]+),metric:(?<metric>[\S-]+)]],
      } 

      The side effect of this is that shared memory will fill up over time due to batcher_policy not being able to send and delete old reports.

      Allowed user_key and app_key format

      User_key 

      Allowed characters: [A-Z a-z 0-9 - _ .], or Base64 format without forward slash (/), no spaces and up to 256 characters.

      App_key

      Allowed characters: [A-Z a-z 0-9 ! " # $ % & ' ( ) * + , - . : ; < = > ? @ [ ] ^ _ ` { | } ~], no spaces and between 5 and 255 characters.

      Regrex from porta code

      user_key

      # letter, number, underscore (_), hyphen-minus (-), dot (.), base64 format
      # In base64 encoding, the character set is [A-Z,a-z,0-9,and + /], if rest length is less than 4, fill of '=' character.
      # ^([A-Za-z0-9+/]{4})* means the String start with 0 time or more base64 group.
      # ([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==) means the String must end of 3 forms in [A-Za-z0-9+/]{4} or [A-Za-z0-9+/]{3}= or [A-Za-z0-9+/]{2}==
      # matches also the non 64B case with (\A[\w\-\.]+\Z)
      USER_KEY_FORMAT = /(([\w\-\.]+)|([A-Za-z0-9+\/]{4})*([A-Za-z0-9+\/]{4}|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==))/

      app_key

       # The following characters are accepted:
        # A-Z a-z 0-9 ! " # $ % & ' ( ) * + , - . / : ; < = > ? @ [ \ ] ^ _ ` { | } ~
        # Spaces are not allowed
        validates :value, format: { with: /\A[\x21-\x7E]+\Z/ },
                          length: { within: 5..255 },
                          uniqueness: { scope: :application_id, case_sensitive: false }

              Unassigned Unassigned
              rhn-support-atra An Tran
              Martin Kudlej Martin Kudlej
              An Tran An Tran
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: