NM-195: Add posture check feature flag (#3780)

* NM-195: fix posture check for untagged resources

* NM-195: reduce default cleanup interval

* NM-195: reduce default cleanup interval

* Add posture checks to feature flag
This commit is contained in:
Abhishek Kondur
2025-12-16 15:58:18 +04:00
committed by GitHub
parent ba9af3bfd6
commit 3e3d8c60a0
2 changed files with 10 additions and 0 deletions
+1
View File
@@ -25,6 +25,7 @@ type FeatureFlags struct {
EnableGwsHA bool `json:"enable_gws_ha"`
EnableDeviceApproval bool `json:"enable_device_approval"`
EnableFlowLogs bool `json:"enable_flow_logs"`
EnablePostureChecks bool `json:"enable_posture_checks"`
}
// AuthParams - struct for auth params
+9
View File
@@ -33,6 +33,9 @@ func AddPostureCheckHook() {
}
}
func RunPostureChecks() error {
if !GetFeatureFlags().EnablePostureChecks {
return nil
}
postureCheckMutex.Lock()
defer postureCheckMutex.Unlock()
nets, err := logic.GetNetworks()
@@ -82,6 +85,9 @@ func RunPostureChecks() error {
}
func CheckPostureViolations(d models.PostureCheckDeviceInfo, network models.NetworkID) ([]models.Violation, models.Severity) {
if !GetFeatureFlags().EnablePostureChecks {
return []models.Violation{}, models.SeverityUnknown
}
pcLi, err := (&schema.PostureCheck{NetworkID: network.String()}).ListByNetwork(db.WithContext(context.TODO()))
if err != nil || len(pcLi) == 0 {
return []models.Violation{}, models.SeverityUnknown
@@ -90,6 +96,9 @@ func CheckPostureViolations(d models.PostureCheckDeviceInfo, network models.Netw
return violations, level
}
func GetPostureCheckViolations(checks []schema.PostureCheck, d models.PostureCheckDeviceInfo) ([]models.Violation, models.Severity) {
if !GetFeatureFlags().EnablePostureChecks {
return []models.Violation{}, models.SeverityUnknown
}
var violations []models.Violation
highest := models.SeverityUnknown