-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add scripts to generate corpus #192
Conversation
Apologies for the delay in updating this PR! My latest commits resolve #191 and make the suggested changes to the scripts. I decided to leave the default timeout to 15 minutes for now -- I expect we'll change it in the future after we have more evidence about what timeout leads to the "best" corpus tests. This PR will need to be merged after cedar#589. |
let mut responses = Vec::with_capacity(requests.len()); | ||
for request in requests.iter() { | ||
let authorizer = Authorizer::new(); | ||
let response = authorizer.is_authorized(request.clone(), &policyset, &input.entities); | ||
responses.push(response); | ||
} |
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.
same here
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.
In fact, would it be possible to share some of this code, which is currently duplicated. (doesn't have to be in this PR)
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.
Reformatted in the latest commit. I didn't deal with the code reuse, but you're right that would be cleaner
/// Check whether a policy set can be successfully parsed | ||
fn well_formed(policies: &PolicySet) -> bool { | ||
policies | ||
.static_policies() | ||
.map(ToString::to_string) | ||
.all(|p| Policy::from_str(&p).is_ok()) | ||
} |
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.
is it sufficent to check the .static_policies()
? should we also check templates? is there an easy way to iterate over both static policies and templates?
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.
The current code only writes out the static policies because the relevant abac*
targets only generate static policies. The general function is .policies()
.
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.
Sounds good.
Issue #, if available:
Description of changes:
Added scripts to generate corpus files, towards solving cedar#552. Also included some minor refactoring + added support for logging corpus tests from the
abac-type-directed
targets and resolves #191.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.