mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-15 23:55:03 +03:00
Merge pull request #3209 from eduar-hte/cleanup_api
Add cleanup methods to complete C based ABI
This commit is contained in:
commit
630751eee6
@ -68,6 +68,8 @@ int main (int argc, char **argv)
|
|||||||
msc_process_response_body(transaction);
|
msc_process_response_body(transaction);
|
||||||
msc_process_logging(transaction);
|
msc_process_logging(transaction);
|
||||||
end:
|
end:
|
||||||
|
if(error != NULL)
|
||||||
|
msc_rules_error_cleanup(error);
|
||||||
msc_rules_cleanup(rules);
|
msc_rules_cleanup(rules);
|
||||||
msc_cleanup(modsec);
|
msc_cleanup(modsec);
|
||||||
|
|
||||||
|
@ -99,6 +99,7 @@ int msc_rules_add_remote(RulesSet *rules, const char *key, const char *uri,
|
|||||||
const char **error);
|
const char **error);
|
||||||
int msc_rules_add_file(RulesSet *rules, const char *file, const char **error);
|
int msc_rules_add_file(RulesSet *rules, const char *file, const char **error);
|
||||||
int msc_rules_add(RulesSet *rules, const char *plain_rules, const char **error);
|
int msc_rules_add(RulesSet *rules, const char *plain_rules, const char **error);
|
||||||
|
void msc_rules_error_cleanup(const char *error);
|
||||||
int msc_rules_cleanup(RulesSet *rules);
|
int msc_rules_cleanup(RulesSet *rules);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -723,6 +723,9 @@ void msc_transaction_cleanup(Transaction *transaction);
|
|||||||
/** @ingroup ModSecurity_C_API */
|
/** @ingroup ModSecurity_C_API */
|
||||||
int msc_intervention(Transaction *transaction, ModSecurityIntervention *it);
|
int msc_intervention(Transaction *transaction, ModSecurityIntervention *it);
|
||||||
|
|
||||||
|
/** @ingroup ModSecurity_C_API */
|
||||||
|
void msc_intervention_cleanup(ModSecurityIntervention *it);
|
||||||
|
|
||||||
/** @ingroup ModSecurity_C_API */
|
/** @ingroup ModSecurity_C_API */
|
||||||
int msc_process_logging(Transaction *transaction);
|
int msc_process_logging(Transaction *transaction);
|
||||||
|
|
||||||
|
@ -311,6 +311,21 @@ extern "C" int msc_rules_add(RulesSet *rules, const char *plain_rules,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name msc_rules_error_cleanup
|
||||||
|
* @brief Deallocates an error message buffer returned by a msc_rules_xxx function.
|
||||||
|
*
|
||||||
|
* This is a helper function to free the error message buffer allocated
|
||||||
|
* by a msc_rules_xxx function.
|
||||||
|
*
|
||||||
|
* @param error Error message pointer.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
extern "C" void msc_rules_error_cleanup(const char *error) {
|
||||||
|
free((void*) error);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" int msc_rules_cleanup(RulesSet *rules) {
|
extern "C" int msc_rules_cleanup(RulesSet *rules) {
|
||||||
delete rules;
|
delete rules;
|
||||||
return true;
|
return true;
|
||||||
|
@ -2273,6 +2273,22 @@ extern "C" int msc_intervention(Transaction *transaction,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name msc_intervention_cleanup
|
||||||
|
* @brief Removes all the resources allocated by a given Intervention.
|
||||||
|
*
|
||||||
|
* This is a helper function to free any allocated buffers owned by the
|
||||||
|
* intervention.
|
||||||
|
*
|
||||||
|
* @param it ModSecurity intervention.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
extern "C" void msc_intervention_cleanup(ModSecurityIntervention *it) {
|
||||||
|
intervention::free(it);
|
||||||
|
intervention::clean(it);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name msc_get_response_body
|
* @name msc_get_response_body
|
||||||
* @brief Retrieve a buffer with the updated response body.
|
* @brief Retrieve a buffer with the updated response body.
|
||||||
|
@ -73,7 +73,7 @@ int main(int argc, char *argv[]) {
|
|||||||
modsecurity::ModSecurity *modsec;
|
modsecurity::ModSecurity *modsec;
|
||||||
modsecurity::RulesSet *rules;
|
modsecurity::RulesSet *rules;
|
||||||
modsecurity::ModSecurityIntervention it;
|
modsecurity::ModSecurityIntervention it;
|
||||||
modsecurity::intervention::reset(&it);
|
modsecurity::intervention::clean(&it);
|
||||||
modsec = new modsecurity::ModSecurity();
|
modsec = new modsecurity::ModSecurity();
|
||||||
modsec->setConnectorInformation("ModSecurity-benchmark v0.0.1-alpha" \
|
modsec->setConnectorInformation("ModSecurity-benchmark v0.0.1-alpha" \
|
||||||
" (ModSecurity benchmark utility)");
|
" (ModSecurity benchmark utility)");
|
||||||
@ -167,6 +167,8 @@ int main(int argc, char *argv[]) {
|
|||||||
next_request:
|
next_request:
|
||||||
modsecTransaction->processLogging();
|
modsecTransaction->processLogging();
|
||||||
delete modsecTransaction;
|
delete modsecTransaction;
|
||||||
|
modsecurity::intervention::free(&it);
|
||||||
|
modsecurity::intervention::clean(&it);
|
||||||
}
|
}
|
||||||
|
|
||||||
delete rules;
|
delete rules;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user