Skip to content

Convert the script to a python package #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
169 changes: 137 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,36 +1,104 @@

# AWS Sentinel

AWS Sentinel is a command-line security scanner for AWS resources. It helps identify common security issues in your AWS account, such as:
AWS Sentinel is a powerful command-line security scanner for AWS resources. It helps identify common security issues and misconfigurations in your AWS environment.

- Public S3 buckets
- Security groups with port 22 (SSH) open to the public
- Unencrypted EBS volumes
- IAM users without Multi-Factor Authentication (MFA)
## Features

## Usage
AWS Sentinel currently checks for the following security issues:

- **S3 Buckets**: Identifies publicly accessible buckets
- **EC2 Security Groups**: Finds security groups with port 22 (SSH) open to the public
- **EBS Volumes**: Detects unencrypted volumes
- **IAM Users**: Identifies users without Multi-Factor Authentication (MFA)

## Installation

You can install AWS Sentinel using pip:

You can clone this repo:
```bash
pip install aws-sentinel
```

``` bash
git clone https://github.com/rishabkumar7/aws-sentinel
Or using uv
```bash
uv pip install aws-sentinel
```

Once clone, you can run AWS Sentinel from the command line:
## Usage

### Basic Usage

``` bash
python main.py --profile your-aws-profile --region your-aws-region
Run a full security scan using your default AWS profile:

```bash
aws-sentinel scan
```

If you don't specify a profile or region, it will use the default profile and `us-east-1` region.

### Options
### Command Options

```
Usage: aws-sentinel scan [OPTIONS]

Options:
--profile TEXT AWS profile to use for authentication (from
~/.aws/credentials)
--region TEXT AWS region to scan for security issues
--checks TEXT Comma-separated list of checks to run
(s3,ec2,ebs,iam) or "all"
--output [table|json|csv] Output format for scan results
--severity [low|medium|high|all]
Filter results by minimum severity level
-v, --verbose Enable verbose output
-h, --help Show this message and exit.

```

### Examples

Run a scan with a specific AWS profile and region:

```bash
aws-sentinel scan --profile production --region us-west-2
```

Run only specific security checks:

```bash
aws-sentinel scan --checks s3,iam
```

- `--profile`: AWS profile to use (default: "default")
- `--region`: AWS region to check (default: "us-east-1")
Export results in JSON format:

```bash
aws-sentinel scan --output json > security_report.json
```

Export results in CSV format:

```bash
aws-sentinel scan --output csv > security_report.csv
```

Show only high severity issues:

```bash
aws-sentinel scan --severity high
```

Get detailed documentation:

```bash
aws-sentinel docs
```

## Example Output

``` bash
### Table Format (Default)

```bash
█████╗ ██╗ ██╗███████╗ ███████╗███████╗███╗ ██╗████████╗██╗███╗ ██╗███████╗██╗
██╔══██╗██║ ██║██╔════╝ ██╔════╝██╔════╝████╗ ██║╚══██╔══╝██║████╗ ██║██╔════╝██║
███████║██║ █╗ ██║███████╗ ███████╗█████╗ ██╔██╗ ██║ ██║ ██║██╔██╗ ██║█████╗ ██║
Expand All @@ -54,44 +122,81 @@ Initializing security checks...
+--------+---------------+------------------------------------------+
```

### JSON Format

```json
{
"scan_results": {
"profile": "default",
"region": "us-east-1",
"scan_time": "2025-04-15T14:32:17.654321",
"issues_count": 3,
"issues": [
{
"service": "S3",
"resource": "public-bucket",
"issue": "Public bucket",
"severity": "HIGH"
},
{
"service": "EC2",
"resource": "sg-12345abcde",
"issue": "Security group with port 22 open to public",
"severity": "HIGH"
},
{
"service": "IAM",
"resource": "admin-user",
"issue": "User without MFA",
"severity": "HIGH"
}
]
}
}

```

## Requirements

- Python 3.9+
- AWS credentials configured (via AWS CLI or environment variables)
- Required permissions to access AWS resources

## Development

To set up AWS Sentinel for development:
To set up the project for development:

1. Clone the repository:

``` bash
git clone https://github.com/yourusername/aws-sentinel.git cd aws-sentinel
```
```bash
git clone https://github.com/rishabkumar7/aws-sentinel.git
cd aws-sentinel

```

2. Create a virtual environment:

``` bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate`
```
```bash
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
```

3. Install development dependencies:

``` bash
pip install -r requirements.txt
```
```bash
pip install -e '.[dev]'
```

4. Run tests:
4. Run the tests:

``` bash
python unittest test_aws_sentinel.py
```
```bash
python -m unittest discover tests
```

## License

MIT License

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
Contributions are welcome! Please feel free to submit an Issue and a Pull Request.
20 changes: 20 additions & 0 deletions aws_sentinel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"""
AWS Sentinel - Security Scanner for AWS Resources

A command-line tool to identify security vulnerabilities and
misconfigurations in your AWS account.
"""

__version__ = '0.1.0'
__author__ = 'Rishab Kumar'
__email__ = '[email protected]'
__license__ = 'MIT'
__description__ = 'Security scanner for AWS resources'
__url__ = 'https://github.com/rishabkumar7/aws-sentinel'

from .core import (
check_public_buckets,
check_public_security_groups,
check_unencrypted_ebs_volumes,
check_iam_users_without_mfa
)
14 changes: 14 additions & 0 deletions aws_sentinel/ascii_art.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
ASCII art for AWS Sentinel CLI
"""

BANNER = """
█████╗ ██╗ ██╗███████╗ ███████╗███████╗███╗ ██╗████████╗██╗███╗ ██╗███████╗██╗
██╔══██╗██║ ██║██╔════╝ ██╔════╝██╔════╝████╗ ██║╚══██╔══╝██║████╗ ██║██╔════╝██║
███████║██║ █╗ ██║███████╗ ███████╗█████╗ ██╔██╗ ██║ ██║ ██║██╔██╗ ██║█████╗ ██║
██╔══██║██║███╗██║╚════██║ ╚════██║██╔══╝ ██║╚██╗██║ ██║ ██║██║╚██╗██║██╔══╝ ██║
██║ ██║╚███╔███╔╝███████║ ███████║███████╗██║ ╚████║ ██║ ██║██║ ╚████║███████╗███████╗
╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝ ╚══════╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚══════╝

AWS Security Sentinel
"""
Loading