-
Notifications
You must be signed in to change notification settings - Fork 375
filters/accesslog: Add maskAccessLogQuery filter
#3471
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
base: master
Are you sure you want to change the base?
Conversation
50aca5c to
fcff629
Compare
b844976 to
7af633f
Compare
maskAccessLogAuery filter
3fb7525 to
c69d2c7
Compare
maskAccessLogAuery filtermaskAccessLogQuery filter
| } else { | ||
| return | ||
| } | ||
| require.Error(t, err, "Expected error creating filter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: you can also use require.Condition to remove the outer if.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that it will look more complex with Condition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess @MustafaSaber meant to remove the if ti.isError and replace it with a oneliner err check.
I don't like require/assert lib but feel free to let or change it.
logging/access.go
Outdated
|
|
||
| // maskQueryParams masks (i.e., hashing) specific query parameters in the provided request's URI. | ||
| // Returns the obfuscated URI. | ||
| func maskQueryParams(req *http.Request, maskedQueryParams map[string]bool) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can also inline map len check here and return early
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But this function returns string, means we need to allocate new one even for early return.
logging/access.go
Outdated
| if stripQuery { | ||
| uri = stripQueryString(uri) | ||
| } else if keys, ok := additional[KeyMaskedQueryParams].(map[string]bool); ok { | ||
| if len(keys) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the link is broken for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this one #3471 (comment)
ff42068 to
46828d4
Compare
filters/accesslog/control.go
Outdated
| bag[AccessLogEnabledKey] = al | ||
| if f, ok := bag[AccessLogEnabledKey]; ok { | ||
| a := f.(*AccessLogFilter) | ||
| maps.Copy(a.MaskedQueryParams, al.MaskedQueryParams) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This modifies filter instance from parallel requests and will panic.
f6d8b28 to
5e2ba42
Compare
|
@ponimas can you please create user visible docs: docs/reference/filters.md in logs section ? Rest seems good to go. I classify this as major change because it modifies code paths that are already in use, which means it does not classify as completely "new" filter. |
5e2ba42 to
2b2d1a8
Compare
2b2d1a8 to
92f8424
Compare
Deployment ChecklistThis change falls under the deployment policy. 💁 Since Nov 10th, we are in the RED deployment zone. This means all changes released to production must adhere to the following requirements:
👉 Regardless of which boxes you click in this comment, merge/deployment will not be blocked. |
92f8424 to
f2101d8
Compare
4e29ed5 to
37c6cfb
Compare
e298dd4 to
264ca18
Compare
37c6cfb to
e2dce2c
Compare
|
👍 |
Test: reduce logging in test Test: fix flaky test that depend on tcp.Listen to find a free port to use in tests. The implementation was done twice and had race conditions caused by a TOCTOU Test: fix flakytest TestRedisAddrUpdater --------- Signed-off-by: Sandor Szücs <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
feature: allow to set redis username fix: reduce logging and remove unnecessary roundtrips to redis redis/go-redis#3536 ref: redis/go-redis#3536 (comment) Signed-off-by: Sandor Szücs <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
follow up on zalando#3737 Signed-off-by: Mustafa Abdelrahman <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
follow up on zalando#3740 Signed-off-by: Mustafa Abdelrahman <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Signed-off-by: Remy Chantenay <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Signed-off-by: Remy Chantenay <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Signed-off-by: Remy Chantenay <[email protected]> Signed-off-by: Aleksandr Ponimaskin <[email protected]>
…parameters filtering This change allows to use several maskAccessLogQuery filters in one route. This allows us to have default masked values in prepend filters. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
…ions Replace google/go-cmp with stretchr/testify in accessLogFormat control tests. The change also improves readability by replacing nested conditional statements with straightforward assertions. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
The commit corrects a bug in the AccessLogFilter.Request method where an incorrect type assertion was being performed. The code was attempting to assert a value from the state bag as an AccessLogFilter value rather than a pointer (*AccessLogFilter), which would cause runtime errors when two or more instances of the filter are used. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
This commit adds tests to verify that the access log control filters correctly merge masked query parameters from multiple filters. The tests validate that parameters from different filters are correctly combined and that repeated parameters are properly handled. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
This commit removes the redundant array type declaration in the test files by using the short syntax for array literals. The Go compiler can infer the type from the context. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Using map[string]struct{} for MaskedQueryParams to represent a set
of query parameters more efficiently. This is a common Go pattern
for implementing sets, where we care only about the existence of a key
and not any associated value. The empty struct requires no memory allocation
for values.
Signed-off-by: Aleksandr Ponimaskin <[email protected]>
This change replaces a classic for loop indexing with a more idiomatic range iteration over values in the maskAccessLogQuery.CreateFilter method. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
This test was testing the xxhash.Sum64String library function Signed-off-by: Aleksandr Ponimaskin <[email protected]>
This commit simplifies the logic in maskQueryParams by removing an unnecessary intermediate variable for the hashed value and directly using the hash function result in the params.Set() call. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Consolidated nested if statements in access.go for better readability while preserving the same functionality. The code now checks both conditions (keys exist and length > 0) in a single if statement rather than using nested conditionals. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Replace `struct{}{}` with `{}` in map declarations for the `struct{}` type in the test files. This uses Go's shorthand struct literal syntax, making the code more concise and readable while maintaining the same functionality.
Signed-off-by: Aleksandr Ponimaskin <[email protected]>
This commit moves the responsibility for managing masked query parameters from the proxy to the AccessLogFilter. It properly stores masquerading information in the state bag under the AccessLogAdditionalDataKey, ensuring better isolation between components. A new constant KeyMaskedQueryParams has been moved from logging to accesslog package for better organization, and the code now uses maps.Copy for compatibility. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
The test was incorrectly comparing the entire AccessLogFilter struct when it should only be comparing the masked query parameters map. This change updates the test to correctly access the masked query parameters from the state bag and compare only that specific field. Signed-off-by: Aleksandr Ponimaskin <[email protected]>
Signed-off-by: Aleksandr Ponimaskin <[email protected]>
e2dce2c to
ae3afc1
Compare
Introduce a new
maskAccessLogQueryfilter that masks/obfuscates values of specific sensitive query parameters in access logs.Additionally, refactor
accesslog/control_test.goto use testify/assert for improved test readability.See the previous PR for discussion details - #2674
Closing #2156, #2674