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

NAS-130498 / 24.10 / Omit SMB audit results from audit.query output by default #14163

Merged
merged 2 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/middlewared/middlewared/plugins/audit/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@


ALL_AUDITED = [svc[0] for svc in AUDITED_SERVICES]
BULK_AUDIT = ['SMB']
NON_BULK_AUDIT = [svc for svc in ALL_AUDITED if svc not in BULK_AUDIT]

# We set the refquota limit
QUOTA_WARN = TNUserProp.REFQUOTA_WARN.value
QUOTA_CRIT = TNUserProp.REFQUOTA_CRIT.value
Expand Down Expand Up @@ -129,7 +132,7 @@ async def compress(self, data):

@accepts(Dict(
'audit_query',
List('services', items=[Str('db_name', enum=ALL_AUDITED)], default=ALL_AUDITED),
List('services', items=[Str('db_name', enum=ALL_AUDITED)], default=NON_BULK_AUDIT),
Ref('query-filters'),
Ref('query-options'),
register=True
Expand Down
7 changes: 5 additions & 2 deletions src/middlewared/middlewared/plugins/audit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def parse_query_filters(
can loosen these restrictions with appropriate levels of testing and
validation in auditbackend plugin.
"""
services_to_check = set(services)
services_to_check = services_in = set(services)
filters_out = []

for f in filters:
Expand All @@ -122,7 +122,10 @@ def parse_query_filters(

match f[1]:
case '=' | 'in':
services_to_check = services_to_check & svcs
if services_in == services_to_check:
services_to_check = svcs
else:
services_to_check = services_to_check & svcs
case '!=' | 'nin':
services_to_check = services_to_check - svcs
case _:
Expand Down
Loading