feat(api): replace _provider_id property with label-based isolation and regex injection for custom queries#10402
Conversation
…nd regex injection for custom queries
|
✅ All necessary |
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
There was a problem hiding this comment.
Pull request overview
This PR refactors Attack Paths provider isolation from the _provider_id property to dynamic provider labels (_Provider_{uuid}), and adds a Cypher rewriter to automatically scope custom user-supplied queries by injecting the provider label into node patterns.
Changes:
- Replace
_provider_idproperty-based isolation with_Provider_{uuid}label-based isolation across sync, schema lookups, and API graph serialization. - Update predefined Attack Paths queries/templates and remove now-redundant provider filters/indexes.
- Add a regex-based Cypher rewriter with unit tests to inject provider scoping into custom Cypher queries.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| api/src/backend/tasks/jobs/attack_paths/sync.py | Stops writing _provider_id to synced nodes/relationships; relies on dynamic labels + _provider_element_id. |
| api/src/backend/tasks/jobs/attack_paths/queries.py | Removes provider property usage from sync templates and findings cleanup; adjusts findings templates. |
| api/src/backend/tasks/jobs/attack_paths/indexes.py | Removes indexes tied to removed provider properties (incl. findings provider_uid). |
| api/src/backend/tasks/jobs/attack_paths/config.py | Removes _provider_id isolation property constant; keeps _provider_element_id and label helpers. |
| api/src/backend/api/tests/test_cypher_rewriter.py | Adds unit tests for provider-label injection behavior in custom queries. |
| api/src/backend/api/tests/test_attack_paths.py | Updates tests to reflect label-based filtering and custom query rewriting. |
| api/src/backend/api/attack_paths/views_helpers.py | Uses label-based filtering for serialization; injects provider label into custom queries; schema query now label-scoped. |
| api/src/backend/api/attack_paths/queries/schema.py | Builds Cartography schema query scoped via provider label. |
| api/src/backend/api/attack_paths/queries/aws.py | Removes redundant provider filters from predefined AWS queries. |
| api/src/backend/api/attack_paths/database.py | Updates provider subgraph operations to match by provider label instead of property. |
| api/src/backend/api/attack_paths/cypher_rewriter.py | Introduces regex-based Cypher rewriting to inject provider labels into node patterns. |
| api/CHANGELOG.md | Documents the provider-isolation refactor and custom-query rewriting change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
🔒 Container Security ScanImage: 📊 Vulnerability Summary
4 package(s) affected
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #10402 +/- ##
==========================================
+ Coverage 93.37% 93.42% +0.04%
==========================================
Files 219 221 +2
Lines 30426 30655 +229
==========================================
+ Hits 28409 28638 +229
Misses 2017 2017
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Description
_provider_idproperty with_Provider_{uuid}label-based isolation across the Attack Paths module.CAN_ACCESSpath connectivity, andProwlerFindingdrops its redundantprovider_uidfilter.cypher_rewriter.py).Steps to review
Run tests and a local scan on an AWS provider using the UI. Then run Attack Paths pre-defined queries and some custom ones.
Checklist
API
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.