8000 Support for Env and File in parser and scan by paulschmelzer · Pull Request #231 · secureCodeBox/secureCodeBox · GitHub
[go: up one dir, main page]

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
8 changes: 8 additions & 0 deletions operator/apis/execution/v1/parsedefinition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ type ParseDefinitionSpec struct {
Image string `json:"image,omitempty"`
// ImagePullSecrets used to access private parser images
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// TTLSecondsAfterFinished configures the ttlSecondsAfterFinished field for the created parse job
// +nullable
TTLSecondsAfterFinished *int32 `json:"ttlSecondsAfterFinished,omitempty"`

// Env allows to specify environment vars for the parser container.
Env []corev1.EnvVar `json:"env,omitempty"`
// Volumes allows to specify volumes for the parser container.
Volumes []corev1.Volume `json:"volumes,omitempty"`
// VolumeMounts allows to specify volume mounts for the parser container.
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`
}

// ParseDefinitionStatus defines the observed state of ParseDefinition
Expand Down
4 changes: 4 additions & 0 deletions operator/apis/execution/v1/scan_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ type ScanSpec struct {

// Env allows to specify environment vars for the scanner container. These will be merged will the env vars specified for the first container of the pod defined in the ScanType
Env []corev1.EnvVar `json:"env,omitempty"`
// Volumes allows to specify volumes for the scan container.
Volumes []corev1.Volume `json:"volumes,omitempty"`
// VolumeMounts allows to specify volume mounts for the scan container.
VolumeMounts []corev1.VolumeMount `json:"volumeMounts,omitempty"`

Cascades *metav1.LabelSelector `json:"cascades,omitempty"`
}
Expand Down
35 changes: 35 additions & 0 deletions operator/apis/execution/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1,256 changes: 1,256 additions & 0 deletions operator/config/crd/bases/cascading.securecodebox.io_cascadingrules.yaml

Large diffs are not rendered by default.

1,316 changes: 1,316 additions & 0 deletions operator/config/crd/bases/execution.securecodebox.io_parsedefinitions.yaml

Large diffs are not rendered by default.

1,217 changes: 1,217 additions & 0 deletions operator/config/crd/bases/execution.securecodebox.io_scans.yaml

Large diffs are not rendered by default.

1,256 changes: 1,256 additions & 0 deletions operator/config/crd/bases/execution.securecodebox.io_scheduledscans.yaml

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions operator/controllers/execution/scans/parse_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,22 @@ func (r *ScanReconciler) startParser(scan *executionv1.Scan) error {
},
}

// Merge Env from ParserTemplate
job.Spec.Template.Spec.Containers[0].Env = append(
job.Spec.Template.Spec.Containers[0].Env,
parseDefinition.Spec.Env...,
)
// Merge VolumeMounts from ParserTemplate
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(
job.Spec.Template.Spec.Containers[0].VolumeMounts,
parseDefinition.Spec.VolumeMounts...,
)
// Merge Volumes from ParserTemplate
job.Spec.Template.Spec.Volumes = append(
job.Spec.Template.Spec.Volumes,
parseDefinition.Spec.Volumes...,
)

if err := ctrl.SetControllerReference(scan, job, r.Scheme); err != nil {
return err
}
Expand Down
10 changes: 10 additions & 0 deletions operator/controllers/execution/scans/scan_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,16 @@ func (r *ScanReconciler) constructJobForScan(scan *executionv1.Scan, scanType *e
job.Spec.Template.Spec.Containers[0].Env,
scan.Spec.Env...,
)
// Merge VolumeMounts from ScanTemplate with VolumeMounts defined in scan
job.Spec.Template.Spec.Containers[0].VolumeMounts = append(
job.Spec.Template.Spec.Containers[0].VolumeMounts,
scan.Spec.VolumeMounts...,
)
// Merge Volumes from ScanTemplate with Volumes defined in scan
job.Spec.Template.Spec.Volumes = append(
job.Spec.Template.Spec.Volumes,
scan.Spec.Volumes...,
)

// Using command over args
job.Spec.Template.Spec.Containers[0].Command = command
Expand Down
1,256 changes: 1,256 additions & 0 deletions operator/crds/cascading.securecodebox.io_cascadingrules.yaml

Large diffs are not rendered by default.

Loading
0