Skip to content

Commit 7aeb1d8

Browse files
postgres -> sqlite3
1 parent 10f89ee commit 7aeb1d8

29 files changed

Lines changed: 1341 additions & 380 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,6 @@ __debug_bin
4242

4343
# Temporary files
4444
*.tmp
45-
*.temp
45+
*.temp
46+
47+
*this-session-is-being-continued-from-a-previous-co.txt

CLAUDE.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ nomad job run deployments/nomad/scanner-web.nomad
231231

232232
### Database Operations
233233
- Database migrations are handled automatically
234-
- Default PostgreSQL
234+
- Uses SQLite for lightweight, embedded storage
235+
- Database file is created automatically on first run
235236

236237
## Debugging Tips
237238

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A production-ready Cobra CLI tool for web application security testing and bug b
1616
- **Workflow Engine**: Complex multi-stage scanning pipelines
1717
- **Distributed Scanning**: Redis-based job queue with worker pools
1818
- **Observability**: OpenTelemetry integration with structured logging via otelzap
19-
- **Result Management**: Normalized result schema with PostgreSQL/SQLite storage
19+
- **Result Management**: Normalized result schema with SQLite storage (lightweight, embedded database)
2020
- **Deployment Ready**: Docker containers and Nomad job specifications
2121
- **Security Features**: Rate limiting, scope validation, audit trails
2222

@@ -64,8 +64,8 @@ logger:
6464
format: json
6565

6666
database:
67-
driver: postgres
68-
dsn: "host=localhost user=webscan password=password dbname=webscan"
67+
driver: sqlite3
68+
dsn: "webscan.db" # SQLite database file path
6969

7070
redis:
7171
addr: localhost:6379

cmd/discover_favicon.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ func runFaviconDiscovery(cmd *cobra.Command, args []string) error {
191191
// Load target hosts
192192
targetHosts, err := loadTargetHosts(hosts, hostsFile)
193193
if err != nil {
194-
return fmt.Errorf("failed to load target hosts: %v", err)
194+
return fmt.Errorf("failed to load target hosts: %w", err)
195195
}
196196

197197
if len(targetHosts) == 0 {
@@ -213,7 +213,7 @@ func runFaviconDiscovery(cmd *cobra.Command, args []string) error {
213213
// Initialize scanner
214214
scanner, err := favicon.NewScanner(config)
215215
if err != nil {
216-
return fmt.Errorf("failed to initialize favicon scanner: %v", err)
216+
return fmt.Errorf("failed to initialize favicon scanner: %w", err)
217217
}
218218

219219
fmt.Printf("🔍 Starting favicon discovery scan\n")
@@ -229,7 +229,7 @@ func runFaviconDiscovery(cmd *cobra.Command, args []string) error {
229229
// Scan hosts
230230
results, err := scanner.ScanHosts(ctx, targetHosts)
231231
if err != nil {
232-
return fmt.Errorf("scan failed: %v", err)
232+
return fmt.Errorf("scan failed: %w", err)
233233
}
234234

235235
duration := time.Since(start)
@@ -264,7 +264,7 @@ func runFaviconHash(cmd *cobra.Command, args []string) error {
264264
// Load target hosts
265265
targetHosts, err := loadTargetHosts(hosts, hostsFile)
266266
if err != nil {
267-
return fmt.Errorf("failed to load target hosts: %v", err)
267+
return fmt.Errorf("failed to load target hosts: %w", err)
268268
}
269269

270270
if len(targetHosts) == 0 {
@@ -353,7 +353,7 @@ func runFaviconAdd(cmd *cobra.Command, args []string) error {
353353

354354
// Add entry
355355
if err := database.AddEntry(entry); err != nil {
356-
return fmt.Errorf("failed to add entry: %v", err)
356+
return fmt.Errorf("failed to add entry: %w", err)
357357
}
358358

359359
fmt.Printf("✅ Added favicon hash mapping:\n")
@@ -381,19 +381,19 @@ func runFaviconExport(cmd *cobra.Command, args []string) error {
381381
// Load custom database if specified
382382
if customDatabase != "" {
383383
if err := database.LoadFromFile(customDatabase); err != nil {
384-
return fmt.Errorf("failed to load custom database: %v", err)
384+
return fmt.Errorf("failed to load custom database: %w", err)
385385
}
386386
}
387387

388388
// Export database
389389
data, err := database.ExportDatabase(exportFormat)
390390
if err != nil {
391-
return fmt.Errorf("failed to export database: %v", err)
391+
return fmt.Errorf("failed to export database: %w", err)
392392
}
393393

394394
if exportFile != "" {
395395
if err := os.WriteFile(exportFile, data, 0644); err != nil {
396-
return fmt.Errorf("failed to write export file: %v", err)
396+
return fmt.Errorf("failed to write export file: %w", err)
397397
}
398398
fmt.Printf("📄 Database exported to: %s\n", exportFile)
399399
} else {
@@ -410,7 +410,7 @@ func runFaviconStats(cmd *cobra.Command, args []string) error {
410410
// Load custom database if specified
411411
if customDatabase != "" {
412412
if err := database.LoadFromFile(customDatabase); err != nil {
413-
return fmt.Errorf("failed to load custom database: %v", err)
413+
return fmt.Errorf("failed to load custom database: %w", err)
414414
}
415415
}
416416

@@ -450,7 +450,7 @@ func loadTargetHosts(hostList []string, filename string) ([]string, error) {
450450
if filename != "" {
451451
data, err := os.ReadFile(filename)
452452
if err != nil {
453-
return nil, fmt.Errorf("failed to read hosts file: %v", err)
453+
return nil, fmt.Errorf("failed to read hosts file: %w", err)
454454
}
455455

456456
lines := strings.Split(string(data), "\n")
@@ -478,12 +478,12 @@ func loadTargetHosts(hostList []string, filename string) ([]string, error) {
478478
func outputFaviconJSON(results []*favicon.FaviconResult, filename string) error {
479479
data, err := json.MarshalIndent(results, "", " ")
480480
if err != nil {
481-
return fmt.Errorf("failed to marshal results: %v", err)
481+
return fmt.Errorf("failed to marshal results: %w", err)
482482
}
483483

484484
if filename != "" {
485485
if err := os.WriteFile(filename, data, 0644); err != nil {
486-
return fmt.Errorf("failed to write file: %v", err)
486+
return fmt.Errorf("failed to write file: %w", err)
487487
}
488488
fmt.Printf("📄 Results saved to: %s\n", filename)
489489
} else {
@@ -502,12 +502,12 @@ func outputFaviconCSV(results []*favicon.FaviconResult, filename string) error {
502502

503503
data, err := scanner.ExportResults(results, "csv")
504504
if err != nil {
505-
return fmt.Errorf("failed to export CSV: %v", err)
505+
return fmt.Errorf("failed to export CSV: %w", err)
506506
}
507507

508508
if filename != "" {
509509
if err := os.WriteFile(filename, data, 0644); err != nil {
510-
return fmt.Errorf("failed to write file: %v", err)
510+
return fmt.Errorf("failed to write file: %w", err)
511511
}
512512
fmt.Printf("📄 Results saved to: %s\n", filename)
513513
} else {

0 commit comments

Comments
 (0)