[Bro] conditional loading

Dnj dnj0496 at gmail.com
Mon Nov 30 21:00:11 PST 2015


Thanks Athiny, Grant,
I'll try your suggestions. 

> On Nov 30, 2015, at 7:42 PM, Grant Stavely <grant at grantstavely.com> wrote:
> 
> Innelegant but I just have the same process that creates populated files create empty ones for bro to @load in environments where they aren't applicable and e.g. a puppet template would be overkill.
> 
> Grant
> 
>> On Nov 30, 2015, at 19:16, anthony kasza <anthony.kasza at gmail.com> wrote:
>> 
>> I have no clue if it would work but... You could try to make a global variable in the script you're testing for (something like global is_loaded: bool) then check if it is defined with @ifdef. If so, the script was loaded.
>> 
>> -AK
>> 
>>> On Nov 30, 2015 6:43 PM, "Dk Jack" <dnj0496 at gmail.com> wrote:
>>> the directives don't seem to have file test operators. I tried to do the following...
>>> 
>>> local c = "test -f filters.bro";
>>> local cmd = Exec::Command($cmd=c);
>>> 
>>> when (local res = Exec::run(cmd))
>>> {
>>>   @if (res$exit_code == 0)
>>>   {
>>>     @load filters.bro;
>>>   }
>>> }
>>> 
>>> 
>>> However, I am getting parsing errors...
>>> 
>>> ---------------------------------------------------------------
>>> referencing a local name in @if (res)
>>> invalid expression in @if (res$exit_code == 0)
>>> ---------------------------------------------------------------
>>> 
>>> Dnj
>>> 
>>> 
>>>> On Mon, Nov 30, 2015 at 4:41 PM, anthony kasza <anthony.kasza at gmail.com> wrote:
>>>> See here:
>>>> https://www.bro.org/sphinx/script-reference/directives.html
>>>> 
>>>> -AK
>>>> 
>>>>> On Nov 30, 2015 4:36 PM, "Dk Jack" <dnj0496 at gmail.com> wrote:
>>>>> Hi,
>>>>> Is it possible to perform conditional loading of bro script files ?
>>>>> In my local.bro file, I'd like to do something like this:
>>>>> 
>>>>> if file 'filters.bro' exists
>>>>> {
>>>>> @load filters.bro
>>>>> }
>>>>> 
>>>>> The file filters.bro may or may not exist because it's getting generated from an external program.
>>>>> Thanks for your help in advance.
>>>>> 
>>>>> Dnj
>>>>> 
>>>>> _______________________________________________
>>>>> Bro mailing list
>>>>> bro at bro-ids.org
>>>>> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/bro
>> _______________________________________________
>> Bro mailing list
>> bro at bro-ids.org
>> http://mailman.ICSI.Berkeley.EDU/mailman/listinfo/bro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ICSI.Berkeley.EDU/pipermail/bro/attachments/20151130/cff1a339/attachment.html 


More information about the Bro mailing list