Pull request 1787: 5639-querylog-filter-fix

Fixes #5639.

Squashed commit of the following:

commit 1aa02c8fa2b858f9c9a41c5dd6746d4d2e3de654
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Sun Mar 26 13:39:29 2023 +0300

    querylog: fix filtered log filter
This commit is contained in:
Ainar Garipov 2023-03-26 14:19:19 +03:00
parent fb7b8bba6a
commit 0df32601bb
2 changed files with 10 additions and 9 deletions

View file

@ -123,6 +123,8 @@ In this release, the schema version has changed from 17 to 20.
### Fixed ### Fixed
- Query log not showing all filtered queries when the “Filtered” log filter is
selected ([#5639]).
- Panic in empty hostname in the filter's URL ([#5631]). - Panic in empty hostname in the filter's URL ([#5631]).
- Panic caused by empty top-level domain name label in `/etc/hosts` files - Panic caused by empty top-level domain name label in `/etc/hosts` files
([#5584]). ([#5584]).
@ -133,6 +135,7 @@ In this release, the schema version has changed from 17 to 20.
[#5567]: https://github.com/AdguardTeam/AdGuardHome/issues/5567 [#5567]: https://github.com/AdguardTeam/AdGuardHome/issues/5567
[#5584]: https://github.com/AdguardTeam/AdGuardHome/issues/5584 [#5584]: https://github.com/AdguardTeam/AdGuardHome/issues/5584
[#5631]: https://github.com/AdguardTeam/AdGuardHome/issues/5631 [#5631]: https://github.com/AdguardTeam/AdGuardHome/issues/5631
[#5639]: https://github.com/AdguardTeam/AdGuardHome/issues/5639
[rfc6761]: https://www.rfc-editor.org/rfc/rfc6761 [rfc6761]: https://www.rfc-editor.org/rfc/rfc6761

View file

@ -150,12 +150,18 @@ func (c *searchCriterion) ctFilteringStatusCase(
switch c.value { switch c.value {
case filteringStatusAll: case filteringStatusAll:
return true return true
case filteringStatusFiltered:
return isFiltered || reason.In(
filtering.NotFilteredAllowList,
filtering.Rewritten,
filtering.RewrittenAutoHosts,
filtering.RewrittenRule,
)
case case
filteringStatusBlocked, filteringStatusBlocked,
filteringStatusBlockedParental, filteringStatusBlockedParental,
filteringStatusBlockedSafebrowsing, filteringStatusBlockedSafebrowsing,
filteringStatusBlockedService, filteringStatusBlockedService,
filteringStatusFiltered,
filteringStatusSafeSearch: filteringStatusSafeSearch:
return isFiltered && c.isFilteredWithReason(reason) return isFiltered && c.isFilteredWithReason(reason)
case filteringStatusWhitelisted: case filteringStatusWhitelisted:
@ -184,7 +190,6 @@ func (c *searchCriterion) ctFilteringStatusCase(
// - filteringStatusBlockedParental // - filteringStatusBlockedParental
// - filteringStatusBlockedSafebrowsing // - filteringStatusBlockedSafebrowsing
// - filteringStatusBlockedService // - filteringStatusBlockedService
// - filteringStatusFiltered
// - filteringStatusSafeSearch // - filteringStatusSafeSearch
func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched bool) { func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched bool) {
switch c.value { switch c.value {
@ -196,13 +201,6 @@ func (c *searchCriterion) isFilteredWithReason(reason filtering.Reason) (matched
return reason == filtering.FilteredSafeBrowsing return reason == filtering.FilteredSafeBrowsing
case filteringStatusBlockedService: case filteringStatusBlockedService:
return reason == filtering.FilteredBlockedService return reason == filtering.FilteredBlockedService
case filteringStatusFiltered:
return reason.In(
filtering.NotFilteredAllowList,
filtering.Rewritten,
filtering.RewrittenAutoHosts,
filtering.RewrittenRule,
)
case filteringStatusSafeSearch: case filteringStatusSafeSearch:
return reason == filtering.FilteredSafeSearch return reason == filtering.FilteredSafeSearch
default: default: