Fixed #2016 issue - Allow referencing entities JSON files in run-test…#2171
Closed
mihai2500 wants to merge 1 commit intocedar-policy:mainfrom
Closed
Fixed #2016 issue - Allow referencing entities JSON files in run-test…#2171mihai2500 wants to merge 1 commit intocedar-policy:mainfrom
mihai2500 wants to merge 1 commit intocedar-policy:mainfrom
Conversation
Comment on lines
+1849
to
+1852
| let test_file_path = Path::new(&args.tests); | ||
| let test_file_dir = test_file_path | ||
| .parent() | ||
| .unwrap_or_else(|| Path::new(".")); |
Contributor
There was a problem hiding this comment.
I think we want to do something here to protect against possible path traversal. We mainly see this being used as a development tools, but it'd be best to proactively prevent this in case it's called on untrusted input.
2 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
…s input
Description of changes
Added support for referencing external entity JSON files in the cedar/cedar-policy-cli/src/lib.rs (run-tests) .
Added support for referencing external entity JSON files in the cedar/cedar-policy-cli/tests/sample.rs (cedar run-tests) command instead of requiring entities to be defined inline in test JSON.
Changes:
Modified CheckedTestCaseSeed to track the test file directory for resolving relative paths;
Updated the deserializer to detect when entities is a string (file path) vs. inline JSON array;
Entity file paths are resolved relative to the test file's directory;
Added test case demonstrating the new functionality;
Issue #, if available
Fixed issue #2016
Checklist for requesting a review
The change in this PR is (choose one, and delete the other options):
cedar-policy.I confirm that this PR (choose one, and delete the other options):
I confirm that
cedar-spec(choose one, and delete the other options):cedar-spec. (Post your PR anyways, and we'll discuss in the comments.)I confirm that
docs.cedarpolicy.com(choose one, and delete the other options):