Repository navigation
Conversation
Signed-off-by: David Kwon <dakwon@redhat.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #142 +/- ##
==========================================
+ Coverage 64.47% 65.17% +0.69%
==========================================
Files 15 16 +1
Lines 563 580 +17
==========================================
+ Hits 363 378 +15
- Misses 180 182 +2
Partials 20 20
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| if config.TLSMinVersion == "" { | ||
| return nil | ||
| } | ||
| minVersion, err := strconv.ParseUint(config.TLSMinVersion, 10, 16) |
There was a problem hiding this comment.
Could we allow only known TLS versions here? ParseUint(..., 10, 16) accepts any uint16.
There was a problem hiding this comment.
In my latest commit, I updated this so that the TLS version is parsed by VersionName() from crypto/tls
| minVersion, err := strconv.ParseUint(config.TLSMinVersion, 10, 16) | ||
| if err != nil { | ||
| logrus.Warnf("Invalid TLS min version %q, using Go default", config.TLSMinVersion) | ||
| return nil |
There was a problem hiding this comment.
Returning nil hands the decision to Go’s runtime default environment. Would an explicit &tls.Config{MinVersion: tls.VersionTLS12} work for both the unset and invalid cases? The behaviour would be the same today, but it wouldn’t depend on the environment.
There was a problem hiding this comment.
IMHO I prefer to leave this as is in case TLS 1.2 becomes deprecated, WDYT?
Move tls related logic to tls.go Signed-off-by: David Kwon <dakwon@redhat.com>
| ) | ||
|
|
||
| func TestBuildTLSConfig_EmptyVersion(t *testing.T) { | ||
| logrus.SetOutput(io.Discard) |
There was a problem hiding this comment.
These tests set config.TLSMinVersion and the global logrus output without restoring them, which could leak into other tests in main. Maybe add a t.Cleanup to reset both?
There was a problem hiding this comment.
On second thought, These tests could be converted into a table driven test, WDYT?
There was a problem hiding this comment.
Sounds good, updated in my latest commit
| ) | ||
|
|
||
| func TestBuildTLSConfig_EmptyVersion(t *testing.T) { | ||
| logrus.SetOutput(io.Discard) |
There was a problem hiding this comment.
On second thought, These tests could be converted into a table driven test, WDYT?
| return nil | ||
| } | ||
| name := tls.VersionName(uint16(minVersion)) | ||
| if strings.HasPrefix(name, "0x") { |
There was a problem hiding this comment.
nit, tls.VersionName(768) returns "SSLv3" rather than a 0x… string, so TLS_MIN_VERSION=768 would pass this check and log “Setting TLS min version to SSLv3”, even though crypto/tls doesn’t support SSLv3. Would an explicit allowlist work here?
switch v := uint16(minVersion); v {
case tls.VersionTLS10, tls.VersionTLS11, tls.VersionTLS12, tls.VersionTLS13:
logrus.Infof("Setting TLS min version to %s", tls.VersionName(v))
return &tls.Config{MinVersion: v}
default:
logrus.Warnf("Unsupported TLS min version %q, using Go default", config.TLSMinVersion)
return nil
}There was a problem hiding this comment.
I initially wanted to avoid hardcoding TLS versions in case TLS 1.4 is adopted, but that seems like that would be quite far into the future. Anyways, I've updated the code to only accept TLS 1.0 - 1.3
| logrus.Infof("==> TLS min version: %s", TLSMinVersion) | ||
| } | ||
|
|
||
| func ResetConfigForTest() { |
There was a problem hiding this comment.
Could we add TLSMinVersion = "" to ResetConfigForTest()? Then the new field is cleared like the others.
There was a problem hiding this comment.
Updated in my latest commit
… test functions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: David Kwon <dakwon@redhat.com>
| # Enable using Podman instead of Docker | ||
| export DOCKER ?= podman | ||
| export WEB_TERMINAL_EXEC_IMG ?= quay.io/wto/web-terminal-exec:next | ||
| export ARCH ?= amd64 |
There was a problem hiding this comment.
On main, ARCH is unset, so GOARCH is empty and Go builds for the host. With this default, make compile always produces amd64, and build/Dockerfile runs it without passing ARCH. Suggest passing ARG TARGETARCH through the Dockerfile.
There was a problem hiding this comment.
Updated in the latest commits to use TARGETARCH in the build/Dockerfile.
| This repository contains a Makefile to simplify development of Web Terminal Exec. The following environment variables can be set to configure behavior: | ||
| * `DOCKER`: configure container build tool to use for building container images. Default is `podman`. | ||
| * `WEB_TERMINAL_EXEC_IMG`: Configure image name and tag for container builds. Default is `quay.io/wto/web-terminal-exec:next`. | ||
| * `ARCH`: Configure target architecture for the image build (e.g. `amd64`, `arm64`, `s390x`, `ppc64le`). Default is `amd64`. |
There was a problem hiding this comment.
could TLS_MIN_VERSION be documented here?
There was a problem hiding this comment.
I created a new section in the readme for this:
## Environment variables
The following environment variables configure runtime behavior of the server:
| Variable | Description | Default |
|----------|-------------|---------|
| `TLS_MIN_VERSION` | Minimum TLS version as a decimal uint16 value. Supported values: `769` (TLS 1.0), `770` (TLS 1.1), `771` (TLS 1.2), `772` (TLS 1.3). | Go default |
Update build/Dockerfile to default to amd64, pass in TARGETARCH to make compile Signed-off-by: David Kwon <dakwon@redhat.com>
Signed-off-by: David Kwon <dakwon@redhat.com>
What does this PR do?
The exec image will read the minimum TLS version from an environment variable and apply it to the server.
What issues does this PR fix or reference?
https://redhat.atlassian.net/browse/WTO-353?search_id=ecd2f8bd-0ab7-4924-9d77-6cef1d370be1&referrer=quick-find&xpis=eyJicmlkZ2UiOiJxdWlja0ZpbmQiLCJpZCI6IjE3OTIxODI4OTc4MTIiLCJzb3VyY2UiOiJqaXJhLXNvZnR3YXJlIn0%3D
Is it tested? How?
Please refer to redhat-developer/web-terminal-operator#203