Description
Hello, I have encountered issues in understanding how the parser generator works in the project.
Task:
- I need to add a new parameter called domain_id.
- My custom parameter domain_id is used in the ngx_modsecurity_module module and determines the value of the domain_id directive in the server context.
Example usage:
server {
server_name vts;
domain_id 1150; # <<<<<<=======
listen 80;
access_log off;
location /status { vhost_traffic_status_display; vhost_traffic_status_display_format html; }
location /stub-status {
stub_status on;
}
}
- I would like my code owasp-modsecurity/ModSecurity to be able to receive the domain_id parameter from ngx_modsecurity_module and use it in rules, as well as see the domain_id value in modsec json logs.
- I added code (briefly, just to show what exactly was done and at what stage I got stuck):
- m_variableDomainId(t, "DOMAIN_ID"),
- int msc_add_domain_id(Transaction *transaction, int domain_id);
- int Transaction::addDomainId(int domain_id) {
this->m_domainId = domain_id;
m_variableDomainId.set(std::to_string(this->m_domainId), m_variableOffset);
return true;
}
- domain_id.h file
- int msc_add_domain_id(Transaction *transaction, int domain_id);
- Call of the msc_add_domain_id function in the ngx_modsecurity_module module.
Problem:
I don’t understand how to generate the code in such a way that the appropriate code appears in the necessary files. It seems that bison, lex, and yacc are needed for this.
Searching for a solution:
I searched for similar PRs, and this one has something similar to what I need:
owasp-modsecurity/ModSecurity@fa6e418
But I don't fully understand:
- What code needs to be written before running the parser generator.
- At what stage to run the parser (which code should be written before running the parser).
- How exactly to run the parser correctly.
Could you please help me understand what the entire process of adding a new parameter looks like?
For example, my domain_id.
If needed, and if it is relevant, I will later write a part of the documentation that describes the process of adding a new parameter, based on our dialogue, and make a PR.