-
Notifications
You must be signed in to change notification settings - Fork 794
Performance improvements for file permission and ownership templates #8456
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
Merged
yuumasato
merged 3 commits into
ComplianceAsCode:stabilization-v0.1.61
from
marcusburghardt:recursive_find_performance
Mar 30, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
1 change: 0 additions & 1 deletion
1
shared/templates/file_groupowner/tests/correct_groupowner.pass.sh
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| {{% for path in FILEPATH %}} | ||
| {{% if IS_DIRECTORY and FILE_REGEX %}} | ||
|
|
||
1 change: 0 additions & 1 deletion
1
shared/templates/file_groupowner/tests/incorrect_groupowner.fail.sh
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| groupadd group_test | ||
|
|
||
|
|
||
1 change: 0 additions & 1 deletion
1
shared/templates/file_groupowner/tests/missing_file_test.pass.sh
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| {{% for path in FILEPATH %}} | ||
| {{% if MISSING_FILE_PASS %}} | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| {{% for path in FILEPATH %}} | ||
| {{% if IS_DIRECTORY and FILE_REGEX %}} | ||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| useradd testuser_123 | ||
|
|
||
|
|
||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| {{% for path in FILEPATH %}} | ||
| {{% if MISSING_FILE_PASS %}} | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
1 change: 0 additions & 1 deletion
1
shared/templates/file_permissions/tests/correct_permissions.pass.sh
This file contains hidden or 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 |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| #!/bin/bash | ||
| # | ||
|
|
||
| {{% for path in FILEPATH %}} | ||
| {{% if IS_DIRECTORY and FILE_REGEX %}} | ||
|
|
||
3 changes: 1 addition & 2 deletions
3
shared/templates/file_permissions/tests/lenient_permissions.fail.sh
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 OVAL template now doesn't contain this parameter at all. How does it work now?
The docs says:
I have an impression that it now doesn't work when this is set to
false. When it's set tofalseand the given file doesn't exist the rule should fail. But with this PR change if the given file doesn't exist, thecheck_existence="none_exists"is satisfied, therefore the rule will pass. Is my understanding correct?Now the question is how to solve this change. I assume that the
missing_file_passset tofalsemakes sense only when looking for specific files and not for recursive search. For the recursive search (i.e. rules withrecursive: true) we usually don't care if something exists. But, our problem is mainly for recursively searching rules because in these rules we have the problem of collecting large amounts of item. We don't need this optimization for rules that match a single file or a couple of file in the same directory. Therefore we could have 2 versions of the OVAL code: one for recursive searching with the filter optimization and one for the other cases. We will document that themissing_file_pass = falseis mutually exclusive withrecursive = true. WDYT?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.
We should remove this parameter. I didn't propose to remove from documentation because it should also be removed from many
rule.ymlfiles and I don't think this is mandatory for now since a behavior change is not expected. We can gradually deprecate this parameter for these affected templates.These templates intend to assess the permissions and ownership (uid and gid) of files. Doesn't make any sense to me this assessment for files which are not present. If a file actually doesn't exist, it is quite logical that it won't have problems with permissions and ownership. The idea of the parameter
missing_file_passonly makes sense for templates and rules which actually want to asses file existence and not their properties, likefile_existencetemplate or thebanner_etc_motdrule, for example.Also, seems that this parameter was introduced in these templates due to the design of the old OVAL logic where an empty file_object would affect the results based on the
check_existence=parameter. In other words, this parameter is useless for these templates if we usedcheck_existence=none_existfor thefile_test.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 agree with Jan here, the rule passing when a specific file is absent is a behaviour changes we do not want.
We have a specific parameter that allows this behaviour, and I think we should keep it, (if we want to remove it, it should be done in master).
I think it depends on the expectation of the rule. There may be rules that don't care if it is missing, while others may care if the file is missing.
From my PoV, this is a flexibility of the template that we want to keep.