-
Notifications
You must be signed in to change notification settings - Fork 231
USHIFT-6925 USHIFT-6851: Introduce Post-Quantum Curves to Ingress defaults and FIPs detection #6622
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
eslutsky
wants to merge
5
commits into
openshift:main
Choose a base branch
from
eslutsky:microshift-fips-detection
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
Show all changes
5 commits
Select commit
Hold shift + click to select a range
60cf2ba
NO-ISSUE: Add FIPS detection for ingress controller
eslutsky d65e623
NO-ISSUE: Filter non-FIPS TLS 1.3 ciphers in ingress router
eslutsky 0852771
NO-ISSUE: Configure TLS curves based on FIPS mode for PQC readiness
eslutsky 9e1e64a
add test for ingress Post Quantum curves support
eslutsky a9aaf1e
address PR review comments
eslutsky 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 |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| package components | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
|
|
||
| configv1 "github.com/openshift/api/config/v1" | ||
| "github.com/openshift/microshift/pkg/assets" | ||
| "github.com/openshift/microshift/pkg/config" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "k8s.io/utils/ptr" | ||
| ) | ||
|
|
||
| func newTestConfig() *config.Config { | ||
| return &config.Config{ | ||
| DNS: config.DNS{BaseDomain: "example.com"}, | ||
| Network: config.Network{ | ||
| ClusterNetwork: []string{"10.42.0.0/16"}, | ||
| ServiceNetwork: []string{"10.43.0.0/16"}, | ||
| }, | ||
| Ingress: config.IngressConfig{ | ||
| Ports: config.IngressPortsConfig{ | ||
| Http: ptr.To(80), | ||
| Https: ptr.To(443), | ||
| }, | ||
| TuningOptions: config.IngressControllerTuningOptions{ | ||
| HeaderBufferBytes: 32768, | ||
| HeaderBufferMaxRewriteBytes: 8192, | ||
| HealthCheckInterval: &metav1.Duration{Duration: 5 * time.Second}, | ||
| ClientTimeout: &metav1.Duration{Duration: 30 * time.Second}, | ||
| ClientFinTimeout: &metav1.Duration{Duration: 1 * time.Second}, | ||
| ServerTimeout: &metav1.Duration{Duration: 30 * time.Second}, | ||
| ServerFinTimeout: &metav1.Duration{Duration: 1 * time.Second}, | ||
| TunnelTimeout: &metav1.Duration{Duration: 1 * time.Hour}, | ||
| TLSInspectDelay: &metav1.Duration{Duration: 5 * time.Second}, | ||
| ThreadCount: 4, | ||
| MaxConnections: 50000, | ||
| }, | ||
| ForwardedHeaderPolicy: "Append", | ||
| TLSSecurityProfile: &configv1.TLSSecurityProfile{ | ||
| Type: configv1.TLSProfileIntermediateType, | ||
| }, | ||
| ServingCertificateSecret: "router-certs-default", | ||
| DefaultHttpVersionPolicy: 1, | ||
| LogEmptyRequests: "Log", | ||
| HTTPEmptyRequestsPolicy: "Respond", | ||
| AccessLogging: config.AccessLogging{ | ||
| Status: config.AccessLoggingDisabled, | ||
| }, | ||
| }, | ||
| } | ||
| } | ||
|
|
||
| func requireStringParam(t *testing.T, params assets.RenderParams, key string) string { | ||
| t.Helper() | ||
| v, ok := params[key] | ||
| if !ok { | ||
| t.Fatalf("missing param %q", key) | ||
| } | ||
| s, ok := v.(string) | ||
| if !ok { | ||
| t.Fatalf("param %q has type %T, want string", key, v) | ||
| } | ||
| return s | ||
| } | ||
|
|
||
| func TestGenerateIngressParamsFIPSCiphers(t *testing.T) { | ||
| t.Run("FIPS enabled filters non-FIPS TLS 1.3 ciphers", func(t *testing.T) { | ||
| cfg := newTestConfig() | ||
| params, err := generateIngressParams(cfg, true) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| cipherSuites := requireStringParam(t, params, "RouterCiphersSuites") | ||
| if strings.Contains(cipherSuites, "TLS_CHACHA20_POLY1305_SHA256") { | ||
| t.Errorf("FIPS mode should filter out TLS_CHACHA20_POLY1305_SHA256, got: %s", cipherSuites) | ||
| } | ||
| if !strings.Contains(cipherSuites, "TLS_AES_128_GCM_SHA256") { | ||
| t.Errorf("FIPS mode should keep TLS_AES_128_GCM_SHA256, got: %s", cipherSuites) | ||
| } | ||
| if !strings.Contains(cipherSuites, "TLS_AES_256_GCM_SHA384") { | ||
| t.Errorf("FIPS mode should keep TLS_AES_256_GCM_SHA384, got: %s", cipherSuites) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("non-FIPS keeps all TLS 1.3 ciphers", func(t *testing.T) { | ||
| cfg := newTestConfig() | ||
| params, err := generateIngressParams(cfg, false) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| cipherSuites := requireStringParam(t, params, "RouterCiphersSuites") | ||
| if !strings.Contains(cipherSuites, "TLS_CHACHA20_POLY1305_SHA256") { | ||
| t.Errorf("non-FIPS mode should keep TLS_CHACHA20_POLY1305_SHA256, got: %s", cipherSuites) | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| func TestGenerateIngressParamsFIPSCurves(t *testing.T) { | ||
| t.Run("FIPS enabled uses only NIST curves", func(t *testing.T) { | ||
| cfg := newTestConfig() | ||
| params, err := generateIngressParams(cfg, true) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| curves := requireStringParam(t, params, "RouterTLSCurves") | ||
| if strings.Contains(curves, "X25519MLKEM768") { | ||
| t.Errorf("FIPS mode should exclude X25519MLKEM768, got: %s", curves) | ||
| } | ||
| for _, c := range strings.Split(curves, ":") { | ||
| if c == "X25519" { | ||
| t.Errorf("FIPS mode should exclude X25519, got: %s", curves) | ||
| } | ||
| } | ||
| if curves != "P-256:P-384:P-521" { | ||
| t.Errorf("FIPS mode curves should be P-256:P-384:P-521, got: %s", curves) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("non-FIPS includes PQC hybrid curve", func(t *testing.T) { | ||
| cfg := newTestConfig() | ||
| params, err := generateIngressParams(cfg, false) | ||
| if err != nil { | ||
| t.Fatalf("unexpected error: %v", err) | ||
| } | ||
|
|
||
| curves := requireStringParam(t, params, "RouterTLSCurves") | ||
| if !strings.Contains(curves, "X25519MLKEM768") { | ||
| t.Errorf("non-FIPS mode should include X25519MLKEM768, got: %s", curves) | ||
| } | ||
| if curves != "X25519MLKEM768:X25519:P-256:P-384:P-521" { | ||
| t.Errorf("non-FIPS mode curves should be X25519MLKEM768:X25519:P-256:P-384:P-521, got: %s", curves) | ||
| } | ||
| }) | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.