Stop Leaking API Keys: Build a Secret Scanner in Python
I hid six fake keys in a project. My first scanner found three.
Video #90 ยท AI security and governance
Steps in the video
Files
- compare.py (19 lines)
- fix.py (11 lines)
- project.py (37 lines)
- scan.py (26 lines)
Tested with
Python 3.12.15
What this does not show
Six habits I chose and fake keys from a seeded generator; the three shapes are simplified and the entropy limit of 3.2 is a guess; real scanners were not compared; a key that was already pushed stays in the history and must be revoked and replaced.
Sources
Learning IT by Example.