Commit Graph

281 Commits

Author SHA1 Message Date
Lee Chagolla-Christensen fa4f1b05bd Merge remote-tracking branch 'origin/main' into perf_updates 2025-11-12 00:07:15 -08:00
Lee Chagolla-Christensen 5de5e23a30 Centralize workflow management and improve resource cleanup
Workflow Client Simplification:
- Removed async_workflow_client.py
- Removed taskhub_client.py
- Renamed set_fastapi_loop to set_workflow_runtime_loop

Workflow Purger Enhancement (+354 lines):
- Added configurable timeout detection for workflows
- Implemented database cursor streaming for batches
- Parallelized Dapr purge operations

Database Schema Changes:
- Added TIMEOUT status to workflow enum

Resource Management Refactor:
- Use AsyncExitStack in lifespan function
- Added cancel_task helper for graceful shutdowns
- Registered cleanup callbacks for automatic teardown

File Enrichment Controller:
- Moved event loop setup before FastAPI
- Extracted health endpoint to separate router

Performance Improvements:
- Changed DPAPI monitor interval: 5s to 30s
- Implemented parallel workflow purge operations
- Added DB cursor for workflow purging
- Removed PID logging

New Features:
- Refactored timeout termination for workflows

Configuration Updates:
- MAX_PARALLEL_WORKFLOWS: 2 to 1 (debug)
- WORKFLOW_CLIENT_LOG_LEVEL: INFO to DEBUG
- Enhanced README debugging instructions for file enrichment
- Disabled structlog timestamp processor

Web API Changes:
- Changed TERMINATED to TIMEOUT in queries
- Updated reporting routes for new status

Infrastructure:
- Added jq and iputils-ping to dev Dockerfile
2025-11-11 23:59:43 -08:00
harmj0y 416d8fde2c Prod image build fix 2025-11-09 21:30:00 -08:00
harmj0y bf52bc62af Moved Agents to Settings page, combined Chrome+DPAPI
- Moved `Agents` to Settings page
- Combined Chromium + DPAPI pages
2025-11-09 14:17:54 -08:00
Lee Chagolla-Christensen 50a8e4e25f Merge branch 'main' of github.com:SpecterOps/Nemesis 2025-11-08 16:15:14 -08:00
Lee Chagolla-Christensen 5d7b9bb31d Centralized workflow purging/tracking, perf improvements
Infrastructure:
- Enable pg_stat_statements extension for query monitoring
- Increase Postgres max connections and shared buffers
- Bump RabbitMQ prefetchCount to 100
- Add curl/netstat/htop to dev Docker image

Database:
- Add indexes for findings and workflows
- Add workflow status constraint and is_purged column
- Index workflows by object_id for active workflows

Workflow tracking:
- Add WorkflowStatus enum
- Added finalize_workflow activity
- Generate instance IDs with name prefix pattern
  (<name>.<instance>.<object_id>)

Workflow purging:
- Create WorkflowPurger to purge Dapr workflow data (kills perf over
  time)
- added to file_enrichment/document_conversion
- New workflows column to track purge workflows

File linking:
- Optimize upserts to single query (perf)

