mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 11:38:20 +00:00
Prefer explicit construction to coercion in record initialization
While we support initializing records via coercion from an expression list, e.g., local x: X = [$x1=1, $x2=2]; this can sometimes obscure the code to readers, e.g., when assigning to value declared and typed elsewhere. The language runtime has a similar overhead since instead of just constructing a known type it needs to check at runtime that the coercion from the expression list is valid; this can be slower than just writing the readible code in the first place, see #4559. With this patch we use explicit construction, e.g., local x = X($x1=1, $x2=2);
This commit is contained in:
parent
54f9e45597
commit
d5fd29edcd
139 changed files with 786 additions and 788 deletions
|
@ -13,10 +13,10 @@ event http_header(c: connection, is_orig: bool, name: string, value: string) &gr
|
|||
# Remove the occasional port value that shows up here.
|
||||
local host = gsub(value, /:[[:digit:]]+$/, "");
|
||||
if ( is_valid_ip(host) )
|
||||
Intel::seen([$host=to_addr(host),
|
||||
$indicator_type=Intel::ADDR,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_HOST_HEADER]);
|
||||
Intel::seen(Intel::Seen($host=to_addr(host),
|
||||
$indicator_type=Intel::ADDR,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_HOST_HEADER));
|
||||
break;
|
||||
|
||||
case "X-FORWARDED-FOR":
|
||||
|
@ -25,10 +25,10 @@ event http_header(c: connection, is_orig: bool, name: string, value: string) &gr
|
|||
local addrs = extract_ip_addresses(value);
|
||||
for ( i in addrs )
|
||||
{
|
||||
Intel::seen([$host=to_addr(addrs[i]),
|
||||
$indicator_type=Intel::ADDR,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_X_FORWARDED_FOR_HEADER]);
|
||||
Intel::seen(Intel::Seen($host=to_addr(addrs[i]),
|
||||
$indicator_type=Intel::ADDR,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_X_FORWARDED_FOR_HEADER));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -38,36 +38,36 @@ event http_header(c: connection, is_orig: bool, name: string, value: string) &gr
|
|||
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::DOMAIN"
|
||||
{
|
||||
if ( ! is_orig || name != "HOST" )
|
||||
return;
|
||||
return;
|
||||
|
||||
# Remove the occasional port value that shows up here.
|
||||
local host = gsub(value, /:[[:digit:]]+$/, "");
|
||||
if ( ! is_valid_ip(host) )
|
||||
Intel::seen([$indicator=host,
|
||||
$indicator_type=Intel::DOMAIN,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_HOST_HEADER]);
|
||||
Intel::seen(Intel::Seen($indicator=host,
|
||||
$indicator_type=Intel::DOMAIN,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_HOST_HEADER));
|
||||
}
|
||||
|
||||
|
||||
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::URL"
|
||||
{
|
||||
if ( ! is_orig || name != "REFERER" )
|
||||
return;
|
||||
return;
|
||||
|
||||
Intel::seen([$indicator=sub(value, /^.*:\/\//, ""),
|
||||
$indicator_type=Intel::URL,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_REFERRER_HEADER]);
|
||||
Intel::seen(Intel::Seen($indicator=sub(value, /^.*:\/\//, ""),
|
||||
$indicator_type=Intel::URL,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_REFERRER_HEADER));
|
||||
}
|
||||
|
||||
event http_header(c: connection, is_orig: bool, name: string, value: string) &group="Intel::SOFTWARE"
|
||||
{
|
||||
if ( ! is_orig || name != "USER-AGENT" )
|
||||
return;
|
||||
return;
|
||||
|
||||
Intel::seen([$indicator=value,
|
||||
$indicator_type=Intel::SOFTWARE,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_USER_AGENT_HEADER]);
|
||||
Intel::seen(Intel::Seen($indicator=value,
|
||||
$indicator_type=Intel::SOFTWARE,
|
||||
$conn=c,
|
||||
$where=HTTP::IN_USER_AGENT_HEADER));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue