Salma/advanced hunting - #36
Merged
Merged
Conversation
- Implement shared queryRunner with KQL translation and index scoping - Add HuntingQuery model and migration
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an “Advanced Hunting” capability by adding endpoints to execute Elasticsearch queries (ES|QL/KQL) and CRUD “saved hunting queries” persisted in PostgreSQL (Prisma), plus optional seed tooling and mock data to populate log sources/events and initial hunting queries.
Changes:
- Added a new Hunting module (routes/controllers/services/types/validation) and registered it under
/hunting. - Implemented a shared query runner for ES|QL/KQL execution with result shaping, plus shared DTO/result types and validation.
- Added Prisma schema + migration for
HuntingQuery, and added seed script + mock dataset for local/demo environments.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/scripts/seedMockData.ts | Adds a script to seed Postgres log sources + hunting queries and index mock events into Elasticsearch. |
| src/scripts/mockData.json | Provides mock log sources, events, and default hunting queries used by the seed script. |
| src/routes/index.ts | Registers the new /hunting router. |
| src/modules/Hunting/validation/hunting.validation.ts | Adds Zod validation schemas for hunting query execution and saved queries. |
| src/modules/Hunting/types/types.ts | Adds DTO/types for hunting execution and saved-query CRUD/listing. |
| src/modules/Hunting/services/hunting.service.ts | Implements Elasticsearch execution and Postgres CRUD/pagination for saved queries. |
| src/modules/Hunting/routes/hunting.routes.ts | Defines authenticated hunting endpoints for execution and saved-query CRUD. |
| src/modules/Hunting/controllers/hunting.controller.ts | Adds request handlers for executing queries and managing saved queries. |
| src/common/validation/query.validation.ts | Adds shared body validation for query execution payloads. |
| src/common/utils/queryRunner.ts | Implements ES |
| src/common/interfaces/query.types.ts | Adds shared interfaces for query execution DTO and normalized results. |
| prisma/schema.prisma | Adds the HuntingQuery Prisma model. |
| prisma/migrations/20260712145451_add_hunting_query_model/migration.sql | Creates the HuntingQuery table + unique index (and currently also creates an unrelated enum). |
| docker-compose.yml | Exposes Postgres on host port 5433 while keeping container port 5432 for the API container. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1
to
+3
| -- CreateEnum | ||
| CREATE TYPE "crdb_internal_region" AS ENUM ('aws-eu-central-1'); | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Comment on lines
+1
to
+3
| -- CreateEnum | ||
| CREATE TYPE "crdb_internal_region" AS ENUM ('aws-eu-central-1'); | ||
|
|
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.