Skip to content

Commit

Permalink
Merge pull request #135 from jaksi/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
jaksi authored Aug 3, 2024
2 parents de4bd71 + 1b314b4 commit 0627956
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 32 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: golangci/golangci-lint-action@v3
- uses: golangci/golangci-lint-action@v6
test:
name: Test
strategy:
Expand All @@ -21,7 +21,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: ^1.18
go-version: ^1.22
- run: go test -race -timeout 1m
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
- uses: actions/setup-go@v5
with:
go-version: "^1.18"
go-version: "^1.22"
- run: go build -o sshesame-linux-amd64
env:
GOOS: linux
Expand Down
5 changes: 2 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path"
Expand Down Expand Up @@ -148,14 +147,14 @@ func generateKey(dataDir string, signature keySignature) (string, error) {
if err != nil {
return "", err
}
if err := ioutil.WriteFile(keyFile, pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyBytes}), 0600); err != nil {
if err := os.WriteFile(keyFile, pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: keyBytes}), 0600); err != nil {
return "", err
}
return keyFile, nil
}

func loadKey(keyFile string) (ssh.Signer, error) {
keyBytes, err := ioutil.ReadFile(keyFile)
keyBytes, err := os.ReadFile(keyFile)
if err != nil {
return nil, err
}
Expand Down
20 changes: 10 additions & 10 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package main
import (
"errors"
"fmt"
"io/ioutil"
"log"
"os"
"path"
"reflect"
"testing"
Expand Down Expand Up @@ -114,7 +114,7 @@ func verifyConfig(t *testing.T, cfg *config, expected *config) {
}

func verifyDefaultKeys(t *testing.T, dataDir string) {
files, err := ioutil.ReadDir(dataDir)
files, err := os.ReadDir(dataDir)
if err != nil {
t.Fatalf("Faield to list directory: %v", err)
}
Expand All @@ -125,7 +125,7 @@ func verifyDefaultKeys(t *testing.T, dataDir string) {
}
keys := map[string]string{}
for _, file := range files {
keyBytes, err := ioutil.ReadFile(path.Join(dataDir, file.Name()))
keyBytes, err := os.ReadFile(path.Join(dataDir, file.Name()))
if err != nil {
t.Fatalf("Failed to read key: %v", err)
}
Expand Down Expand Up @@ -281,7 +281,7 @@ server:
expectedConfig.SSHProto.Version = "SSH-2.0-sshesame"
expectedConfig.SSHProto.Banner = "This is an SSH honeypot. Everything is logged and monitored."
verifyConfig(t, cfg, expectedConfig)
files, err := ioutil.ReadDir(dataDir)
files, err := os.ReadDir(dataDir)
if err != nil {
t.Fatalf("Failed to read directory: %v", err)
}
Expand Down Expand Up @@ -316,7 +316,7 @@ func TestLogReloadSameFile(t *testing.T) {
if err := cfg.logFileHandle.Close(); err != nil {
t.Fatalf("Failed to close log file: %v", err)
}
logs, err := ioutil.ReadFile(cfg.Logging.File)
logs, err := os.ReadFile(cfg.Logging.File)
if err != nil {
t.Fatalf("Failed to read log file: %v", err)
}
Expand Down Expand Up @@ -344,15 +344,15 @@ func TestLogReloadDifferentFile(t *testing.T) {
if err := cfg.logFileHandle.Close(); err != nil {
t.Fatalf("Failed to close log file: %v", err)
}
logs1, err := ioutil.ReadFile(logFile1)
logs1, err := os.ReadFile(logFile1)
if err != nil {
t.Fatalf("Failed to read log file: %v", err)
}
expectedLogs1 := "test1\n"
if string(logs1) != expectedLogs1 {
t.Errorf("logs1=%v, want %v", string(logs1), expectedLogs1)
}
logs2, err := ioutil.ReadFile(logFile2)
logs2, err := os.ReadFile(logFile2)
if err != nil {
t.Fatalf("Failed to read log file: %v", err)
}
Expand All @@ -368,15 +368,15 @@ func TestExistingKey(t *testing.T) {
if err != nil {
t.Fatalf("Failed to generate key: %v", err)
}
oldKey, err := ioutil.ReadFile(oldKeyFile)
oldKey, err := os.ReadFile(oldKeyFile)
if err != nil {
t.Fatalf("Failed to read key: %v", err)
}
newKeyFile, err := generateKey(dataDir, ed25519_key)
if err != nil {
t.Fatalf("Failed to generate key: %v", err)
}
newKey, err := ioutil.ReadFile(newKeyFile)
newKey, err := os.ReadFile(newKeyFile)
if err != nil {
t.Fatalf("Failed to read key: %v", err)
}
Expand All @@ -386,7 +386,7 @@ func TestExistingKey(t *testing.T) {
}

func TestDefaultConfigFile(t *testing.T) {
configBytes, err := ioutil.ReadFile("sshesame.yaml")
configBytes, err := os.ReadFile("sshesame.yaml")
if err != nil {
t.Fatalf("Failed to read config file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module github.com/jaksi/sshesame

go 1.18
go 1.22

require (
github.com/adrg/xdg v0.5.0
github.com/jaksi/sshutils v0.0.11
github.com/jaksi/sshutils v0.0.13
github.com/prometheus/client_golang v1.19.1
golang.org/x/crypto v0.25.0
golang.org/x/term v0.22.0
Expand Down
12 changes: 10 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/jaksi/sshutils v0.0.11 h1:MNFPPHkDD+FQJl+SPTL1U8LQ9AJrx87lArEyR35yvsk=
github.com/jaksi/sshutils v0.0.11/go.mod h1:H1/OsmZrqUwTydEeQVT4cTMXO7IDUDb2ClYvGQNg5Ss=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/jaksi/sshutils v0.0.13 h1:0XKYoXU4xzeur8q5uCAerjkcLh9DaEe9OQOhVKuSSJ0=
github.com/jaksi/sshutils v0.0.13/go.mod h1:H1/OsmZrqUwTydEeQVT4cTMXO7IDUDb2ClYvGQNg5Ss=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE=
github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho=
github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw=
Expand All @@ -22,7 +26,9 @@ github.com/prometheus/common v0.48.0/go.mod h1:0/KsvlIEfPQCQ5I2iNSAWKPZziNCvRs5E
github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo=
github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
Expand All @@ -33,6 +39,8 @@ google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGm
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"flag"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -35,7 +34,7 @@ func main() {
cfg := &config{}
configString := ""
if *configFile != "" {
configBytes, err := ioutil.ReadFile(*configFile)
configBytes, err := os.ReadFile(*configFile)
if err != nil {
errorLogger.Fatalf("Failed to read config file: %v", err)
}
Expand All @@ -50,7 +49,7 @@ func main() {
go func() {
for signal := range reloadSignals {
infoLogger.Printf("Reloading config due to %s", signal)
configBytes, err := ioutil.ReadFile(*configFile)
configBytes, err := os.ReadFile(*configFile)
if err != nil {
warningLogger.Printf("Failed to read config file: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"os"
"path"
"path/filepath"
"reflect"
Expand Down Expand Up @@ -520,7 +520,7 @@ func TestReplay(t *testing.T) {
}
t.Run(testName, func(t *testing.T) {
logBuffer := setupLogBuffer(t, cfg)
testCaseBytes, err := ioutil.ReadFile(testFile)
testCaseBytes, err := os.ReadFile(testFile)
if err != nil {
t.Fatal(err)
}
Expand Down
6 changes: 3 additions & 3 deletions testproxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"flag"
"fmt"
"io"
"io/ioutil"
"net"
"os"

"golang.org/x/crypto/ssh"
)
Expand Down Expand Up @@ -479,7 +479,7 @@ func main() {
NoClientAuth: true,
ServerVersion: "SSH-2.0-OpenSSH_7.2",
}
hostKeyBytes, err := ioutil.ReadFile(*hostKeyFile)
hostKeyBytes, err := os.ReadFile(*hostKeyFile)
if err != nil {
panic(err)
}
Expand All @@ -489,7 +489,7 @@ func main() {
}
serverConfig.AddHostKey(hostKey)

clientKeyBytes, err := ioutil.ReadFile(*clientKeyFile)
clientKeyBytes, err := os.ReadFile(*clientKeyFile)
if err != nil {
panic(err)
}
Expand Down
4 changes: 2 additions & 2 deletions testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package main

import (
"bytes"
"io/ioutil"
"log"
"os"
"path/filepath"
"testing"
)
Expand Down Expand Up @@ -75,7 +75,7 @@ func writeTestKeys(t *testing.T, dataDir string) {
"host_ecdsa_key": testECDSAKey,
"host_ed25519_key": testEd25519Key,
} {
if err := ioutil.WriteFile(filepath.Join(dataDir, fileName), []byte(content), 0600); err != nil {
if err := os.WriteFile(filepath.Join(dataDir, fileName), []byte(content), 0600); err != nil {
t.Fatal(err)
}
}
Expand Down

0 comments on commit 0627956

Please sign in to comment.