From 9ce3d56221014d962c089a5551cc212b24306a89 Mon Sep 17 00:00:00 2001 From: artaasadi Date: Wed, 18 Dec 2024 22:22:08 +0100 Subject: [PATCH] fix: add artifact_digest to container-vulnerability-scanner --- assets/tasks/container_grype_check.yaml | 9 +++++---- services/tasks/cmd.go | 1 + services/tasks/db/models/task.go | 1 + services/tasks/scheduler/publisher.go | 2 +- services/tasks/scheduler/service.go | 1 + services/tasks/scheduler/task_schedule.go | 4 +++- services/tasks/worker/model.go | 1 + 7 files changed, 13 insertions(+), 6 deletions(-) diff --git a/assets/tasks/container_grype_check.yaml b/assets/tasks/container_grype_check.yaml index 19ae2722a..53168ea97 100644 --- a/assets/tasks/container_grype_check.yaml +++ b/assets/tasks/container_grype_check.yaml @@ -1,8 +1,9 @@ -ID: "container-grype-check" -Name: "Container Grype Check" +ID: "container-vulnerability-scanner" +Name: "Container Vulnerability Scanner" Description: "Check if all container artifacts are free of vulnerabilities" -ImageURL: "ghcr.io/opengovern/og-task-grype:local-v0.0.53" -Command: "/og-task-grype" +ImageURL: "ghcr.io/opengovern/og-task-container-vulnerability:local-v0.0.57" +Command: "/og-task-container-vulnerability" +ResultType: "oci_container_vulnerabilities" WorkloadType: "deployment" EnvVars: {} Interval: 0 # Minutes diff --git a/services/tasks/cmd.go b/services/tasks/cmd.go index 802954404..76814d1e1 100644 --- a/services/tasks/cmd.go +++ b/services/tasks/cmd.go @@ -180,6 +180,7 @@ func setupTasks(ctx context.Context, cfg config.Config, db db.Database, kubeClie err = db.CreateTask(&models.Task{ ID: task.ID, Name: task.Name, + ResultType: task.ResultType, Description: task.Description, ImageUrl: task.ImageURL, Interval: task.Interval, diff --git a/services/tasks/db/models/task.go b/services/tasks/db/models/task.go index a6b1ec621..50fa865f1 100644 --- a/services/tasks/db/models/task.go +++ b/services/tasks/db/models/task.go @@ -9,6 +9,7 @@ type Task struct { gorm.Model ID string `gorm:"primarykey"` Name string `gorm:"unique;not null"` // Enforces uniqueness and non-null constraint + ResultType string Description string ImageUrl string Interval uint64 diff --git a/services/tasks/scheduler/publisher.go b/services/tasks/scheduler/publisher.go index 036adf099..d3911aa21 100644 --- a/services/tasks/scheduler/publisher.go +++ b/services/tasks/scheduler/publisher.go @@ -45,7 +45,7 @@ func (s *TaskScheduler) runPublisher(ctx context.Context) error { TaskDefinition: tasks.TaskDefinition{ RunID: run.ID, TaskType: s.TaskID, - ResultType: s.TaskID, // TODO: specify result type + ResultType: s.ResultType, Params: params, }, ExtraInputs: nil, diff --git a/services/tasks/scheduler/service.go b/services/tasks/scheduler/service.go index 9fc740594..06da8ab75 100644 --- a/services/tasks/scheduler/service.go +++ b/services/tasks/scheduler/service.go @@ -74,6 +74,7 @@ func (s *MainScheduler) Start(ctx context.Context) error { s.jq, s.cfg, task.ID, + task.ResultType, natsConfig, task.Interval, task.Timeout) diff --git a/services/tasks/scheduler/task_schedule.go b/services/tasks/scheduler/task_schedule.go index 0c0462612..b7e16be46 100644 --- a/services/tasks/scheduler/task_schedule.go +++ b/services/tasks/scheduler/task_schedule.go @@ -28,6 +28,7 @@ type TaskScheduler struct { cfg config.Config TaskID string + ResultType string NatsConfig NatsConfig Interval uint64 Timeout uint64 @@ -41,7 +42,7 @@ func NewTaskScheduler( cfg config.Config, - taskID string, natsConfig NatsConfig, interval uint64, timeout uint64) *TaskScheduler { + taskID, ResultType string, natsConfig NatsConfig, interval uint64, timeout uint64) *TaskScheduler { return &TaskScheduler{ runSetupNatsStreams: runSetupNatsStreams, logger: logger, @@ -51,6 +52,7 @@ func NewTaskScheduler( cfg: cfg, TaskID: taskID, + ResultType: ResultType, NatsConfig: natsConfig, Interval: interval, Timeout: timeout, diff --git a/services/tasks/worker/model.go b/services/tasks/worker/model.go index 34acbcd78..ba2c88e02 100644 --- a/services/tasks/worker/model.go +++ b/services/tasks/worker/model.go @@ -31,6 +31,7 @@ type Task struct { Description string `yaml:"Description"` ImageURL string `yaml:"ImageURL"` Command string `yaml:"Command"` + ResultType string `yaml:"ResultType"` WorkloadType WorkloadType `yaml:"WorkloadType"` EnvVars map[string]string `yaml:"EnvVars"` Interval uint64 `yaml:"Interval"`