Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Regal lint fails when setting capabilities in config.yaml in windows #1202

Closed
geirs73 opened this issue Oct 15, 2024 · 3 comments · Fixed by #1209
Closed

Regal lint fails when setting capabilities in config.yaml in windows #1202

geirs73 opened this issue Oct 15, 2024 · 3 comments · Fixed by #1209

Comments

@geirs73
Copy link

geirs73 commented Oct 15, 2024

We need to lint against a bit older opa.exe in production. Seems like this is a problem on windows. At least for me.

.regal/config.yaml:

capabilities:
  from:
    engine: opa
    version: 0.64.1

Our rego bundle resides in directory named rego in directory C:\git\work\policies. Trying to run linting.

regal.exe lint -c .regal/config.yaml rego

failed to decode user config from C:\git\work\policies\.regal: failed to load capabilities: failed to load capabilities due to error: no capabilities version found 0.64.1

Not sure why this happens. I do not have opa.exe (this is windows) in $PATH, so if regal.exe needs to call opa.exe to get it, it will probably not find it.

I also tried downloading the opa capabilities file and store it locally, to get around the above problem.

capabilities:
  from:
    file: "v0.64.1.json"
regal.exe lint -c .regal/config.yaml rego

failed to decode user config from C:\git\work\policies\.regal: failed to load capabilities: failed to parse URL 'file://C:\git\work\policies\v0.64.1.json': parse "file://C:\\git\\work\\policies\\v0.64.1.json": invalid port ":\\git\\work\\policies\\v0.64.1.json" after host

Seems like there is some issue concerning how paths are handled on Windows here?

OS: Windows 11

Regal:
Version:    0.28.0
Go Version: go1.22.5
Platform:   windows/amd64
Commit:     9503967b3cd1d3725d078b04dd55ee9ec807b3f3
Timestamp:  2024-10-07T15:17:16Z
Hostname:   github.actions.local
@geirs73 geirs73 changed the title Regal lint fails when setting capabilites in config.yaml in windows Regal lint fails when setting capabilities in config.yaml in windows Oct 15, 2024
@anderseknert
Copy link
Member

Thanks for reporting this!

As for the first issue — can you try using v0.64.1 (with a v prefix) for version rather than 0.64.1? The latter will IIRC be interpreted as either a number or some binary representation, which isn't going to work. Either way, we should improve the error handling in that case, and make sure that it's clear what's expected.

I'll have to look into why loading the capabilities from file doesn't work. The capabilities system was somewhat remodeled recently to allow EOPA to be set as an engine, and perhaps that introduced a change in behavior. Or it's isolated to Windows as you suggested. Some digging to do!

@geirs73
Copy link
Author

geirs73 commented Oct 15, 2024

The 'v' did it. Since that worked, the next issue may not be that important, however, I think testing all file-path-related functionality on windows images probably is a good idea, due to how the error message looked. Thanks!

anderseknert added a commit that referenced this issue Oct 16, 2024
As reported in #1202 (thanks @geirs73!)

Note however that this does not address the Windows path loading
issue from the same issue though.

Signed-off-by: Anders Eknert <anders@styra.com>
anderseknert added a commit that referenced this issue Oct 16, 2024
As reported in #1202 (thanks @geirs73!)

Note however that this does not address the Windows path loading
issue from the same issue though.

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert
Copy link
Member

Better error reporting for when the version is either numeric, or missing a v prefix: #1208

The Windows path issue will have to be addressed separately, but we'll get to that.

anderseknert added a commit that referenced this issue Oct 16, 2024
As reported in #1202 (thanks @geirs73!)

Note however that this does not address the Windows path loading
issue from the same issue though.

Signed-off-by: Anders Eknert <anders@styra.com>
charlieegan3 added a commit to charlieegan3/regal that referenced this issue Oct 16, 2024
This change ensures that config files with relative capabilities
references work correctly.

Fixes StyraInc#1202

Signed-off-by: Charlie Egan <charlie@styra.com>
charlieegan3 pushed a commit to charlieegan3/regal that referenced this issue Jan 6, 2025
)

As reported in StyraInc#1202 (thanks @geirs73!)

Note however that this does not address the Windows path loading
issue from the same issue though.

Signed-off-by: Anders Eknert <anders@styra.com>
charlieegan3 added a commit to charlieegan3/regal that referenced this issue Jan 6, 2025
This change ensures that config files with relative capabilities
references work correctly.

Fixes StyraInc#1202

Signed-off-by: Charlie Egan <charlie@styra.com>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants