mirror of
https://github.com/falcosecurity/falco.git
synced 2025-09-05 16:50:34 +00:00
Falco engine changes to support multiple files in rule load results
The methods that throw exceptions from stringified results need to additionally pass a rules_contents_t struct. This also meant that they need to call the filename + content version of load_rules. To avoid some duplicate code between the two load_rules_file methods, move the work of opening the file into a private method read_file(). It can throw an exception, which is passed through for the void return method and caught + converted into a load_result error for the method that returns a load_result. Also, to avoid duplicate code between the void load_rules and load_rules_file methods, add a private method interpret_load_result() which throws an exception if the result has an error and prints warnings otherwise if verbose is true. Signed-off-by: Mark Stemm <mark.stemm@gmail.com>
This commit is contained in:
@@ -233,6 +233,17 @@ public:
|
||||
std::string& err);
|
||||
|
||||
private:
|
||||
|
||||
// Throws falco_exception if the file can not be read
|
||||
void read_file(const std::string& filename, std::string& contents);
|
||||
|
||||
// For load_rules methods that throw exceptions on error,
|
||||
// interpret a load_result and throw an exception if needed.
|
||||
void interpret_load_result(std::unique_ptr<falco::load_result>& res,
|
||||
const std::string& rules_filename,
|
||||
const std::string& rules_content,
|
||||
bool verbose);
|
||||
|
||||
indexed_vector<falco_source> m_sources;
|
||||
|
||||
falco_source* find_source(std::size_t index);
|
||||
|
Reference in New Issue
Block a user