Skip to content

Commit

Permalink
feat: add support for InsecureIgnoreHostKey (#503)
Browse files Browse the repository at this point in the history
Signed-off-by: Udit107710 <[email protected]>
  • Loading branch information
Udit107710 authored Nov 19, 2021
1 parent 4a1b016 commit b15c3bc
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/v1alpha1/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type Git struct {
// PasswordSecret is the secret selector to the repository password
PasswordSecret *corev1.SecretKeySelector `json:"passwordSecret,omitempty" protobuf:"bytes,8,opt,name=passwordSecret"`

// InsecureIgnoreHostKey is the bool value for ignoring check for host key
InsecureIgnoreHostKey bool `json:"insecureIgnoreHostKey,omitempty" protobuf:"bytes,10,opt,name=insecureIgnoreHostKey"`

// SSHPrivateKeySecret is the secret selector to the repository ssh private key
SSHPrivateKeySecret *corev1.SecretKeySelector `json:"sshPrivateKeySecret,omitempty" protobuf:"bytes,9,opt,name=sshPrivateKeySecret"`
// +kubebuilder:default=.
Expand Down
8 changes: 8 additions & 0 deletions config/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for
ignoring check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the
repository password
Expand Down Expand Up @@ -8406,6 +8410,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for ignoring
check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the repository
password
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/dataflow.argoproj.io_pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for
ignoring check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the
repository password
Expand Down
4 changes: 4 additions & 0 deletions config/crd/bases/dataflow.argoproj.io_steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for ignoring
check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the repository
password
Expand Down
8 changes: 8 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for
ignoring check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the
repository password
Expand Down Expand Up @@ -8406,6 +8410,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for ignoring
check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the repository
password
Expand Down
8 changes: 8 additions & 0 deletions config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for
ignoring check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the
repository password
Expand Down Expand Up @@ -8406,6 +8410,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for ignoring
check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the repository
password
Expand Down
8 changes: 8 additions & 0 deletions config/quick-start.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for
ignoring check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the
repository password
Expand Down Expand Up @@ -8406,6 +8410,10 @@ spec:
type: array
image:
type: string
insecureIgnoreHostKey:
description: InsecureIgnoreHostKey is the bool value for ignoring
check for host key
type: boolean
passwordSecret:
description: PasswordSecret is the secret selector to the repository
password
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require (
github.com/uber/jaeger-client-go v2.29.1+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible
github.com/weaveworks/promrus v1.2.0
golang.org/x/crypto v0.0.0-20210915214749-c084706c2272
k8s.io/api v0.20.4
k8s.io/apimachinery v0.20.4
k8s.io/client-go v0.20.4
Expand Down Expand Up @@ -115,7 +116,6 @@ require (
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.16.0 // indirect
golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 // indirect
golang.org/x/mod v0.5.1-0.20210830214625-1b1db11ec8f4 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect
Expand Down
4 changes: 4 additions & 0 deletions runner/init/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/go-git/go-git/v5/plumbing/transport/ssh"
ssh2 "golang.org/x/crypto/ssh"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/strings"
Expand Down Expand Up @@ -93,6 +94,9 @@ func Exec(ctx context.Context) error {
if v, err := ssh.NewPublicKeys("git", sshPrivateKey.Data[k.Key], ""); err != nil {
return fmt.Errorf("failed to get create public keys: %w", err)
} else {
if k := g.InsecureIgnoreHostKey; k {
v.HostKeyCallback = ssh2.InsecureIgnoreHostKey()
}
auth = v
}
}
Expand Down

0 comments on commit b15c3bc

Please sign in to comment.