<commit_before>@load global-ext
@load smtp-ext

module SMTP;

export {
	# If set to T, this will split inbound and outbound transactions
	# into separate files.  F merges everything into a single file.
	const split_log_file = F &redef;
	
	# Which mail transactions to log.
	# Choices are: Inbound, Outbound, All
	const logging = All &redef;
}

event bro_init()
	{
	LOG::create_logs("smtp-ext", logging, split_log_file, T);
	LOG::define_header("smtp-ext", cat_sep("\t", "", 
	                                      "ts",
	                                      "orig_h", "orig_p",
	                                      "resp_h", "resp_p",
	                                      "helo", "message-id", "in-reply-to", 
	                                      "mailfrom", "rcptto",
	                                      "date", "from", "reply_to", "to",
	                                      "files", "last_reply", "x-originating-ip",
	                                      "path", "is_webmail", "agent"));
	}

event smtp_ext(id: conn_id, si: smtp_ext_session_info)
	{
	if ( si$mailfrom != "" )
		local log = LOG::get_file("smtp-ext", id$resp_h, F);
		print log, cat_sep("\t", "\\N",
		                   network_time(),
		                   id$orig_h, port_to_count(id$orig_p), id$resp_h, port_to_count(id$resp_p),
		                   si$helo,
		                   si$msg_id,
		                   si$in_reply_to,
		                   si$mailfrom,
		                   fmt_str_set(si$rcptto, /["'<>]|([[:blank:]].*$)/),
		                   si$date, 
		                   si$from, 
		                   si$reply_to, 
		                   fmt_str_set(si$to, /["']/),
		                   fmt_str_set(si$files, /["']/),
		                   si$last_reply, 
		                   si$x_originating_ip,
		                   si$path,
		                   si$is_webmail,
		                   si$agent);<commit_msg>small bug in logging.smtp-ext.bro<commit_after>@load global-ext
@load smtp-ext

module SMTP;

export {
	# If set to T, this will split inbound and outbound transactions
	# into separate files.  F merges everything into a single file.
	const split_log_file = F &redef;
	
	# Which mail transactions to log.
	# Choices are: Inbound, Outbound, All
	const logging = All &redef;
}

event bro_init()
	{
	LOG::create_logs("smtp-ext", logging, split_log_file, T);
	LOG::define_header("smtp-ext", cat_sep("\t", "", 
	                                      "ts",
	                                      "orig_h", "orig_p",
	                                      "resp_h", "resp_p",
	                                      "helo", "message-id", "in-reply-to", 
	                                      "mailfrom", "rcptto",
	                                      "date", "from", "reply_to", "to",
	                                      "files", "last_reply", "x-originating-ip",
	                                      "path", "is_webmail", "agent"));
	}

event smtp_ext(id: conn_id, si: smtp_ext_session_info)
	{
	if ( si$mailfrom != "" )
		{
		local log = LOG::get_file("smtp-ext", id$resp_h, F);
		print log, cat_sep("\t", "\\N",
		                   network_time(),
		                   id$orig_h, port_to_count(id$orig_p), id$resp_h, port_to_count(id$resp_p),
		                   si$helo,
		                   si$msg_id,
		                   si$in_reply_to,
		                   si$mailfrom,
		                   fmt_str_set(si$rcptto, /["'<>]|([[:blank:]].*$)/),
		                   si$date, 
		                   si$from, 
		                   si$reply_to, 
		                   fmt_str_set(si$to, /["']/),
		                   fmt_str_set(si$files, /["']/),
		                   si$last_reply, 
		                   si$x_originating_ip,
		                   si$path,
		                   si$is_webmail,
		                   si$agent);
		}
{'fraction_non_alphanumeric': 0.13021920668058456, 'fraction_numerical': 0.0, 'mean_word_length': 1.2349854227405248, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '878310', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1142, 'n_words': 224}