Skip to content

Commit

Permalink
fix: fix security issues
Browse files Browse the repository at this point in the history
  • Loading branch information
davidebianchi committed Mar 20, 2022
1 parent 27f2667 commit f653e82
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions controllers/sleepinfo/cronjobs/cronjobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ func (c cronjobs) Sleep(ctx context.Context) error {

func (c cronjobs) WakeUp(ctx context.Context) error {
for _, cronjob := range c.data {
cronjob := cronjob

cjLogger := c.Log.WithValues("cronjob", cronjob.GetName(), "namespace", cronjob.GetNamespace())
cronjobSuspended, found, err := getSuspendStatus(cronjob)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions controllers/sleepinfo/deployments/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func (d deployments) HasResource() bool {

func (d deployments) Sleep(ctx context.Context) error {
for _, deployment := range d.data {
deployment := deployment

deploymentReplicas := *deployment.Spec.Replicas
if deploymentReplicas == 0 {
continue
Expand All @@ -51,6 +53,8 @@ func (d deployments) Sleep(ctx context.Context) error {

func (d deployments) WakeUp(ctx context.Context) error {
for _, deployment := range d.data {
deployment := deployment

deployLogger := d.Log.WithValues("deployment", deployment.Name, "namespace", deployment.Namespace)
if *deployment.Spec.Replicas != 0 {
deployLogger.Info("replicas not 0 during wake up")
Expand Down
5 changes: 4 additions & 1 deletion controllers/sleepinfo/sleepinfo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ func getSleepInfoData(secret *v1.Secret, sleepInfo *kubegreenv1alpha1.SleepInfo)
}
data := secret.Data

setOriginalResourceInfoToRestoreInSleepInfo(data, &sleepInfoData)
err = setOriginalResourceInfoToRestoreInSleepInfo(data, &sleepInfoData)
if err != nil {
return SleepInfoData{}, fmt.Errorf("fails to set original resource info to restore in SleepInfo %s: %s", sleepInfo.Name, err)
}

lastSchedule, err := time.Parse(time.RFC3339, string(data[lastScheduleKey]))
if err != nil {
Expand Down

0 comments on commit f653e82

Please sign in to comment.