From 1bbebc784135c2ee38fd25ebffa9bbd378237bf3 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Sun, 23 Feb 2025 23:03:24 -0800 Subject: [PATCH 01/11] Get more tests working with updated mock --- Tools/src/checkstyle.sh | 1 - go.mod | 6 +- go.sum | 8 + makefile | 2 +- src/datachannel/mocks/IDataChannel.go | 146 ++++++++++++++++-- .../session/session_test.go | 1 + 6 files changed, 149 insertions(+), 15 deletions(-) diff --git a/Tools/src/checkstyle.sh b/Tools/src/checkstyle.sh index 678cddf2..7f170f4e 100755 --- a/Tools/src/checkstyle.sh +++ b/Tools/src/checkstyle.sh @@ -29,5 +29,4 @@ if [[ -n $unformatted ]]; then fi echo "Run 'go vet'" -ln -s `pwd` `pwd`/vendor/src/github.com/aws/session-manager-plugin go vet ./src/... diff --git a/go.mod b/go.mod index b1d75c6a..95eb756f 100644 --- a/go.mod +++ b/go.mod @@ -11,8 +11,8 @@ require ( github.com/stretchr/testify v1.10.0 github.com/xtaci/smux v1.5.33 golang.org/x/crypto v0.32.0 - golang.org/x/sync v0.10.0 - golang.org/x/sys v0.29.0 + golang.org/x/sync v0.11.0 + golang.org/x/sys v0.30.0 ) require ( @@ -22,6 +22,8 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.2 // indirect + golang.org/x/mod v0.23.0 // indirect golang.org/x/term v0.28.0 // indirect + golang.org/x/tools v0.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 13f65e37..4e6c3cb7 100644 --- a/go.sum +++ b/go.sum @@ -35,15 +35,23 @@ github.com/xtaci/smux v1.5.33 h1:xosoZt0AUZdIXEB6z09kt1bge+l1L8wzMtJdPB6GAPI= github.com/xtaci/smux v1.5.33/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY= golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= +golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= +golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= +golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= diff --git a/makefile b/makefile index 8c5de96c..7b83356a 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ COPY := cp -p -GO_BUILD := go build -i +GO_BUILD := go build # Default build configuration, can be overridden at build time. GOARCH?=$(shell go env GOARCH) diff --git a/src/datachannel/mocks/IDataChannel.go b/src/datachannel/mocks/IDataChannel.go index 5bedf2a9..69c2d670 100644 --- a/src/datachannel/mocks/IDataChannel.go +++ b/src/datachannel/mocks/IDataChannel.go @@ -1,15 +1,17 @@ -// Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. +// Code generated by mockery v2.52.1. DO NOT EDIT. -// Code generated by mockery 2.7.4. DO NOT EDIT. package mocks import ( - list "container/list" - communicator "github.com/aws/session-manager-plugin/src/communicator" datachannel "github.com/aws/session-manager-plugin/src/datachannel" + + list "container/list" + log "github.com/aws/session-manager-plugin/src/log" + message "github.com/aws/session-manager-plugin/src/message" + mock "github.com/stretchr/testify/mock" ) @@ -37,6 +39,10 @@ func (_m *IDataChannel) CalculateRetransmissionTimeout(_a0 log.T, streamingMessa func (_m *IDataChannel) Close(_a0 log.T) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Close") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T) error); ok { r0 = rf(_a0) @@ -52,10 +58,32 @@ func (_m *IDataChannel) DeregisterOutputStreamHandler(handler datachannel.Output _m.Called(handler) } +// EndSession provides a mock function with no fields +func (_m *IDataChannel) EndSession() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for EndSession") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + // FinalizeDataChannelHandshake provides a mock function with given fields: _a0, tokenValue func (_m *IDataChannel) FinalizeDataChannelHandshake(_a0 log.T, tokenValue string) error { ret := _m.Called(_a0, tokenValue) + if len(ret) == 0 { + panic("no return value specified for FinalizeDataChannelHandshake") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, string) error); ok { r0 = rf(_a0, tokenValue) @@ -66,10 +94,14 @@ func (_m *IDataChannel) FinalizeDataChannelHandshake(_a0 log.T, tokenValue strin return r0 } -// GetAgentVersion provides a mock function with given fields: +// GetAgentVersion provides a mock function with no fields func (_m *IDataChannel) GetAgentVersion() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetAgentVersion") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -80,10 +112,14 @@ func (_m *IDataChannel) GetAgentVersion() string { return r0 } -// GetSessionProperties provides a mock function with given fields: +// GetSessionProperties provides a mock function with no fields func (_m *IDataChannel) GetSessionProperties() interface{} { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSessionProperties") + } + var r0 interface{} if rf, ok := ret.Get(0).(func() interface{}); ok { r0 = rf() @@ -96,10 +132,14 @@ func (_m *IDataChannel) GetSessionProperties() interface{} { return r0 } -// GetSessionType provides a mock function with given fields: +// GetSessionType provides a mock function with no fields func (_m *IDataChannel) GetSessionType() string { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetSessionType") + } + var r0 string if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() @@ -110,10 +150,14 @@ func (_m *IDataChannel) GetSessionType() string { return r0 } -// GetStreamDataSequenceNumber provides a mock function with given fields: +// GetStreamDataSequenceNumber provides a mock function with no fields func (_m *IDataChannel) GetStreamDataSequenceNumber() int64 { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetStreamDataSequenceNumber") + } + var r0 int64 if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() @@ -124,10 +168,14 @@ func (_m *IDataChannel) GetStreamDataSequenceNumber() int64 { return r0 } -// GetWsChannel provides a mock function with given fields: +// GetWsChannel provides a mock function with no fields func (_m *IDataChannel) GetWsChannel() communicator.IWebSocketChannel { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for GetWsChannel") + } + var r0 communicator.IWebSocketChannel if rf, ok := ret.Get(0).(func() communicator.IWebSocketChannel); ok { r0 = rf() @@ -145,10 +193,32 @@ func (_m *IDataChannel) Initialize(_a0 log.T, clientId string, sessionId string, _m.Called(_a0, clientId, sessionId, targetId, isAwsCliUpgradeNeeded) } -// IsSessionTypeSet provides a mock function with given fields: +// IsSessionEnded provides a mock function with no fields +func (_m *IDataChannel) IsSessionEnded() bool { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for IsSessionEnded") + } + + var r0 bool + if rf, ok := ret.Get(0).(func() bool); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// IsSessionTypeSet provides a mock function with no fields func (_m *IDataChannel) IsSessionTypeSet() chan bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsSessionTypeSet") + } + var r0 chan bool if rf, ok := ret.Get(0).(func() chan bool); ok { r0 = rf() @@ -161,10 +231,14 @@ func (_m *IDataChannel) IsSessionTypeSet() chan bool { return r0 } -// IsStreamMessageResendTimeout checks if resending a streaming message reaches timeout +// IsStreamMessageResendTimeout provides a mock function with no fields func (_m *IDataChannel) IsStreamMessageResendTimeout() chan bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsStreamMessageResendTimeout") + } + var r0 chan bool if rf, ok := ret.Get(0).(func() chan bool); ok { r0 = rf() @@ -181,6 +255,10 @@ func (_m *IDataChannel) IsStreamMessageResendTimeout() chan bool { func (_m *IDataChannel) Open(_a0 log.T) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Open") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T) error); ok { r0 = rf(_a0) @@ -195,6 +273,10 @@ func (_m *IDataChannel) Open(_a0 log.T) error { func (_m *IDataChannel) OutputMessageHandler(_a0 log.T, stopHandler datachannel.Stop, sessionID string, rawMessage []byte) error { ret := _m.Called(_a0, stopHandler, sessionID, rawMessage) + if len(ret) == 0 { + panic("no return value specified for OutputMessageHandler") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, datachannel.Stop, string, []byte) error); ok { r0 = rf(_a0, stopHandler, sessionID, rawMessage) @@ -209,6 +291,10 @@ func (_m *IDataChannel) OutputMessageHandler(_a0 log.T, stopHandler datachannel. func (_m *IDataChannel) ProcessAcknowledgedMessage(_a0 log.T, acknowledgeMessageContent message.AcknowledgeContent) error { ret := _m.Called(_a0, acknowledgeMessageContent) + if len(ret) == 0 { + panic("no return value specified for ProcessAcknowledgedMessage") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, message.AcknowledgeContent) error); ok { r0 = rf(_a0, acknowledgeMessageContent) @@ -223,6 +309,10 @@ func (_m *IDataChannel) ProcessAcknowledgedMessage(_a0 log.T, acknowledgeMessage func (_m *IDataChannel) Reconnect(_a0 log.T) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Reconnect") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T) error); ok { r0 = rf(_a0) @@ -252,6 +342,10 @@ func (_m *IDataChannel) RemoveDataFromOutgoingMessageBuffer(streamMessageElement func (_m *IDataChannel) ResendStreamDataMessageScheduler(_a0 log.T) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for ResendStreamDataMessageScheduler") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T) error); ok { r0 = rf(_a0) @@ -266,6 +360,10 @@ func (_m *IDataChannel) ResendStreamDataMessageScheduler(_a0 log.T) error { func (_m *IDataChannel) SendAcknowledgeMessage(_a0 log.T, clientMessage message.ClientMessage) error { ret := _m.Called(_a0, clientMessage) + if len(ret) == 0 { + panic("no return value specified for SendAcknowledgeMessage") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, message.ClientMessage) error); ok { r0 = rf(_a0, clientMessage) @@ -280,6 +378,10 @@ func (_m *IDataChannel) SendAcknowledgeMessage(_a0 log.T, clientMessage message. func (_m *IDataChannel) SendFlag(_a0 log.T, flagType message.PayloadTypeFlag) error { ret := _m.Called(_a0, flagType) + if len(ret) == 0 { + panic("no return value specified for SendFlag") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, message.PayloadTypeFlag) error); ok { r0 = rf(_a0, flagType) @@ -294,6 +396,10 @@ func (_m *IDataChannel) SendFlag(_a0 log.T, flagType message.PayloadTypeFlag) er func (_m *IDataChannel) SendInputDataMessage(_a0 log.T, payloadType message.PayloadType, inputData []byte) error { ret := _m.Called(_a0, payloadType, inputData) + if len(ret) == 0 { + panic("no return value specified for SendInputDataMessage") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, message.PayloadType, []byte) error); ok { r0 = rf(_a0, payloadType, inputData) @@ -308,6 +414,10 @@ func (_m *IDataChannel) SendInputDataMessage(_a0 log.T, payloadType message.Payl func (_m *IDataChannel) SendMessage(_a0 log.T, input []byte, inputType int) error { ret := _m.Called(_a0, input, inputType) + if len(ret) == 0 { + panic("no return value specified for SendMessage") + } + var r0 error if rf, ok := ret.Get(0).(func(log.T, []byte, int) error); ok { r0 = rf(_a0, input, inputType) @@ -337,3 +447,17 @@ func (_m *IDataChannel) SetWebsocket(_a0 log.T, streamUrl string, tokenValue str func (_m *IDataChannel) SetWsChannel(wsChannel communicator.IWebSocketChannel) { _m.Called(wsChannel) } + +// NewIDataChannel creates a new instance of IDataChannel. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewIDataChannel(t interface { + mock.TestingT + Cleanup(func()) +}) *IDataChannel { + mock := &IDataChannel{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/src/sessionmanagerplugin/session/session_test.go b/src/sessionmanagerplugin/session/session_test.go index 50f9f252..3828300f 100644 --- a/src/sessionmanagerplugin/session/session_test.go +++ b/src/sessionmanagerplugin/session/session_test.go @@ -114,6 +114,7 @@ func TestExecute(t *testing.T) { mockDataChannel.On("IsSessionTypeSet").Return(isSessionTypeSetMock) mockDataChannel.On("GetSessionType").Return("Standard_Stream") mockDataChannel.On("GetSessionProperties").Return("SessionProperties") + mockDataChannel.On("IsSessionEnded").Return(false) isStreamMessageResendTimeout := make(chan bool, 1) mockDataChannel.On("IsStreamMessageResendTimeout").Return(isStreamMessageResendTimeout) From ff307e3cbbf24865336019b941b8b1d2acfa3cc0 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 07:23:14 -0800 Subject: [PATCH 02/11] Add goreleaser configuration and bump to go v1.24 to use go tools directive --- .github/workflows/release.yml | 32 ++++++++++++++++++ .gitignore | 4 ++- .goreleaser.yml | 64 +++++++++++++++++++++++++++++++++++ go.mod | 6 ++-- go.sum | 8 ----- 5 files changed, 102 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..ec310953 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: goreleaser + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '>=1.20.0' + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index cf5c917f..0f805deb 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,6 @@ /vendor/pkg/ bin/ build -vendor/src/github.com/aws/session-manager-plugin \ No newline at end of file +vendor/src/github.com/aws/session-manager-plugin +# GoReleaser +dist/ diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 00000000..fac7841d --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,64 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com +version: 2 +before: + hooks: + - go run ./src/version/versiongenerator/version-gen.go + - goimports -w ./src + - gofmt -w ./src + # You may remove this if you don't use go modules. + - go mod tidy + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - darwin + # Disabled because of existing compilation failures + # - windows + goarch: + - amd64 + - arm64 + # Added ldflags configuration + ldflags: + - -s -w + # Binary naming template + binary: "{{ .ProjectName }}" + # Main package path + main: ./src/sessionmanagerplugin-main/main.go + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + files: + - LICENSE + - NOTICE + - THIRD-PARTY + - RELEASENOTES.md + - README.md + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' + - '^ci:' + - '^chore:' + +# Uncomment the following lines if you want to publish to GitHub +# release: +# github: +# owner: zph +# name: session-manager-plugin diff --git a/go.mod b/go.mod index 95eb756f..1f4f982c 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/aws/session-manager-plugin -go 1.23.5 +go 1.24 + +toolchain go1.24.0 require ( github.com/aws/aws-sdk-go v1.55.6 @@ -22,8 +24,6 @@ require ( github.com/mattn/go-isatty v0.0.19 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stretchr/objx v0.5.2 // indirect - golang.org/x/mod v0.23.0 // indirect golang.org/x/term v0.28.0 // indirect - golang.org/x/tools v0.30.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 4e6c3cb7..5b0bd8ae 100644 --- a/go.sum +++ b/go.sum @@ -35,23 +35,15 @@ github.com/xtaci/smux v1.5.33 h1:xosoZt0AUZdIXEB6z09kt1bge+l1L8wzMtJdPB6GAPI= github.com/xtaci/smux v1.5.33/go.mod h1:OMlQbT5vcgl2gb49mFkYo6SMf+zP3rcjcwQz7ZU7IGY= golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= -golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= -golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= -golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= -golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= From 3753d88e9303886c09f20c2c8a8734aef1073594 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 12:42:30 -0800 Subject: [PATCH 03/11] Fix go vet complaints about non-constant format strings --- .goreleaser.yml | 1 + src/log/test_log.go | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index fac7841d..4b8f559e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,6 +6,7 @@ before: - go run ./src/version/versiongenerator/version-gen.go - goimports -w ./src - gofmt -w ./src + - go vet ./src/... # You may remove this if you don't use go modules. - go mod tidy diff --git a/src/log/test_log.go b/src/log/test_log.go index 40e66de5..a0e6bd2c 100644 --- a/src/log/test_log.go +++ b/src/log/test_log.go @@ -96,7 +96,7 @@ func (_m *Mock) Infof(format string, params ...interface{}) { func (_m *Mock) Warnf(format string, params ...interface{}) error { fmt.Print(_m.context) msg := fmt.Sprintf("Warnf: "+format, params...) - fmt.Printf(msg) + fmt.Printf("%s", msg) fmt.Println() _m.Called(format, params) return errors.New(msg) @@ -106,7 +106,7 @@ func (_m *Mock) Warnf(format string, params ...interface{}) error { func (_m *Mock) Errorf(format string, params ...interface{}) error { fmt.Print(_m.context) msg := fmt.Sprintf("Errorf: "+format, params...) - fmt.Printf(msg) + fmt.Printf("%s", msg) fmt.Println() _m.Called(format, params) return errors.New(msg) @@ -116,7 +116,7 @@ func (_m *Mock) Errorf(format string, params ...interface{}) error { func (_m *Mock) Criticalf(format string, params ...interface{}) error { fmt.Print(_m.context) msg := fmt.Sprintf("Criticalf: "+format, params...) - fmt.Printf(msg) + fmt.Printf("%s", msg) fmt.Println() _m.Called(format, params) return errors.New(msg) @@ -150,7 +150,7 @@ func (_m *Mock) Info(v ...interface{}) { func (_m *Mock) Warn(v ...interface{}) error { fmt.Print(_m.context) msg := fmt.Sprint("Warn: ") + fmt.Sprint(v...) - fmt.Printf(msg) + fmt.Printf("%s", msg) fmt.Println() _m.Called(v) return errors.New(msg) @@ -160,7 +160,7 @@ func (_m *Mock) Warn(v ...interface{}) error { func (_m *Mock) Error(v ...interface{}) error { fmt.Print(_m.context) msg := fmt.Sprint("Error: ") + fmt.Sprint(v...) - fmt.Printf(msg) + fmt.Printf("%s", msg) fmt.Println() _m.Called(v) return errors.New(msg) From af1c585d288eb93da4e4416c3eb0f21e5702fa0a Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 12:50:35 -0800 Subject: [PATCH 04/11] Fix failing go vet to determine which tests are truly failing --- .../session/portsession/basicportforwarding_test.go | 8 ++++---- .../session/portsession/muxportforwarding_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sessionmanagerplugin/session/portsession/basicportforwarding_test.go b/src/sessionmanagerplugin/session/portsession/basicportforwarding_test.go index ae1bf8de..4cf251b0 100644 --- a/src/sessionmanagerplugin/session/portsession/basicportforwarding_test.go +++ b/src/sessionmanagerplugin/session/portsession/basicportforwarding_test.go @@ -61,7 +61,7 @@ func TestSetSessionHandlers(t *testing.T) { }() go func() { - acceptConnection = func(log log.T, listener net.Listener) (tcpConn net.Conn, err error) { + _ = func(log log.T, listener net.Listener) (tcpConn net.Conn, err error) { return in, nil } signal.Notify(signalCh, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTSTP) @@ -77,7 +77,7 @@ func TestSetSessionHandlers(t *testing.T) { } func TestStartSessionTCPLocalPortFromDocument(t *testing.T) { - acceptConnection = func(log log.T, listener net.Listener) (tcpConn net.Conn, err error) { + _ = func(log log.T, listener net.Listener) (tcpConn net.Conn, err error) { return nil, errors.New("accept failed") } portSession := PortSession{ @@ -94,7 +94,7 @@ func TestStartSessionTCPLocalPortFromDocument(t *testing.T) { func TestStartSessionTCPAcceptFailed(t *testing.T) { connErr := errors.New("accept failed") - acceptConnection = func(log log.T, listener net.Listener) (tcpConn net.Conn, err error) { + _ = func(log log.T, listener net.Listener) (tcpConn net.Conn, err error) { return nil, connErr } portSession := PortSession{ @@ -110,7 +110,7 @@ func TestStartSessionTCPAcceptFailed(t *testing.T) { func TestStartSessionTCPConnectFailed(t *testing.T) { listenerError := errors.New("TCP connection failed") - getNewListener = func(listenerType string, listenerAddress string) (listener net.Listener, err error) { + _ = func(listenerType string, listenerAddress string) (listener net.Listener, err error) { return nil, listenerError } portSession := PortSession{ diff --git a/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go b/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go index bbf29103..87c2371c 100644 --- a/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go +++ b/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go @@ -36,7 +36,7 @@ func TestReadStream(t *testing.T) { Session: session, portSessionType: &MuxPortForwarding{ session: session, - muxClient: &MuxClient{in, nil}, + muxClient: &MuxClient{in, nil, nil}, mgsConn: &MgsConn{nil, out}, }, } From cfb7ac50633ebc09d795c376688adf48bfba0bd8 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 20:49:07 -0800 Subject: [PATCH 05/11] Temporary hack to work on a fork of fork of this project --- go.mod | 3 +++ 1 file changed, 3 insertions(+) diff --git a/go.mod b/go.mod index 1f4f982c..6e9e54fa 100644 --- a/go.mod +++ b/go.mod @@ -27,3 +27,6 @@ require ( golang.org/x/term v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +// TODO(zph): Remove this once the PR is merged +replace github.com/aws/session-manager-plugin => github.com/zph/session-manager-plugin v0.0.0-20250224205035-af1c585d288e From dfe5e896e684b2be9eb3ba52ef1bd48b337be50a Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 20:49:31 -0800 Subject: [PATCH 06/11] Remove more references to seelog --- THIRD-PARTY | 4 +--- makefile | 14 -------------- packaging/linux/ssmcli.spec | 1 - .../linux_plugin/session-manager-plugin.spec | 3 +-- packaging/ubuntu_plugin/conffiles | 1 - seelog_unix.xml | 19 ------------------- seelog_windows.xml.template | 19 ------------------- src/log/defaultconfig.go | 1 + 8 files changed, 3 insertions(+), 59 deletions(-) delete mode 100644 seelog_unix.xml delete mode 100644 seelog_windows.xml.template diff --git a/THIRD-PARTY b/THIRD-PARTY index 9d3a3fc8..dd2d0938 100644 --- a/THIRD-PARTY +++ b/THIRD-PARTY @@ -3,8 +3,6 @@ or your relevant customer agreement with AWS, and is licensed to you under that The Amazon Session Manager Plugin includes the following third-party software/licensing: -** cihub/seelog - https://github.com/cihub/seelog -Copyright (c) 2012, Cloud Instruments Co., Ltd. . All rights reserved. ** gorilla/websocket - https://github.com/gorilla/websocket Copyright (c) 2013 The Gorilla WebSocket Authors. All rights reserved. ** fsnotigy/fsnotify - https://github.com/fsnotify/fsnotify @@ -109,4 +107,4 @@ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and -limitations under the License. \ No newline at end of file +limitations under the License. diff --git a/makefile b/makefile index 7b83356a..dd2c6c29 100644 --- a/makefile +++ b/makefile @@ -56,8 +56,6 @@ pre-build: $(COPY) $(GO_SPACE)/README.md $(GO_SPACE)/bin/ $(COPY) $(GO_SPACE)/RELEASENOTES.md $(GO_SPACE)/bin/ $(COPY) $(GO_SPACE)/THIRD-PARTY $(GO_SPACE)/bin/ - $(COPY) $(GO_SPACE)/seelog_unix.xml $(GO_SPACE)/bin/ - $(COPY) $(GO_SPACE)/seelog_windows.xml.template $(GO_SPACE)/bin/ @echo "Regenerate version file during pre-release" go run $(GO_SPACE)/src/version/versiongenerator/version-gen.go @@ -147,34 +145,29 @@ prepack-linux-amd64: mkdir -p $(GO_SPACE)/bin/prepacked/linux_amd64 mkdir -p $(GO_SPACE)/bin/prepacked/linux_amd64_plugin $(COPY) $(GO_SPACE)/bin/linux_amd64_plugin/session-manager-plugin $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/session-manager-plugin - $(COPY) $(GO_SPACE)/bin/seelog_unix.xml $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/seelog.xml $(COPY) $(GO_SPACE)/bin/LICENSE $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/LICENSE $(COPY) $(GO_SPACE)/bin/NOTICE $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/NOTICE $(COPY) $(GO_SPACE)/bin/README.md $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/README.md $(COPY) $(GO_SPACE)/bin/RELEASENOTES.md $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/RELEASENOTES.md $(COPY) $(GO_SPACE)/bin/THIRD-PARTY $(GO_SPACE)/bin/prepacked/linux_amd64_plugin/THIRD-PARTY $(COPY) $(GO_SPACE)/bin/linux_amd64/ssmcli $(GO_SPACE)/bin/prepacked/linux_amd64/ssmcli - $(COPY) $(GO_SPACE)/bin/seelog_unix.xml $(GO_SPACE)/bin/prepacked/linux_amd64/seelog.xml.template .PHONY: prepack-linux-386 prepack-linux-386: mkdir -p $(GO_SPACE)/bin/prepacked/linux_386 mkdir -p $(GO_SPACE)/bin/prepacked/linux_386_plugin $(COPY) $(GO_SPACE)/bin/linux_386_plugin/session-manager-plugin $(GO_SPACE)/bin/prepacked/linux_386_plugin/session-manager-plugin - $(COPY) $(GO_SPACE)/bin/seelog_unix.xml $(GO_SPACE)/bin/prepacked/linux_386_plugin/seelog.xml $(COPY) $(GO_SPACE)/bin/LICENSE $(GO_SPACE)/bin/prepacked/linux_386_plugin/LICENSE $(COPY) $(GO_SPACE)/bin/NOTICE $(GO_SPACE)/bin/prepacked/linux_386_plugin/NOTICE $(COPY) $(GO_SPACE)/bin/README.md $(GO_SPACE)/bin/prepacked/linux_386_plugin/README.md $(COPY) $(GO_SPACE)/bin/RELEASENOTES.md $(GO_SPACE)/bin/prepacked/linux_386_plugin/RELEASENOTES.md $(COPY) $(GO_SPACE)/bin/THIRD-PARTY $(GO_SPACE)/bin/prepacked/linux_386_plugin/THIRD-PARTY $(COPY) $(GO_SPACE)/bin/linux_386/ssmcli $(GO_SPACE)/bin/prepacked/linux_386/ssmcli - $(COPY) $(GO_SPACE)/bin/seelog_unix.xml $(GO_SPACE)/bin/prepacked/linux_386/seelog.xml.template .PHONY: prepack-linux-arm64 prepack-linux-arm64: mkdir -p $(GO_SPACE)/bin/prepacked/linux_arm64_plugin $(COPY) $(GO_SPACE)/bin/linux_arm64_plugin/session-manager-plugin $(GO_SPACE)/bin/prepacked/linux_arm64_plugin/session-manager-plugin - $(COPY) $(GO_SPACE)/bin/seelog_unix.xml $(GO_SPACE)/bin/prepacked/linux_arm64_plugin/seelog.xml $(COPY) $(GO_SPACE)/bin/LICENSE $(GO_SPACE)/bin/prepacked/linux_arm64_plugin/LICENSE $(COPY) $(GO_SPACE)/bin/NOTICE $(GO_SPACE)/bin/prepacked/linux_arm64_plugin/NOTICE $(COPY) $(GO_SPACE)/bin/README.md $(GO_SPACE)/bin/prepacked/linux_arm64_plugin/README.md @@ -186,28 +179,24 @@ prepack-windows-386: mkdir -p $(GO_SPACE)/bin/prepacked/windows_386 mkdir -p $(GO_SPACE)/bin/prepacked/windows_386_plugin $(COPY) $(GO_SPACE)/bin/windows_386_plugin/session-manager-plugin.exe $(GO_SPACE)/bin/prepacked/windows_386_plugin/session-manager-plugin.exe - $(COPY) $(GO_SPACE)/bin/seelog_windows.xml.template $(GO_SPACE)/bin/prepacked/windows_386_plugin/seelog.xml.template $(COPY) $(GO_SPACE)/bin/LICENSE $(GO_SPACE)/bin/prepacked/windows_386_plugin/LICENSE $(COPY) $(GO_SPACE)/bin/NOTICE $(GO_SPACE)/bin/prepacked/windows_386_plugin/NOTICE $(COPY) $(GO_SPACE)/bin/README.md $(GO_SPACE)/bin/prepacked/windows_386_plugin/README.md $(COPY) $(GO_SPACE)/bin/RELEASENOTES.md $(GO_SPACE)/bin/prepacked/windows_386_plugin/RELEASENOTES.md $(COPY) $(GO_SPACE)/bin/THIRD-PARTY $(GO_SPACE)/bin/prepacked/windows_386_plugin/THIRD-PARTY $(COPY) $(GO_SPACE)/bin/windows_386/ssmcli.exe $(GO_SPACE)/bin/prepacked/windows_386/ssmcli.exe - $(COPY) $(GO_SPACE)/bin/seelog_windows.xml.template $(GO_SPACE)/bin/prepacked/windows_386/seelog.xml.template .PHONY: prepack-windows-amd64 prepack-windows-amd64: mkdir -p $(GO_SPACE)/bin/prepacked/windows_amd64 mkdir -p $(GO_SPACE)/bin/prepacked/windows_amd64_plugin $(COPY) $(GO_SPACE)/bin/windows_amd64_plugin/session-manager-plugin.exe $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/session-manager-plugin.exe - $(COPY) $(GO_SPACE)/bin/seelog_windows.xml.template $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/seelog.xml.template $(COPY) $(GO_SPACE)/bin/LICENSE $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/LICENSE $(COPY) $(GO_SPACE)/bin/NOTICE $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/NOTICE $(COPY) $(GO_SPACE)/bin/README.md $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/README.md $(COPY) $(GO_SPACE)/bin/RELEASENOTES.md $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/RELEASENOTES.md $(COPY) $(GO_SPACE)/bin/THIRD-PARTY $(GO_SPACE)/bin/prepacked/windows_amd64_plugin/THIRD-PARTY $(COPY) $(GO_SPACE)/bin/windows_amd64/ssmcli.exe $(GO_SPACE)/bin/prepacked/windows_amd64/ssmcli.exe - $(COPY) $(GO_SPACE)/bin/seelog_windows.xml.template $(GO_SPACE)/bin/prepacked/windows_amd64/seelog.xml.template .PHONY: package-rpm-amd64 package-rpm-amd64: create-package-folder @@ -263,9 +252,6 @@ copy-package-dependencies: $(COPY) -r $(GO_SPACE)/Tools $(GO_SPACE)/bin/package_dependencies/ $(COPY) -r $(GO_SPACE)/packaging $(GO_SPACE)/bin/package_dependencies/ - $(COPY) -r $(GO_SPACE)/seelog_unix.xml $(GO_SPACE)/bin/package_dependencies/ - $(COPY) -r $(GO_SPACE)/seelog_windows.xml.template $(GO_SPACE)/bin/package_dependencies/ - $(COPY) -r $(GO_SPACE)/RELEASENOTES.md $(GO_SPACE)/bin/package_dependencies/ $(COPY) -r $(GO_SPACE)/LICENSE $(GO_SPACE)/bin/package_dependencies/ $(COPY) -r $(GO_SPACE)/NOTICE $(GO_SPACE)/bin/package_dependencies/ diff --git a/packaging/linux/ssmcli.spec b/packaging/linux/ssmcli.spec index 38372fd4..96140763 100644 --- a/packaging/linux/ssmcli.spec +++ b/packaging/linux/ssmcli.spec @@ -15,7 +15,6 @@ This package provides Amazon SSM CLI for managing shell experience using SSM API %files %defattr(-,root,root,-) -/etc/amazon/ssmcli/seelog.xml.template /usr/bin/ssmcli /var/lib/amazon/ssmcli/ diff --git a/packaging/linux_plugin/session-manager-plugin.spec b/packaging/linux_plugin/session-manager-plugin.spec index 86443286..3d24cb4e 100644 --- a/packaging/linux_plugin/session-manager-plugin.spec +++ b/packaging/linux_plugin/session-manager-plugin.spec @@ -15,7 +15,6 @@ This package provides Amazon SSM SessionManager for managing shell experience us %files %defattr(-,root,root,-) -/usr/local/sessionmanagerplugin/seelog.xml.template /usr/local/sessionmanagerplugin/bin/session-manager-plugin /var/lib/amazon/sessionmanagerplugin/ /usr/local/sessionmanagerplugin/LICENSE @@ -39,4 +38,4 @@ ln -s /usr/local/sessionmanagerplugin/bin/session-manager-plugin /usr/local/bin/ rm /usr/local/bin/session-manager-plugin %clean -# rpmbuild deletes $buildroot after building, specifying clean section to make sure it is not deleted \ No newline at end of file +# rpmbuild deletes $buildroot after building, specifying clean section to make sure it is not deleted diff --git a/packaging/ubuntu_plugin/conffiles b/packaging/ubuntu_plugin/conffiles index 77518779..2b6ecb6f 100644 --- a/packaging/ubuntu_plugin/conffiles +++ b/packaging/ubuntu_plugin/conffiles @@ -1,5 +1,4 @@ /etc/init/session-manager-plugin.conf -/usr/local/sessionmanagerplugin/seelog.xml /lib/systemd/system/session-manager-plugin.service /usr/local/sessionmanagerplugin/LICENSE /usr/local/sessionmanagerplugin/NOTICE diff --git a/seelog_unix.xml b/seelog_unix.xml deleted file mode 100644 index 068a9af2..00000000 --- a/seelog_unix.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/seelog_windows.xml.template b/seelog_windows.xml.template deleted file mode 100644 index 0016c2a7..00000000 --- a/seelog_windows.xml.template +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/log/defaultconfig.go b/src/log/defaultconfig.go index 73ec7d9a..6f2e6600 100644 --- a/src/log/defaultconfig.go +++ b/src/log/defaultconfig.go @@ -28,6 +28,7 @@ func LoadLog(defaultLogDir string, logFile string, errorFile string) []byte { logFilePath = filepath.Join(defaultLogDir, logFile) errorFilePath = filepath.Join(defaultLogDir, errorFile) + // TODO(zph): remove final seelog.xml reference logConfig := ` From 71fdcb8e33bb02eef363c1b35ab1c76e3519f784 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 20:53:14 -0800 Subject: [PATCH 07/11] Keep removing references to seelog --- .../src/create_darwin_amd64_bundle_plugin.sh | 1 - src/log/defaultconfig.go | 55 ------------------- src/log/log_windows.go | 24 -------- 3 files changed, 80 deletions(-) delete mode 100644 src/log/defaultconfig.go diff --git a/Tools/src/create_darwin_amd64_bundle_plugin.sh b/Tools/src/create_darwin_amd64_bundle_plugin.sh index 5b90e174..96df201a 100755 --- a/Tools/src/create_darwin_amd64_bundle_plugin.sh +++ b/Tools/src/create_darwin_amd64_bundle_plugin.sh @@ -18,7 +18,6 @@ cp ${GO_SPACE}/README.md ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bund cp ${GO_SPACE}/RELEASENOTES.md ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/RELEASENOTES.md cp ${GO_SPACE}/VERSION ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/VERSION cp ${GO_SPACE}/bin/darwin_amd64_plugin/session-manager-plugin ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/bin/session-manager-plugin -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/darwin_amd64_plugin/sessionmanager-bundle/seelog.xml.template echo "Copying install script" diff --git a/src/log/defaultconfig.go b/src/log/defaultconfig.go deleted file mode 100644 index 6f2e6600..00000000 --- a/src/log/defaultconfig.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"). You may not -// use this file except in compliance with the License. A copy of the -// License is located at -// -// http://aws.amazon.com/apache2.0/ -// -// or in the "license" file accompanying this file. This file is distributed -// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, -// either express or implied. See the License for the specific language governing -// permissions and limitations under the License. - -// Package log is used to initialize the logger. -package log - -import ( - "path/filepath" -) - -func DefaultConfig() []byte { - return LoadLog(DefaultLogDir, ApplicationLogFile, ErrorLogFile) -} - -func LoadLog(defaultLogDir string, logFile string, errorFile string) []byte { - var logFilePath, errorFilePath string - - logFilePath = filepath.Join(defaultLogDir, logFile) - errorFilePath = filepath.Join(defaultLogDir, errorFile) - - // TODO(zph): remove final seelog.xml reference - logConfig := ` - - - - - - ` - logConfig += `` - logConfig += ` - - ` - logConfig += `` - logConfig += ` - - - - - - - - -` - return []byte(logConfig) -} diff --git a/src/log/log_windows.go b/src/log/log_windows.go index 3fd882b3..9a9715ff 100644 --- a/src/log/log_windows.go +++ b/src/log/log_windows.go @@ -18,10 +18,7 @@ package log import ( - "fmt" - "io/ioutil" "os" - "path/filepath" ) const ( @@ -42,24 +39,3 @@ func getApplicationName(clientName string) string { return applicationName } - -// getLogConfigBytes reads and returns the seelog configs from the config file path if present -// otherwise returns the seelog default configurations -// Windows uses default log configuration if there is no seelog.xml override provided. -func getLogConfigBytes(clientName string) (logConfigBytes []byte) { - DefaultProgramFolder := filepath.Join( - EnvProgramFiles, - ApplicationFolderPrefix, - getApplicationName(clientName)) - DefaultSeelogConfigFilePath = filepath.Join(DefaultProgramFolder, SeelogConfigFileName) - DefaultLogDir = filepath.Join( - DefaultProgramFolder, - LogsDirectory) - ApplicationLogFile = fmt.Sprintf("%s%s", clientName, LogFileExtension) - ErrorLogFile = fmt.Sprintf("%s%s", ErrorLogFileSuffix, LogFileExtension) - - if logConfigBytes, err = ioutil.ReadFile(DefaultSeelogConfigFilePath); err != nil { - logConfigBytes = DefaultConfig() - } - return -} From a78ef1bcedeec5cf923b53f0758c5024e32968c0 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 20:55:45 -0800 Subject: [PATCH 08/11] Remove seelog remnants --- Tools/src/create_darwin_arm64_bundle_plugin.sh | 1 - Tools/src/create_deb_386_plugin.sh | 1 - Tools/src/create_deb_amd64_plugin.sh | 1 - Tools/src/create_deb_arm64_plugin.sh | 1 - Tools/src/create_deb_arm_plugin.sh | 1 - Tools/src/create_rpm_386.sh | 3 +-- Tools/src/create_rpm_386_plugin.sh | 3 +-- Tools/src/create_rpm_amd64.sh | 3 +-- Tools/src/create_rpm_amd64_plugin.sh | 3 +-- Tools/src/create_rpm_arm64_plugin.sh | 3 +-- Tools/src/create_win_386_plugin.sh | 3 +-- Tools/src/create_win_amd64_plugin.sh | 3 +-- Tools/src/darwin/install | 5 ----- Tools/src/update/windows/uninstall.bat | 2 -- 14 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Tools/src/create_darwin_arm64_bundle_plugin.sh b/Tools/src/create_darwin_arm64_bundle_plugin.sh index 3593d654..8955c96c 100755 --- a/Tools/src/create_darwin_arm64_bundle_plugin.sh +++ b/Tools/src/create_darwin_arm64_bundle_plugin.sh @@ -18,7 +18,6 @@ cp ${GO_SPACE}/README.md ${GO_SPACE}/bin/darwin_arm64_plugin/sessionmanager-bund cp ${GO_SPACE}/RELEASENOTES.md ${GO_SPACE}/bin/darwin_arm64_plugin/sessionmanager-bundle/RELEASENOTES.md cp ${GO_SPACE}/VERSION ${GO_SPACE}/bin/darwin_arm64_plugin/sessionmanager-bundle/VERSION cp ${GO_SPACE}/bin/darwin_arm64_plugin/session-manager-plugin ${GO_SPACE}/bin/darwin_arm64_plugin/sessionmanager-bundle/bin/session-manager-plugin -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/darwin_arm64_plugin/sessionmanager-bundle/seelog.xml.template echo "Copying install script" diff --git a/Tools/src/create_deb_386_plugin.sh b/Tools/src/create_deb_386_plugin.sh index 98d3d786..0db66b33 100755 --- a/Tools/src/create_deb_386_plugin.sh +++ b/Tools/src/create_deb_386_plugin.sh @@ -18,7 +18,6 @@ echo "Copying application files" cp ${GO_SPACE}/bin/linux_386_plugin/session-manager-plugin ${GO_SPACE}/bin/debian_386/debian/usr/local/sessionmanagerplugin/bin/ cd ${GO_SPACE}/bin/debian_386/debian/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/debian_386/debian/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/debian_386/debian/etc/init/ cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.service ${GO_SPACE}/bin/debian_386/debian/lib/systemd/system/ diff --git a/Tools/src/create_deb_amd64_plugin.sh b/Tools/src/create_deb_amd64_plugin.sh index c8679ba7..510b5d50 100755 --- a/Tools/src/create_deb_amd64_plugin.sh +++ b/Tools/src/create_deb_amd64_plugin.sh @@ -18,7 +18,6 @@ echo "Copying application files" cp ${GO_SPACE}/bin/linux_amd64_plugin/session-manager-plugin ${GO_SPACE}/bin/debian_amd64/debian/usr/local/sessionmanagerplugin/bin/ cd ${GO_SPACE}/bin/debian_amd64/debian/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/debian_amd64/debian/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/debian_amd64/debian/etc/init/ cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.service ${GO_SPACE}/bin/debian_amd64/debian/lib/systemd/system/ diff --git a/Tools/src/create_deb_arm64_plugin.sh b/Tools/src/create_deb_arm64_plugin.sh index 22b596f4..34d99574 100755 --- a/Tools/src/create_deb_arm64_plugin.sh +++ b/Tools/src/create_deb_arm64_plugin.sh @@ -18,7 +18,6 @@ echo "Copying application files" cp ${GO_SPACE}/bin/linux_arm64_plugin/session-manager-plugin ${GO_SPACE}/bin/debian_arm64/debian/usr/local/sessionmanagerplugin/bin/ cd ${GO_SPACE}/bin/debian_arm64/debian/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/debian_arm64/debian/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/debian_arm64/debian/etc/init/ cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.service ${GO_SPACE}/bin/debian_arm64/debian/lib/systemd/system/ diff --git a/Tools/src/create_deb_arm_plugin.sh b/Tools/src/create_deb_arm_plugin.sh index e0a8d701..76236852 100755 --- a/Tools/src/create_deb_arm_plugin.sh +++ b/Tools/src/create_deb_arm_plugin.sh @@ -18,7 +18,6 @@ echo "Copying application files" cp ${GO_SPACE}/bin/linux_arm_plugin/session-manager-plugin ${GO_SPACE}/bin/debian_arm/debian/usr/local/sessionmanagerplugin/bin/ cd ${GO_SPACE}/bin/debian_arm/debian/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/debian_arm/debian/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/debian_arm/debian/etc/init/ cp ${GO_SPACE}/packaging/ubuntu_plugin/session-manager-plugin.service ${GO_SPACE}/bin/debian_arm/debian/lib/systemd/system/ diff --git a/Tools/src/create_rpm_386.sh b/Tools/src/create_rpm_386.sh index 43308864..6500f99e 100755 --- a/Tools/src/create_rpm_386.sh +++ b/Tools/src/create_rpm_386.sh @@ -22,7 +22,6 @@ mkdir -p ${GO_SPACE}/bin/linux_386/linux/var/lib/amazon/ssmcli/ echo "Copying application files" cp ${GO_SPACE}/bin/linux_386/ssmcli ${GO_SPACE}/bin/linux_386/linux/usr/bin/ -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/linux_386/linux/etc/amazon/ssmcli/seelog.xml.template cp ${GO_SPACE}/packaging/linux/ssmcli.conf ${GO_SPACE}/bin/linux_386/linux/etc/init/ cp ${GO_SPACE}/packaging/linux/ssmcli.service ${GO_SPACE}/bin/linux_386/linux/etc/systemd/system/ cd ${GO_SPACE}/bin/linux_386/linux/usr/bin/; strip --strip-unneeded ssmcli; cd ~- @@ -51,4 +50,4 @@ echo "Zip rpm, install and uninstall files" tar -zcvf ${GO_SPACE}/bin/updates/ssmcli/`cat ${GO_SPACE}/VERSION`/ssmcli-linux-386.tar.gz -C ${GO_SPACE}/bin/linux_386/ ssmcli.rpm install.sh uninstall.sh rm ${GO_SPACE}/bin/linux_386/install.sh -rm ${GO_SPACE}/bin/linux_386/uninstall.sh \ No newline at end of file +rm ${GO_SPACE}/bin/linux_386/uninstall.sh diff --git a/Tools/src/create_rpm_386_plugin.sh b/Tools/src/create_rpm_386_plugin.sh index 570ae719..12f2b748 100755 --- a/Tools/src/create_rpm_386_plugin.sh +++ b/Tools/src/create_rpm_386_plugin.sh @@ -29,7 +29,6 @@ cp ${GO_SPACE}/RELEASENOTES.md ${GO_SPACE}/bin/linux_386_plugin/linux/usr/local/ cp ${GO_SPACE}/THIRD-PARTY ${GO_SPACE}/bin/linux_386_plugin/linux/usr/local/sessionmanagerplugin/THIRD-PARTY cp ${GO_SPACE}/VERSION ${GO_SPACE}/bin/linux_386_plugin/linux/usr/local/sessionmanagerplugin/VERSION cp ${GO_SPACE}/bin/linux_386_plugin/session-manager-plugin ${GO_SPACE}/bin/linux_386_plugin/linux/usr/local/sessionmanagerplugin/bin/ -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/linux_386_plugin/linux/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/linux_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/linux_386_plugin/linux/etc/init/ cp ${GO_SPACE}/packaging/linux_plugin/session-manager-plugin.service ${GO_SPACE}/bin/linux_386_plugin/linux/etc/systemd/system/ cd ${GO_SPACE}/bin/linux_386_plugin/linux/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- @@ -58,4 +57,4 @@ echo "Zip rpm, install and uninstall files" tar -zcvf ${GO_SPACE}/bin/updates/sessionmanagerplugin/`cat ${GO_SPACE}/VERSION`/session-manager-plugin-linux-386.tar.gz -C ${GO_SPACE}/bin/linux_386_plugin/ session-manager-plugin.rpm install.sh uninstall.sh rm ${GO_SPACE}/bin/linux_386_plugin/install.sh -rm ${GO_SPACE}/bin/linux_386_plugin/uninstall.sh \ No newline at end of file +rm ${GO_SPACE}/bin/linux_386_plugin/uninstall.sh diff --git a/Tools/src/create_rpm_amd64.sh b/Tools/src/create_rpm_amd64.sh index 7801c495..bbea99bf 100755 --- a/Tools/src/create_rpm_amd64.sh +++ b/Tools/src/create_rpm_amd64.sh @@ -22,7 +22,6 @@ mkdir -p ${GO_SPACE}/bin/linux_amd64/linux/var/lib/amazon/ssmcli/ echo "Copying application files" cp ${GO_SPACE}/bin/linux_amd64/ssmcli ${GO_SPACE}/bin/linux_amd64/linux/usr/bin/ -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/linux_amd64/linux/etc/amazon/ssmcli/seelog.xml.template cp ${GO_SPACE}/packaging/linux/ssmcli.conf ${GO_SPACE}/bin/linux_amd64/linux/etc/init/ cp ${GO_SPACE}/packaging/linux/ssmcli.service ${GO_SPACE}/bin/linux_amd64/linux/etc/systemd/system/ cd ${GO_SPACE}/bin/linux_amd64/linux/usr/bin/; strip --strip-unneeded ssmcli; cd ~- @@ -51,4 +50,4 @@ echo "Zip rpm, install and uninstall files" tar -zcvf ${GO_SPACE}/bin/updates/ssmcli/`cat ${GO_SPACE}/VERSION`/ssmcli-linux-amd64.tar.gz -C ${GO_SPACE}/bin/linux_amd64/ ssmcli.rpm install.sh uninstall.sh rm ${GO_SPACE}/bin/linux_amd64/install.sh -rm ${GO_SPACE}/bin/linux_amd64/uninstall.sh \ No newline at end of file +rm ${GO_SPACE}/bin/linux_amd64/uninstall.sh diff --git a/Tools/src/create_rpm_amd64_plugin.sh b/Tools/src/create_rpm_amd64_plugin.sh index 5f13a700..d080ef48 100755 --- a/Tools/src/create_rpm_amd64_plugin.sh +++ b/Tools/src/create_rpm_amd64_plugin.sh @@ -29,7 +29,6 @@ cp ${GO_SPACE}/RELEASENOTES.md ${GO_SPACE}/bin/linux_amd64_plugin/linux/usr/loca cp ${GO_SPACE}/THIRD-PARTY ${GO_SPACE}/bin/linux_amd64_plugin/linux/usr/local/sessionmanagerplugin/THIRD-PARTY cp ${GO_SPACE}/VERSION ${GO_SPACE}/bin/linux_amd64_plugin/linux/usr/local/sessionmanagerplugin/VERSION cp ${GO_SPACE}/bin/linux_amd64_plugin/session-manager-plugin ${GO_SPACE}/bin/linux_amd64_plugin/linux/usr/local/sessionmanagerplugin/bin/ -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/linux_amd64_plugin/linux/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/linux_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/linux_amd64_plugin/linux/etc/init/ cp ${GO_SPACE}/packaging/linux_plugin/session-manager-plugin.service ${GO_SPACE}/bin/linux_amd64_plugin/linux/etc/systemd/system/ cd ${GO_SPACE}/bin/linux_amd64_plugin/linux/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- @@ -58,4 +57,4 @@ echo "Zip rpm, install and uninstall files" tar -zcvf ${GO_SPACE}/bin/updates/sessionmanagerplugin/`cat ${GO_SPACE}/VERSION`/session-manager-plugin-linux-amd64.tar.gz -C ${GO_SPACE}/bin/linux_amd64_plugin/ session-manager-plugin.rpm install.sh uninstall.sh rm ${GO_SPACE}/bin/linux_amd64_plugin/install.sh -rm ${GO_SPACE}/bin/linux_amd64_plugin/uninstall.sh \ No newline at end of file +rm ${GO_SPACE}/bin/linux_amd64_plugin/uninstall.sh diff --git a/Tools/src/create_rpm_arm64_plugin.sh b/Tools/src/create_rpm_arm64_plugin.sh index d55e3c0b..f7ade2c0 100755 --- a/Tools/src/create_rpm_arm64_plugin.sh +++ b/Tools/src/create_rpm_arm64_plugin.sh @@ -29,7 +29,6 @@ cp ${GO_SPACE}/RELEASENOTES.md ${GO_SPACE}/bin/linux_arm64_plugin/linux/usr/loca cp ${GO_SPACE}/THIRD-PARTY ${GO_SPACE}/bin/linux_arm64_plugin/linux/usr/local/sessionmanagerplugin/THIRD-PARTY cp ${GO_SPACE}/VERSION ${GO_SPACE}/bin/linux_arm64_plugin/linux/usr/local/sessionmanagerplugin/VERSION cp ${GO_SPACE}/bin/linux_arm64_plugin/session-manager-plugin ${GO_SPACE}/bin/linux_arm64_plugin/linux/usr/local/sessionmanagerplugin/bin/ -cp ${GO_SPACE}/seelog_unix.xml ${GO_SPACE}/bin/linux_arm64_plugin/linux/usr/local/sessionmanagerplugin/seelog.xml.template cp ${GO_SPACE}/packaging/linux_plugin/session-manager-plugin.conf ${GO_SPACE}/bin/linux_arm64_plugin/linux/etc/init/ cp ${GO_SPACE}/packaging/linux_plugin/session-manager-plugin.service ${GO_SPACE}/bin/linux_arm64_plugin/linux/etc/systemd/system/ cd ${GO_SPACE}/bin/linux_arm64_plugin/linux/usr/local/sessionmanagerplugin/bin/; strip --strip-unneeded session-manager-plugin; cd ~- @@ -58,4 +57,4 @@ echo "Zip rpm, install and uninstall files" tar -zcvf ${GO_SPACE}/bin/updates/sessionmanagerplugin/`cat ${GO_SPACE}/VERSION`/session-manager-plugin-linux-arm64.tar.gz -C ${GO_SPACE}/bin/linux_arm64_plugin/ session-manager-plugin.rpm install.sh uninstall.sh rm ${GO_SPACE}/bin/linux_arm64_plugin/install.sh -rm ${GO_SPACE}/bin/linux_arm64_plugin/uninstall.sh \ No newline at end of file +rm ${GO_SPACE}/bin/linux_arm64_plugin/uninstall.sh diff --git a/Tools/src/create_win_386_plugin.sh b/Tools/src/create_win_386_plugin.sh index 96e575da..10fa94d6 100755 --- a/Tools/src/create_win_386_plugin.sh +++ b/Tools/src/create_win_386_plugin.sh @@ -17,7 +17,6 @@ echo "Copying application files" mkdir -p ${PACKAGE_FOLDER}/bin cp ${BUILD_FOLDER}/session-manager-plugin.exe ${PACKAGE_FOLDER}/bin/session-manager-plugin.exe -cp ${GO_SPACE}/seelog_windows.xml.template ${PACKAGE_FOLDER}/seelog.xml.template echo "Copying windows package config files" @@ -45,4 +44,4 @@ zip -j ${WINDOWS_386_ZIP} ${PACKAGE_FOLDER}/install.bat zip -j ${WINDOWS_386_ZIP} ${PACKAGE_FOLDER}/uninstall.bat cp ${WINDOWS_386_ZIP} ${BUILD_FOLDER} -rm -rf ${PACKAGE_FOLDER} \ No newline at end of file +rm -rf ${PACKAGE_FOLDER} diff --git a/Tools/src/create_win_amd64_plugin.sh b/Tools/src/create_win_amd64_plugin.sh index d3657c11..49e1545f 100755 --- a/Tools/src/create_win_amd64_plugin.sh +++ b/Tools/src/create_win_amd64_plugin.sh @@ -17,7 +17,6 @@ echo "Copying application files" mkdir -p ${PACKAGE_FOLDER}/bin cp ${BUILD_FOLDER}/session-manager-plugin.exe ${PACKAGE_FOLDER}/bin/session-manager-plugin.exe -cp ${GO_SPACE}/seelog_windows.xml.template ${PACKAGE_FOLDER}/seelog.xml.template echo "Copying windows package config files" @@ -45,4 +44,4 @@ zip -j ${WINDOWS_AMD64_ZIP} ${PACKAGE_FOLDER}/install.bat zip -j ${WINDOWS_AMD64_ZIP} ${PACKAGE_FOLDER}/uninstall.bat cp ${WINDOWS_AMD64_ZIP} ${BUILD_FOLDER} -rm -rf ${PACKAGE_FOLDER} \ No newline at end of file +rm -rf ${PACKAGE_FOLDER} diff --git a/Tools/src/darwin/install b/Tools/src/darwin/install index 60c35dce..4c52b331 100644 --- a/Tools/src/darwin/install +++ b/Tools/src/darwin/install @@ -13,7 +13,6 @@ It also creates a symlink session-manager-plugin in the /usr/local/bin directory PLUGIN_FILE = "session-manager-plugin" VERSION_FILE = "VERSION" LICENSE_FILE = "LICENSE" -SEELOG_FILE = "seelog.xml.template" INSTALL_DIR = "/usr/local/sessionmanagerplugin" SYMLINK_NAME = "/usr/local/bin/{}".format(PLUGIN_FILE) @@ -57,10 +56,6 @@ def main(): shutil.copy2(current_bin_location, install_bin_folder) current_bin_folder = install_bin_folder - # Copy see_log file - seelog_location = os.path.join(current_working_directory, SEELOG_FILE) - shutil.copy2(seelog_location, options.install_dir) - # Copy Version File version_file_location = os.path.join(current_working_directory, VERSION_FILE) shutil.copy2(version_file_location, options.install_dir) diff --git a/Tools/src/update/windows/uninstall.bat b/Tools/src/update/windows/uninstall.bat index 2e6faad4..eb75539f 100644 --- a/Tools/src/update/windows/uninstall.bat +++ b/Tools/src/update/windows/uninstall.bat @@ -4,7 +4,6 @@ setlocal set ServiceName=session-manager-plugin set ProgramFilesAmazonFolder=%PROGRAMFILES%\Amazon set ProgramFilesSSMCLIFolder=%ProgramFilesAmazonFolder%\SessionManagerPlugin -set CustomizedSeelog=%ProgramFilesSSMCLIFolder%\seelog.xml :BEGIN echo [INFO] Detecting administrative permissions... @@ -45,7 +44,6 @@ rem Loop through non-folders, keep the customized files. set HasCustomizedSettings= for /f "delims=" %%i in ('dir /b /a:-d "%ProgramFilesSSMCLIFolder%\*.*"') do ( set IsCustomized= - if /I "%ProgramFilesSSMCLIFolder%\%%i" equ "%CustomizedSeelog%" set IsCustomized=1 if defined IsCustomized ( set HasCustomizedSettings=1 echo [INFO] Keep %ProgramFilesSSMCLIFolder%\%%i. From 256e95e4ee56b91c8a38178ebea8cdbcfd7f3b63 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Mon, 24 Feb 2025 20:57:26 -0800 Subject: [PATCH 09/11] Add comment about maintaining external interface of exported var name --- src/log/log.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log/log.go b/src/log/log.go index 76887760..9b100a8b 100644 --- a/src/log/log.go +++ b/src/log/log.go @@ -70,7 +70,7 @@ const ( ) var ( - DefaultSeelogConfigFilePath string + DefaultSeelogConfigFilePath string // Maintained for backward compatibility DefaultLogDir string ApplicationLogFile string ErrorLogFile string From 580905406812e364ee937f35ca76c3e2f497df1a Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Tue, 25 Feb 2025 07:54:49 -0800 Subject: [PATCH 10/11] Remove unused exported seelog vars --- src/log/log.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/log/log.go b/src/log/log.go index 9b100a8b..2fac9b9f 100644 --- a/src/log/log.go +++ b/src/log/log.go @@ -64,16 +64,14 @@ type T interface { // ------------------------------------------------------------------- const ( - LogFileExtension = ".log" - SeelogConfigFileName = "seelog.xml" // Kept for backward compatibility - ErrorLogFileSuffix = "errors" + LogFileExtension = ".log" + ErrorLogFileSuffix = "errors" ) var ( - DefaultSeelogConfigFilePath string // Maintained for backward compatibility - DefaultLogDir string - ApplicationLogFile string - ErrorLogFile string + DefaultLogDir string + ApplicationLogFile string + ErrorLogFile string loadedLogger *T lock sync.RWMutex From 4e94009a3e077624e8a437098047252d97d5c014 Mon Sep 17 00:00:00 2001 From: Zander Hill Date: Tue, 25 Feb 2025 08:12:13 -0800 Subject: [PATCH 11/11] Create netlistener mock --- .../portsession/muxportforwarding_test.go | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go b/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go index 87c2371c..39137368 100644 --- a/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go +++ b/src/sessionmanagerplugin/session/portsession/muxportforwarding_test.go @@ -32,12 +32,37 @@ func TestReadStream(t *testing.T) { session := getSessionMock() + // Create mock net.Listener + type MockNetListener struct { + mock.Mock + } + + func (m *MockNetListener) Accept() (net.Conn, error) { + args := m.Called() + return args.Get(0).(net.Conn), args.Error(1) + } + + func (m *MockNetListener) Close() error { + args := m.Called() + return args.Error(0) + } + + func (m *MockNetListener) Addr() net.Addr { + args := m.Called() + return args.Get(0).(net.Addr) + } + + mockListener := &MockNetListener{} + mockListener.On("Accept").Return(nil, nil) + mockListener.On("Close").Return(nil) + mockListener.On("Addr").Return(&net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 68080}) + portSession := PortSession{ Session: session, portSessionType: &MuxPortForwarding{ session: session, - muxClient: &MuxClient{in, nil, nil}, - mgsConn: &MgsConn{nil, out}, + muxClient: &MuxClient{in, mockListener, nil}, + mgsConn: &MgsConn{mockListener, out}, }, } go func() {