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

topdown/crypto: Add URIStrings field to JSON certs #6424

Merged

Conversation

charlieegan3
Copy link
Contributor

Fixes #6416, see issue for discussion.

Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@charlieegan3 it would be helpful if we could explain the need for this change in the commit message body. Thanks!

}
}

v, err := ast.InterfaceToValue(processedCerts)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd probably need something similar for crypto.x509.parse_and_verify_certificates ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, I've updated the implementation of this too in f71330c

// add a field to certs containing the URIs as strings
processedCerts := make([]struct {
x509.Certificate
RawURIs []string `json:"RawURIs"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment about naming: I think the "raw" in RawURIs might give the impression that these are presented exactly as they appear in the subjectAltName extension. However, in general, passing a string through url.Parse and then URL.String will not always result in the original string.1

What do you think about naming this field URIStrings instead? (Or something else that doesn't have "raw" in the name?)

Footnotes

  1. Here are a few pathological examples: https://go.dev/play/p/I3cnmN5W6dy. It's possible that this shouldn't ever matter if the subjectAltName extension conforms to all the requirements of RFC 5280 4.2.1.6, but I don't really understand this well enough to say for sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point, I've updated the field name in f71330c

@charlieegan3 charlieegan3 force-pushed the add-raw-uris-to-certs branch 2 times, most recently from 18a2c11 to f71330c Compare November 21, 2023 11:28
@charlieegan3 charlieegan3 changed the title topdown/crypto: Add RawURIs field to JSON certs topdown/crypto: Add URIStrings field to JSON certs Nov 21, 2023
@charlieegan3 charlieegan3 force-pushed the add-raw-uris-to-certs branch 2 times, most recently from e09a139 to f5363d3 Compare November 21, 2023 17:12
johanfylling
johanfylling previously approved these changes Nov 24, 2023
Copy link
Contributor

@johanfylling johanfylling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link

netlify bot commented Nov 29, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 7f377bd
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/65677a9aa2ca8f0008404197
😎 Deploy Preview https://deploy-preview-6424--openpolicyagent.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Nov 29, 2023

Deploy Preview for openpolicyagent ready!

Name Link
🔨 Latest commit 3805e5e
🔍 Latest deploy log https://app.netlify.com/sites/openpolicyagent/deploys/65679acb1d29b600082e8d07
😎 Deploy Preview https://deploy-preview-6424--openpolicyagent.netlify.app/docs/edge/comparison-to-other-systems
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@charlieegan3 charlieegan3 force-pushed the add-raw-uris-to-certs branch 2 times, most recently from cf27335 to 08bee46 Compare November 29, 2023 18:08
This is being added to make it easier to write policy on the contents of
certificate URI SANs. This is where information like SPIFFE IDs etc are
contained and it's helpful to Rego authors to have access to these
values without rebuilding the URI from the parsed data under URIs.

Fixes open-policy-agent#6416

Signed-off-by: Charlie Egan <[email protected]>
Signed-off-by: Charlie Egan <[email protected]>
Also, add a test for missing URI case.

Signed-off-by: Charlie Egan <[email protected]>
Signed-off-by: Charlie Egan <[email protected]>
Copy link
Member

@ashutosh-narkar ashutosh-narkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ashutosh-narkar ashutosh-narkar merged commit 7a32e8f into open-policy-agent:main Nov 29, 2023
24 checks passed
@charlieegan3 charlieegan3 deleted the add-raw-uris-to-certs branch November 30, 2023 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide SAN URIs as plain strings in crypto.x509.parse_certificates output
4 participants