-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vdk-audit: [bug fix] Fix incorrectly detected event (#2548)
The logic in the `_audit()` method filters the forbidden events and detects if an executed event is allowed or not. However, the way it matches the events is by partial string match (the `event in not_permitted_event` part). This means that if a forbidden event is, e.g., `os.removexattr` and the event that is passed to the method is `os.remove`, there will be a match, because `os.remove` is a sub-string of `os.removexattr`. With this change, the `_audit()` method switches to exact string match when filtering for forbidden events, in order to avoid situations where unexpected events are matched. Testing done: Added test Signed-off-by: Andon Andonov <[email protected]>
- Loading branch information
Showing
3 changed files
with
33 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
...plugins/vdk-audit/tests/functional/jobs/os-remove-command-job/10_os_remove_command_job.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Copyright 2021-2023 VMware, Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
import os | ||
|
||
from vdk.api.job_input import IJobInput | ||
|
||
|
||
def run(job_input: IJobInput): | ||
with open("test_file.txt", "w") as f: | ||
f.write("Some string") | ||
|
||
os.remove("test_file.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters