Skip to content

Commit

Permalink
Fix checkmarx findings (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
alxsap authored May 4, 2021
1 parent 633b223 commit 8971b03
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
7 changes: 7 additions & 0 deletions changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
date: TBD
changes:

- type: internal
impact: patch
title: Fixed checkmarx scan
description: |-
The checkmarks scan reported some low findings which are fixed now.
pullRequestNumber: 223

- type: security
impact: patch
title: Update JFR image to 210413_777e270 with secure agent protocols
Expand Down
3 changes: 2 additions & 1 deletion pkg/k8s/pipelineRun.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ func (r *pipelineRun) HasDeletionTimestamp() bool {
func (r *pipelineRun) AddFinalizer() error {
changed, finalizerList := utils.AddStringIfMissing(r.apiObj.ObjectMeta.Finalizers, FinalizerName)
if changed {
r.updateFinalizers(finalizerList)
err := r.updateFinalizers(finalizerList)
return err
}
return nil
}
Expand Down
5 changes: 4 additions & 1 deletion pkg/runctl/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,10 @@ func (c *Controller) syncHandler(key string) error {

// As soon as we have a result we can cleanup
if pipelineRun.GetStatus().Result != api.ResultUndefined && pipelineRun.GetStatus().State != api.StateCleaning {
c.changeState(pipelineRun, api.StateCleaning)
err = c.changeState(pipelineRun, api.StateCleaning)
if err != nil {
klog.V(1).Infof("WARN: change state to cleaning failed with: %s", err.Error())
}
}

if pipelineRun.GetStatus().State == api.StateNew {
Expand Down
7 changes: 5 additions & 2 deletions pkg/runctl/run_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (c *runManager) prepareRunNamespace(ctx *runContext) error {
// If something goes wrong while creating objects inside the namespaces, we delete everything.
cleanupOnError := func() {
if err != nil {
c.cleanup(ctx)
c.cleanup(ctx) // clean-up ignoring error
}
}
defer cleanupOnError()
Expand Down Expand Up @@ -506,7 +506,10 @@ func (c *runManager) createTektonTaskRun(ctx *runContext) error {
},
}
c.addTektonTaskRunParamsForJenkinsfileRunnerImage(ctx, &tektonTaskRun)
c.addTektonTaskRunParamsForPipeline(ctx, &tektonTaskRun)
err = c.addTektonTaskRunParamsForPipeline(ctx, &tektonTaskRun)
if err != nil {
return serrors.Classify(err, stewardv1alpha1.ResultErrorConfig)
}
err = c.addTektonTaskRunParamsForLoggingElasticsearch(ctx, &tektonTaskRun)
if err != nil {
return serrors.Classify(err, stewardv1alpha1.ResultErrorConfig)
Expand Down
8 changes: 4 additions & 4 deletions pkg/tenantctl/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (c *Controller) syncHandler(key string) error {
if err != nil {
return err
}
tenant, err = c.removeFinalizerAndUpdate(tenant)
_, err = c.removeFinalizerAndUpdate(tenant)
if err == nil {
c.syncCount++
}
Expand All @@ -226,7 +226,7 @@ func (c *Controller) syncHandler(key string) error {
if !equality.Semantic.DeepEqual(origTenant.Status, tenant.Status) {
if _, err := c.updateStatus(tenant); err != nil {
if !c.isInitialized(origTenant) && c.isInitialized(tenant) {
c.deleteTenantNamespace(tenant.Status.TenantNamespaceName, tenant, config)
c.deleteTenantNamespace(tenant.Status.TenantNamespaceName, tenant, config) // clean-up ignoring error
}
return err
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func (c *Controller) reconcileUninitialized(config clientConfig, tenant *api.Ten

nsName, err := c.createTenantNamespace(config, tenant)
if err != nil {
condMsg := fmt.Sprintf("Failed to create a new tenant namespace.")
condMsg := "Failed to create a new tenant namespace."
tenant.Status.SetCondition(&knativeapis.Condition{
Type: knativeapis.ConditionReady,
Status: corev1.ConditionFalse,
Expand All @@ -271,7 +271,7 @@ func (c *Controller) reconcileUninitialized(config clientConfig, tenant *api.Ten

_, err = c.reconcileTenantRoleBinding(tenant, nsName, config)
if err != nil {
condMsg := fmt.Sprintf("Failed to initialize a new tenant namespace because the RoleBinding could not be created.")
condMsg := "Failed to initialize a new tenant namespace because the RoleBinding could not be created."
tenant.Status.SetCondition(&knativeapis.Condition{
Type: knativeapis.ConditionReady,
Status: corev1.ConditionFalse,
Expand Down

0 comments on commit 8971b03

Please sign in to comment.