Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@ linters:
rules:
- linters:
- bodyclose
- dupword
- errcheck
- errchkjson
- forbidigo
- gocritic
- gosec
- govet
- misspell
- musttag
- nilerr
- noctx
Expand Down
2 changes: 1 addition & 1 deletion api/datareading.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type DataReadingsPost struct {

// DataReading is the output of a DataGatherer.
type DataReading struct {
// ClusterID is optional as it can be infered from the agent
// ClusterID is optional as it can be inferred from the agent
// token when using basic authentication.
ClusterID string `json:"cluster_id,omitempty"`
DataGatherer string `json:"data-gatherer"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func init() {
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
// If the root command or sub-command returns an error, the error message will
// will be logged and the process will exit with status 1.
// be logged and the process will exit with status 1.
func Execute() {
logs.AddFlags(rootCmd.PersistentFlags())
ctx := klog.NewContext(context.Background(), klog.Background())
Expand Down
6 changes: 3 additions & 3 deletions pkg/agent/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ func InitAgentCmdFlags(c *cobra.Command, cfg *AgentCmdFlags) {
}

// TLSPKMode controls how to authenticate to TLSPK / Jetstack Secure. Only one
// TLSPKMode may be provided if using using those backends.
// TLSPKMode may be provided if using those backends.
type TLSPKMode string

const (
Expand Down Expand Up @@ -738,11 +738,11 @@ func validateCredsAndCreateClient(log logr.Logger, flagCredentialsPath, flagClie
var creds client.Credentials

if flagClientID != "" && flagCredentialsPath != "" {
errs = multierror.Append(errs, fmt.Errorf("--client-id and --credentials-file cannot be used simultanously"))
errs = multierror.Append(errs, fmt.Errorf("--client-id and --credentials-file cannot be used simultaneously"))
break
}
if flagPrivateKeyPath != "" && flagCredentialsPath != "" {
errs = multierror.Append(errs, fmt.Errorf("--private-key-path and --credentials-file cannot be used simultanously"))
errs = multierror.Append(errs, fmt.Errorf("--private-key-path and --credentials-file cannot be used simultaneously"))
break
}
if flagClientID == "" && flagPrivateKeyPath == "" && flagCredentialsPath == "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ func Test_ValidateAndCombineConfig(t *testing.T) {
assert.Equal(t, true, got.MachineHubMode)
})

t.Run("machinehub + venafi-cloud-keypair-auth should work simultanously", func(t *testing.T) {
t.Run("machinehub + venafi-cloud-keypair-auth should work simultaneously", func(t *testing.T) {
t.Setenv("POD_NAMESPACE", "venafi")
t.Setenv("KUBECONFIG", withFile(t, fakeKubeconfig))
privKeyPath := withFile(t, fakePrivKeyPEM)
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func Run(cmd *cobra.Command, args []string) (returnErr error) {
}

// Health check endpoint. Since we haven't figured a good way of knowning
// what "ready" means for the agent, we just return 200 OK inconditionally.
// what "ready" means for the agent, we just return 200 OK unconditionally.
// The goal is to satisfy some Kubernetes distributions, like OpenShift,
// that require a liveness and health probe to be present for each pod.
log.Info("Healthz endpoints enabled", "path", "/healthz")
Expand Down
2 changes: 2 additions & 0 deletions pkg/client/client_venconn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ func run_TestVenConnClient_PostDataReadingsWithOptions(ctx context.Context, rest
// sub-test-has-special-chars-and-is-also-super-super-super-super-
//
// Only the last part of the test name is used.
//
// nolint:dupword
func testNameToNamespace(t testing.TB) string {
regex := regexp.MustCompile("[^a-zA-Z0-9-]")

Expand Down
2 changes: 1 addition & 1 deletion pkg/datagatherer/k8s/dynamic.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ func RemoveUnstructuredKeys(excludeKeys []*regexp.Regexp, obj *unstructured.Unst
return
}

// The field may be nil since yaml.Unmarshal's omitempty might not be set on
// The field may be nil since yaml.Unmarshal's omitempty might not be set
// on this struct field.
if annotsRaw == nil {
return
Expand Down
14 changes: 7 additions & 7 deletions pkg/internal/cyberark/identity/advance_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func Test_IdentityAdvanceAuthentication(t *testing.T) {
MechanismID: successMechanismID,
SessionID: successSessionID,
TenantID: "foo",
PersistantLogin: true,
PersistentLogin: true,
},

expectedError: nil,
Expand All @@ -37,7 +37,7 @@ func Test_IdentityAdvanceAuthentication(t *testing.T) {
MechanismID: successMechanismID,
SessionID: successSessionID,
TenantID: "foo",
PersistantLogin: true,
PersistentLogin: true,
},

expectedError: fmt.Errorf(`got a failure response from request to advance authentication: message="Authentication (login or challenge) has failed. Please try again or contact your system administrator.", error="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:55555555555555555555555555555555"`),
Expand All @@ -50,7 +50,7 @@ func Test_IdentityAdvanceAuthentication(t *testing.T) {
MechanismID: successMechanismID,
SessionID: successSessionID,
TenantID: "foo",
PersistantLogin: true,
PersistentLogin: true,
},

expectedError: fmt.Errorf(`got a failure response from request to advance authentication: message="Authentication (login or challenge) has failed. Please try again or contact your system administrator.", error="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:55555555555555555555555555555555"`),
Expand All @@ -63,7 +63,7 @@ func Test_IdentityAdvanceAuthentication(t *testing.T) {
MechanismID: "foo",
SessionID: successSessionID,
TenantID: "foo",
PersistantLogin: true,
PersistentLogin: true,
},

expectedError: fmt.Errorf(`got a failure response from request to advance authentication: message="Authentication (login or challenge) has failed. Please try again or contact your system administrator.", error="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:55555555555555555555555555555555"`),
Expand All @@ -76,20 +76,20 @@ func Test_IdentityAdvanceAuthentication(t *testing.T) {
MechanismID: successMechanismID,
SessionID: "foo",
TenantID: "foo",
PersistantLogin: true,
PersistentLogin: true,
},

expectedError: fmt.Errorf(`got a failure response from request to advance authentication: message="Authentication (login or challenge) has failed. Please try again or contact your system administrator.", error="aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee:55555555555555555555555555555555"`),
},
"persistant login not set": {
"persistent login not set": {
username: successUser,
password: []byte(successPassword),
advanceBody: advanceAuthenticationRequestBody{
Action: ActionAnswer,
MechanismID: successMechanismID,
SessionID: successSessionID,
TenantID: "foo",
PersistantLogin: false,
PersistentLogin: false,
},

expectedError: fmt.Errorf("got unexpected status code 403 Forbidden from request to advance authentication in CyberArk Identity API"),
Expand Down
6 changes: 3 additions & 3 deletions pkg/internal/cyberark/identity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ type advanceAuthenticationRequestBody struct {
// get the Identity API URL, but we set it anyway to be explicit.
TenantID string `json:"TenantId"`

// PersistantLogin is documented to "[indicate] whether the session should persist after the user
// PersistentLogin is documented to "[indicate] whether the session should persist after the user
// closes the browser"; for service-to-service auth which we're trying to do, we set this to true.
PersistantLogin bool `json:"PersistantLogin"`
PersistentLogin bool `json:"PersistentLogin"`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

// advanceAuthenticationResponseResult is the specific information returned for a successful AdvanceAuthentication call
Expand Down Expand Up @@ -370,7 +370,7 @@ func (c *Client) doStartAuthentication(ctx context.Context, username string) (ad
response.MechanismID = mechanism.MechanismID
response.SessionID = startAuthResponse.Result.SessionID
response.TenantID = c.subdomain
response.PersistantLogin = true
response.PersistentLogin = true

return response, nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/cyberark/identity/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ func (mis *mockIdentityServer) handleAdvanceAuthentication(w http.ResponseWriter
// Important: The actual server will return 200 OK even if the login fails.
// Most failure responses should copy that.

if !advanceBody.PersistantLogin {
if !advanceBody.PersistentLogin {
// this is something we enforce but wouldn't actually be an error from
// a real server, so we return a different error here
w.WriteHeader(http.StatusForbidden)
_, _ = w.Write([]byte(`expected PersistantLogin to be true`))
_, _ = w.Write([]byte(`expected PersistentLogin to be true`))
return
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/internal/cyberark/identity/start_authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ func Test_IdentityStartAuthentication(t *testing.T) {
t.Errorf("expected advanceAuthenticationRequestBody.Action to be %s but got %s", ActionAnswer, advanceBody.Action)
}

if !advanceBody.PersistantLogin {
t.Error("expected advanceAuthenticationRequestBody.PersistantLogin to be true but it wasn't")
if !advanceBody.PersistentLogin {
t.Error("expected advanceAuthenticationRequestBody.PersistentLogin to be true but it wasn't")
}

})
Expand Down