51/71
Sign inSign up free

825. Mask Secrets in the Job Log

hard 40 XP ~12 minHands-on lab

The deploy job of data-pipeline pipes its output through scripts/mask.sh (in /home/student/repos/data-pipeline), which should replace the values of the secret variables named in MASK_VARS with ***. Yesterday the log showed the database password in clear text, and another job failed with sed: -e expression #1, char 16: unknown option to 's'.

Task

Fix scripts/mask.sh so that it copies stdin to stdout and:

  • replaces every occurrence of the value of each variable named in MASK_VARS (space-separated) with ***,
  • treats values literally: they may contain / . * & \ $ | @ and spaces, and text that merely looks similar must not be touched,
  • when one secret contains another, the longer one is masked as a whole (no ***-extra leftovers),
  • skips variables that are unset, empty or shorter than 6 characters,
  • passes everything through unchanged when MASK_VARS is unset.

About this machine

Ubuntu 24.04 with no internet access. You are student with passwordless sudo. The grader checks the final state of the machine, not the commands you typed. Values like names and ports are generated for you.

Teaching or writing about this? Embed this lab on your page

TerminalNot started

Your machine is ready to start

A fresh, isolated Ubuntu machine boots in a few seconds with the task already set up.

No account needed: 3 of 3 free tries left. Guest machines last 30 minutes.