How sidharathbansal/nsg-security-check works
Project Type & Purpose
• This is a utility project built with Bash scripts that leverage the Azure CLI to audit and clean up Azure Network Security Groups (NSGs).
• Its main functions are scanning NSGs for security risks (e.g., open ports like 22, 3389, 27017 and rules allowing access from anywhere) and cleaning up unused NSGs.
Analyzing the File Structure
• The project is very lightweight and consists of three files:
• README.md: Contains the project overview and instructions.
• nsg_audit.sh: A script to scan for risky NSG configurations.
• nsg_cleanup.sh: A script to remove unassigned NSGs.
• The absence of complex directories indicates that the architecture is script-based and not layered as in full-stack or microservices designs.
Main Components
a. Azure CLI and Authentication:
• A component representing the Azure CLI tool, including prerequisites like being logged in and necessary permissions.
b. NSG Audit Script:
• Nsg_audit.sh as a component that orchestrates scanning of NSGs.
c. NSG Cleanup Script:
• Nsg_cleanup.sh as a component that automates deletion.
• Similarly, show its interaction with the Azure API to remove unassigned NSGs.
d. Azure NSG Resources:
• Azure NSGs as external resources that are queried and/or manipulated by the scripts.
e. Data Flow & Feedback:
• That after scanning, feedback is provided to the user (e.g., listing vulnerable NSGs), and then cleanup actions are performed.
Relationships and Interactions
• How each script invokes the Azure CLI.
• Data retrieval from Azure NSG resources.
• The decision or conditional flows (e.g., identifying rules with open ports and unassigned NSGs).
Architectural Patterns & Design Principles
• Separation of concerns: One script focuses on auditing while the other performs cleanup.
• Direct interaction with external systems (Azure).
• The use of automation to maintain security hygiene.
• Even though it’s simple, it emphasizes modularity by keeping audit and cleanup functionality separated.
Relevant Technologies & Tools
• Azure CLI: Mention that it is central to executing commands against the Azure environment.
• Bash Scripting: The underlying technology of both scripts.
• Azure Network Security Groups (NSGs): The target resources being managed.