Patch To Remove Numbers From The Logs

Home » Asterisk Users » Patch To Remove Numbers From The Logs
Asterisk Users 4 Comments

Hi,

We have a project where people will be making payments over the phone. I
would like block Asterisk from logging any time the system is processing a card. So be it SayDigits(123456789), when the user enters DTMF or when I
pass a card number as a variable to an AGI etc. I assume this affects others and I would like to have the patch created in a way that a. will be accepted by Sangoma and b. will work for anyone else that has this issue. My idea was to have a channel variable for exampleSet(CHANNEL(LOG_DIGITS)=OFF) and then have ast_logger check to see if the variable is set. The problem I faced that wherever the logger is called a string is passed. So any digits (e.g. channel ID, thread ID etc.)
would have the digits removed which I assume would hurt people. My solution was to have a configuration file where you would put in regex strings that we would replace. For instance if I set LOG_DIGITS=OFF and in the Dialplan I had CARDA11111111111111
EXP_MOTH
EXP_YEAR 25

In the configuration file I would have CARD=([0-9]{15,16})
EXP_MONTH=([1-2]?[0-9])
EXP_YEAR=(202[5-9])

The system would then look for any of the above expressions and then replace the numbers with an X. Does that seem like a patch that would get accepted? is that completely in left field? Any thoughts on a better way of doing it? I know I can change the verbosity to 0 but then I would get nothing at all in the logs.

TIA.

Dovid

4 thoughts on - Patch To Remove Numbers From The Logs

  • Are you talking strictly about normal messages generated by the dialplan or all messages, even warnings, errors, etc generated internally?

    Would you need to do this on a channel-by-channel basis or could you set a global variable?

    Are those variables set on the channel?

    I’d skip the config file and make teh regexes global dialplan variables.

  • Because we would want to enable and disable it. Meaning we want all the logging on in general however at certain times where there is sensitive information we would not want it logged

    Yes they are. For instance Exten => _XX,1,Set(Month=${EXTEN})

    But then how would you have multiple? Have the strings comma delimited or one large string (e.g. CARD=([0-9]{15,16})|EXP_MONTH=([1-2]?[0-9])|EXP_YEAR=(202[5-9])). One possible is the limit of a line in Asterisk if I recall correctly, was 256
    characters.

  • If you need something quick you could create a batch script with sed or awk to remove the log lines you want and attach it to the prerotate script of logrotate (in case you use any of these in your env). Certainly this is not a final solution but it is already something that doesn’t depend on an asterisk patch…..

  • “Playing ‘digits/3.ulaw'” in the logs. It can be a credit card number OR it could be telling them how much money they are paying. If the latter I want to keep it. If it’s repeating a credit card I don’t.