aura-security 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +446 -0
- package/deploy/AWS-DEPLOYMENT.md +358 -0
- package/deploy/terraform/main.tf +362 -0
- package/deploy/terraform/terraform.tfvars.example +6 -0
- package/dist/agents/base.d.ts +44 -0
- package/dist/agents/base.js +96 -0
- package/dist/agents/index.d.ts +14 -0
- package/dist/agents/index.js +17 -0
- package/dist/agents/policy/evaluator.d.ts +15 -0
- package/dist/agents/policy/evaluator.js +183 -0
- package/dist/agents/policy/index.d.ts +12 -0
- package/dist/agents/policy/index.js +15 -0
- package/dist/agents/policy/validator.d.ts +15 -0
- package/dist/agents/policy/validator.js +182 -0
- package/dist/agents/scanners/gitleaks.d.ts +14 -0
- package/dist/agents/scanners/gitleaks.js +155 -0
- package/dist/agents/scanners/grype.d.ts +14 -0
- package/dist/agents/scanners/grype.js +109 -0
- package/dist/agents/scanners/index.d.ts +15 -0
- package/dist/agents/scanners/index.js +27 -0
- package/dist/agents/scanners/npm-audit.d.ts +13 -0
- package/dist/agents/scanners/npm-audit.js +129 -0
- package/dist/agents/scanners/semgrep.d.ts +14 -0
- package/dist/agents/scanners/semgrep.js +131 -0
- package/dist/agents/scanners/trivy.d.ts +14 -0
- package/dist/agents/scanners/trivy.js +122 -0
- package/dist/agents/types.d.ts +137 -0
- package/dist/agents/types.js +91 -0
- package/dist/auditor/index.d.ts +3 -0
- package/dist/auditor/index.js +2 -0
- package/dist/auditor/pipeline.d.ts +19 -0
- package/dist/auditor/pipeline.js +240 -0
- package/dist/auditor/validator.d.ts +17 -0
- package/dist/auditor/validator.js +58 -0
- package/dist/aura/client.d.ts +29 -0
- package/dist/aura/client.js +125 -0
- package/dist/aura/index.d.ts +4 -0
- package/dist/aura/index.js +2 -0
- package/dist/aura/server.d.ts +45 -0
- package/dist/aura/server.js +343 -0
- package/dist/cli.d.ts +17 -0
- package/dist/cli.js +1433 -0
- package/dist/client/index.d.ts +41 -0
- package/dist/client/index.js +170 -0
- package/dist/compliance/index.d.ts +40 -0
- package/dist/compliance/index.js +292 -0
- package/dist/database/index.d.ts +77 -0
- package/dist/database/index.js +395 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +762 -0
- package/dist/integrations/aura-scanner.d.ts +69 -0
- package/dist/integrations/aura-scanner.js +155 -0
- package/dist/integrations/aws-scanner.d.ts +63 -0
- package/dist/integrations/aws-scanner.js +624 -0
- package/dist/integrations/config.d.ts +69 -0
- package/dist/integrations/config.js +212 -0
- package/dist/integrations/github.d.ts +45 -0
- package/dist/integrations/github.js +201 -0
- package/dist/integrations/gitlab.d.ts +36 -0
- package/dist/integrations/gitlab.js +110 -0
- package/dist/integrations/index.d.ts +11 -0
- package/dist/integrations/index.js +11 -0
- package/dist/integrations/local-scanner.d.ts +146 -0
- package/dist/integrations/local-scanner.js +1654 -0
- package/dist/integrations/notifications.d.ts +99 -0
- package/dist/integrations/notifications.js +305 -0
- package/dist/integrations/scanners.d.ts +57 -0
- package/dist/integrations/scanners.js +217 -0
- package/dist/integrations/slop-scanner.d.ts +69 -0
- package/dist/integrations/slop-scanner.js +155 -0
- package/dist/integrations/webhook.d.ts +37 -0
- package/dist/integrations/webhook.js +256 -0
- package/dist/orchestrator/index.d.ts +72 -0
- package/dist/orchestrator/index.js +187 -0
- package/dist/output/index.d.ts +152 -0
- package/dist/output/index.js +399 -0
- package/dist/pipeline/index.d.ts +72 -0
- package/dist/pipeline/index.js +313 -0
- package/dist/sbom/index.d.ts +94 -0
- package/dist/sbom/index.js +298 -0
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/input.schema.d.ts +87 -0
- package/dist/schemas/input.schema.js +44 -0
- package/dist/schemas/output.schema.d.ts +115 -0
- package/dist/schemas/output.schema.js +64 -0
- package/dist/serve-visualizer.d.ts +2 -0
- package/dist/serve-visualizer.js +78 -0
- package/dist/slop/client.d.ts +29 -0
- package/dist/slop/client.js +125 -0
- package/dist/slop/index.d.ts +4 -0
- package/dist/slop/index.js +2 -0
- package/dist/slop/server.d.ts +45 -0
- package/dist/slop/server.js +343 -0
- package/dist/types/events.d.ts +62 -0
- package/dist/types/events.js +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/visualizer/index.d.ts +4 -0
- package/dist/visualizer/index.js +181 -0
- package/dist/websocket/index.d.ts +88 -0
- package/dist/websocket/index.js +195 -0
- package/dist/zones/index.d.ts +7 -0
- package/dist/zones/index.js +7 -0
- package/dist/zones/manager.d.ts +101 -0
- package/dist/zones/manager.js +304 -0
- package/dist/zones/types.d.ts +78 -0
- package/dist/zones/types.js +33 -0
- package/package.json +84 -0
- package/visualizer/app.js +0 -0
- package/visualizer/index-minimal.html +1771 -0
- package/visualizer/index.html +2933 -0
- package/visualizer/landing.html +1328 -0
- package/visualizer/styles.css +0 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
# AWS Deployment Guide
|
|
2
|
+
|
|
3
|
+
This guide covers deploying aurasecurity to AWS with a professional setup including:
|
|
4
|
+
- EC2 instance running the application
|
|
5
|
+
- nginx reverse proxy with SSL
|
|
6
|
+
- Domain setup with Route 53
|
|
7
|
+
- Optional: Load balancer for high availability
|
|
8
|
+
|
|
9
|
+
## Architecture
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
┌─────────────┐
|
|
13
|
+
│ Route 53 │
|
|
14
|
+
│ (DNS) │
|
|
15
|
+
└──────┬──────┘
|
|
16
|
+
│
|
|
17
|
+
┌──────▼──────┐
|
|
18
|
+
│ Application │
|
|
19
|
+
│ Load Balancer│ (optional)
|
|
20
|
+
└──────┬──────┘
|
|
21
|
+
│
|
|
22
|
+
┌────────────┼────────────┐
|
|
23
|
+
│ │ │
|
|
24
|
+
┌─────▼─────┐┌─────▼─────┐┌─────▼─────┐
|
|
25
|
+
│ EC2 ││ EC2 ││ EC2 │
|
|
26
|
+
│ (nginx + ││ (nginx + ││ (nginx + │
|
|
27
|
+
│ node) ││ node) ││ node) │
|
|
28
|
+
└───────────┘└───────────┘└───────────┘
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
For most use cases, a single EC2 instance is sufficient.
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## Option 1: Single EC2 Instance (Recommended for Start)
|
|
36
|
+
|
|
37
|
+
### Step 1: Launch EC2 Instance
|
|
38
|
+
|
|
39
|
+
1. Go to AWS Console → EC2 → Launch Instance
|
|
40
|
+
2. Choose settings:
|
|
41
|
+
- **AMI**: Ubuntu 22.04 LTS
|
|
42
|
+
- **Instance type**: t3.small (2 vCPU, 2GB RAM) or larger
|
|
43
|
+
- **Key pair**: Create or select existing
|
|
44
|
+
- **Security Group**: Allow ports 22 (SSH), 80 (HTTP), 443 (HTTPS)
|
|
45
|
+
|
|
46
|
+
### Step 2: Connect and Install Dependencies
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# SSH into your instance
|
|
50
|
+
ssh -i your-key.pem ubuntu@<EC2-PUBLIC-IP>
|
|
51
|
+
|
|
52
|
+
# Update system
|
|
53
|
+
sudo apt update && sudo apt upgrade -y
|
|
54
|
+
|
|
55
|
+
# Install Node.js 20
|
|
56
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
|
|
57
|
+
sudo apt install -y nodejs
|
|
58
|
+
|
|
59
|
+
# Install nginx
|
|
60
|
+
sudo apt install -y nginx
|
|
61
|
+
|
|
62
|
+
# Install security tools (optional but recommended)
|
|
63
|
+
sudo apt install -y gitleaks
|
|
64
|
+
sudo snap install trivy
|
|
65
|
+
|
|
66
|
+
# Install pip and semgrep
|
|
67
|
+
sudo apt install -y python3-pip
|
|
68
|
+
pip3 install semgrep
|
|
69
|
+
|
|
70
|
+
# Verify installations
|
|
71
|
+
node --version # Should show v20.x
|
|
72
|
+
nginx -v # Should show nginx version
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Step 3: Deploy aurasecurity
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# Create app directory
|
|
79
|
+
sudo mkdir -p /var/www/aura-security
|
|
80
|
+
sudo chown ubuntu:ubuntu /var/www/aura-security
|
|
81
|
+
|
|
82
|
+
# Install aurasecurity
|
|
83
|
+
cd /var/www/aura-security
|
|
84
|
+
npm install aura-security
|
|
85
|
+
|
|
86
|
+
# Or clone from GitHub for latest
|
|
87
|
+
git clone https://github.com/aurasecurity/aura-security.git .
|
|
88
|
+
npm install
|
|
89
|
+
npm run build
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Step 4: Create systemd Services
|
|
93
|
+
|
|
94
|
+
Create the API service:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
sudo tee /etc/systemd/system/aura-api.service << 'EOF'
|
|
98
|
+
[Unit]
|
|
99
|
+
Description=aurasecurity API Server
|
|
100
|
+
After=network.target
|
|
101
|
+
|
|
102
|
+
[Service]
|
|
103
|
+
Type=simple
|
|
104
|
+
User=ubuntu
|
|
105
|
+
WorkingDirectory=/var/www/aura-security
|
|
106
|
+
ExecStart=/usr/bin/node dist/index.js
|
|
107
|
+
Restart=on-failure
|
|
108
|
+
RestartSec=10
|
|
109
|
+
Environment=NODE_ENV=production
|
|
110
|
+
Environment=AURA_PORT=3000
|
|
111
|
+
Environment=WS_PORT=3001
|
|
112
|
+
|
|
113
|
+
[Install]
|
|
114
|
+
WantedBy=multi-user.target
|
|
115
|
+
EOF
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Create the visualizer service:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
sudo tee /etc/systemd/system/aura-visualizer.service << 'EOF'
|
|
122
|
+
[Unit]
|
|
123
|
+
Description=aurasecurity Visualizer
|
|
124
|
+
After=network.target
|
|
125
|
+
|
|
126
|
+
[Service]
|
|
127
|
+
Type=simple
|
|
128
|
+
User=ubuntu
|
|
129
|
+
WorkingDirectory=/var/www/aura-security
|
|
130
|
+
ExecStart=/usr/bin/node dist/serve-visualizer.js
|
|
131
|
+
Restart=on-failure
|
|
132
|
+
RestartSec=10
|
|
133
|
+
Environment=NODE_ENV=production
|
|
134
|
+
Environment=VISUALIZER_PORT=8080
|
|
135
|
+
|
|
136
|
+
[Install]
|
|
137
|
+
WantedBy=multi-user.target
|
|
138
|
+
EOF
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Enable and start services:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
sudo systemctl daemon-reload
|
|
145
|
+
sudo systemctl enable aura-api aura-visualizer
|
|
146
|
+
sudo systemctl start aura-api aura-visualizer
|
|
147
|
+
|
|
148
|
+
# Check status
|
|
149
|
+
sudo systemctl status aura-api
|
|
150
|
+
sudo systemctl status aura-visualizer
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Step 5: Configure nginx
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
sudo tee /etc/nginx/sites-available/aura-security << 'EOF'
|
|
157
|
+
server {
|
|
158
|
+
listen 80;
|
|
159
|
+
server_name your-domain.com www.your-domain.com;
|
|
160
|
+
|
|
161
|
+
# Landing page and static assets
|
|
162
|
+
location / {
|
|
163
|
+
proxy_pass http://127.0.0.1:8080;
|
|
164
|
+
proxy_http_version 1.1;
|
|
165
|
+
proxy_set_header Host $host;
|
|
166
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
167
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
168
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
# API endpoints
|
|
172
|
+
location /api/ {
|
|
173
|
+
rewrite ^/api/(.*)$ /$1 break;
|
|
174
|
+
proxy_pass http://127.0.0.1:3000;
|
|
175
|
+
proxy_http_version 1.1;
|
|
176
|
+
proxy_set_header Host $host;
|
|
177
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
178
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
179
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
# Direct Aura endpoints (info, tools, memory, etc.)
|
|
183
|
+
location ~ ^/(info|tools|memory|settings|audits|stats|notifications)(/.*)?$ {
|
|
184
|
+
proxy_pass http://127.0.0.1:3000;
|
|
185
|
+
proxy_http_version 1.1;
|
|
186
|
+
proxy_set_header Host $host;
|
|
187
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
# WebSocket for real-time updates
|
|
191
|
+
location /ws {
|
|
192
|
+
proxy_pass http://127.0.0.1:3001;
|
|
193
|
+
proxy_http_version 1.1;
|
|
194
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
195
|
+
proxy_set_header Connection "upgrade";
|
|
196
|
+
proxy_set_header Host $host;
|
|
197
|
+
proxy_read_timeout 86400;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
EOF
|
|
201
|
+
|
|
202
|
+
# Enable site
|
|
203
|
+
sudo ln -sf /etc/nginx/sites-available/aura-security /etc/nginx/sites-enabled/
|
|
204
|
+
sudo rm -f /etc/nginx/sites-enabled/default
|
|
205
|
+
|
|
206
|
+
# Test and reload
|
|
207
|
+
sudo nginx -t
|
|
208
|
+
sudo systemctl reload nginx
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Step 6: Add SSL with Let's Encrypt
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Install certbot
|
|
215
|
+
sudo apt install -y certbot python3-certbot-nginx
|
|
216
|
+
|
|
217
|
+
# Get certificate (replace with your domain)
|
|
218
|
+
sudo certbot --nginx -d your-domain.com -d www.your-domain.com
|
|
219
|
+
|
|
220
|
+
# Auto-renewal is set up automatically
|
|
221
|
+
# Test renewal:
|
|
222
|
+
sudo certbot renew --dry-run
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Step 7: Configure Domain (Route 53)
|
|
226
|
+
|
|
227
|
+
1. Go to AWS Route 53
|
|
228
|
+
2. Create/select your hosted zone
|
|
229
|
+
3. Create an A record:
|
|
230
|
+
- Name: `your-domain.com` (or subdomain like `security.your-domain.com`)
|
|
231
|
+
- Type: A
|
|
232
|
+
- Value: Your EC2 public IP
|
|
233
|
+
- TTL: 300
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Option 2: Docker Deployment
|
|
238
|
+
|
|
239
|
+
If you prefer Docker:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
# Install Docker
|
|
243
|
+
curl -fsSL https://get.docker.com | sudo sh
|
|
244
|
+
sudo usermod -aG docker ubuntu
|
|
245
|
+
|
|
246
|
+
# Pull and run
|
|
247
|
+
docker pull aurasecurity/aura-security:latest
|
|
248
|
+
docker run -d \
|
|
249
|
+
--name aura-security \
|
|
250
|
+
-p 3000:3000 \
|
|
251
|
+
-p 3001:3001 \
|
|
252
|
+
-p 8080:8080 \
|
|
253
|
+
-v aura-data:/app/.aura-security \
|
|
254
|
+
aurasecurity/aura-security:latest
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
Then configure nginx as shown above.
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
## Environment Variables
|
|
262
|
+
|
|
263
|
+
Set these in your systemd service or `.env` file:
|
|
264
|
+
|
|
265
|
+
| Variable | Default | Description |
|
|
266
|
+
|----------|---------|-------------|
|
|
267
|
+
| `AURA_PORT` | 3000 | API server port |
|
|
268
|
+
| `WS_PORT` | 3001 | WebSocket port |
|
|
269
|
+
| `VISUALIZER_PORT` | 8080 | Web UI port |
|
|
270
|
+
| `AWS_ACCESS_KEY_ID` | - | For AWS scanning |
|
|
271
|
+
| `AWS_SECRET_ACCESS_KEY` | - | For AWS scanning |
|
|
272
|
+
| `AWS_DEFAULT_REGION` | us-east-1 | AWS region |
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## Security Recommendations
|
|
277
|
+
|
|
278
|
+
1. **Use IAM Roles**: Instead of hardcoding AWS credentials, attach an IAM role to your EC2 instance with the permissions needed for scanning.
|
|
279
|
+
|
|
280
|
+
2. **Security Groups**: Only allow:
|
|
281
|
+
- Port 22 from your IP only
|
|
282
|
+
- Ports 80/443 from anywhere
|
|
283
|
+
|
|
284
|
+
3. **Enable AWS WAF**: If using ALB, add WAF rules for additional protection.
|
|
285
|
+
|
|
286
|
+
4. **Regular Updates**:
|
|
287
|
+
```bash
|
|
288
|
+
# Set up unattended upgrades
|
|
289
|
+
sudo apt install -y unattended-upgrades
|
|
290
|
+
sudo dpkg-reconfigure -plow unattended-upgrades
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Monitoring
|
|
296
|
+
|
|
297
|
+
### CloudWatch Logs
|
|
298
|
+
|
|
299
|
+
```bash
|
|
300
|
+
# Install CloudWatch agent
|
|
301
|
+
wget https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/amd64/latest/amazon-cloudwatch-agent.deb
|
|
302
|
+
sudo dpkg -i amazon-cloudwatch-agent.deb
|
|
303
|
+
|
|
304
|
+
# Configure to send logs
|
|
305
|
+
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### Health Checks
|
|
309
|
+
|
|
310
|
+
Add to nginx config:
|
|
311
|
+
|
|
312
|
+
```nginx
|
|
313
|
+
location /health {
|
|
314
|
+
proxy_pass http://127.0.0.1:3000/info;
|
|
315
|
+
access_log off;
|
|
316
|
+
}
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Cost Estimate
|
|
322
|
+
|
|
323
|
+
| Resource | Specification | Monthly Cost (approx) |
|
|
324
|
+
|----------|--------------|----------------------|
|
|
325
|
+
| EC2 t3.small | 2 vCPU, 2GB RAM | ~$15 |
|
|
326
|
+
| EBS | 20GB gp3 | ~$2 |
|
|
327
|
+
| Route 53 | Hosted zone | ~$0.50 |
|
|
328
|
+
| Data transfer | 10GB | ~$1 |
|
|
329
|
+
| **Total** | | **~$20/month** |
|
|
330
|
+
|
|
331
|
+
For higher traffic, consider t3.medium (~$30/month) or add a load balancer.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Troubleshooting
|
|
336
|
+
|
|
337
|
+
### Services not starting
|
|
338
|
+
|
|
339
|
+
```bash
|
|
340
|
+
# Check logs
|
|
341
|
+
sudo journalctl -u aura-api -f
|
|
342
|
+
sudo journalctl -u aura-visualizer -f
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### 502 Bad Gateway
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
# Check if services are running
|
|
349
|
+
sudo systemctl status aura-api
|
|
350
|
+
sudo systemctl status aura-visualizer
|
|
351
|
+
|
|
352
|
+
# Check ports
|
|
353
|
+
sudo netstat -tlnp | grep -E '3000|3001|8080'
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### WebSocket not connecting
|
|
357
|
+
|
|
358
|
+
Make sure your nginx config has the WebSocket upgrade headers and the security group allows port 3001 (or use nginx proxy for all WebSocket traffic).
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
# aurasecurity - AWS Infrastructure
|
|
2
|
+
# Deploy with: terraform init && terraform apply
|
|
3
|
+
|
|
4
|
+
terraform {
|
|
5
|
+
required_providers {
|
|
6
|
+
aws = {
|
|
7
|
+
source = "hashicorp/aws"
|
|
8
|
+
version = "~> 5.0"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
provider "aws" {
|
|
14
|
+
region = var.aws_region
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
# Variables
|
|
18
|
+
variable "aws_region" {
|
|
19
|
+
description = "AWS region"
|
|
20
|
+
default = "us-east-1"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
variable "instance_type" {
|
|
24
|
+
description = "EC2 instance type"
|
|
25
|
+
default = "t3.small"
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
variable "key_name" {
|
|
29
|
+
description = "SSH key pair name"
|
|
30
|
+
type = string
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
variable "domain_name" {
|
|
34
|
+
description = "Domain name for the application (optional)"
|
|
35
|
+
default = ""
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# Data sources
|
|
39
|
+
data "aws_ami" "ubuntu" {
|
|
40
|
+
most_recent = true
|
|
41
|
+
owners = ["099720109477"] # Canonical
|
|
42
|
+
|
|
43
|
+
filter {
|
|
44
|
+
name = "name"
|
|
45
|
+
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
filter {
|
|
49
|
+
name = "virtualization-type"
|
|
50
|
+
values = ["hvm"]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
data "aws_availability_zones" "available" {
|
|
55
|
+
state = "available"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# VPC
|
|
59
|
+
resource "aws_vpc" "main" {
|
|
60
|
+
cidr_block = "10.0.0.0/16"
|
|
61
|
+
enable_dns_hostnames = true
|
|
62
|
+
enable_dns_support = true
|
|
63
|
+
|
|
64
|
+
tags = {
|
|
65
|
+
Name = "aura-security-vpc"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
resource "aws_subnet" "public" {
|
|
70
|
+
vpc_id = aws_vpc.main.id
|
|
71
|
+
cidr_block = "10.0.1.0/24"
|
|
72
|
+
availability_zone = data.aws_availability_zones.available.names[0]
|
|
73
|
+
map_public_ip_on_launch = true
|
|
74
|
+
|
|
75
|
+
tags = {
|
|
76
|
+
Name = "aura-security-public"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
resource "aws_internet_gateway" "main" {
|
|
81
|
+
vpc_id = aws_vpc.main.id
|
|
82
|
+
|
|
83
|
+
tags = {
|
|
84
|
+
Name = "aura-security-igw"
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
resource "aws_route_table" "public" {
|
|
89
|
+
vpc_id = aws_vpc.main.id
|
|
90
|
+
|
|
91
|
+
route {
|
|
92
|
+
cidr_block = "0.0.0.0/0"
|
|
93
|
+
gateway_id = aws_internet_gateway.main.id
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
tags = {
|
|
97
|
+
Name = "aura-security-public-rt"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
resource "aws_route_table_association" "public" {
|
|
102
|
+
subnet_id = aws_subnet.public.id
|
|
103
|
+
route_table_id = aws_route_table.public.id
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
# Security Group
|
|
107
|
+
resource "aws_security_group" "aura_security" {
|
|
108
|
+
name = "aura-security-sg"
|
|
109
|
+
description = "Security group for aurasecurity"
|
|
110
|
+
vpc_id = aws_vpc.main.id
|
|
111
|
+
|
|
112
|
+
# SSH
|
|
113
|
+
ingress {
|
|
114
|
+
from_port = 22
|
|
115
|
+
to_port = 22
|
|
116
|
+
protocol = "tcp"
|
|
117
|
+
cidr_blocks = ["0.0.0.0/0"] # Restrict to your IP in production
|
|
118
|
+
description = "SSH access"
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
# HTTP
|
|
122
|
+
ingress {
|
|
123
|
+
from_port = 80
|
|
124
|
+
to_port = 80
|
|
125
|
+
protocol = "tcp"
|
|
126
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
127
|
+
description = "HTTP access"
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# HTTPS
|
|
131
|
+
ingress {
|
|
132
|
+
from_port = 443
|
|
133
|
+
to_port = 443
|
|
134
|
+
protocol = "tcp"
|
|
135
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
136
|
+
description = "HTTPS access"
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
# All outbound
|
|
140
|
+
egress {
|
|
141
|
+
from_port = 0
|
|
142
|
+
to_port = 0
|
|
143
|
+
protocol = "-1"
|
|
144
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
tags = {
|
|
148
|
+
Name = "aura-security-sg"
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
# IAM Role for EC2 (for AWS scanning)
|
|
153
|
+
resource "aws_iam_role" "aura_security" {
|
|
154
|
+
name = "aura-security-ec2-role"
|
|
155
|
+
|
|
156
|
+
assume_role_policy = jsonencode({
|
|
157
|
+
Version = "2012-10-17"
|
|
158
|
+
Statement = [
|
|
159
|
+
{
|
|
160
|
+
Action = "sts:AssumeRole"
|
|
161
|
+
Effect = "Allow"
|
|
162
|
+
Principal = {
|
|
163
|
+
Service = "ec2.amazonaws.com"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
]
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
# IAM Policy for security scanning (read-only)
|
|
171
|
+
resource "aws_iam_role_policy" "aura_security_scan" {
|
|
172
|
+
name = "aura-security-scan-policy"
|
|
173
|
+
role = aws_iam_role.aura_security.id
|
|
174
|
+
|
|
175
|
+
policy = jsonencode({
|
|
176
|
+
Version = "2012-10-17"
|
|
177
|
+
Statement = [
|
|
178
|
+
{
|
|
179
|
+
Effect = "Allow"
|
|
180
|
+
Action = [
|
|
181
|
+
"iam:List*",
|
|
182
|
+
"iam:Get*",
|
|
183
|
+
"s3:List*",
|
|
184
|
+
"s3:GetBucket*",
|
|
185
|
+
"s3:GetEncryptionConfiguration",
|
|
186
|
+
"ec2:Describe*",
|
|
187
|
+
"lambda:List*",
|
|
188
|
+
"lambda:GetFunction*",
|
|
189
|
+
"rds:Describe*"
|
|
190
|
+
]
|
|
191
|
+
Resource = "*"
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
})
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
resource "aws_iam_instance_profile" "aura_security" {
|
|
198
|
+
name = "aura-security-instance-profile"
|
|
199
|
+
role = aws_iam_role.aura_security.name
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
# EC2 Instance
|
|
203
|
+
resource "aws_instance" "aura_security" {
|
|
204
|
+
ami = data.aws_ami.ubuntu.id
|
|
205
|
+
instance_type = var.instance_type
|
|
206
|
+
key_name = var.key_name
|
|
207
|
+
subnet_id = aws_subnet.public.id
|
|
208
|
+
vpc_security_group_ids = [aws_security_group.aura_security.id]
|
|
209
|
+
iam_instance_profile = aws_iam_instance_profile.aura_security.name
|
|
210
|
+
|
|
211
|
+
root_block_device {
|
|
212
|
+
volume_size = 20
|
|
213
|
+
volume_type = "gp3"
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
user_data = <<-EOF
|
|
217
|
+
#!/bin/bash
|
|
218
|
+
set -e
|
|
219
|
+
|
|
220
|
+
# Update system
|
|
221
|
+
apt-get update
|
|
222
|
+
apt-get upgrade -y
|
|
223
|
+
|
|
224
|
+
# Install Node.js 20
|
|
225
|
+
curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
226
|
+
apt-get install -y nodejs
|
|
227
|
+
|
|
228
|
+
# Install nginx
|
|
229
|
+
apt-get install -y nginx
|
|
230
|
+
|
|
231
|
+
# Install security tools
|
|
232
|
+
apt-get install -y gitleaks python3-pip
|
|
233
|
+
snap install trivy
|
|
234
|
+
pip3 install semgrep
|
|
235
|
+
|
|
236
|
+
# Create app directory
|
|
237
|
+
mkdir -p /var/www/aura-security
|
|
238
|
+
cd /var/www/aura-security
|
|
239
|
+
|
|
240
|
+
# Install aurasecurity
|
|
241
|
+
npm install aura-security
|
|
242
|
+
|
|
243
|
+
# Create systemd services
|
|
244
|
+
cat > /etc/systemd/system/slop-api.service << 'SVCEOF'
|
|
245
|
+
[Unit]
|
|
246
|
+
Description=aurasecurity API Server
|
|
247
|
+
After=network.target
|
|
248
|
+
|
|
249
|
+
[Service]
|
|
250
|
+
Type=simple
|
|
251
|
+
User=root
|
|
252
|
+
WorkingDirectory=/var/www/aura-security
|
|
253
|
+
ExecStart=/usr/bin/npx aura-security serve
|
|
254
|
+
Restart=on-failure
|
|
255
|
+
RestartSec=10
|
|
256
|
+
Environment=NODE_ENV=production
|
|
257
|
+
|
|
258
|
+
[Install]
|
|
259
|
+
WantedBy=multi-user.target
|
|
260
|
+
SVCEOF
|
|
261
|
+
|
|
262
|
+
cat > /etc/systemd/system/slop-visualizer.service << 'SVCEOF'
|
|
263
|
+
[Unit]
|
|
264
|
+
Description=aurasecurity Visualizer
|
|
265
|
+
After=network.target
|
|
266
|
+
|
|
267
|
+
[Service]
|
|
268
|
+
Type=simple
|
|
269
|
+
User=root
|
|
270
|
+
WorkingDirectory=/var/www/aura-security
|
|
271
|
+
ExecStart=/usr/bin/npx aura-security visualizer
|
|
272
|
+
Restart=on-failure
|
|
273
|
+
RestartSec=10
|
|
274
|
+
Environment=NODE_ENV=production
|
|
275
|
+
|
|
276
|
+
[Install]
|
|
277
|
+
WantedBy=multi-user.target
|
|
278
|
+
SVCEOF
|
|
279
|
+
|
|
280
|
+
# Enable and start services
|
|
281
|
+
systemctl daemon-reload
|
|
282
|
+
systemctl enable slop-api slop-visualizer
|
|
283
|
+
systemctl start slop-api slop-visualizer
|
|
284
|
+
|
|
285
|
+
# Configure nginx
|
|
286
|
+
cat > /etc/nginx/sites-available/aura-security << 'NGINXEOF'
|
|
287
|
+
server {
|
|
288
|
+
listen 80;
|
|
289
|
+
server_name _;
|
|
290
|
+
|
|
291
|
+
location / {
|
|
292
|
+
proxy_pass http://127.0.0.1:8080;
|
|
293
|
+
proxy_http_version 1.1;
|
|
294
|
+
proxy_set_header Host $host;
|
|
295
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
296
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
297
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
location ~ ^/(info|tools|memory|settings|audits|stats|notifications)(/.*)?$ {
|
|
301
|
+
proxy_pass http://127.0.0.1:3000;
|
|
302
|
+
proxy_http_version 1.1;
|
|
303
|
+
proxy_set_header Host $host;
|
|
304
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
location /ws {
|
|
308
|
+
proxy_pass http://127.0.0.1:3001;
|
|
309
|
+
proxy_http_version 1.1;
|
|
310
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
311
|
+
proxy_set_header Connection "upgrade";
|
|
312
|
+
proxy_set_header Host $host;
|
|
313
|
+
proxy_read_timeout 86400;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
NGINXEOF
|
|
317
|
+
|
|
318
|
+
ln -sf /etc/nginx/sites-available/aura-security /etc/nginx/sites-enabled/
|
|
319
|
+
rm -f /etc/nginx/sites-enabled/default
|
|
320
|
+
nginx -t && systemctl reload nginx
|
|
321
|
+
EOF
|
|
322
|
+
|
|
323
|
+
tags = {
|
|
324
|
+
Name = "aura-security"
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
# Elastic IP (optional, for stable IP)
|
|
329
|
+
resource "aws_eip" "aura_security" {
|
|
330
|
+
instance = aws_instance.aura_security.id
|
|
331
|
+
domain = "vpc"
|
|
332
|
+
|
|
333
|
+
tags = {
|
|
334
|
+
Name = "aura-security-eip"
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
# Outputs
|
|
339
|
+
output "public_ip" {
|
|
340
|
+
description = "Public IP address"
|
|
341
|
+
value = aws_eip.aura_security.public_ip
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
output "public_dns" {
|
|
345
|
+
description = "Public DNS name"
|
|
346
|
+
value = aws_instance.aura_security.public_dns
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
output "landing_url" {
|
|
350
|
+
description = "Landing page URL"
|
|
351
|
+
value = "http://${aws_eip.aura_security.public_ip}"
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
output "dashboard_url" {
|
|
355
|
+
description = "Dashboard URL"
|
|
356
|
+
value = "http://${aws_eip.aura_security.public_ip}/app"
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
output "ssh_command" {
|
|
360
|
+
description = "SSH command to connect"
|
|
361
|
+
value = "ssh -i ${var.key_name}.pem ubuntu@${aws_eip.aura_security.public_ip}"
|
|
362
|
+
}
|