-
Notifications
You must be signed in to change notification settings - Fork 200
CFE-4529: Added policy function getacls() #5832
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
Merged
Changes from all commits
Commits
Show all changes
2 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
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
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 |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| ############################################################################## | ||
| # | ||
| # Test policy function getacls() | ||
| # | ||
| ############################################################################## | ||
|
|
||
| body common control | ||
| { | ||
| inputs => { "../../default.cf.sub" }; | ||
| bundlesequence => { default("$(this.promise_filename)") }; | ||
| version => "1.0"; | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| body acl user_root_rwx_acl | ||
| { | ||
| acl_method => "append"; | ||
| acl_default => "access"; | ||
| aces => { "user:root:rwx" }; | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent init | ||
| { | ||
| files: | ||
| "$(G.testdir)/." | ||
| create => "true", | ||
| acl => user_root_rwx_acl, | ||
| handle => "Default ACLs is set"; | ||
| "$(G.testdir)/foo" | ||
| create => "true", | ||
| depends_on => { "Default ACLs is set" }, | ||
| comment => "Inherits ACLs from parent directory"; | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent test | ||
| { | ||
| meta: | ||
| "description" -> { "CFE-4529" } | ||
| string => "Test policy function getacls()"; | ||
|
|
||
| "test_soft_fail" | ||
| string => "windows", | ||
| meta => { "ENT-13019" }; | ||
|
|
||
| vars: | ||
| "default_acls" | ||
| slist => getacls("$(G.testdir)", "default"), | ||
| if => fileexists("$(G.testdir)"); | ||
| "access_acls" | ||
| slist => getacls("$(G.testdir)/foo", "access"), | ||
| if => fileexists("$(G.testdir)/foo"); | ||
| } | ||
|
|
||
| ############################################################################## | ||
|
|
||
| bundle agent check | ||
| { | ||
| classes: | ||
| "acls_not_supported" | ||
| expression => eval("$(with) == 0", "class", "infix"), | ||
| with => length("test.default_acls"), | ||
| comment => "getacls() returns empty list if unsupported"; | ||
| "default_ok" | ||
| expression => some("$(expected)", "test.default_acls"); | ||
| "access_ok" | ||
| expression => some("$(expected)", "test.access_acls"); | ||
|
|
||
| vars: | ||
| "expected" | ||
| string => ".*user:root:rwx.*"; | ||
|
|
||
| reports: | ||
| acls_not_supported:: | ||
| "$(this.promise_filename) Skip/unsupported"; | ||
| default_ok&access_ok:: | ||
| "$(this.promise_filename) Pass"; | ||
| !(default_ok&access_ok):: | ||
| "$(this.promise_filename) FAIL"; | ||
| "Expecting one match of '$(expected)' in default ACLs [$(with)]" | ||
| with => join(", ", "test.default_acls"); | ||
| "Expecting one match of '$(expected)' in access ACLs [$(with)]" | ||
| with => join(", ", "test.access_acls"); | ||
| } | ||
|
|
||
| ############################################################################## |
Oops, something went wrong.
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.
@larsewi I am a bit unsure about this error. Directories might not have acls on them, and rather than error, it sort of feels more correct to simply return an empty list. I want to say that getindcies and some other functions behave similarly to that.
This came up after the workshop when i was following up on a note to add example output to the documentation example.
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 was triggered by this update from @nickanderson and error is definitely not okl I assume we want the same as the
getfaclcommand: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.
Good catch 🚀 Fix here #5902