Enforced provider and projectID in db call#6303
Enforced provider and projectID in db call#6303DharunMR wants to merge 1 commit intomindersec:mainfrom
Conversation
evankanderson
left a comment
There was a problem hiding this comment.
It looks like you may also have a merge conflict, but this looks good other than a few small comments -- I'd like to avoid adding remote (serial) lookups in loop contexts -- I didn't look in enough detail to know for sure here if that was happening..
8e99b54 to
5c1b61d
Compare
evankanderson
left a comment
There was a problem hiding this comment.
I think you just force-pushed to the wrong branch. :-/
5c1b61d to
6933e2f
Compare
Unfortunatly! now solved it |
1063a3e to
d7067a1
Compare
|
@evankanderson i've verified the tests pass locally ,but fails ci |
evankanderson
left a comment
There was a problem hiding this comment.
One small concern about duplicating getAuthorizedProjects logic twice, and some code that I think is functionally dead and should probably be removed.
| } | ||
|
|
||
| ewp, err := ps.getEntityWithProperties(ctx, *ent, opts) | ||
| projects, err := ps.getAuthorizedProjects(ctx, ent.ProjectID) |
There was a problem hiding this comment.
Verified that this is only called by getEntityInner, which is only called by the strategies in handlers/strategies/entity for handling updates of resources which were auto-created due to parent resources.
There was a problem hiding this comment.
(In response to the question whether this was called in a loop)
There was a problem hiding this comment.
I had actually removed getAuthorizedProjects in my latest commit
676c0cb to
32fc7d8
Compare
d655ebe to
2c90a2a
Compare
|
(This has a merge conflict again, sorry!) |
2c90a2a to
6699a36
Compare
resolved it now |
Signed-off-by: DharunMR <maddharun56@gmail.com>
6699a36 to
4a67fc4
Compare
Summary
This PR implements strict security boundaries for entity retrieval and property management by enforcing the Security Triple (EntityID, ProjectID, ProviderID) across the database and service layers.
Previously, certain database calls and service methods relied on incomplete identifiers, which theoretically could allow for cross-provider or cross-project data access if an ID was known. This refactor ensures that every entity-related operation is strictly bounded by both the project and the provider that owns the entity.
Key Changes:
Database Layer (SQL)
Enforced Constraints: Updated GetEntityByID, GetEntityByName, and DeleteEntity queries in entities.sql to require project_id and provider_id. Property Security: Updated property-related queries (GetProperty, GetAllPropertiesForEntity, DeleteProperty) to utilize JOIN or USING clauses against entity_instances, ensuring property operations cannot bypass entity ownership boundaries. Optimized Flush Cache: Updated ListFlushCache to join with entity_instances, allowing background workers to retrieve the provider_id directly from the database without extra Go-side lookups.
Service Layer (Go)
Property Service: Refactored EntityWithPropertiesByID and related methods to accept and validate the full Security Triple. Repository Service: Updated GetRepositoryById, GetRepositoryByName, and Delete methods to pass mandatory security parameters. EEA & Background Workers: Updated the Event Aggregator and reconcilers to use the ProviderID now provided by the enhanced flush cache queries.
API & Middleware
Controlplane: Updated API handlers (Artifacts, Repositories, Profiles) to translate provider names from the request context into UUIDs via providerStore.GetByName to satisfy the new database constraints.
Fixes Enforce provider and project ID in
GetEntityByIDdb call #4417Fixes Enforce provider and project ID in EntityWithProperties in the properties service #4419
Testing
Test Suite
Ran go test ./... (100% passing) to verify that the embedded database correctly respects the new project_id slices and that all handlers propagate context properly.Manual Verification