Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit the number of log records for security events #1749

Open
krizhanovsky opened this issue Nov 10, 2022 · 1 comment
Open

Limit the number of log records for security events #1749

krizhanovsky opened this issue Nov 10, 2022 · 1 comment

Comments

@krizhanovsky
Copy link
Contributor

krizhanovsky commented Nov 10, 2022

Motivation

Nearly everyone of our team already complained about and was confused by the number of messages, which can be printed on various rate limits, e.g. #1649 (comment) . We use net_warn_ratelimited(), so the system wont go out of service, but other important messages can be rate limited.

Also this behavior is confusing and doesn't make the system user friendly, e.g. this makes issues for our test development.

Scope

http_limits must be extended with a ratelimit option for the maximum number of messages printed for a client per second (0 - unlimited, minimum - 1, maximum 1000). TfwClient must be extended with

unsigned long sec_ev_n  :16,
              sec_ev_ts :48;

, where sec_ev_n is the events counter and sec_ev_ts are the 48 less significant bits of jiffies (assume that we never wrap up the 48 bits).

Once a client hits the limit, we still need to account sec_ev_n and stop on 0xffff meaning overflow. When one second passes and we can zero the counter and print the next bunch of records, we should print how many records was suppressed for the client. We do not do sliding window to minimize the memory requirements to handle each client.

The task must make a step in #537: security log must have a separate API and implemented in a new files log_security.c (also please rename access_log.c to log_access.c and move the function declarations from access_log.h to log.h).

Testing

Probably no special tests are required, just making the current tests more explicit about the number of expected log messages.

@krizhanovsky
Copy link
Contributor Author

The recent merge of tempesta-tech/tempesta-test#265 causes the log overflow on -R option, so the task is crucial since the current master in https://github.com/tempesta-tech/tempesta-test probably will break the CI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants