#define FILE_ALL_ON 0xFFFFFFFF
#define FILE_ALL_OFF 0x00000000
-#define FILE_RESUME_BLOCK 0x01
-#define FILE_RESUME_LOG 0x02
+enum FileAction
+{
+ FILE_ACTION_DEFAULT = 0,
+ FILE_RESUME_BLOCK,
+ FILE_RESUME_LOG
+};
#define UTF_16_LE_BOM "\xFF\xFE"
#define UTF_16_LE_BOM_LEN 2
virtual FileVerdict signature_lookup(Flow*, FileInfo*)
{ return FILE_VERDICT_UNKNOWN; }
- virtual void log_file_action(Flow*, int) { }
+ virtual void log_file_action(Flow*, FileInfo*, FileAction) { }
};
if (verdict == FILE_VERDICT_LOG)
{
if (resume)
- policy->log_file_action(flow, FILE_RESUME_LOG);
+ policy->log_file_action(flow, file, FILE_RESUME_LOG);
}
else if (verdict == FILE_VERDICT_BLOCK)
{
Active::set_delayed_action(Active::ACT_BLOCK, true);
store_verdict(flow, file);
if (resume)
- policy->log_file_action(flow, FILE_RESUME_BLOCK);
+ policy->log_file_action(flow, file, FILE_RESUME_BLOCK);
return true;
}
else if (verdict == FILE_VERDICT_REJECT)
Active::set_delayed_action(Active::ACT_RESET, true);
store_verdict(flow, file);
if (resume)
- policy->log_file_action(flow, FILE_RESUME_BLOCK);
+ policy->log_file_action(flow, file, FILE_RESUME_BLOCK);
return true;
}
else if (verdict == FILE_VERDICT_PENDING)
/*Take the cached verdict*/
Active::set_delayed_action(Active::ACT_DROP, true);
if (resume)
- policy->log_file_action(flow, FILE_RESUME_BLOCK);
+ policy->log_file_action(flow, file, FILE_RESUME_BLOCK);
return true;
}
if (fname and name_size)
context->set_file_name((const char*)fname, name_size);
- context->log_file_event(flow);
+ context->log_file_event(flow, file_policy);
}
}
file_type_context = nullptr;
}
-void FileContext::log_file_event(Flow* flow)
+void FileContext::log_file_event(Flow* flow, FilePolicyBase* policy)
{
// wait for file name is set to log file event
if ( is_file_name_set() )
{
+ bool log_needed = true;
+
switch (verdict)
{
case FILE_VERDICT_LOG:
DataBus::publish("file_event", (const uint8_t*)"RESET", 5, flow);
break;
default:
+ log_needed = false;
break;
}
+
+ if (policy and log_needed)
+ policy->log_file_action(flow, this, FILE_ACTION_DEFAULT);
+
if ( config->trace_type )
print(std::cout);
}
FileVerdict verdict = policy->signature_lookup(flow, this);
if ( verdict != FILE_VERDICT_UNKNOWN || final_lookup )
{
- log_file_event(flow);
+ log_file_event(flow, policy);
config_file_signature(false);
file_stats->signatures_processed[get_file_type()][get_file_direction()]++;
}
file_enforcer->apply_verdict(flow, this, v, false, policy);
}
- log_file_event(flow);
+ log_file_event(flow, policy);
}
}
void update_file_size(int data_size, FilePosition position);
void stop_file_capture();
FileCaptureState process_file_capture(const uint8_t* file_data, int data_size, FilePosition);
- void log_file_event(Flow*);
+ void log_file_event(Flow*, FilePolicyBase*);
FileVerdict file_signature_lookup(Flow*);
void set_signature_state(bool gen_sig);
file->config_file_capture(capture_enabled);
}
-FileVerdict FilePolicy::type_lookup(Flow* flow, FileInfo* file)
+FileVerdict FilePolicy::type_lookup(Flow*, FileInfo* file)
{
FileRule rule = match_file_rule(nullptr, file);
file->config_file_signature(rule.use.signature_enabled);