business-decision/query-security-bundle
QuerySecurityBundle appears to address SQL injection, query manipulation, and unauthorized data access risks—critical for applications handling sensitive business logic (e.g., financial, healthcare, or compliance-driven systems). It aligns well with Laravel/Symfony ecosystems where ORM-level security is a priority.QueryBuilder events (before:, after:) could mirror Symfony’s event system.SELECT id, name FROM users WHERE user_id = ? AND department = ?).QuerySecurityListener could be replicated with Laravel’s Model::boot() or QueryException handling.config/query_security.php.JOIN with WHERE clauses).| Component | Symfony Equivalent | Laravel Alternative |
|---|---|---|
| Event Listeners | kernel.events |
Eloquent Model::boot() or QueryException |
| Configuration | YAML/XML | PHP array (config/) or .env |
| Dependency Injection | Symfony DI | Laravel Service Container |
| Query Builder | Doctrine DBAL | Laravel Query Builder |
Log facade + monolog for audit trails.Phase 1: Proof of Concept (2 weeks)
laravel-query-security).QuerySecurityService with:
allowedFields(['id', 'name'])).whereDepartment($user->department)).User, Payment).Phase 2: Full Integration (4 weeks)
Model::boot() or QueryException listeners.config/query_security.php:
'policies' => [
'App\Models\User' => [
'allowed_fields' => ['id', 'name', 'email'],
'row_filters' => [
'admin' => fn($query) => $query->where('is_admin', true),
],
],
],
ValidateQueryMiddleware).Phase 3: Optimization (2 weeks)
Model::boot()) or 10+ (for improved Query Builder).illuminate/database < v8).User::all() in admin panel).try-catch in query listeners).config/query_security.php reduce scattered if statements in controllers.payments table").dd($query->toSql()) to inspect secured queries.WHERE user_id = ?).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Misconfigured Policy | Legitimate queries blocked | Unit tests + canary releases |
| Database Connection Drop | Secured queries fail silently | Retry logic + circuit breakers |
| Policy Cache Invalidation | Stale rules applied | Cache invalidation on policy change |
| ORM Version Incompatibility | Bundle breaks on Laravel update | Semantic versioning + deprecation warnings |
QUERY_SECURITY.md with:
@policy("allowed_fields")).php artisan make:query-policy User --fields=id,name --filters=department
config('query_security.enabled' = false)).How can I help you explore Laravel packages today?