Engined¶
Package main provides the Engine-AntiGinx daemon (Engined) that listens for security scan tasks from a RabbitMQ message queue and executes them asynchronously.
Engined acts as a background worker service that:
- Connects to RabbitMQ and consumes messages from "scan_queue"
- Parses incoming JSON task payloads containing target URLs
- Spawns the Engine-AntiGinx scanner for each task
- Handles graceful shutdown on interrupt signals (SIGINT)
Architecture:
┌─────────────┐ ┌─────────────┐ ┌─────────────────┐
│ Backend │────▶│ RabbitMQ │────▶│ Engined │
│ (Producer) │ │ scan_queue │ │ (Consumer) │
└─────────────┘ └─────────────┘ └────────┬────────┘
│
▼
┌─────────────────┐
│ Engine-AntiGinx│
│ Scanner (App) │
└─────────────────┘
Environment Variables:
- RABBITMQ_URL: Connection string for RabbitMQ (required) Example: amqp://guest:guest@localhost:5672/
Message Format (JSON):
Error Handling:
- Invalid JSON messages are NACK'd without requeue
- Scanner execution errors are NACK'd without requeue
- Successful scans are ACK'd to remove from queue
Graceful Shutdown:
The daemon handles SIGINT (Ctrl+C) gracefully by:
- Setting shutdown flag to prevent new task processing
- Completing any in-progress task
- Closing RabbitMQ connections
- Exiting cleanly
Index¶
- func consumeSafe(msgs \<-chan amqp.Delivery, isShuttingDown *bool, errMidConn chan *amqp.Error, closeChannel chan os.Signal)
- func findParam(params []*types.CommandParameter, paramToFind string) int
- func handleScanError(stderrBuff *bytes.Buffer, msg amqp.Delivery)
- func main()
- func runScan(messageBody []byte, stderrBuff *bytes.Buffer) error
- type EngineTask
- type RabbitConfig
- func configureRabbitConnection(queueUrl string) (*RabbitConfig, error)
func consumeSafe¶
func consumeSafe(msgs <-chan amqp.Delivery, isShuttingDown *bool, errMidConn chan *amqp.Error, closeChannel chan os.Signal)
func findParam¶
func handleScanError¶
func main¶
main is the entry point for the Engine-AntiGinx daemon. It establishes a connection to RabbitMQ, sets up message consumption, and enters an infinite loop to process incoming scan tasks.
The daemon performs the following steps:
- Set up interrupt signal handling for graceful shutdown
- Read RABBITMQ_URL from environment variables
- Establish connection to RabbitMQ
- Create a channel and start consuming from "scan_queue"
- Process each message by spawning the scanner subprocess
- ACK/NACK messages based on processing success
- Handle graceful shutdown on SIGINT
The main loop uses a select statement to handle:
- Incoming messages from RabbitMQ
- Interrupt signals for shutdown
Environment Requirements:
- RABBITMQ_URL must be set
- RabbitMQ server must be accessible
- "scan_queue" must exist in RabbitMQ
func runScan¶
type EngineTask¶
EngineTask represents a security scan task received from the message queue. It contains the necessary information to execute a security assessment against a target URL.
Fields:
- Id: Unique identifier for the task, used for tracking and reporting
- Target: The URL to scan (e.g., "https://example.com")
JSON Example:
type RabbitConfig¶
type RabbitConfig struct {
ConnCh *amqp.Connection
TaskCh *amqp.Channel
ErrMidConnCh chan *amqp.Error
}
func configureRabbitConnection¶
Generated by gomarkdoc