Skip to content

Commit 1cd9be3

Browse files
committed
do not restrict with cluster name
Signed-off-by: Avraham Shalev <[email protected]>
1 parent 8af0838 commit 1cd9be3

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

exceptions/exceptionprocessor.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,16 +163,16 @@ func (p *Processor) hasException(clusterName string, designator *armotypes.Porta
163163
p.designatorCache.Set(designator, attributes)
164164
}
165165

166-
if attributes.GetCluster() == "" && attributes.GetNamespace() == "" && attributes.GetKind() == "" && attributes.GetName() == "" && attributes.GetPath() == "" && len(attributes.GetLabels()) == 0 {
166+
if attributes.GetCluster() == "" && attributes.GetNamespace() == "" && attributes.GetKind() == "" && attributes.GetName() == "" && attributes.GetResourceID() == "" && attributes.GetPath() == "" && len(attributes.GetLabels()) == 0 {
167167
return false // if designators are empty
168168
}
169169

170-
if attributes.GetCluster() != "" {
171-
if !p.compareCluster(attributes.GetCluster(), clusterName) { // TODO - where do we receive cluster name from?
172-
return false // cluster name does not match
173-
} else if attributes.GetResourceID() != "" && !p.compareResourceID(workload, attributes.GetResourceID()) { //resourceID is applicable only if cluster name is specified
174-
return false // names do not match
175-
}
170+
if attributes.GetCluster() != "" && !p.compareCluster(attributes.GetCluster(), clusterName) { // TODO - where do we receive cluster name from?
171+
return false // cluster name does not match
172+
}
173+
174+
if attributes.GetResourceID() != "" && !p.compareResourceID(workload, attributes.GetResourceID()) {
175+
return false // resourceID does not match
176176
}
177177

178178
if attributes.GetNamespace() != "" && !p.compareNamespace(workload, attributes.GetNamespace()) {

exceptions/exceptionprocessor_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,7 @@ func TestGetResourceExceptions(t *testing.T) {
182182

183183
exceptionPolicyResourceID := postureResourceIDExceptionPolicyMock(idObj.GetID())
184184
exceptionPolicyResourceIDRegex := postureResourceIDExceptionPolicyMock("*")
185-
exceptionPolicyResourceIDNoCluster := postureResourceIDExceptionPolicyMock(idObj.GetID())
186-
delete(exceptionPolicyResourceIDNoCluster.Resources[0].Attributes, armotypes.AttributeCluster)
185+
exceptionPolicyResourceOtherID := postureResourceIDExceptionPolicyMock("v1/core/default/ConfigMap/test")
187186

188187
exceptionPolicy := postureLabelsRegexExceptionPolicyAlertOnlyMock()
189188
exceptionPolicyRegex := postureLabelsRegexExceptionPolicyAlertOnlyMock()
@@ -246,8 +245,8 @@ func TestGetResourceExceptions(t *testing.T) {
246245
expectedExceptionsCount: 1,
247246
},
248247
{
249-
desc: "exception by ID with no cluster",
250-
exceptionPolicy: exceptionPolicyResourceIDNoCluster,
248+
desc: "exception with not matching ID",
249+
exceptionPolicy: exceptionPolicyResourceOtherID,
251250
workloadObj: idObj,
252251
expectedExceptionsCount: 0,
253252
},

0 commit comments

Comments
 (0)