Skip to content

Salma/advanced hunting - #36

Merged
salmaaliia merged 12 commits into
mainfrom
salma/Advanced-hunting
Jul 12, 2026
Merged

salmaaliia merged 12 commits into
mainfrom
salma/Advanced-hunting

Conversation

@salmaaliia

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 thread src/common/utils/queryRunner.ts Outdated
Comment thread src/modules/Hunting/controllers/hunting.controller.ts Outdated
Comment thread src/scripts/seedMockData.ts
Comment on lines +1 to +3
-- CreateEnum
CREATE TYPE "crdb_internal_region" AS ENUM ('aws-eu-central-1');

salmaaliia and others added 3 commits July 13, 2026 01:32
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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.

Comment thread src/modules/Hunting/controllers/hunting.controller.ts Outdated
Comment thread src/scripts/seedMockData.ts Outdated
Comment on lines +1 to +3
-- CreateEnum
CREATE TYPE "crdb_internal_region" AS ENUM ('aws-eu-central-1');

salmaaliia and others added 4 commits July 13, 2026 01:48
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>
@salmaaliia
salmaaliia merged commit ec8120e into main Jul 12, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Task board Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants