A developer asks to print a secret in the log "just once" to debug. What do you do instead?
BeginnerScenarioSecrets, OIDC & Environments
Answer
Situation read → Debugging a credential problem without exposure.
What I'd do →
- Check presence and shape without the value:
test -n "$TOKEN" && echo "len=${#TOKEN}", or compare a hash prefix:echo -n "$TOKEN" | sha256sum | cut -c1-8. - Test the credential against the API and print only the status code.
- If the value is wrong, rotate it and re-set with
gh secret set.
Why → Logs are readable by everyone with repo read access and are retained for 90 days.
Interview tip → "Verify shape and behaviour, never the value."
More on Secrets, OIDC & Environments
You find AWS access keys stored as repo secrets in 25 repos. Plan the migration.IntermediateStaging and prod need different database URLs and different AWS roles, using one workflow. How?BeginnerSecurity requires two people for prod deploys: the author cannot approve. Configure it.BeginnerWrite the AWS trust policy for a role used only by the prod deploy job of one repo.IntermediatePR workflows need read-only AWS access for `terraform plan`, including from same-repo branches. How do you set trust?AdvancedA team stores a 200 KB kubeconfig and certificates as secrets and hits the size limit. What do you recommend?Intermediate