Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
b6a8330
X-Smart-Branch-Parent: master
JoukoVirtanen Oct 1, 2025
4034460
Trying to control process baseline auto locking via operator
JoukoVirtanen Sep 6, 2025
c4448b7
Fixed style
JoukoVirtanen Sep 7, 2025
d021a21
Trying to fix one of the style errors
JoukoVirtanen Sep 7, 2025
1bf884a
Trying to fix style
JoukoVirtanen Sep 7, 2025
4167c0d
Changed autoLockProcessBaseline to autoLockProcessBaselines
JoukoVirtanen Sep 8, 2025
92de6a9
Fixed some generated files
JoukoVirtanen Sep 8, 2025
288c782
Added blank line that had been accidentally deleted
JoukoVirtanen Sep 8, 2025
27d4d35
Update operator/api/v1alpha1/securedcluster_types.go
JoukoVirtanen Sep 10, 2025
43deb73
Updated comments and ordering
JoukoVirtanen Sep 10, 2025
3ed1814
Using an enum instead of a boolean
JoukoVirtanen Sep 10, 2025
c73c8b9
Added a file that had been forgotten
JoukoVirtanen Sep 10, 2025
edba5a3
Fixd style
JoukoVirtanen Sep 10, 2025
132af7a
Changed some names
JoukoVirtanen Sep 10, 2025
c78c0f3
Added unit tests
JoukoVirtanen Sep 11, 2025
2a92335
Use SetBoolValue for brevity
JoukoVirtanen Sep 11, 2025
b37df3d
Fixed inconsistencies in securedcluster_types.go
JoukoVirtanen Sep 11, 2025
a7e6c60
Fixed style
JoukoVirtanen Sep 11, 2025
65adbc2
Added a default
JoukoVirtanen Sep 11, 2025
914e7cd
Changed description for ProcessBaselines. Updated generated files
JoukoVirtanen Sep 11, 2025
df0f5d6
Trying to fix UI
JoukoVirtanen Sep 12, 2025
5fd9a77
Fixed typo that was preventing the drop down from working properly
JoukoVirtanen Sep 15, 2025
c673f27
Updated generated files
JoukoVirtanen Sep 15, 2025
c1b665c
Set default in defaults.go
JoukoVirtanen Sep 17, 2025
b394b9f
Update operator/internal/securedcluster/values/translation/translatio…
JoukoVirtanen Sep 17, 2025
e429362
Removed if sc.Spec.ProcessBaselines != nil. Various fixes
JoukoVirtanen Sep 17, 2025
1308d96
Capitalized display name
JoukoVirtanen Sep 22, 2025
c0b1eaa
Generated files
JoukoVirtanen Sep 22, 2025
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
46 changes: 37 additions & 9 deletions operator/api/v1alpha1/securedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,26 +65,30 @@ type SecuredClusterSpec struct {
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=6,displayName="Kubernetes Audit Logs Ingestion Settings"
AuditLogs *AuditLogsSpec `json:"auditLogs,omitempty"`

// Settings relating to process baselines.
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=7,displayName="Process Baselines Settings"
ProcessBaselines *ProcessBaselinesSpec `json:"processBaselines,omitempty"`

// Settings for the Scanner component, which is responsible for vulnerability scanning of container
// images stored in a cluster-local image repository.
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=7,displayName="Scanner Component Settings"
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=8,displayName="Scanner Component Settings"
Scanner *LocalScannerComponentSpec `json:"scanner,omitempty"`

// Settings for the Scanner V4 components, which can run in addition to the previously existing Scanner components
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=8,displayName="Scanner V4 Component Settings"
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=9,displayName="Scanner V4 Component Settings"
ScannerV4 *LocalScannerV4ComponentSpec `json:"scannerV4,omitempty"`
// Above default is necessary to make the nested default work see: https://github.com/kubernetes-sigs/controller-tools/issues/622

// Settings related to Transport Layer Security, such as Certificate Authorities.
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=9
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=10
TLS *TLSConfig `json:"tls,omitempty"`

// Additional image pull secrets to be taken into account for pulling images.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Image Pull Secrets",order=10,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Image Pull Secrets",order=11,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
ImagePullSecrets []LocalSecretReference `json:"imagePullSecrets,omitempty"`

// Customizations to apply on all Central Services components.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName=Customizations,order=11,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName=Customizations,order=12,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Customize *CustomizeSpec `json:"customize,omitempty"`

// Deprecated field. This field will be removed in a future release.
Expand All @@ -93,22 +97,46 @@ type SecuredClusterSpec struct {
Misc *MiscSpec `json:"misc,omitempty"`

// Overlays
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName=Overlays,order=12,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName=Overlays,order=13,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:hidden"}
Overlays []*K8sObjectOverlay `json:"overlays,omitempty"`

// Monitoring configuration.
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=13,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=14,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Monitoring *GlobalMonitoring `json:"monitoring,omitempty"`

// Set this parameter to override the default registry in images. For example, nginx:latest -> <registry override>/library/nginx:latest
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Custom Default Image Registry",order=14,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Custom Default Image Registry",order=15,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
RegistryOverride *string `json:"registryOverride,omitempty"`

// Network configuration.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName=Network,order=15,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName=Network,order=16,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:advanced"}
Network *GlobalNetworkSpec `json:"network,omitempty"`
}

// ProcessBaselinesAutoLockMode is a type for values of spec.processBaselineAutoLockMode.
// +kubebuilder:validation:Enum=Enabled;Disabled
type ProcessBaselinesAutoLockMode string

const (
// ProcessBaselineLockModeEnabled means: Process baseline auto-locking will be enabled
ProcessBaselinesAutoLockModeEnabled ProcessBaselinesAutoLockMode = "Enabled"
// ProcessBaselineLockModeDisabled means: Process baseline auto-locking will be disabled
ProcessBaselinesAutoLockModeDisabled ProcessBaselinesAutoLockMode = "Disabled"
)

// Pointer returns the given ProcessBaselineAutoLockMode as a pointer, needed in k8s resource structs.
func (p ProcessBaselinesAutoLockMode) Pointer() *ProcessBaselinesAutoLockMode {
return &p
}

// ProcessBaselinesSpec defines settings for the process baseline auto-locking feature.
type ProcessBaselinesSpec struct {
// Should process baselines be automatically locked when the observation period (1 hour by default) ends.
// The default is: Disabled.
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=1,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:select:Enabled", "urn:alm:descriptor:com.tectonic.ui:select:Disabled"}
AutoLock *ProcessBaselinesAutoLockMode `json:"autoLock,omitempty"`
}

// SensorComponentSpec defines settings for sensor.
type SensorComponentSpec struct {
//+operator-sdk:csv:customresourcedefinitions:type=spec,order=1
Expand Down
25 changes: 25 additions & 0 deletions operator/api/v1alpha1/zz_generated.deepcopy.go

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

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,18 @@ spec:
- AvoidTaints
type: string
type: object
processBaselines:
description: Settings relating to process baselines.
properties:
autoLock:
description: |-
Should process baselines be automatically locked when the observation period (1 hour by default) ends.
The default is: Disabled.
enum:
- Enabled
- Disabled
type: string
type: object
registryOverride:
description: Set this parameter to override the default registry in
images. For example, nginx:latest -> <registry override>/library/nginx:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,14 @@ spec:
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:select:CORE_BPF
- urn:alm:descriptor:com.tectonic.ui:select:NoCollection
- description: |-
Should process baselines be automatically locked when the observation period (1 hour by default) ends.
The default is: Disabled.
displayName: Auto Lock
path: processBaselines.autoLock
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:select:Enabled
- urn:alm:descriptor:com.tectonic.ui:select:Disabled
- description: Controls the number of analyzer replicas and autoscaling.
displayName: Scaling
path: scanner.analyzer.scaling
Expand Down Expand Up @@ -1158,6 +1166,9 @@ spec:
- description: Settings relating to the ingestion of Kubernetes audit logs.
displayName: Kubernetes Audit Logs Ingestion Settings
path: auditLogs
- description: Settings relating to process baselines.
displayName: Process Baselines Settings
path: processBaselines
- description: |-
Settings for the Scanner component, which is responsible for vulnerability scanning of container
images stored in a cluster-local image repository.
Expand Down
3 changes: 3 additions & 0 deletions operator/internal/securedcluster/defaults/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ var staticDefaults = platform.SecuredClusterSpec{
AuditLogs: &platform.AuditLogsSpec{
Collection: platform.AuditLogsCollectionAuto.Pointer(),
},
ProcessBaselines: &platform.ProcessBaselinesSpec{
AutoLock: platform.ProcessBaselinesAutoLockModeDisabled.Pointer(),
},
Scanner: &platform.LocalScannerComponentSpec{
ScannerComponent: platform.LocalScannerComponentAutoSense.Pointer(),
Analyzer: &platform.ScannerAnalyzerComponent{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ func (t Translator) translate(ctx context.Context, sc platform.SecuredCluster) (
v.AddChild("network", translation.GetGlobalNetwork(sc.Spec.Network))
}

v.AddChild("autoLockProcessBaselines", getProcessBaselinesValues(sc.Spec.ProcessBaselines))

return v.Build()
}

Expand Down Expand Up @@ -362,6 +364,16 @@ func (t Translator) getAuditLogsValues(auditLogs *platform.AuditLogsSpec) *trans
return &cv
}

func getProcessBaselinesValues(processBaselines *platform.ProcessBaselinesSpec) *translation.ValuesBuilder {
if processBaselines == nil || processBaselines.AutoLock == nil {
return nil
}
cv := translation.NewValuesBuilder()
cv.SetBoolValue("enabled", *processBaselines.AutoLock == platform.ProcessBaselinesAutoLockModeEnabled)

return &cv
}

func (t Translator) getCollectorValues(perNode *platform.PerNodeSpec) *translation.ValuesBuilder {
cv := translation.NewValuesBuilder()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,76 @@ func (s *TranslationTestSuite) TestTranslate() {
},
},
},
"process baseline auto-locking enabled": {
args: args{
client: newDefaultFakeClient(t),
sc: platform.SecuredCluster{
ObjectMeta: metav1.ObjectMeta{Namespace: "stackrox"},
Spec: platform.SecuredClusterSpec{
ClusterName: ptr.To("test-cluster"),
ProcessBaselines: &platform.ProcessBaselinesSpec{
AutoLock: platform.ProcessBaselinesAutoLockModeEnabled.Pointer(),
},
},
},
},
want: chartutil.Values{
"clusterName": "test-cluster",
"ca": map[string]string{"cert": "ca central content"},
"createSecrets": false,
"scanner": map[string]interface{}{
"disable": false,
},
"sensor": map[string]interface{}{
"localImageScanning": map[string]string{
"enabled": "true",
},
},
"monitoring": map[string]interface{}{
"openshift": map[string]interface{}{
"enabled": true,
},
},
"autoLockProcessBaselines": map[string]interface{}{
"enabled": true,
},
},
},
"process baseline auto-locking disabled": {
args: args{
client: newDefaultFakeClient(t),
sc: platform.SecuredCluster{
ObjectMeta: metav1.ObjectMeta{Namespace: "stackrox"},
Spec: platform.SecuredClusterSpec{
ClusterName: ptr.To("test-cluster"),
ProcessBaselines: &platform.ProcessBaselinesSpec{
AutoLock: platform.ProcessBaselinesAutoLockModeDisabled.Pointer(),
},
},
},
},
want: chartutil.Values{
"clusterName": "test-cluster",
"ca": map[string]string{"cert": "ca central content"},
"createSecrets": false,
"scanner": map[string]interface{}{
"disable": false,
},
"sensor": map[string]interface{}{
"localImageScanning": map[string]string{
"enabled": "true",
},
},
"monitoring": map[string]interface{}{
"openshift": map[string]interface{}{
"enabled": true,
},
},
"autoLockProcessBaselines": map[string]interface{}{
"enabled": false,
},
},
},
}

for name, tt := range tests {
Expand Down
Loading