-
Notifications
You must be signed in to change notification settings - Fork 73
🌱 OPRUN-4550: Replace generated mozilla_data.go with go:embed + runtime parsing #2634
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
Open
tmshort
wants to merge
1
commit into
operator-framework:main
Choose a base branch
from
tmshort:use-embed-to-update-profiles
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,53 +1,98 @@ | ||
| package tlsprofiles | ||
|
|
||
| // DO NOT EDIT, GENERATED BY hack/tools/update-tls-profiles.sh | ||
| // DATA SOURCE: https://ssl-config.mozilla.org/guidelines/latest.json | ||
| // DATA VERSION: 6 | ||
| // This file embeds the Mozilla SSL/TLS Configuration Guidelines JSON and parses | ||
| // it at init() time to populate the modern and intermediate TLS profiles. | ||
| // Run `make update-tls-profiles` to refresh mozilla_data.json from the upstream spec. | ||
|
|
||
| import ( | ||
| "crypto/tls" | ||
| _ "embed" | ||
| "encoding/json" | ||
| "fmt" | ||
| ) | ||
|
|
||
| var modernTLSProfile = tlsProfile{ | ||
| ciphers: cipherSlice{ | ||
| cipherNums: []uint16{ | ||
| tls.TLS_AES_128_GCM_SHA256, | ||
| tls.TLS_AES_256_GCM_SHA384, | ||
| tls.TLS_CHACHA20_POLY1305_SHA256, | ||
| }, | ||
| }, | ||
| curves: curveSlice{ | ||
| curveNums: []tls.CurveID{ | ||
| X25519MLKEM768, | ||
| X25519, | ||
| prime256v1, | ||
| secp384r1, | ||
| }, | ||
| }, | ||
| minTLSVersion: tls.VersionTLS13, | ||
| //go:embed mozilla_data.json | ||
| var mozillaDataJSON []byte | ||
|
|
||
| // skippedCiphers records cipher names from mozilla_data.json that are not | ||
| // supported by Go's crypto/tls and were omitted from the profiles. | ||
| var skippedCiphers []string | ||
|
|
||
| var ( | ||
| modernTLSProfile tlsProfile | ||
| intermediateTLSProfile tlsProfile | ||
| ) | ||
|
|
||
| type mozillaConfiguration struct { | ||
| Ciphersuites []string `json:"ciphersuites"` | ||
| Ciphers struct { | ||
| IANA []string `json:"iana"` | ||
| } `json:"ciphers"` | ||
| TLSCurves []string `json:"tls_curves"` | ||
| TLSVersions []string `json:"tls_versions"` | ||
| } | ||
|
|
||
| var intermediateTLSProfile = tlsProfile{ | ||
| ciphers: cipherSlice{ | ||
| cipherNums: []uint16{ | ||
| tls.TLS_AES_128_GCM_SHA256, | ||
| tls.TLS_AES_256_GCM_SHA384, | ||
| tls.TLS_CHACHA20_POLY1305_SHA256, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, | ||
| tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, | ||
| tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, | ||
| tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, | ||
| tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, | ||
| }, | ||
| }, | ||
| curves: curveSlice{ | ||
| curveNums: []tls.CurveID{ | ||
| X25519MLKEM768, | ||
| X25519, | ||
| prime256v1, | ||
| secp384r1, | ||
| }, | ||
| }, | ||
| minTLSVersion: tls.VersionTLS12, | ||
| type mozillaSpec struct { | ||
| Configurations map[string]mozillaConfiguration `json:"configurations"` | ||
| } | ||
|
|
||
| func init() { | ||
| var spec mozillaSpec | ||
| if err := json.Unmarshal(mozillaDataJSON, &spec); err != nil { | ||
| panic(fmt.Sprintf("tlsprofiles: failed to parse embedded mozilla_data.json: %v", err)) | ||
| } | ||
|
|
||
| for _, name := range []string{"modern", "intermediate"} { | ||
| cfg, ok := spec.Configurations[name] | ||
| if !ok { | ||
| panic(fmt.Sprintf("tlsprofiles: profile %q not found in embedded mozilla_data.json", name)) | ||
| } | ||
|
|
||
| p, skipped := parseProfile(name, cfg) | ||
| skippedCiphers = append(skippedCiphers, skipped...) | ||
|
|
||
| switch name { | ||
| case "modern": | ||
| modernTLSProfile = p | ||
| case "intermediate": | ||
| intermediateTLSProfile = p | ||
| } | ||
| } | ||
| } | ||
|
|
||
| func parseProfile(name string, cfg mozillaConfiguration) (tlsProfile, []string) { | ||
| var skipped []string | ||
| var cipherNums []uint16 | ||
| for _, c := range append(cfg.Ciphersuites, cfg.Ciphers.IANA...) { | ||
| id := cipherSuiteId(c) | ||
| if id == 0 { | ||
| skipped = append(skipped, c) | ||
| continue | ||
| } | ||
| cipherNums = append(cipherNums, id) | ||
| } | ||
|
|
||
| var curveNums []tls.CurveID | ||
| for _, c := range cfg.TLSCurves { | ||
| id := curveId(c) | ||
| if id == 0 { | ||
| continue | ||
| } | ||
| curveNums = append(curveNums, id) | ||
| } | ||
|
|
||
| if len(cfg.TLSVersions) == 0 { | ||
| panic(fmt.Sprintf("tlsprofiles: profile %q has no tls_versions in embedded mozilla_data.json", name)) | ||
| } | ||
|
|
||
| var version tlsVersion | ||
| if err := version.Set(cfg.TLSVersions[0]); err != nil { | ||
| panic(fmt.Sprintf("tlsprofiles: profile %q has unrecognized tls_versions[0] %q: %v", name, cfg.TLSVersions[0], err)) | ||
| } | ||
|
|
||
| return tlsProfile{ | ||
| ciphers: cipherSlice{cipherNums: cipherNums}, | ||
| curves: curveSlice{curveNums: curveNums}, | ||
| minTLSVersion: version, | ||
| }, skipped | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| { | ||
| "version": 6.0, | ||
| "href": "https://ssl-config.mozilla.org/guidelines/6.0.json", | ||
| "configurations": { | ||
| "modern": { | ||
| "certificate_curves": ["prime256v1", "secp384r1"], | ||
| "certificate_signatures": ["ecdsa-with-SHA256", "ecdsa-with-SHA384", "ecdsa-with-SHA512"], | ||
| "certificate_types": ["ecdsa"], | ||
| "ciphers": { | ||
| "iana": [], | ||
| "openssl": [] | ||
| }, | ||
| "ciphersuites": [ | ||
| "TLS_AES_128_GCM_SHA256", | ||
| "TLS_AES_256_GCM_SHA384", | ||
| "TLS_CHACHA20_POLY1305_SHA256" | ||
| ], | ||
| "dh_param_size": null, | ||
| "ecdh_param_size": 256, | ||
| "hsts_min_age": 63072000, | ||
| "maximum_certificate_lifespan": 90, | ||
| "ocsp_staple": true, | ||
| "oldest_clients": ["Firefox 63", "Android 10.0", "Chrome 70", "Edge 75", "Java 11", "OpenSSL 1.1.1", "Opera 57", "Safari 12.1"], | ||
| "recommended_certificate_lifespan": 90, | ||
| "rsa_key_size": null, | ||
| "server_preferred_order": false, | ||
| "tls_curves": ["X25519MLKEM768", "X25519", "prime256v1", "secp384r1"], | ||
| "tls_versions": ["TLSv1.3"] | ||
| }, | ||
| "intermediate": { | ||
| "certificate_curves": ["prime256v1", "secp384r1"], | ||
| "certificate_signatures": ["sha256WithRSAEncryption", "ecdsa-with-SHA256", "ecdsa-with-SHA384", "ecdsa-with-SHA512"], | ||
| "certificate_types": ["ecdsa", "rsa"], | ||
| "ciphers": { | ||
| "iana": [ | ||
| "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", | ||
| "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", | ||
| "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", | ||
| "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", | ||
| "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", | ||
| "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" | ||
| ], | ||
| "openssl": [ | ||
| "ECDHE-ECDSA-AES128-GCM-SHA256", | ||
| "ECDHE-RSA-AES128-GCM-SHA256", | ||
| "ECDHE-ECDSA-AES256-GCM-SHA384", | ||
| "ECDHE-RSA-AES256-GCM-SHA384", | ||
| "ECDHE-ECDSA-CHACHA20-POLY1305", | ||
| "ECDHE-RSA-CHACHA20-POLY1305" | ||
| ] | ||
| }, | ||
| "ciphersuites": [ | ||
| "TLS_AES_128_GCM_SHA256", | ||
| "TLS_AES_256_GCM_SHA384", | ||
| "TLS_CHACHA20_POLY1305_SHA256" | ||
| ], | ||
| "dh_param_size": 2048, | ||
| "ecdh_param_size": 256, | ||
| "hsts_min_age": 63072000, | ||
| "maximum_certificate_lifespan": 366, | ||
| "ocsp_staple": true, | ||
| "oldest_clients": ["Firefox 31.3.0", "Android 4.4.2", "Chrome 49", "Edge 15 on Windows 10", "IE 11 on Windows 10", "Java 8u161", "OpenSSL 1.0.1l", "Opera 20", "Safari 9"], | ||
| "recommended_certificate_lifespan": 90, | ||
| "rsa_key_size": 2048, | ||
| "server_preferred_order": false, | ||
| "tls_curves": ["X25519MLKEM768", "X25519", "prime256v1", "secp384r1"], | ||
| "tls_versions": ["TLSv1.2", "TLSv1.3"] | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me here we drop the only usage of gojq, but we keep it still in bingo files (.bingo/gojq.mod, .bingo/Variables.mk, ...).
Should we drop it also from bingo?
Should be something like: