Skip to content

Commit

Permalink
feat: Support PodSecurityPolicy relationship (via Pods)
Browse files Browse the repository at this point in the history
Signed-off-by: Justin Toh <[email protected]>
  • Loading branch information
tohjustin committed Oct 15, 2021
1 parent 999ec43 commit c707036
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/graph/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const (
RelationshipPodNode Relationship = "PodNode"
RelationshipPodPriorityClass Relationship = "PodPriorityClass"
RelationshipPodRuntimeClass Relationship = "PodRuntimeClass"
RelationshipPodSecurityPolicy Relationship = "PodSecurityPolicy"
RelationshipPodVolume Relationship = "PodVolume"
RelationshipPodVolumeCSIDriver Relationship = "PodVolumeCSIDriver"
RelationshipPodVolumeCSIDriverSecret Relationship = "PodVolumeCSIDriverSecret" //nolint:gosec
Expand Down Expand Up @@ -518,6 +519,15 @@ func getPodRelationships(n *Node) (*RelationshipMap, error) {
result.AddDependencyByKey(ref.Key(), RelationshipPodRuntimeClass)
}

// RelationshipPodSecurityPolicy
// Hardcode "k8s.io/kubernetes/pkg/security/podsecuritypolicy/util.ValidatedPSPAnnotation"
// as "kubernetes.io/psp" so we don't need import the entire k8s.io/kubernetes
// package
if psp, ok := pod.Annotations["kubernetes.io/psp"]; ok {
ref = ObjectReference{Group: "policy", Kind: "PodSecurityPolicy", Name: psp}
result.AddDependencyByKey(ref.Key(), RelationshipPodSecurityPolicy)
}

// RelationshipPodVolume
// RelationshipPodVolumeCSIDriver
// RelationshipPodVolumeCSIDriverSecret
Expand Down

0 comments on commit c707036

Please sign in to comment.