Challenge, Easy,  on  CI/CDSecurity

In this challenge, you'll practice how to pass secrets to functions and use them within your code.

Preparation

To complete this challenge, ensure you have a Dagger module initialized at ~/my-module using your preferred SDK.

Passing secrets to functions

Implement a function named readSecret that takes a parameter of type secret called secret and simply returns it as-is.

In the following examples, you’ll call this function and pass secrets to it from various providers. To complete each challenge, enter the plaintext secret values into the appropriate input fields.

Hint 1 💡

Secret providers are documented here.

Hint 2 💡

The command you need to use:

dagger call read-secret --secret <???> plaintext

💡 plaintext method returns the plaintext value of the secret.

Hint 3 💡

Try addressing the secret: provider://identifier.

Environment variable MY_SECRET:

File ~/.secret:

Result of executing ~/secret.sh:

Read from Vault (running locally) from path my/secret (key: value):

Using secrets in containers

Implement a function named secretVar that accepts a parameter of type secret called secret, and returns an alpine container with the secret mounted as an environment variable named MY_SECRET.

Hint 4 💡

Take a look at this example.

Implement a function named secretMount that accepts a parameter of type secret called secret, and returns an alpine container with the secret mounted as a file at /tmp/secret.

Hint 5 💡

Take a look at this example.

References

Discussion:  Discord
Categories: CI/CDSecurity
Tags:  #dagger

Level up your Server Side game — Join 10,000 engineers who receive insightful learning materials straight to their inbox