Skip to content

Commit 2a3f2d2

Browse files
authored
feat(shield): use secure_light for netsec_enabled (#2233)
1 parent e0cb546 commit 2a3f2d2

File tree

3 files changed

+61
-2
lines changed

3 files changed

+61
-2
lines changed

charts/shield/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ maintainers:
1313
- name: mavimo
1414
1515
type: application
16-
version: 1.4.0
16+
version: 1.4.1
1717
appVersion: "1.0.0"

charts/shield/templates/host/_configmap_helpers.tpl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@
4343
{{- $config | toYaml }}
4444
{{- end }}
4545
46+
{{/* Check if semver. The regex is from the code of the library Helm uses for semver. */}}
47+
{{- define "shield.is_semver" -}}
48+
{{- if regexMatch "^v?([0-9]+)(\\.[0-9]+)?(\\.[0-9]+)?(-([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?(\\+([0-9A-Za-z\\-]+(\\.[0-9A-Za-z\\-]+)*))?$" . }}
49+
true
50+
{{- end -}}
51+
{{- end -}}
52+
4653
{{- define "host.features.netsec_enabled" }}
4754
{{- if or .Values.features.investigations.network_security.enabled
4855
(dig "network_topology" "enabled" false .Values.host.additional_settings) }}
@@ -66,7 +73,7 @@ true
6673
{{/* Calculate the agent mode based on enabled features */}}
6774
{{- define "host.configmap.agent_mode" }}
6875
{{- $mode := "secure_light" }}
69-
{{- if (include "host.features.netsec_enabled" .) }}
76+
{{- if and (include "host.features.netsec_enabled" .) (include "shield.is_semver" .Values.host.image.tag) (semverCompare "< 13.9.0" .Values.host.image.tag) }}
7077
{{- $mode = "secure" }}
7178
{{- end }}
7279
{{- if (include "host.features.monitor_enabled" .) }}

charts/shield/tests/host/configmap-dragent-yaml_test.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,26 +983,78 @@ tests:
983983
investigations:
984984
network_security:
985985
enabled: true
986+
host:
987+
image:
988+
tag: 13.8.0
986989
asserts:
987990
- matchRegex:
988991
path: data['dragent.yaml']
989992
pattern: |
990993
feature:
991994
mode: secure
992995
996+
- it: Test enabling NetSec does not flip agent to secure mode for unknown version
997+
set:
998+
features:
999+
investigations:
1000+
network_security:
1001+
enabled: true
1002+
host:
1003+
image:
1004+
tag: notAVersion
1005+
asserts:
1006+
- matchRegex:
1007+
path: data['dragent.yaml']
1008+
pattern: |
1009+
feature:
1010+
mode: secure_light
1011+
1012+
- it: Test enabling NetSec does not flip agent to secure mode for 13.9.0
1013+
set:
1014+
features:
1015+
investigations:
1016+
network_security:
1017+
enabled: true
1018+
host:
1019+
image:
1020+
tag: 13.9.0
1021+
asserts:
1022+
- matchRegex:
1023+
path: data['dragent.yaml']
1024+
pattern: |
1025+
feature:
1026+
mode: secure_light
1027+
9931028
- it: Test enabling NetSec in additional_settings flips agent to secure mode
9941029
set:
9951030
host:
9961031
additional_settings:
9971032
network_topology:
9981033
enabled: true
1034+
image:
1035+
tag: 13.8.0
9991036
asserts:
10001037
- matchRegex:
10011038
path: data['dragent.yaml']
10021039
pattern: |
10031040
feature:
10041041
mode: secure
10051042
1043+
- it: Test enabling NetSec in additional_settings does not flip agent to secure mode for 13.9.0
1044+
set:
1045+
host:
1046+
additional_settings:
1047+
network_topology:
1048+
enabled: true
1049+
image:
1050+
tag: 13.9.0
1051+
asserts:
1052+
- matchRegex:
1053+
path: data['dragent.yaml']
1054+
pattern: |
1055+
feature:
1056+
mode: secure_light
1057+
10061058
- it: Test enabling a monitor feature forces agent mode to monitor
10071059
set:
10081060
features:

0 commit comments

Comments
 (0)