Open pckvcode opened 1 month ago
conftest project version used github.com/open-policy-agent/conftest v0.51.0
I encountered the same issue when using the conftest binary locally on Windows. Please find the attachment.
hi @pckvcode
Very nice find! The corresponding code block seems to be added from the very beginning of the OPA: https://github.com/open-policy-agent/opa/pull/176/files
With the current form, I can verify it ignores the C as the following:
example.com:C:/foo/bar
It should normally be able to open files using different drivers intuitively, so +1 from my side, though we need to check this strictly in unit tests-e2e to make sure it doesn't break any of the core features under the hood
Feel free to propose a PR containing multiple cases for unit-tests to OPA, and feel free to ping us in the PR to review
Thanks for your investigations
Earlier, there was an issue with loading policies using the path C:/path/to/policy/
on Windows. This was resolved by adding the file:///
prefix, so the policy path became file:///C:/path/to/policy/
. For more details please refer this link
However, we're now encountering an issue with loading the data.yaml
file from other drives on Windows. I tried the following two options, but neither worked:
file:///C:/path/to/data/data.yaml
a:file:///C:/path/to/data/data.yaml
I've attached screenshots of the errors.
Command used:
.\conftest.exe test C:/Users/pck/Punith/test_files/config.yaml --policy file:///C:/Users/pck/Punith/test_files/policy --data C:/Users/pck/Punith/test_files/data.yaml
Steps to reproduce:
data.yaml
in the C drive.. \conftest.exe test C:/Users/pck/Punith/test_files/config.yaml --policy file:///C:/Users/pck/Punith/test_files/policy --data C:/Users/pck/Punith/test_files/data.yaml
Error: running test: load: load documents: 1 error occurred during loading: CreateFile /Users/pck/Punith/test_files/data.yaml: The system cannot find the path specified.
It seems there may be an issue with how data files are loaded. Could we apply the same logic used for loading policy files here to loading data files here?
More details:
Screenshot of files keeping in C drive
@boranx Any suggestion on the above comments
bug: Accessing Rego Policies from Different Drives in Windows
Not able to access Rego policies from another drive in Windows. Error occurs while integrating with Golang.
Example: If
go-binary/main.go
is in the D drive and tries to access Rego policies located in the C drive (or vice-versa), an error occurs:OPA loader should identify Windows C, D drives and load files.
Quick Fix
Short Description
Steps To Reproduce
Expected Behavior
Code should be able to load Rego policies from other drives (C, D, or E drives) in Windows.
Additional Context
Bug in code: opa/loader.go#L575
Current:
New:
Description: It should not separate the prefix if it detects C/D/E drives.
New test case to be added: opa/loader_test.go#L825