Level 7 / Project 13 - Service Account Policy Check¶
Home: README
Learn Your Way¶
| Read | Build | Watch | Test | Review | Visualize | Try |
|---|---|---|---|---|---|---|
| — | This project | — | — | Flashcards | — | — |
Focus¶
- account usage compliance checks
Why this project exists¶
This project gives you level-appropriate practice in a realistic operations context. Goal: run the baseline, alter behavior, break one assumption, recover safely, and explain the fix.
Run (copy/paste)¶
Use <repo-root> as the folder containing this repository's README.md.
cd <repo-root>/projects/level-7/13-service-account-policy-check
python project.py --input data/sample_input.txt --output data/output_summary.json
pytest -q
Expected terminal output¶
Expected artifacts¶
data/output_summary.json- Passing tests
- Updated
notes.md
Alter it (required)¶
- Add an
"inactive_days"rule that flags accounts not used within N days. - Add a
remediation_suggestionfield to each Violation (e.g. "rotate key" or "reduce permissions"). - Re-run script and tests — verify new rule and suggestions appear in the compliance report.
Break it (required)¶
- Provide a naming pattern with invalid regex syntax (e.g.
"[invalid") and observe the crash. - Set
key_created_atto a timestamp in the far future and see negative key age. - Capture the
re.erroror confusing "key is -100 days old" message.
Fix it (required)¶
- Wrap
re.match()in a try/except forre.errorand report "invalid pattern" as a violation. - Clamp negative key ages to zero (future timestamps mean "just rotated").
- Add tests for invalid regex patterns and future key timestamps.
Explain it (teach-back)¶
- Why is least-privilege important for service accounts?
- What happened when the regex pattern was malformed?
- How did the try/except prevent a full pipeline crash on one bad rule?
- How do real cloud platforms (AWS IAM, GCP) enforce service account policies?
Mastery check¶
You can move on when you can: - run baseline without docs, - explain one core function line-by-line, - break and recover in one session, - keep tests passing after your change.
Related Concepts¶
| ← Prev | Home | Next → |
|---|---|---|