Skip to content

Commit

Permalink
Fix functions
Browse files Browse the repository at this point in the history
Signed-off-by: jnathangreeg <jonathang@armosec.io>
  • Loading branch information
jnathangreeg committed Aug 25, 2024
1 parent b9e6834 commit 5585a50
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 19 deletions.
16 changes: 0 additions & 16 deletions admission/rules/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,3 @@ func GetContainerNameFromExecToPodEvent(event admission.Attributes) string {
}
return ""
}

// GetContainerNameFromPortForwardEvent returns the container name from the admission event for port-forward operations.
func GetContainerNameFromPortForwardEvent(event admission.Attributes) string {
if event.GetSubresource() == "portforward" {
if obj := event.GetObject(); obj != nil {
if unstructuredObj, ok := obj.(*unstructured.Unstructured); ok {
if object, ok := unstructuredObj.Object["object"].(map[string]interface{}); ok {
if containerName, ok := object["container"].(string); ok {
return containerName
}
}
}
}
}
return ""
}
3 changes: 0 additions & 3 deletions admission/rules/v1/r2001_portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ func (rule *R2001PortForward) ProcessEvent(event admission.Attributes, access in
logger.L().Error("Failed to get parent workload details", helpers.Error(err))
return nil
}
containerName := GetContainerNameFromPortForwardEvent(event)

ruleFailure := GenericRuleFailure{
BaseRuntimeAlert: apitypes.BaseRuntimeAlert{
AlertName: rule.Name(),
Expand Down Expand Up @@ -114,7 +112,6 @@ func (rule *R2001PortForward) ProcessEvent(event admission.Attributes, access in
WorkloadNamespace: workloadNamespace,
WorkloadKind: workloadKind,
NodeName: nodeName,
ContainerName: containerName,
},
RuleID: R2001ID,
}
Expand Down

0 comments on commit 5585a50

Please sign in to comment.