Configuration:
- PII info in env.example
2025-11-08 16:08:11 -08:00
harmj0y 75037a4b5d Exposed Nemesis MCP
- Exposed Nemesis Postgres MCP on /mcp route
- Added `tools/mcp_bridge.py`
2025-11-08 14:54:44 -08:00
harmj0y ac6704cd71 Poetry fixes
- Poetry fixes
2025-11-07 15:13:25 -08:00
Will Schroeder 1339efabbd Merge pull request #91 from SpecterOps/llm_chat_over_data
Llm chat over data
2025-11-07 13:48:45 -08:00
harmj0y 21e75426d3 npm fix for frontend
npm fix for frontend
2025-11-07 13:30:32 -08:00
harmj0y ff80fcdc35 Update poetry.lock 2025-11-07 13:24:01 -08:00
Will Schroeder 3628bf18d7 Merge branch 'main' into llm_chat_over_data 2025-11-07 13:22:16 -08:00
harmj0y 8b7ec6540d Update poetry.lock 2025-11-07 13:20:33 -08:00
harmj0y a706b50816 Update poetry.lock 2025-11-07 13:10:37 -08:00
harmj0y a014c52338 missed library
-missed library
2025-11-07 13:03:06 -08:00
harmj0y cf8b72b955 Added additional tools for searching for host access
- Added additional tools for searching for host access
2025-11-07 13:01:37 -08:00
harmj0y 09129e4bf1 frontend package fix
frontend package fix
2025-11-07 12:30:33 -08:00
harmj0y cd215a5255 Fixed UUID casting for chatbot tools
- Fixed UUID casting for chatbot tools
2025-11-07 12:17:00 -08:00
Lee Chagolla-Christensen b92f56a8a7 fix presidio on prod, debug logs 2025-11-07 10:55:12 -08:00
Lee Chagolla-Christensen caf9815890 Merge branch 'main' of github.com:SpecterOps/Nemesis 2025-11-07 10:54:45 -08:00
harmj0y 7de1e17e76 Added text searching tool
- Added text searching tool
2025-11-07 09:24:08 -08:00
Lee Chagolla-Christensen 562a4e71ca Optimize observability stack and workflow throughput
Performance and configuration improvements:
- Tune OpenTelemetry Collector with batching, queuing, and memory limits
- Optimize Jaeger for write-heavy workloads with consistency disabled
- Add Prometheus scraping for OTel Collector internal metrics
- Increase document conversion prefetch count from 1 to 5
- Add CPU limit (2 cores) for document-conversion service
- Disable Tesseract OCR in default Tika config for faster processing

Workflow tracking enhancements:
- Add WorkflowTrackingService for centralized workflow state management
- Implement finalize_workflow activities for both services
- Track enrichment success/failure per workflow instance
- Support updating workflow status by object_id for subscriptions

Code improvements:
- Refactor PDF analyzer with modular extraction functions
- Add Unicode surrogate sanitization to prevent JSONB errors
- Update PII analyzer with improved error handling
- Add documentation links to Tika and Tesseract configuration

