Skip to content

Commit 977d5bd

Browse files
Add ja5h filtration.
- Also remove some unnecessary files.
1 parent 294658a commit 977d5bd

File tree

4 files changed

+61
-2
lines changed

4 files changed

+61
-2
lines changed

fw/http.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5999,6 +5999,15 @@ __check_authority_correctness(TfwHttpReq *req)
59995999
return true;
60006000
}
60016001

6002+
static bool
6003+
tfw_http_check_ja5h_req_limit(TfwHttpReq *req)
6004+
{
6005+
u64 limit = http_get_ja5_recs_limit(req->ja5h);
6006+
u64 rate = ja5h_get_records_rate(req->ja5h);
6007+
6008+
return rate > limit;
6009+
}
6010+
60026011
/**
60036012
* @return zero on success and negative value otherwise.
60046013
* TODO enter the function depending on current GFSM state.
@@ -6160,6 +6169,14 @@ tfw_http_req_process(TfwConn *conn, TfwStream *stream, struct sk_buff *skb,
61606169

61616170
req->ja5h.method = req->method;
61626171

6172+
if (tfw_http_check_ja5h_req_limit(req)) {
6173+
TFW_INC_STAT_BH(clnt.msgs_filtout);
6174+
return tfw_http_req_parse_block(req, 403,
6175+
"parsed request exceeded ja5h limit",
6176+
HTTP2_ECODE_PROTO);
6177+
}
6178+
6179+
61636180
/*
61646181
* The message is fully parsed, the rest of the data in the
61656182
* stream may represent another request or its part.

fw/t/unit/helpers.c

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,4 +465,48 @@ tfw_vhost_get_cache_use_stale(TfwLocation *loc, TfwVhost *vhost)
465465
return NULL;
466466
}
467467

468+
void
469+
http_ja5_cfgop_cleanup(TfwCfgSpec *cs)
470+
{
471+
472+
}
473+
474+
int
475+
ja5_cfgop_begin(TfwCfgSpec *cs, TfwCfgEntry *ce)
476+
{
477+
return 0;
478+
}
479+
480+
u64
481+
http_get_ja5_storage_size(void)
482+
{
483+
return 0;
484+
}
485+
486+
bool
487+
ja5h_init_filter(size_t max_storage_size)
488+
{
489+
return true;
490+
}
491+
492+
int
493+
http_ja5_cfgop_finish(TfwCfgSpec *cs)
494+
{
495+
return 0;
496+
}
497+
498+
u64
499+
http_get_ja5_recs_limit(HttpJa5h fingerprint)
500+
{
501+
return UINT_MAX;
502+
}
503+
504+
u32
505+
ja5h_get_records_rate(HttpJa5h fingerprint)
506+
{
507+
return 0;
508+
}
509+
510+
TfwCfgSpec ja5_hash_specs[0];
511+
468512
unsigned int cache_default_ttl = 60;

fw/t/unit/ja5_conf.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

fw/t/unit/ja5_filter.c

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)