Nmap is the standard for network reconnaissance and vulnerability discovery. Pre-commit hooks run checks before code leaves your machine. When combined, you get an automated guard that scans for open ports, misconfigured services, and weak network exposure—before changes land in your repository.
Here’s how it works.
- Install Nmap on your local environment.
- Set up a pre-commit framework such as
pre-commitorhusky. - Write a hook script that calls Nmap against defined targets—internal dev environments, staging systems, or containers you spin up for testing.
- Parse Nmap’s output to fail the commit if risky ports or services are detected.
This approach keeps dangerous configurations from reaching production. It catches exposed databases, forgotten admin panels, and insecure protocols early. It also enforces consistent security checks across your team without relying on manual scans.