Skip to content

Querying out specific env vars defined in Kubernetes workloads #116

Closed Answered by arlimus
tas50 asked this question in Q&A
Discussion options

You must be logged in to vote

Great question! The recommended way to approach these is to find a check that works well for one item and then translate it to apply to all of them.

1. Check for dangerous ENV variables

Given any one container (like the one you used in your example), we can write a query to look at its properties like so:

k8s.pods[0].containers[0] {
   ...
}

This check can now be written with the new env field. Let's look for the two you have in your example: LOGIN and PASSWORD and make sure that neither is set:

k8s.pods[0].containers[0] {
   env["LOGIN"] == null && env["PASSWORD"] == null
}

2. Applying it to all assets

Now that we have the assertion, we can apply this to all assets. In your case, you are…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tas50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants