[Bro-Dev] [JIRA] (BIT-1333) Bro's ASCII logging facilities do not escape escape characters

Robin Sommer (JIRA) jira at bro-tracker.atlassian.net
Tue Apr 14 12:32:00 PDT 2015


    [ https://bro-tracker.atlassian.net/browse/BIT-1333?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=20300#comment-20300 ] 

Robin Sommer commented on BIT-1333:
-----------------------------------

I don't think this is quite right yet: we can't really generally escape backslashes on "print". If we did, we'd get for example this:

{code}
# cat a.bro
event bro_init()
        {
        local a = "abc\0def";
        local b = escape_string(a);
        print b;
        }

# bro ./a.bro
abc\\x00def
{code}

I.e, the escape_string() inserts "\x00", and then the print escapes that backslash.

What if we did the backslash escape only on "special request", that is when calling escape_string() and simiarl functions? If one wants the reversible representation, one would then need to call such a function; whereas the semantics for a normal print would remain at "make sure it doesn't output non-printable characters", without being reversible. 

> Bro's ASCII logging facilities do not escape escape characters
> --------------------------------------------------------------
>
>                 Key: BIT-1333
>                 URL: https://bro-tracker.atlassian.net/browse/BIT-1333
>             Project: Bro Issue Tracker
>          Issue Type: Problem
>          Components: Bro
>    Affects Versions: 2.3
>            Reporter: Paul Pearce
>            Assignee: Robin Sommer
>             Fix For: 2.4
>
>
> * Bro escapes non-printable ASCII characters with either \x?? or ^ depending on the character (https://www.bro.org/sphinx/scripts/base/bif/strings.bif.bro.html). 
> * Bro does not however escape \ or ^. 
> * This behavior makes recovering the original string impossible as you can not differentiate between an escaped sequence and a string containing those characters. 
> Examples: 
> $ bro -e 'event bro_init() { print "foo \xc2\xae bar \\xc2\\xae baz"; }'
>  foo \xc2\xae bar \xc2\xae baz
> $ bro -e 'event bro_init() { print "foo\x00bar\\0baz"; }'
>  foo\0bar\0baz
> $ bro -e 'event bro_init() { print "foo \16 bar ^N baz"; }'
>  foo ^N bar ^N baz
> Additionally, it would be ideal if there was a way to standardize escaping to a single syntax (\x?? for all, for example). This would allow post-processing of the bro logs in languages like Python or Ruby trivially using existing decode/encode functionality. I'm happy to file a separate feature request for this behavior, if that is preferred.
> I brought this up on the mailing list (http://mailman.icsi.berkeley.edu/pipermail/bro/2015-February/008174.html). It was suggested (off list) that I file a ticket as well.



--
This message was sent by Atlassian JIRA
(v6.4-OD-16-006#64014)


More information about the bro-dev mailing list