CoolerVoid/OctopusWAF

Resource to generate C code based in rules(YAML config file to gen rule)

CoolerVoid opened this issue · 1 comments

Rules in regex don't have a good performance, the good path to solve this, is using re2c or bison, but is harder for common people use and try to create your custom resource, one suggestion to development, is use external YAML file, each line of this file is a rule, something like this following:

label: Anomaly in trade action
endpoint: /trade/sell/product/id/
rule: [0-9]{12}
 if_add_score: [select|union|version]
 points_score: +20 
buffer_max: 12
is_false: blocked
log_title: Error in product
log_request: true
log_ip: true

The lua, C or C++ program to read this YAML, and generate Bison/Re2c code, to gen a C code to include in other directory, gcc or other tool to make a shared library, a module to OctopusWAF load and using dlopen() function resource.

I think, unless your intent is to let users create their own procedural rules, to use Lua or any other script language will be even slower than using regexes (pcre?)... I believe there is a libyaml-dev package somewhere which can be used in pure C code.