Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1API_KEY = "sk_live_51Hx9Zq" | AThe token is hard-coded in the source file and relying on remembering to remove it later is unsafe. Once committed or pushed, it stays in the history and can be stolen. | |
| 2git push origin main | BPublishes commits to a remote repository, so any key committed earlier is now visible to everyone with access to that repository | |
| 3Deleting a file that contains a key in a later commit is not enough, because the old commit history still holds the key | CA hard-coded secret: a live API key typed straight into the source code, where anyone who can read the code can copy it | |
| 4A password committed to a repository can be stolen by anyone who can read it, including the public if the repository is public | Dgit rm config.py && git commit -m "remove key" | |
| 5token = "ghp_a8Kd92Lx" # remove before pushing later | EDeleting the file in a new commit does not remove the keys from earlier commits, so a leaked key can still be found in the history and must be revoked. | |
| 6git rm secrets.txt git commit -m "deleted keys" | Fdb_password = "Summer2024!" |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
hard-coded secret — A key, password or token written directly into source code. Anyone who can read the code or its repository can steal it, and deleting the file later does not remove it from the history.const apiKey = "sk_live_abc123";
fetch(url + "?key=" + apiKey);git add config.py
git commit -m "Add API key"# Public repo: key is now visible
git push origin maingit rm config.py
git commit -m "Remove key"
git log -pecho "config.py" >> .gitignore