{ "name": "libmodsecurity", "version": "3.0.17", "summary": "ModSecurity v3 (libmodsecurity), the web application firewall engine that runs the OWASP Core Rule Set", "category": "library", "license": "Apache-2.0", "homepage": "https://github.com/owasp-modsecurity/ModSecurity", "source": { "url": "https://github.com/owasp-modsecurity/ModSecurity/releases/download/v3.0.17/modsecurity-v3.0.17.tar.gz", "sha256": "f283b33d5c21130fd3a15c84a93a1abe12bd1949edaf44288b12af571b671a50" }, "watch": {"kind": "github-release", "repo": "owasp-modsecurity/ModSecurity", "tag_regex": "^v(3(?:\\.[0-9]+)+)$"}, "deps": [ "pcre2", "libxml2", "yajl" ], "env_packages": [], "static": false, "nss": false, "check": "v=$($PKG_CONFIG --modversion modsecurity) && [ \"$v\" = 3.0.17 ] && cat > \"$TMPDIR/t.c\" <<'CEOF' &&\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nstatic const char *rules =\n \"SecRuleEngine On\\n\"\n \"SecRequestBodyAccess On\\n\"\n \"SecRequestBodyLimit 65536\\n\"\n \"SecRequestBodyLimitAction ProcessPartial\\n\"\n \"SecRule REQUEST_HEADERS:Content-Type \\\"@rx ^application/json\\\" \\\"id:1,phase:1,pass,nolog,ctl:requestBodyProcessor=JSON\\\"\\n\"\n \"SecRule ARGS:json.q \\\"@rx (?i)union\\\\s+select\\\" \\\"id:2,phase:2,deny,status:403,msg:'SQL in q'\\\"\\n\"\n \"SecRule INBOUND_DATA_ERROR \\\"@eq 1\\\" \\\"id:3,phase:2,deny,status:413,msg:'over the limit'\\\"\\n\";\n\n/* one POST through the rules: a JSON body in memory, or a file through msc_request_body_from_file */\nstatic int post(ModSecurity *ms, RulesSet *rs, const char *body, const char *file) {\n ModSecurityIntervention it;\n memset(&it, 0, sizeof it);\n it.status = 200;\n Transaction *t = msc_new_transaction(ms, rs, NULL);\n msc_process_connection(t, \"192.0.2.7\", 40000, \"127.0.0.1\", 80);\n msc_process_uri(t, \"/api\", \"POST\", \"1.1\");\n msc_add_request_header(t, (const unsigned char *)\"Host\", (const unsigned char *)\"localhost\");\n msc_add_request_header(t, (const unsigned char *)\"Content-Type\", (const unsigned char *)\"application/json\");\n msc_process_request_headers(t);\n if (file) {\n msc_request_body_from_file(t, file);\n } else {\n msc_append_request_body(t, (const unsigned char *)body, strlen(body));\n }\n msc_process_request_body(t);\n msc_intervention(t, &it);\n if (it.log) free(it.log);\n if (it.url) free(it.url);\n msc_transaction_cleanup(t);\n return it.status;\n}\n\nint main(int argc, char **argv) {\n const char *err = NULL;\n ModSecurity *ms = msc_init();\n RulesSet *rs = msc_create_rules_set();\n FILE *f;\n int a, b, c, i;\n struct rusage ru;\n msc_set_connector_info(ms, \"bvs-check\");\n if (msc_rules_add(rs, rules, &err) < 0) {\n printf(\"rules: %s\\n\", err);\n return 1;\n }\n a = post(ms, rs, \"{\\\"q\\\":\\\"1 UNION SELECT password FROM users\\\"}\", NULL);\n b = post(ms, rs, \"{\\\"q\\\":\\\"hello\\\"}\", NULL);\n /* a body of 64 MiB in a file, over the 64 KiB limit: read in pieces and stopped at the limit, so the process never\n * holds it (the upstream version reserved the whole file) */\n f = fopen(argv[1], \"w\");\n if (!f) return 2;\n fputs(\"{\\\"q\\\":\\\"\", f);\n for (i = 0; i < 64 * 1024 * 1024; i++) fputc('a', f);\n fputs(\"\\\"}\", f);\n fclose(f);\n c = post(ms, rs, NULL, argv[1]);\n getrusage(RUSAGE_SELF, &ru);\n printf(\"%s: JSON body with SQL %d, plain JSON body %d, 64 MiB file over a 64 KiB limit %d, peak memory %ld KiB\\n\", msc_who_am_i(ms), a, b, c, ru.ru_maxrss);\n msc_rules_cleanup(rs);\n msc_cleanup(ms);\n return !(a == 403 && b == 200 && c == 413 && ru.ru_maxrss < 32768);\n}\nCEOF\n$CC $CPPFLAGS $CFLAGS $($PKG_CONFIG --cflags modsecurity) \"$TMPDIR/t.c\" -o \"$TMPDIR/t\" $LDFLAGS $($PKG_CONFIG --libs modsecurity) && \"$TMPDIR/t\" \"$TMPDIR/body.json\" && LD_TRACE_LOADED_OBJECTS=1 \"$TMPDIR/t\" | has \"libmodsecurity\\.so[^ ]* => $PREFIX/lib/\" && n=$(readelf -d lib/libmodsecurity.so.3) && for l in libyajl libxml2 libpcre2-8; do printf '%s\\n' \"$n\" | has \"NEEDED.*\\[$l\\.so\" || { echo \"libmodsecurity: $l is not linked\" >&2; exit 1; }; done && case $n in *libcurl* | *liblua* | *libGeoIP* | *libmaxminddb* | *liblmdb* | *libfuzzy*) echo \"libmodsecurity: links a library it should not\" >&2; exit 1 ;; esac" }