Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ SafetyScan

Automated Security Scanning Tool for Linux

License: MIT Platform Bash Docker Semgrep OWASP ZAP

Comprehensive SAST & DAST security testing in one powerful command

Features β€’ Installation β€’ Usage β€’ Documentation β€’ Contributing


πŸ“– About

SafetyScan is a powerful, automated security scanning tool designed exclusively for Linux environments. It combines the best of both worlds by seamlessly integrating Static Application Security Testing (SAST) and Dynamic Application Security Testing (DAST) to provide comprehensive vulnerability detection for your applications.

⚠️ Linux Only: This tool is built specifically for Linux systems and requires a Linux environment to function properly.

Why SafetyScan?

  • πŸ”„ Two-in-One Solution: Combine SAST and DAST in a single tool
  • 🐳 Isolated Testing: Docker-based containers ensure clean, reproducible scans
  • πŸ“Š Actionable Reports: Get detailed HTML and JSON reports you can actually use
  • ⚑ Developer-Friendly: Simple CLI interface, complex security analysis
  • πŸ†“ Open Source: Free, transparent, and community-driven

✨ Features

πŸ” Static Analysis (SAST)

  • Powered by Semgrep
  • Source code vulnerability detection
  • Insecure coding pattern identification
  • Multi-language support
  • Zero false-positive ruleset

πŸš€ Dynamic Analysis (DAST)

  • Powered by OWASP ZAP
  • Runtime vulnerability testing
  • Active security scanning
  • API endpoint testing
  • Configuration issue detection

🎯 Core Capabilities

  • βœ… Automatic Detection: Identifies project types and dependencies
  • βœ… Flexible Execution: Run SAST, DAST, or both simultaneously
  • βœ… Docker Integration: Containerized scans for security and consistency
  • βœ… Rich Reporting: Multiple report formats (HTML, JSON, TXT)
  • βœ… Easy Setup: Single installation script, global command access
  • βœ… Language Agnostic: Supports Node.js, Python, Java, Go, Ruby, PHP, and more

πŸ’» System Requirements

Minimum Requirements

Component Requirement
Operating System Linux (Ubuntu 18.04+, Debian 10+, CentOS 7+, Fedora 30+, Arch Linux)
Architecture x86_64 (64-bit)
RAM 2 GB minimum, 4 GB recommended
Disk Space 5 GB free space
Docker Version 20.10+
Shell Bash 4.0+
Python Python 3.6+ (optional, for comprehensive reports)

Tested Distributions

  • βœ… Ubuntu 20.04 LTS / 22.04 LTS / 24.04 LTS
  • βœ… Debian 10 (Buster) / 11 (Bullseye) / 12 (Bookworm)
  • βœ… CentOS 7 / 8 / Stream
  • βœ… Fedora 35+
  • βœ… Arch Linux
  • βœ… Linux Mint 20+

Optional Dependencies

Component Purpose Installation
Python 3 Generate comprehensive HTML/MD reports sudo apt install python3 (Ubuntu/Debian)
jq Enhanced JSON parsing in summaries sudo apt install jq (Ubuntu/Debian)

πŸ“₯ Installation

Step 1: Install Docker

Docker is required for SafetyScan to function. Choose your distribution:

Ubuntu / Debian
# Update package index
sudo apt-get update

# Install prerequisites
sudo apt-get install -y \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

# Add Docker's official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Set up stable repository
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Install Docker Engine
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io

# Verify installation
sudo docker --version
CentOS / RHEL / Fedora
# Remove old versions (if any)
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

# Install required packages
sudo yum install -y yum-utils

# Add Docker repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

# Install Docker Engine
sudo yum install -y docker-ce docker-ce-cli containerd.io

# Start Docker
sudo systemctl start docker
sudo systemctl enable docker

# Verify installation
sudo docker --version
Arch Linux
# Install Docker
sudo pacman -S docker

# Start and enable Docker service
sudo systemctl start docker.service
sudo systemctl enable docker.service

# Verify installation
sudo docker --version

Post-Installation: Add User to Docker Group

Run Docker commands without sudo:

# Add your user to the docker group
sudo usermod -aG docker $USER

# Apply changes (log out and back in, or run)
newgrp docker

# Verify - this should work without sudo
docker run hello-world

Step 2: Install SafetyScan

# Clone the repository
git clone https://github.com/IsMohit/SafetyScan-Automated-Security-Scanning-Tool-for-Linux-.git

# Navigate to directory
cd SafetyScan-Automated-Security-Scanning-Tool-for-Linux-

