-
Notifications
You must be signed in to change notification settings - Fork 2
Custom flag for validator log table #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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
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
50 changes: 50 additions & 0 deletions
50
backend/app/alembic/versions/003_added_validator_config.py
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| """Added validator_config table | ||
|
|
||
| Revision ID: 003 | ||
| Revises: 002 | ||
| Create Date: 2026-02-05 09:42:54.128852 | ||
|
|
||
| """ | ||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| from sqlalchemy.dialects import postgresql | ||
| import sqlalchemy as sa | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = '003' | ||
| down_revision: str = '002' | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| op.create_table('validator_config', | ||
| sa.Column('id', sa.Uuid(), nullable=False), | ||
| sa.Column('organization_id', sa.Integer(), nullable=False), | ||
| sa.Column('project_id', sa.Integer(), nullable=False), | ||
| sa.Column('type', sa.String(), nullable=False), | ||
| sa.Column('stage', sa.String(), nullable=False), | ||
| sa.Column('on_fail_action', sa.String(), nullable=False), | ||
| sa.Column( | ||
| "config", | ||
| postgresql.JSONB(astext_type=sa.Text()), | ||
| nullable=False, | ||
| server_default=sa.text("'{}'::jsonb"), | ||
| ), | ||
| sa.Column('is_enabled', sa.Boolean(), nullable=False, server_default=sa.true()), | ||
| sa.Column('created_at', sa.DateTime(), nullable=False), | ||
| sa.Column('updated_at', sa.DateTime(), nullable=False), | ||
|
|
||
| sa.PrimaryKeyConstraint('id'), | ||
| sa.UniqueConstraint('organization_id', 'project_id', 'type', 'stage', name='uq_validator_identity') | ||
| ) | ||
|
|
||
| op.create_index("idx_validator_organization", "validator_config", ["organization_id"]) | ||
| op.create_index("idx_validator_project", "validator_config", ["project_id"]) | ||
| op.create_index("idx_validator_type", "validator_config", ["type"]) | ||
| op.create_index("idx_validator_stage", "validator_config", ["stage"]) | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| op.drop_table('validator_config') |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,11 @@ | ||
| from fastapi import APIRouter | ||
|
|
||
| from app.api.routes import utils, guardrails | ||
| from app.api.routes import utils, guardrails, validator_configs | ||
|
|
||
| api_router = APIRouter() | ||
| api_router.include_router(utils.router) | ||
| api_router.include_router(guardrails.router) | ||
| api_router.include_router(validator_configs.router) | ||
|
|
||
| # if settings.ENVIRONMENT == "local": | ||
| # api_router.include_router(private.router) |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| from typing import Optional | ||
| from uuid import UUID | ||
|
|
||
| from fastapi import APIRouter | ||
|
|
||
| from app.api.deps import AuthDep, SessionDep | ||
| from app.core.enum import Stage, ValidatorType | ||
| from app.schemas.validator_config import ValidatorCreate, ValidatorResponse, ValidatorUpdate | ||
| from app.crud.validator_config import validator_config_crud | ||
| from app.utils import APIResponse | ||
|
|
||
|
|
||
| router = APIRouter( | ||
| prefix="/guardrails/validators/configs", | ||
| tags=["validator configs"], | ||
| ) | ||
|
|
||
|
|
||
| @router.post( | ||
| "/", | ||
| response_model=APIResponse[ValidatorResponse] | ||
| ) | ||
| def create_validator( | ||
| payload: ValidatorCreate, | ||
| session: SessionDep, | ||
| organization_id: int, | ||
| project_id: int, | ||
| _: AuthDep, | ||
| ): | ||
| response_model = validator_config_crud.create(session, organization_id, project_id, payload) | ||
| return APIResponse.success_response(data=response_model) | ||
|
|
||
| @router.get( | ||
| "/", | ||
| response_model=APIResponse[list[ValidatorResponse]] | ||
| ) | ||
| def list_validators( | ||
| organization_id: int, | ||
| project_id: int, | ||
| session: SessionDep, | ||
| _: AuthDep, | ||
| stage: Optional[Stage] = None, | ||
| type: Optional[ValidatorType] = None, | ||
| ): | ||
| response_model = validator_config_crud.list(session, organization_id, project_id, stage, type) | ||
| return APIResponse.success_response(data=response_model) | ||
|
|
||
|
|
||
| @router.get( | ||
| "/{id}", | ||
| response_model=APIResponse[ValidatorResponse] | ||
| ) | ||
| def get_validator( | ||
| id: UUID, | ||
| organization_id: int, | ||
| project_id: int, | ||
| session: SessionDep, | ||
| _: AuthDep, | ||
| ): | ||
| obj = validator_config_crud.get(session, id, organization_id, project_id) | ||
| return APIResponse.success_response(data=validator_config_crud.flatten(obj)) | ||
|
|
||
|
|
||
| @router.patch( | ||
| "/{id}", | ||
| response_model=APIResponse[ValidatorResponse] | ||
| ) | ||
| def update_validator( | ||
| id: UUID, | ||
| organization_id: int, | ||
| project_id: int, | ||
| payload: ValidatorUpdate, | ||
| session: SessionDep, | ||
| _: AuthDep, | ||
| ): | ||
| obj = validator_config_crud.get(session, id, organization_id, project_id) | ||
| response_model = validator_config_crud.update(session, obj, payload.model_dump(exclude_unset=True)) | ||
| return APIResponse.success_response(data=response_model) | ||
|
|
||
|
|
||
| @router.delete( | ||
| "/{id}", | ||
| response_model=APIResponse[dict] | ||
| ) | ||
| def delete_validator( | ||
| id: UUID, | ||
| organization_id: int, | ||
| project_id: int, | ||
| session: SessionDep, | ||
| _: AuthDep, | ||
| ): | ||
| obj = validator_config_crud.get(session, id, organization_id, project_id) | ||
| validator_config_crud.delete(session, obj) | ||
| return APIResponse.success_response(data={"message": "Validator deleted successfully"}) | ||
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
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
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
Empty file.
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ssumption_bias_safety_validator_config.py → ...ssumption_bias_safety_validator_config.py
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
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
2 changes: 1 addition & 1 deletion
2
...rs/pii_remover_safety_validator_config.py → ...ig/pii_remover_safety_validator_config.py
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| from app.crud.request_log import RequestLogCrud | ||
| from app.crud.request_log import RequestLogCrud |
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 1753
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 4736
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 4112
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 429
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 3845
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 136
🏁 Script executed:
# Check the full deps.py file to understand dependency injection cat -n backend/app/api/deps.pyRepository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 1438
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 2872
🏁 Script executed:
Repository: ProjectTech4DevAI/kaapi-guardrails
Length of output: 3018
organization_idandproject_idare unauthenticated query parameters with no tenant validation.These tenant-scoping parameters are passed as plain query parameters with zero validation against the authenticated user's identity. The
AuthDepdependency only validates a static bearer token—it does not extract or enforce tenant affiliation. Any authenticated caller can pass arbitraryorganization_idandproject_idvalues to create, read, update, or delete validators in any tenant. The CRUD layer accepts these parameters without access control checks, enabling cross-tenant data access.🤖 Prompt for AI Agents