S
Situation
Access to restricted content was controlled by an allow list of IP addresses in a text file. Revoked addresses had to be removed by hand, which is slow and easy to get wrong.
T
Task
Write an algorithm that removes revoked addresses automatically and reliably.
A
Action
- Read the file, split it into a list, removed each address on the remove list, and wrote the result back.
- Found and fixed a subtle bug. Removing items from a list while looping over it makes Python skip elements, which could silently leave revoked addresses in place.
- Turned the algorithm into a reusable function that validates IP addresses, uses fast set lookups, keeps the file's header and returns the removed addresses as an audit trail.
- Added a command-line script and four pytest tests, including a regression test for the bug.
R
Result
- All four revoked addresses were removed (17 → 13), and the tests confirmed it.
- Reused the logic as the allow-list tool in the SOC Analyst Toolkit.