# Make install script executable
chmod +x install.sh

# Run installation (may require sudo)
./install.sh

Step 3: Verify Installation

# Check if safetyscan is accessible
safetyscan --help

# Should display usage information

Optional: Install jq for Enhanced JSON Parsing

# Ubuntu/Debian
sudo apt-get install jq

# CentOS/RHEL/Fedora
sudo yum install jq

# Arch Linux
sudo pacman -S jq

πŸš€ Usage

Basic Syntax

safetyscan <project_path> --mode [sast|dast|both] [OPTIONS]

Command-Line Options

Option Description Required Example
<project_path> Path to your project directory βœ… Yes ./myapp
--mode Scan type: sast, dast, or both βœ… Yes --mode both
--start Command to start your application ⚠️ DAST only --start "npm start"
--port Application port number ⚠️ DAST only --port 3000
-h, --help Display help information ❌ No -h

πŸ“š Usage Examples

Example 1: Static Analysis Only

Perfect for code review before runtime testing:

safetyscan ./my-web-app --mode sast

What it does:

  • Analyzes source code for vulnerabilities
  • Identifies insecure coding patterns
  • Generates semgrep.json and semgrep-summary.txt

Example 2: Dynamic Analysis - Node.js Application

Test a running Node.js application:

safetyscan ./my-node-app --mode dast --start "npm install && npm start" --port 3000

What it does:

  • Installs dependencies and starts your app
  • Runs OWASP ZAP against http://localhost:3000
  • Generates HTML and JSON DAST reports

Example 3: Dynamic Analysis - Python Flask Application

Test a Flask web application:

safetyscan ./my-flask-app --mode dast --start "pip install -r requirements.txt && python app.py" --port 5000

Example 4: Dynamic Analysis - Java Spring Boot

Test a Spring Boot application:

safetyscan ./my-spring-app --mode dast --start "mvn spring-boot:run" --port 8080

Example 5: Complete Security Audit (SAST + DAST)

Run both static and dynamic analysis:

safetyscan ./my-application --mode both --start "npm install && npm start" --port 3000

What it does:

  1. βœ… Performs static code analysis (SAST)
  2. βœ… Starts your application in a container
  3. βœ… Runs dynamic security tests (DAST)
  4. βœ… Generates comprehensive reports for both

Example 6: React Application with Custom Port

safetyscan ./my-react-app --mode both --start "npm install && npm run start" --port 3001

Example 7: Django Application

safetyscan ./my-django-app --mode both --start "pip install -r requirements.txt && python manage.py runserver 0.0.0.0:8000" --port 8000

πŸ“‚ Report Structure

After scanning, all reports are saved in a timestamped directory:

<project_root>/
└── reports/
    └── <project_name>_YYYYMMDD_HHMMSS/
        β”œβ”€β”€ semgrep.json                          # Raw SAST output (machine-readable)
        β”œβ”€β”€ semgrep-summary.txt                   # SAST findings summary (human-readable)
        β”œβ”€β”€ zap-report.html                       # Full DAST report (browser-friendly)
        β”œβ”€β”€ zap-report.json                       # Raw DAST output (machine-readable)
        β”œβ”€β”€ zap-warnings.html                     # Critical DAST warnings (prioritized)
        β”œβ”€β”€ scan-summary.txt                      # Overall scan overview
        β”œβ”€β”€ comprehensive-security-report.html    # πŸ†• Comprehensive HTML report
        └── comprehensive-security-report.md      # πŸ†• Comprehensive Markdown report

πŸ†• Comprehensive Security Reports

SafetyScan now generates beautiful, detailed, and organized comprehensive reports that combine both SAST and DAST findings into a single, easy-to-read document!

Features of Comprehensive Reports:

  • πŸ“Š Executive Summary Dashboard - Visual overview of all findings by severity
  • 🎨 Professional Design - Beautiful HTML with gradient headers and color-coded severity badges
  • πŸ“‹ Table of Contents - Easy navigation through all findings
  • πŸ” Detailed Findings - Each vulnerability includes:
    • Severity level with color coding
    • Complete description and context
    • File location and line numbers (SAST)
    • Affected URLs (DAST)
    • CWE/OWASP mappings
    • Remediation guidance
    • Code snippets (when applicable)
  • πŸ’‘ Smart Recommendations - Prioritized action items based on findings
  • πŸ“š Security Resources - Links to OWASP, CWE, and documentation
  • πŸ–¨οΈ Print-Friendly - Optimized CSS for PDF export

