mirror of
https://github.com/gravitl/netmaker.git
synced 2026-04-22 16:07:11 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user