Skip to content

Commit

Permalink
sshc secure by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ferama committed Jan 7, 2022
1 parent a0f1bba commit 0cbbe16
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 8 deletions.
5 changes: 0 additions & 5 deletions pkg/conf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,5 @@ func LoadConfig(filePath string) (*Config, error) {
return nil, err
}

// set some reasonable defaults
if cfg.SshClient != nil {
cfg.SshClient.Insecure = false
}

return &cfg, nil
}
39 changes: 36 additions & 3 deletions pkg/conf/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,40 @@ func TestEmptySshc(t *testing.T) {
if cfg.SshClient != nil {
t.Fatalf("sshclient should be nil")
}
// if cfg.SshD.DisableShell {
// t.Fatalf("disable shell")
// }
}

func TestSshcSecure(t *testing.T) {
path := filepath.Join("testdata", "sshc.yaml")

cfg, err := LoadConfig(path)
if err != nil {
t.Fatalf("can't parse config")
}
if cfg.SshClient.Insecure != false {
t.Fatalf("sshclient should be secure")
}
}

func TestSshcInsecure(t *testing.T) {
path := filepath.Join("testdata", "sshc_insecure.yaml")

cfg, err := LoadConfig(path)
if err != nil {
t.Fatalf("can't parse config")
}
if cfg.SshClient.Insecure != true {
t.Fatalf("sshclient should be insecure")
}
}

func TestSshcSecureDefault(t *testing.T) {
path := filepath.Join("testdata", "sshc_secure_default.yaml")

cfg, err := LoadConfig(path)
if err != nil {
t.Fatalf("can't parse config")
}
if cfg.SshClient.Insecure != false {
t.Fatalf("sshclient should be secure by default")
}
}
5 changes: 5 additions & 0 deletions pkg/conf/testdata/sshc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sshclient:
server: localhost:5022
known_hosts: "./known_hosts"
identity: "~/.ssh/id_rsa"
insecure: false
5 changes: 5 additions & 0 deletions pkg/conf/testdata/sshc_insecure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sshclient:
server: localhost:5022
known_hosts: "./known_hosts"
identity: "~/.ssh/id_rsa"
insecure: true
4 changes: 4 additions & 0 deletions pkg/conf/testdata/sshc_secure_default.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sshclient:
server: localhost:5022
known_hosts: "./known_hosts"
identity: "~/.ssh/id_rsa"

0 comments on commit 0cbbe16

Please sign in to comment.