Report Formats:

  1. HTML Report (comprehensive-security-report.html)

    • Open in any browser
    • Interactive and visually appealing
    • Perfect for sharing with stakeholders
    • Can be converted to PDF
  2. Markdown Report (comprehensive-security-report.md)

    • Text-based, version control friendly
    • Easy to include in documentation
    • Compatible with GitHub, GitLab, etc.
    • Simple to parse programmatically

Traditional Report Files

File Format Purpose Best For
semgrep.json JSON Complete SAST findings with metadata CI/CD integration, automated processing
semgrep-summary.txt Text Human-readable vulnerability summary Quick review, documentation
zap-report.html HTML Comprehensive DAST test results Detailed analysis, stakeholder reports
zap-report.json JSON Structured DAST findings Automation, tracking, dashboards
zap-warnings.html HTML High-priority vulnerabilities Immediate action items
scan-summary.txt Text Combined SAST + DAST overview Executive summary
comprehensive-security-report.html HTML πŸ†• Complete security analysis Primary report for all stakeholders
comprehensive-security-report.md Markdown πŸ†• Text-based full report Documentation, version control

πŸ”§ Technical Architecture

Report Generation Pipeline

SafetyScan uses a two-stage architecture for comprehensive reporting:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    Bash Script (safetyscan.sh)          β”‚
β”‚                                                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚  β”‚ SAST Scan    β”‚        β”‚ DAST Scan    β”‚               β”‚
β”‚  β”‚ (Semgrep)    β”‚        β”‚ (OWASP ZAP)  β”‚               β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚         β”‚                       β”‚                        β”‚
β”‚         β–Ό                       β–Ό                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚  semgrep.json     zap-report.json  β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚               β”‚                                          β”‚
β”‚               β–Ό                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚  Python Report Generator            β”‚                 β”‚
β”‚  β”‚  (report_generator.py)              β”‚                 β”‚
β”‚  β”‚                                      β”‚                 β”‚
β”‚  β”‚  β€’ Parses JSON outputs               β”‚                 β”‚
β”‚  β”‚  β€’ Categorizes by severity           β”‚                 β”‚
β”‚  β”‚  β€’ Generates statistics              β”‚                 β”‚
β”‚  β”‚  β€’ Creates beautiful HTML            β”‚                 β”‚
β”‚  β”‚  β€’ Exports Markdown                  β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚               β”‚                                          β”‚
β”‚               β–Ό                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                 β”‚
β”‚  β”‚  Comprehensive Reports              β”‚                 β”‚
β”‚  β”‚  β€’ HTML with CSS styling            β”‚                 β”‚
β”‚  β”‚  β€’ Markdown for documentation       β”‚                 β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Benefits of this architecture:

  • βœ… Modular design - each component can be updated independently
  • βœ… Language-specific strengths - Bash for orchestration, Python for data processing
  • βœ… Fallback support - Works even if Python is not available
  • βœ… Extensible - Easy to add new report formats or analysis tools

SAST Engine: Semgrep

Technology Semgrep - Open-source static analysis
Analysis Method Abstract Syntax Tree (AST) pattern matching
Language Support 30+ languages including JavaScript, TypeScript, Python, Java, Go, Ruby, PHP, C, C++, C#, Rust
Rulesets OWASP Top 10, CWE, custom security rules
Output Detailed vulnerability locations with severity ratings

DAST Engine: OWASP ZAP

Technology OWASP Zed Attack Proxy (ZAP)
Analysis Method Active web application penetration testing
Test Coverage SQL Injection, XSS, CSRF, Security Headers, SSL/TLS, Authentication
Scanning Mode Automated spider + active scanner
Standards OWASP Top 10, PCI DSS compliance checks

πŸ› οΈ Troubleshooting

Common Issues and Solutions

πŸ”΄ Docker daemon not running

Error: Cannot connect to the Docker daemon

Solution:

# Start Docker service
sudo systemctl start docker

# Enable Docker to start on boot
sudo systemctl enable docker

# Check Docker status
sudo systemctl status docker
πŸ”΄ Permission denied (Docker socket)

Error: Got permission denied while trying to connect to the Docker daemon socket

Solution:

# Add user to docker group
sudo usermod -aG docker $USER

# Apply changes
newgrp docker

# OR log out and back in

# Verify
docker run hello-world
πŸ”΄ Port already in use

Error: Port 3000 is already in use

Solution:

# Find process using the port
sudo lsof -i :3000

# OR
sudo netstat -tulpn | grep :3000

