Skip to content

Commit b5330d4

Browse files
committed
feat: add network inventory scanner options
1 parent 7007e71 commit b5330d4

15 files changed

Lines changed: 1914 additions & 19 deletions

api/v1alpha2/mondooauditconfig_types.go

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ type KubernetesResources struct {
119119
// +optional
120120
ActiveDeadline *metav1.Duration `json:"activeDeadline,omitempty"`
121121

122+
// NetworkInventory configures extended Kubernetes network inventory collection.
123+
// This remains scan-time only and does not configure admission webhooks or network policy enforcement.
124+
NetworkInventory NetworkInventorySpec `json:"networkInventory,omitempty"`
125+
122126
// ExternalClusters defines remote K8s clusters to scan from this operator instance.
123127
// Each external cluster will have its own CronJob created with the appropriate kubeconfig.
124128
// +optional
@@ -157,6 +161,99 @@ type ResourceWatcherSpec struct {
157161
ResourceTypes []string `json:"resourceTypes,omitempty"`
158162
}
159163

164+
// NetworkInventorySpec configures extended Kubernetes network posture inventory.
165+
type NetworkInventorySpec struct {
166+
// Enable enables extended network inventory options in the Kubernetes scanner inventory.
167+
Enable bool `json:"enable,omitempty"`
168+
169+
// HBN configures collection hints for HBN network resources.
170+
HBN HBNNetworkInventorySpec `json:"hbn,omitempty"`
171+
172+
// MultiNetworkPolicy configures collection hints for secondary-interface NetworkPolicy resources.
173+
MultiNetworkPolicy MultiNetworkPolicyInventorySpec `json:"multiNetworkPolicy,omitempty"`
174+
175+
// Classifications configures custom CIDR classifications used by network posture resources.
176+
Classifications NetworkInventoryClassifications `json:"classifications,omitempty"`
177+
178+
// ObservedFlows configures optional flow evidence integrations.
179+
ObservedFlows ObservedFlowsSpec `json:"observedFlows,omitempty"`
180+
}
181+
182+
// HBNNetworkInventorySpec configures HBN network inventory collection hints.
183+
type HBNNetworkInventorySpec struct {
184+
// Enable enables HBN resource collection hints when network inventory is enabled.
185+
// +kubebuilder:default=true
186+
Enable *bool `json:"enable,omitempty"`
187+
188+
// IncludeLegacyResources includes legacy Telekom HBN API groups in addition to current HBN resources.
189+
// +kubebuilder:default=true
190+
IncludeLegacyResources *bool `json:"includeLegacyResources,omitempty"`
191+
}
192+
193+
// MultiNetworkPolicyInventorySpec configures secondary-interface NetworkPolicy collection hints.
194+
type MultiNetworkPolicyInventorySpec struct {
195+
// Enable enables MultiNetworkPolicy and NetworkAttachmentDefinition collection hints when network inventory is enabled.
196+
// +kubebuilder:default=true
197+
Enable *bool `json:"enable,omitempty"`
198+
}
199+
200+
// NetworkInventoryClassifications configures CIDR classification overrides.
201+
type NetworkInventoryClassifications struct {
202+
// PublicCIDRs are CIDR ranges treated as public exposure ranges.
203+
// +optional
204+
PublicCIDRs []string `json:"publicCidrs,omitempty"`
205+
206+
// PrivateCIDRs are CIDR ranges treated as private/internal ranges.
207+
// +optional
208+
PrivateCIDRs []string `json:"privateCidrs,omitempty"`
209+
210+
// TrustedEgressCIDRs are CIDR ranges treated as approved egress destinations.
211+
// +optional
212+
TrustedEgressCIDRs []string `json:"trustedEgressCidrs,omitempty"`
213+
}
214+
215+
// ObservedFlowsSpec configures optional network-flow evidence integrations.
216+
type ObservedFlowsSpec struct {
217+
// Enable enables observed flow metadata collection. Endpoint sources remain individually opt-in;
218+
// when no endpoint is enabled, the scanner receives observedFlows.enabled=true without a flow source.
219+
Enable bool `json:"enable,omitempty"`
220+
221+
// MaxRecords limits flow records collected per scan.
222+
// +kubebuilder:validation:Minimum=1
223+
// +kubebuilder:default=1000
224+
MaxRecords int `json:"maxRecords,omitempty"`
225+
226+
// Lookback limits how far back flow integrations may query.
227+
// +kubebuilder:default="5m"
228+
// +kubebuilder:validation:XValidation:rule="self.matches('^([0-9]+(\\\\.[0-9]+)?(ns|us|ms|s|m|h))+$')",message="lookback must be a Go duration such as 5m or 10s"
229+
Lookback metav1.Duration `json:"lookback,omitempty"`
230+
231+
// Timeout limits each flow integration query.
232+
// +kubebuilder:default="10s"
233+
// +kubebuilder:validation:XValidation:rule="self.matches('^([0-9]+(\\\\.[0-9]+)?(ns|us|ms|s|m|h))+$')",message="timeout must be a Go duration such as 5m or 10s"
234+
Timeout metav1.Duration `json:"timeout,omitempty"`
235+
236+
// CalicoWhisker configures optional Calico Whisker flow metadata.
237+
CalicoWhisker FlowEndpointSpec `json:"calicoWhisker,omitempty"`
238+
239+
// CiliumHubble configures optional Cilium Hubble flow metadata.
240+
CiliumHubble FlowEndpointSpec `json:"ciliumHubble,omitempty"`
241+
}
242+
243+
// FlowEndpointSpec configures a namespaced Kubernetes Service endpoint for observed flow metadata.
244+
type FlowEndpointSpec struct {
245+
// Enable enables this flow endpoint.
246+
Enable bool `json:"enable,omitempty"`
247+
248+
// Namespace is the namespace that contains the flow endpoint Service.
249+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
250+
Namespace string `json:"namespace,omitempty"`
251+
252+
// ServiceName is the flow endpoint Service name.
253+
// +kubebuilder:validation:Pattern=`^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`
254+
ServiceName string `json:"serviceName,omitempty"`
255+
}
256+
160257
// ExternalCluster defines configuration for scanning a remote K8s cluster
161258
type ExternalCluster struct {
162259
// Name is a unique identifier for this cluster (used in resource names).

api/v1alpha2/zz_generated.deepcopy.go

Lines changed: 129 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)