Skip to content

Commit

Permalink
feat(plugins/k8saudit): extract pod name
Browse files Browse the repository at this point in the history
Signed-off-by: Sanja Kosier <[email protected]>
  • Loading branch information
Sanja Kosier authored and poiana committed May 21, 2024
1 parent 1a559ef commit ab63a13
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugins/k8saudit/pkg/k8saudit/extract.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ func (e *Plugin) ExtractFromJSON(req sdk.ExtractRequest, jsonValue *fastjson.Val
return e.extractFromKeys(req, jsonValue, "objectRef", "resource")
case "ka.target.subresource":
return e.extractFromKeys(req, jsonValue, "objectRef", "subresource")
case "ka.target.pod.name":
resource := string(jsonValue.Get("objectRef").Get("resource").GetStringBytes())
if resource == "pods" {
subresource := string(jsonValue.Get("objectRef").Get("subresource").GetStringBytes())
if subresource == "" {
// if pods; return pod name
return e.extractFromKeys(req, jsonValue, "responseObject", "metadata", "name")
}
}
case "ka.req.binding.subjects":
return e.extractFromKeys(req, jsonValue, "requestObject", "subjects")
case "ka.req.binding.role":
Expand Down

0 comments on commit ab63a13

Please sign in to comment.