# Kill the process (replace PID)
kill -9 <PID>

# OR use a different port
safetyscan ./myapp --mode dast --start "npm start" --port 3001
πŸ”΄ Application fails to start in container

Issue: Application startup command doesn't work in Docker

Solution:

  • Ensure all dependencies are installed in the start command
  • Use && to chain commands: "npm install && npm start"
  • Check application logs in the container
  • Verify the application binds to 0.0.0.0, not just localhost
πŸ”΄ Comprehensive reports not generated

Issue: HTML/Markdown comprehensive reports are missing

Symptoms:

⚠ Python 3 not found - skipping comprehensive report generation

Solution:

# Check Python installation
python3 --version

# Install Python 3 if not present
# Ubuntu/Debian
sudo apt install python3

# CentOS/RHEL
sudo yum install python3

# Fedora
sudo dnf install python3

# Verify report generator is installed
which safetyscan-report-generator
ls -la /usr/local/bin/safetyscan-report-generator

# Reinstall if needed
cd SafetyScan-Automated-Security-Scanning-Tool-for-Linux
sudo ./install.sh

Note: Basic reports (JSON, TXT, HTML from ZAP) will still be generated even without Python.

πŸ”΄ White text in HTML report

Issue: Text appears white on white background in comprehensive report

Solution: This has been fixed in the latest version. Update your installation:

cd SafetyScan-Automated-Security-Scanning-Tool-for-Linux
git pull origin main
sudo ./install.sh

# Or manually update report generator
sudo cp report_generator.py /usr/local/bin/safetyscan-report-generator
sudo chmod +x /usr/local/bin/safetyscan-report-generator
πŸ”΄ HTML tags visible in report

Issue: Seeing <p>, <br> tags in descriptions and solutions

Solution: This has been fixed in the latest version. The report generator now:

  • Strips HTML tags from OWASP ZAP output
  • Preserves formatting by converting tags to newlines
  • Properly escapes content for display

Update to the latest version:

cd SafetyScan-Automated-Security-Scanning-Tool-for-Linux
git pull origin main
sudo ./install.sh
πŸ”΄ Command not found: safetyscan

Solution:

# Reinstall with proper permissions
cd SafetyScan-Automated-Security-Scanning-Tool-for-Linux-
sudo ./install.sh

# OR manually copy
sudo cp safetyscan.sh /usr/local/bin/safetyscan
sudo chmod +x /usr/local/bin/safetyscan
πŸ”΄ Disk space issues

Solution:

# Clean up Docker
docker system prune -a --volumes

# Check disk usage
df -h

# Remove old scan reports
rm -rf ./reports/*_old

🀝 Contributing

We welcome contributions from the community! Here's how you can help:

How to Contribute

  1. 🍴 Fork the repository
  2. 🌿 Create a feature branch
    git checkout -b feature/amazing-feature
  3. πŸ’» Commit your changes
    git commit -m 'Add amazing feature'
  4. πŸ“€ Push to your branch
    git push origin feature/amazing-feature
  5. πŸ”€ Open a Pull Request

Contribution Guidelines

  • βœ… Follow existing code style and conventions
  • βœ… Write clear, descriptive commit messages
  • βœ… Add comments for complex logic
  • βœ… Test your changes thoroughly on multiple Linux distributions
  • βœ… Update documentation for new features
  • βœ… Ensure all scans pass before submitting PR

Ideas for Contributions

  • πŸ†• Add support for additional scanners
  • πŸ› Fix bugs and improve error handling
  • πŸ“– Improve documentation and examples
  • 🎨 Enhance report formatting
  • ⚑ Performance optimizations
  • 🌐 Add CI/CD integration examples

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for full details.

MIT License

Copyright (c) 2025 Mohit Khambekar

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software...

πŸ™ Acknowledgments

SafetyScan is built on the shoulders of giants:


πŸ‘¨β€πŸ’» Author

Mohit Khambekar

GitHub


πŸ“ž Support & Contact

Need help? Have questions? Found a bug?


⭐ Show Your Support

If SafetyScan helps secure your applications, please consider:

  • ⭐ Starring this repository
  • πŸ› Reporting bugs or issues
  • πŸ’‘ Suggesting new features
  • πŸ“’ Sharing with your team and network
  • 🀝 Contributing to the codebase

πŸ“Š Project Stats

GitHub stars GitHub forks GitHub issues GitHub pull requests


Made with ❀️ for the Linux Community

Secure Code. Secure Future.

⬆ Back to Top

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages