# Debugging Policies and Print Statement

**URL:** https://community.zeek.org/t/debugging-policies-and-print-statement/2326
**Category:** Zeek
**Created:** [May 28, 2012, 7:48pm UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326 "2012-05-28T19:48:06Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Chris\_Green](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Chris\_Green](https://community.zeek.org/u/Chris_Green)
#### Post date: [May 28, 2012, 7:48pm UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326/1 "2012-05-28T19:48:06Z")

</div>

Good day,

I’m using bro version 2.0-372 with a new git checkout from master as of 2012-05-27 on Centos6. I’m having an issue where the print statement in the policy debugger displays nothing. Breakpoints and stack tracks seem to work correctly but not being able to inspect variables is making playing with policies frustrating.

Is this a known issue or is there some type of preprocessing make inspection work?

Thanks,  
Chris

In bro\_init() at /usr/local/bro/share/bro/base/utils/site.bro:155  
155 local\_dns\_suffix\_regex = set\_to\_regex(local\_zones, “(^\.?|\.)(~~)$”);  
(Bro [0]) break http\_entity\_data  
Setting breakpoint on http\_entity\_data:  
There are multiple definitions of that event handler.  
Please choose one of the following options:  
[1] /usr/local/bro/share/bro/base/protocols/http/./file-ident.bro:79  
[2] /usr/local/bro/share/bro/base/protocols/http/./file-hash.bro:37  
[3] /usr/local/bro/share/bro/base/protocols/http/./file-extract.bro:32  
[4] /usr/local/bro/share/bro/base/protocols/http/./file-ident.bro:85  
[a] All of the above  
[n] None of the above  
Enter your choice: 2  
Breakpoint 1 set at http\_entity\_data at /usr/local/bro/share/bro/base/protocols/http/./file-hash.bro:37  
(Bro [1]) c  
Continuing.  
Breakpoint 1, http\_entity\_data(c = '[id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], orig=[size=121, state=4, num\_pkts=4, num\_bytes\_ip=216, flow\_label=0], resp=[size=3095, state=4, num\_pkts=4, num\_bytes\_ip=1963, flow\_label=0], start\_time=1338087055.218736, duration=0.27459, service={

}, addl=, hot=0, history=ShACad, uid=cTLeNAfgQo2, dpd=, conn=[ts=1338087055.218736, uid=cTLeNAfgQo2, id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], proto=tcp, service=, duration=, orig\_bytes=, resp\_bytes=, conn\_state=, local\_orig=T, missed\_bytes=121, history=, orig\_pkts=, orig\_ip\_bytes=, resp\_pkts=, resp\_ip\_bytes=], extract\_orig=F, extract\_resp=F, dns=, dns\_state=, ftp=, http=[ts=1338087055.413572, uid=cTLeNAfgQo2, id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], trans\_depth=0, method=, host=, uri=, referrer=, user\_agent=, request\_body\_len=0, response\_body\_len=0, status\_code=200, status\_msg=OK, info\_code=, info\_msg=, filename=, tags={

}, username=, password=, capture\_password=F, proxied=, mime\_type=application/x-dosexec, first\_chunk=T, md5=, calc\_md5=F, calculating\_md5=F, extraction\_file=, extract\_file=F], http\_state=[pending={  
[0] = [ts=1338087055.413572, uid=cTLeNAfgQo2, id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], trans\_depth=0, method=, host=, uri=, referrer=, user\_agent=, request\_body\_len=0, response\_body\_len=0, status\_code=, status\_msg=, info\_code=, info\_msg=, filename=, tags={

}, username=, password=, capture\_password=F, proxied=, mime\_type=, first\_chunk=T, md5=, calc\_md5=F, calculating\_md5=F, extraction\_file=, extract\_file=F],  
[1] = [ts=1338087055.413572, uid=cTLeNAfgQo2, id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], trans\_depth=0, method=, host=, uri=, referrer=, user\_agent=, request\_body\_len=0, response\_body\_len=0, status\_code=200, status\_msg=OK, info\_code=, info\_msg=, filename=, tags={

}, username=, password=, capture\_password=F, proxied=, mime\_type=application/x-dosexec, first\_chunk=T, md5=, calc\_md5=F, calculating\_md5=F, extraction\_file=, extract\_file=F]  
}, current\_request=0, current\_response=1], irc=, smtp=, smtp\_state=, ssh=, ssl=, syslog=, known\_services\_done=F]’, is\_orig = ‘F’, length = ‘1500’, data = ‘MZ\x90\0^C\0\0\0^D\0\0\0\xff\xff\0\0\xb8\0\0\0\0\0\0\0@\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\0\0\0^N\x1f\xba^N\0\xb4^I\xcd!\xb8^AL\xcd!This program cannot be run in DOS mode.^M^M^J$\0\0\0\0\0\0\0PE\0\0L^A^C\0`\xdf\x9cO\0\xe2!\0\0\0\0\0\xe0\0/^C^K^A^B^V\0\xd0^I\0\0\0^A\0\0\xc0^Y\0^P\x85#\0\0\xd0^Y\0\0\xa0#\0\0\0@\0\0^P\0\0\0^B\0\0^D\0\0\0^A\0\0\0^D\0\0\0\0\0\0\0\0\xa0$\0\0^P\0\0\0\0\0\0^B\0\0\x80\0\0 \0\0^P\0\0\0\0^P\0\0^P\0\0\0\0\0\0^P\0\0\0\0\0\0\0\0\0\0\0^T\x9a$\0l^B\0\0\0\xa0#\0^T\xfa\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\xf0\x90#\0^X\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0UPX0\0\0\0\0\0\xc0^Y\0\0^P\0\0\0\0\0\0\0^B\0\0\0\0\0\0\0\0\0\0\0\0\0\0\x80\0\0\xe0UPX1\0\0\0\0\0\xd0^I\0\0\xd0^Y\0\0\xc2^I\0\0^B\0\0\0\0\0\0\0\0\0\0\0\0\0\0@\0\0\xe0.rsrc\0\0\0\0\0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E^?\xe6\xfc\xe6\x8210\x1f\x86yrO\x96s\xffU^R3^V\xa6^UD\xb3^Nt\xed"\x92\xa3``\xd4^Fn\xdb^Lf\xd5\xc2^K1^E\xdf\xa6\xe7\xbc\xb8’=\xa9\xeft\xeb;O1R\x1er\xccC&\x99\xba\x85t\xfa\xc8\xe7^D\xdc5\x1bN@M\x8cFrB2\xe3\x83^So^U\xcf\x9cu\xde9\xe7xV"$Q^K\xef^U^M\xbd\x99\xd5I^EgS\xfe\xaf\xa3^I\x80P\xad!\x88\x97;\x85\xf1\x95\xed^Y^Im\xd9\x93\x9e4O\xe4Y^S\x88\x88^F\xa8’^U\_}\xa1\xcbh.;\xe6\xc7\xac^KSGvF\<\xe4i\xe7GN\0rV\xbd\xcf}`\x84\xa5^G\xe6\xa1U\xc6\x91,^Ct\xe0A\x99\x9d^O\xffj\xe8\xf4n\x86^^J\xf1\x91.\xaa\xc0^Y?\x8bV^N\xc1\x8aJPhh\xfa\xbc\xf3\x9e\xd1yX\0\x1f$^Ml(\xe6\xbd^Ji\xd9’) at /usr/local/bro/share/bro/base/protocols/http/./file-hash.bro:37  
In http\_entity\_data(c = '[id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], orig=[size=121, state=4, num\_pkts=4, num\_bytes\_ip=216, flow\_label=0], resp=[size=3095, state=4, num\_pkts=4, num\_bytes\_ip=1963, flow\_label=0], start\_time=1338087055.218736, duration=0.27459, service={

}, addl=, hot=0, history=ShACad, uid=cTLeNAfgQo2, dpd=, conn=[ts=1338087055.218736, uid=cTLeNAfgQo2, id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_h=209.132.180.131, resp\_p=80/tcp], proto=tcp, service=, duration=, orig\_bytes=, resp\_bytes=, conn\_state=, local\_orig=T, missed\_bytes=121, history=, orig\_pkts=, orig\_ip\_bytes=, resp\_pkts=, resp\_ip\_bytes=], extract\_orig=F, extract\_resp=F, dns=, dns\_state=, ftp=, http=[ts=1338087055.413572, uid=cTLeNAfgQo2, id=[orig\_h=192.168.1.13, orig\_p=50402/tcp, resp\_  
37 if ( is\_orig || ! c?$http ) return;  
(Bro [2]) print c  
(Bro [3]) print is\_orig

---

<div class="post-metadata">

### Author: ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)
#### Post date: [May 29, 2012, 3:25pm UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326/2 "2012-05-29T15:25:02Z")

</div>

The debugger hasn't seen much attention for a while unfortunately, and  
some of its functionality isn't working at the moment. We have a  
ticket tracking that, [http://tracker.bro-ids.org/bro/ticket/678](http://tracker.bro-ids.org/bro/ticket/678), but  
it doesn't look like we'll get to it in time for the next release.

Fwiw, I often just insert print statements into the code while  
developing/debugging.

Robin

---

<div class="post-metadata">

### Author: ![Siwek\_Jon](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@Siwek\_Jon](https://community.zeek.org/u/Siwek_Jon)
#### Post date: [May 29, 2012, 5:48pm UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326/3 "2012-05-29T17:48:57Z")

</div>

> I'm using bro version 2.0-372 with a new git checkout from master as of 2012-05-27 on Centos6. I'm having an issue where the print statement in the policy debugger displays nothing.

It seems that parameters of functions/events take on the module scoping in which they're declared. So in your case, breaking in the "http\_entity\_data" in file-hash.bro is inside the "HTTP" module (there's the "module HTTP;" statement near the top of that script). So qualifying local variables or event parameters with the module name in the script debugger should work:

print HTTP::is\_orig  
print HTTP::c  
print HTTP::c$id

> Breakpoints and stack tracks seem to work correctly

I also noticed that the context string for stack traces is using a static buffer size, so it's getting truncated sometimes and the filename:line won't be there. I can fix that and also give some better error messages for when the 'print' command fails to parse the given args and put that on the fastpath branch, but I'm not sure how bad it will be to try to change local identifiers to not inherit module scoping, or even if that would be "right".

&nbsp;&nbsp;&nbsp;&nbsp;Jon

---

<div class="post-metadata">

### Author: ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)
#### Post date: [May 31, 2012, 12:50am UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326/4 "2012-05-31T00:50:39Z")

</div>

I've merged this into git master now.

Robin

---

<div class="post-metadata">

### Author: ![Chris\_Green](https://avatars.discourse-cdn.com/v4/letter/c/838e76/32.png) [@Chris\_Green](https://community.zeek.org/u/Chris_Green)
#### Post date: [June 3, 2012, 4:59pm UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326/5 "2012-06-03T16:59:39Z")

</div>

Thanks all; things seem more predictable now. Especially helped figuring out c$$http$mime\_type is sniffed and not read from the HTTP header.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)
#### Post date: [May 6, 2022, 3:40pm UTC](https://community.zeek.org/t/debugging-policies-and-print-statement/2326/6 "2022-05-06T15:40:22Z")

</div>