Frontend:
- Update StatsOverview component for workflow metrics display
2025-11-07 00:58:58 -08:00
harmj0y 5991024e94 token warning for chatbot
- token warning for `chatbot`
2025-11-06 20:05:11 -08:00
harmj0y d9dc7ffb6e Changed the chatbot verboseness
-Changed the chatbot verboseness
2025-11-06 19:48:18 -08:00
harmj0y 7c99097c3a Update ChatbotPage.jsx 2025-11-06 19:30:47 -08:00
harmj0y 68586c008b Update ChatbotPage.jsx 2025-11-06 19:22:30 -08:00
harmj0y 61b1199e4d Update ChatbotPage.jsx 2025-11-06 19:21:25 -08:00
harmj0y e23411de22 Tools/MCP working
- Tools/MCP working
- Changed layout of chat interface a bit
2025-11-06 19:16:28 -08:00
harmj0y 672fbb3550 Initial Chatbot commit
- Initial Chatbot commit
2025-11-06 18:30:11 -08:00
harmj0y 78390b410b PII analyzer disabled by default, added documentation
- PII analyzer disabled by default, can be enabled via ENV variable
- Created `enrichment_configuration.md` documentation documenting all enrichment module configurations
2025-11-06 11:08:59 -08:00
Lee Chagolla-Christensen 58dd461532 Refactor document conversion service into Dapr workflow
- Restructure document_conversion to match into workflow structure
- PDF analyzer: use PyMuPDF and extract extensive metadata
- Add PDF test suite with encrypted/unencrypted fixtures
- Add Tika Tesseract OCR configuration support example
- Update Dapr configurations for new document_conversion component
- Remove deprecated helpers from common lib
- Update queue constants and workflow setup
2025-11-06 01:30:10 -08:00
harmj0y e621901c20 First pass at presidio for PII detection
- First pass at presidio for PII detection
2025-11-05 20:17:13 -08:00
harmj0y 2314f52991 Fixes for container status updates
- Fixes for container status updates
2025-11-05 19:32:36 -08:00
harmj0y deab3b0436 Temp disable yara re-running button
- Temp disable yara re-running button until we work out the proper internals for re-running a single enrichment with the new architecture
2025-11-05 13:38:58 -08:00
harmj0y fe6988fb6b Update vuln package
- Update vuln package
2025-11-05 10:40:29 -08:00
Lee Chagolla-Christensen 6ec0a3b61a Workflow performance improvements (#87)
* upgrade to dapr postgresv2 statestore

* actually make it v2

* dapr state table name, cleanup subscriptions/globals

* proper exceptions

* formatting/lint

* Refactor workflow tracking and improve activity input handling

- Extract workflow tracking logic into dedicated WorkflowTrackingService
- Simplify activity signatures to accept specific parameters instead of generic dicts
- Remove unused asyncio event loop references from enrichment modules
- Update YaraRuleManager initialization and method names

* re-added workflow tracking in the DB

* update uvicorn prod options

* enrichment work parallelism, convert queues from broadcast to task queues

* Refactor pubsub and improve workflow parallelism

- Split Dapr pubsub Dapr yaml components into topic-specific queues (alerting, dotnet, dpapi, files, noseyparker, workflow_monitor)
- Update all Dapr volume mounts to reference new topic-specific pubsub components
- Converted queues to task queues
- Use YAML anchors to reduce duplication for file-enrichment replicas
- Pass asyncpg pool to enrichment modules instead of creating connections
- Add asyncpg_pool parameter throughout chromium and enrichment module analyzers
- Update VSCode workspace (removed InspectAssembly, renamed dotnet_api to dotnet_service)
- Added curl commands for Jaeger API to performance docs to help with perf troubleshooting
- Created common.queues module to centralize pubsub/topic names (eases
  future refactoring)

* worker mods

* Workflow performance tuning, fix pubsub config, CLI arg changes

- Fix pubsub deleteWhenUnused typo (deletedWhenUnused)
- Add LOG_LEVEL environment variable support across services
- CLI: Rename --repeat to --times, add --max-files option
- Increase files pubsub prefetchCount from 25 to 50
- Add MAX_PARALLEL_WORKFLOWS configuration
- Fix DotNetAssemblyAnalysis null handling with field validators
- Update dashboard to show cumulative files/findings over time
- Add RUST_LOG environment variable support to noseyparker
- Update CHANGELOG for 2.1.4 release notes

* Dapr 1.16.2 and use db transactions

- Upgrade all Dapr containers from 1.16.1 to 1.16.2
- Reduce enrichment parallelism default from 25 to 5 workflows
- Reduce healthcheck intervals from 10s to 5s for alerting and document conversion
- Fixed DPAPI eventing to use new pubsubs
- Refactor file_linking database operations to use atomic upserts and avoid deadlocks
- Add WriteOnceViolationError handling in DPAPI masterkey analyzer
- Wrap database operations in transactions for enrichment storage and plaintext indexing
- Fix postgres notification handler closure variable capture

* remove unused start_time

* Scheduler persistence, workflow concurrency tuning, and config cleanup

- Add volume for Dapr scheduler and init service
- Add scheduler dependency to file enrichment service
- Add async workflow client libraries
- Format and cleanup compose.yaml (spacing, indentation, empty lines)

* Migrate file_enrichment to async Dapr client and optimize Dockerfile

- Use async DaprClient where possible in file_enrichment
- Improve Dockerfile caching
- Add asyncpg connection pool helper and fix typo in secret store name
- Include VS Code debug configuration for document_conversion
- Remove unused dapr_client from DpapiBlobAnalyzer
- Clean up activity return types and better handle exceptions

* Enrichment tracking for NoseyParker and logging cleanup

- Add workflow_id to NoseyParkerInput and NoseyParkerOutput models
- Remove workflow lookup query in noseyparker subscription handler
- Adjust jaeger_perf_stats.sh output formatting and precision
- Add type hints for async functions

* noseyparker scanner perf, tracing for update_enrichment_results

---------

Co-authored-by: Lee Chagolla-Christensen <lee@localhost>
2025-11-04 14:06:59 -08:00
Will Schroeder 82d8f76e80 Merge pull request #86 from SpecterOps/dependabot_updates_03_11_25-2
Version bumps
2025-11-03 12:40:25 -08:00
harmj0y e271cf8e65 Version bumps
- `brace-expansion` for `frontend`
- `aiohttp` for `housekeeping`
- `tracing-subscriber` for `noseyparker_scanner`
2025-11-03 12:40:05 -08:00
harmj0y 6eababe2ce Bump react-syntax-highlighter
- Bump `react-syntax-highlighter` to resolve https://github.com/SpecterOps/Nemesis/security/dependabot/402
2025-11-03 11:57:40 -08:00
harmj0y 09915c7bf3 Impacket and Cryptography bump
- Impacket and Cryptography bump
2025-11-03 11:32:46 -08:00
Will Schroeder d4049fe199 Dependabot updates 03 11 25 (#84)
* starlette fixes

starlette fixes

* pypdf fixes

pypdf fixes

* bump urllib3

bump urllib3

* vite bump

vite bump

* Bump requests

Bump requests

* Replaced pypdf2 with pypdf

-Replaced pypdf2 with pypdf
2025-11-03 10:42:51 -08:00
harmj0y dd008f3d7b Adjusted severities for several findings
-Adjusted severities for several findings
2025-10-31 16:05:35 -07:00
harmj0y 129f7752c2 Added manual Chromium ABE key submission
- Added manual Chromium ABE key submission (w/ retroactive chromium data decryption)
2025-10-31 15:22:28 -07:00
harmj0y 4b36f9b198 Update DpapiMasterKeys.jsx 2025-10-30 10:06:00 -07:00
harmj0y bfeb234e06 Update documentation
- Added `alerting` and `reporting` pages
- Updated `agents` page
2025-10-30 09:50:59 -07:00
harmj0y 411a818776 Findings/alert triage mods
- Findings/alert filtering options when LLM functionality enabled
- Fixed race-condition for noseyparker/dotnet analysis findings + alerts when these containers insert findings _after_ the main file_enrichment workflow completes
- Changed layout of alerting settings display
2025-10-29 12:32:49 -07:00
harmj0y f9e6e7bff1 Alerting changes
- Move JWT from agents noseyparker subscription in file_enrichment
- Add new fields to published alert in publish_findings.py
- Store alerting settings in database, accessible from Settings.jsx page
- Have alerting apply alerting settings before publishing
- Move Arize Phoenix and Agents into `llm` docker compose profile
2025-10-28 18:55:03 -07:00
Lee Chagolla-Christensen 3b4f110686 Async/performance improvement (#83)
* make all enrichment (should)process methods async

* fix office2john resource leak

* check for none

* more resource errors, add ole hash tests, pytest configs

* update chromium to use async pool

* update registry module to use asyncpg pool

* more asyncpg

* use async get_file_enriched

* update sleep

* fix dapr configs, new ones for workflow services

* remove deprecate/redundant httprequestmax setting

* disable workflow tracking (for now)

---------

Co-authored-by: Lee Chagolla-Christensen <lee@localhost>
2025-10-28 15:12:24 -07:00
harmj0y 1a95440c1c File cache fix
-File cache fix
2025-10-28 11:28:30 -07:00
harmj0y dc26e4959f Fixed container extraction status updates
- Fixed container extraction status updates
2025-10-28 11:18:36 -07:00