For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

AlexBCT's avatar
AlexBCT
Icon for Cumulonimbus rankCumulonimbus
Aug 06, 2021

How to stop an APM variable converting string to number

Hi all,

 

For a specific requirement, I need to add ".0" at the end of a username in APM. I'm doing this using a Variable Assign agent in the VPE.

As the username consists completely of numbers, APM automatically converts the variable to floating point number. Normally not a big problem as it's still stored in strings anyway, but unfortunately a lot of the usernames starts with one or more 0's, meaning during the conversion to floating point, it removes those leading zeroes! (...talk about APM/TCL being too helpful... ;)

 

Does anyone know of a way to force APM to interpret a variable and any modifications on it as strings, rather than numbers?

 

Thanks!

4 Replies

  • Hello Alex.

    This is working for me:

    session.logon.last.username = expr { "[mcget {session.logon.last.username}].0" }

    Regards,

    Dario.

    • AlexBCT's avatar
      AlexBCT
      Icon for Cumulonimbus rankCumulonimbus

      Hi Dario,

       

      Thanks for the response!

      I've just tried this one in my lab, but unfortunately it still strips off the leading 0 when I look at session.logon.last.username afterwards. When you run it with for example 012346 as a username, what does the variable look like afterwards in your system?

       

      Thanks!

      • Dario_Garrido's avatar
        Dario_Garrido
        Icon for Noctilucent rankNoctilucent

        Hello Alex.

        Apply this iRule to your VS.

        when ACCESS_POLICY_AGENT_EVENT {
            if { [ACCESS::policy agent_id] eq "format_username" } {
                ACCESS::session data set session.logon.last.username "[ACCESS::session data get "session.logon.last.username"].0"
            }
        }

        Then configure an iRule Event box in your APM policy with ID "format_username".

        Let me know if this works in your scenario.

        Regards,

        Dario.