I have some parsing in Spicy that is conditional for example the following with a num_ips and then up to 4,
num_ips: uint8;
ip1: addr &ipv4;
ip2: addr &ipv4 if (self.num_ips > 1);
ip3: addr &ipv4 if (self.num_ips > 2);
ip4: addr &ipv4 if (self.num_ips > 3);
The parsing works in Spicy, and based on the num_ips
the ip variables are either set or not set. I am having an issue getting it outputting in the zeek log file. I have everything set up as optional in Zeek, but I think it isn’t getting there because it has a problem in the .evt file (I get no error that I see, I’m guessing).
I tried to make some conditional statements in the evt file which would only send the variables that are set to Zeek, but then the Zeek function gets type mismatches because even though the vars are optional it doesn’t know which ones I’m sending.
on parser::getdata if (self.num_ips == 1) -> event parser::output_log($conn, self.data, self.ip1)
Is there a way to tell Zeek from the evt file which variables I’m sending? ip1=self.ip1
… this gave me an error.
I’m looking for a way not to have a whole bunch of different things in the evt file, and also not have a bunch of Zeek functions one for each value of num_ips
.
I can confirm that everything works as it should because if I set in Spicy the not_set variables to values before it finishes, everything works successfully and I get the values I want. I just don’t want to have all the rest of the values that weren’t present and I just set with dummy values.