Skip to content
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 built-in function support to verify PGP signatures #1873

Closed
platten opened this issue Nov 1, 2019 · 10 comments
Closed

Add built-in function support to verify PGP signatures #1873

platten opened this issue Nov 1, 2019 · 10 comments

Comments

@platten
Copy link

platten commented Nov 1, 2019

We have a use case for verifying annotations containing GPG signatures for Kubernetes manifests. It would be great to have a built-in function in rego which would support that!

@tsandall tsandall added this to To do in Open Policy Agent via automation Nov 5, 2019
@tsandall tsandall changed the title Request: GPG support in rego Add built-in function to verify GPG signatures Nov 22, 2019
@tsandall tsandall changed the title Add built-in function to verify GPG signatures Add built-in function to verify PGP signatures Nov 22, 2019
@tsandall tsandall changed the title Add built-in function to verify PGP signatures Add built-in function support to verify PGP signatures Nov 22, 2019
@tsandall
Copy link
Member

tsandall commented Nov 22, 2019

One thing worth mentioning is that users can easily extend OPA with custom built-in functions: https://www.openpolicyagent.org/docs/edge/extensions/#custom-built-in-functions-in-go

Since we try to avoid pulling thirdparty dependencies into OPA and this would likely require golang.org/x/crypto (which we do not currently vendor) I'd recommend checking out the method above. OPA builds easily and the extension process is quite lightweight--so check it out.

That said golang.org/x/crypto exports a lot of useful functions and I could imagine many users wanting those inside Rego. @patrick-east @koponen-styra do either of you have any opinions here? I'm assuming that as long OPA relies on stable exported APIs from golang.org/x/crypto this might not be a problem?

@koponen-styra
Copy link
Contributor

Having golang.org/x/crypto as a dependency sounds useful, indeed. I'm my limited experience with the library its exported APIs have been stable.

@patrick-east
Copy link
Contributor

+1 for golang.org/x/crypto being pretty safe as a dependency

@ashutosh-narkar ashutosh-narkar moved this from Backlog to Planned - v0.42 in Open Policy Agent Jul 6, 2022
@ashutosh-narkar ashutosh-narkar moved this from Planned - v0.42 to In Progress in Open Policy Agent Jul 6, 2022
@ashutosh-narkar ashutosh-narkar self-assigned this Jul 6, 2022
@srenatus srenatus moved this from In Progress to Planned - v0.43 in Open Policy Agent Jul 25, 2022
@ashutosh-narkar ashutosh-narkar moved this from Planned - v0.43 to In Progress in Open Policy Agent Aug 9, 2022
@ashutosh-narkar
Copy link
Member

ashutosh-narkar commented Aug 9, 2022

@platten would you be able to provide an example of how you plan to use the proposed builtin? I would imagine the builtin takes the public key, signed file and signature file content.

@ashutosh-narkar ashutosh-narkar moved this from In Progress to Backlog in Open Policy Agent Aug 12, 2022
@eshaanm25
Copy link

Hey @ashutosh-narkar! I know this thread is a bit old, but I wanted to add some interest for a GPG decryption function. GPG is often utilized to sign images and is natively used by container runtimes (like CRI-O) to verify if images can be deployed to an environment. Since a great use case of OPA is in Kubernetes, a built-in GPG decryption function would allow for shift-left verification of an image's GPG signature validity prior to deployment using OPA.

I think a GPG decryption function that takes GPG encrypted data and a public key as an input, and outputs the decrypted data would be a great addition to OPA's built-in function library.

@ashutosh-narkar
Copy link
Member

@eshaanm25 that sounds like a useful builtin. Would you like to contribute? We are happy to help you through the process.

@eshaanm25
Copy link

eshaanm25 commented Feb 22, 2023

I'd love to! Would you happen to have some resources or initial guidance for contributing? I'll take a look at the repository tonight and also attend the next open-hours session as well 😄

EDIT: Taking a look at the built-ins, I see topdown/crypto.go as the home for many of the crypto functions. I think GPG functions would be an addition to this collection, what do you think?

@ashutosh-narkar
Copy link
Member

I think GPG functions would be an addition to this collection, what do you think?

That looks right. You can find an example of adding a builtin here and also checkout the code for the recently added builtins for more examples. General code contribution guidelines can be found here. Thanks for looking into this!

@ashutosh-narkar
Copy link
Member

Closing for now. We can re-open based on future need and demand.

@ashutosh-narkar ashutosh-narkar closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2023
Open Policy Agent automation moved this from Backlog to Done Sep 5, 2023
@yogisinha
Copy link
Contributor

Hi @ashutosh-narkar , I can pick this one if this is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

7 participants