Skip to content

About

NetConfigGuard is a Python security research prototype that scans SSH, firewall, Nginx, Docker Compose, and Kubernetes configurations for misconfigurations. It combines rule-based checks with optional Gemini-assisted analysis, de-duplicates findings, suggests fixes, and generates CSV reports, summaries, charts, prompts, and tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

NetConfigGuard

Model-Assisted Verification and Repair of LLM-Generated Network Security Configurations

NetConfigGuard is a Python research prototype for scanning LLM-generated network and security configuration files. It checks SSH, firewall, Nginx, Docker Compose, and Kubernetes configurations for insecure settings using a rule-based verifier and an optional model-assisted analyzer.

Requirements

  • Python 3.10 or newer
  • Dependencies listed in requirements.txt

Install the project dependencies from the project root:

pip install -r requirements.txt

Quick Start

The recommended workflow for grading is:

pip install -r requirements.txt
python -m src.main --model-mode manual
python -m src.evaluate
python -m pytest tests

Optional Gemini verification

python -m src.main --model-mode gemini --gemini-model gemini-2.5-flash --gemini-limit 1
python -m src.evaluate

Usage

Run the default prompt mode

python -m src.main --model-mode prompt

Run manual model-output mode

python -m src.main --model-mode manual

Run Gemini API mode

Run Gemini API mode with the model used in the final report:

python -m src.main --model-mode gemini --gemini-model gemini-2.5-flash

To limit the run to a smaller number of files:

python -m src.main --model-mode gemini --gemini-model gemini-2.5-flash --gemini-limit 3

Regenerate evaluation results

python -m src.evaluate

Run tests

python -m pytest tests

Gemini API Setup

Gemini mode requires an API key stored in the GEMINI_API_KEY environment variable.

Windows PowerShell

$env:GEMINI_API_KEY="your_api_key_here"

macOS/Linux

export GEMINI_API_KEY="your_api_key_here"

Gemini API mode is optional. If the key, quota, or model is unavailable, prompt mode and manual mode still work.

Model note

The final report uses gemini-2.5-flash. Do not use gemini-1.5-flash unless it is available in the current Gemini API, because it was not available during the final project run.

Output Files

After the project runs, generated outputs are written to the results/ directory:

results/rule_findings.csv
results/model_findings.csv
results/hybrid_findings.csv
results/summary.csv
results/issues_by_config_type.png
results/issues_by_severity.png

Project Structure

data/configs/                 Sample configuration files
data/prompts/prompts.csv      Baseline and security-aware prompts
data/model_outputs/           Manual model-output JSON file
src/                          Source code
tests/                        Rule-checker tests
results/                      Generated CSV files, charts, and prompts
README.md                     Project documentation
requirements.txt              Python dependencies

Expected Behavior

When run successfully, NetConfigGuard should:

  • Scan 30 sample configuration files.
  • Generate rule-based findings.
  • Load manual model findings or use Gemini API mode when configured.
  • Produce hybrid findings with de-duplication.
  • Generate a summary CSV and two result charts.
  • Pass the project test suite.

About

NetConfigGuard is a Python security research prototype that scans SSH, firewall, Nginx, Docker Compose, and Kubernetes configurations for misconfigurations. It combines rule-based checks with optional Gemini-assisted analysis, de-duplicates findings, suggests fixes, and generates CSV reports, summaries, charts, prompts, and tests.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages