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

proposal: x/crypto/ssh: export disconnectMsg error type #65186

Open
dblueman opened this issue Jan 20, 2024 · 1 comment
Open

proposal: x/crypto/ssh: export disconnectMsg error type #65186

dblueman opened this issue Jan 20, 2024 · 1 comment
Labels
Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Milestone

Comments

@dblueman
Copy link

Go version

1.12.1

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/daniel/.cache/go-build'
GOENV='/home/daniel/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/daniel/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/daniel/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go-1.21'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go-1.21/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build835199979=/tmp/go-build -gno-record-gcc-switches'

What did you do?

When checking for a particular case where the SSH session should be closed and restablished, I am using a workaround:
err.Error() == "ssh: disconnect, reason 11:"

What did you see happen?

String-comparing the error message works but is brittle and non-optimal.

What did you expect to see?

We would expect type disconnectMsg to be exported (ie DisconnectMsg) to allow comparison via:
sErr ssh.DisconnectMsg if errors.As(err, &sErr) && sErr.Reason == 11) { ...
or just:
if errors.Is(err, ssh.DisconnectMsg) { ...

Similar error types, for example ExitError are exported for this rationale.

I can prepare a non-breaking (API compatible) Pull Request to address this issue if there are no objections?

@seankhliao seankhliao changed the title crypto/ssh: non-exported disconnectMsg prevents checking code proposal: x/crypto/ssh: export disconnectMsg error type Jan 20, 2024
@gopherbot gopherbot added this to the Proposal milestone Jan 20, 2024
@seankhliao seankhliao added the Proposal-Crypto Proposal related to crypto packages or other security issues label Jan 20, 2024
@seankhliao
Copy link
Member

cc @drakkan @golang/security

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Proposal Proposal-Crypto Proposal related to crypto packages or other security issues
Projects
Status: Incoming
Development

No branches or pull requests

4 participants
@dblueman @gopherbot @seankhliao and others