Skip to content

Commit a136bf0

Browse files
committed
fix code reviews
1 parent 9b1f900 commit a136bf0

2 files changed

Lines changed: 23 additions & 27 deletions

File tree

test/e2e/operator/tls/e2e_test.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,18 @@ var _ = Describe("[E2E][Operator][TLS] TLS Scanner Validation", func() {
2323
)
2424

2525
var (
26-
e2e *framework.E2ETestFramework
27-
clf *obs.ClusterLogForwarder
28-
l *loki.Receiver
29-
lokiNS string
30-
scannerNS string
31-
sa *corev1.ServiceAccount
32-
err error
33-
skipTLSScanner bool
26+
e2e *framework.E2ETestFramework
27+
clf *obs.ClusterLogForwarder
28+
l *loki.Receiver
29+
lokiNS string
30+
scannerNS string
31+
sa *corev1.ServiceAccount
32+
err error
3433
)
3534

3635
BeforeEach(func() {
3736
e2e = framework.NewE2ETestFramework()
3837

39-
// Check if TLS Scanner image is available
40-
if tlsscanner.GetImage() == "" {
41-
skipTLSScanner = true
42-
Skip("TLS Scanner image not available")
43-
}
44-
4538
lokiNS = e2e.CreateTestNamespace()
4639
scannerNS = e2e.CreateTestNamespace()
4740

@@ -116,10 +109,6 @@ var _ = Describe("[E2E][Operator][TLS] TLS Scanner Validation", func() {
116109
})
117110

118111
AfterEach(func() {
119-
if skipTLSScanner {
120-
return
121-
}
122-
123112
e2e.Cleanup()
124113
}, framework.DefaultCleanUpTimeout)
125114

test/framework/e2e/tls/scanner.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ func (s *Scanner) Deploy(scannerNamespace, targetNamespace string) (*batchv1.Job
117117
// Create the Job
118118
backoffLimit := int32(0)
119119
ttlSecondsAfterFinished := int32(600) // Keep job for 10 minutes after completion
120-
privileged := true
121120

122121
job := &batchv1.Job{
123122
ObjectMeta: metav1.ObjectMeta{
@@ -140,9 +139,8 @@ func (s *Scanner) Deploy(scannerNamespace, targetNamespace string) (*batchv1.Job
140139
"-csv-file", "/tmp/scan-results.csv",
141140
"-j", "4", // Use 4 concurrent threads
142141
},
143-
SecurityContext: &corev1.SecurityContext{
144-
Privileged: &privileged,
145-
},
142+
// No privileged mode needed - using default "pod" scan mode
143+
// which scans running pods' TLS ports, not host ports
146144
},
147145
},
148146
},
@@ -332,7 +330,7 @@ func ValidateCompliance(results []ScanResult, profileSpec configv1.TLSProfileSpe
332330
return nil
333331
}
334332

335-
// containsTLSVersion checks if the TLS versions string contains at least the minimum required version
333+
// containsTLSVersion checks if all TLS versions meet the minimum required version
336334
func containsTLSVersion(tlsVersions, minVersion string) bool {
337335
// If no TLS versions detected, fail validation
338336
if tlsVersions == "" {
@@ -346,16 +344,25 @@ func containsTLSVersion(tlsVersions, minVersion string) bool {
346344
return true
347345
}
348346

349-
// Check if any of the supported versions meets the minimum
347+
// Check that ALL supported versions meet the minimum
350348
versions := strings.Split(tlsVersions, ",")
349+
foundVersion := false
351350
for _, v := range versions {
352351
v = strings.TrimSpace(v)
353-
if vNum := parseTLSVersion(v); vNum >= minVersionNum {
354-
return true
352+
vNum := parseTLSVersion(v)
353+
if vNum == 0 {
354+
// Skip unparseable versions
355+
continue
356+
}
357+
foundVersion = true
358+
if vNum < minVersionNum {
359+
// Found a version below the minimum - fail validation
360+
return false
355361
}
356362
}
357363

358-
return false
364+
// Return true only if we found at least one version and none were below minimum
365+
return foundVersion
359366
}
360367

361368
// parseTLSVersion converts TLS version string to a comparable number

0 commit comments

Comments
 (0)