Our linter's "safe" autofix would have silently disabled RBAC
Описание и применение
Автоматический исправитель линтера может незаметно отключить контроль доступа на основе ролей в AI‑агенте, если изменить аннотацию типа. Добавлен тест‑гвард, проверяющий точное объявление типа, чтобы предотвратить такой сбой.
Задача
A type annotation change that appears harmless can silently disable role‑based access control (RBAC) in a LangChain‑based AI agent, allowing privileged actions to run as admin.
Результат
Adding a guard test that validates the exact type annotation prevents accidental RBAC bypass caused by automated linting fixes.
Рабочий процесс
- 1. Identify functions with config: Annotated[..., InjectedToolArg] parameter.
- 2. Run a static scanner to ensure the type is exactly RunnableConfig.
- 3. Build a tool instance for each spelling (bare, widened, optional_form).
- 4. Assert that the bare form receives injected config and the others do not.
- 5. Add the guard test to CI pipeline.
- 6. Keep a comment explaining the rule for developers.
- 7. Monitor for framework changes that alter type matching logic.
Доказательства
The guard is a test that asserts the annotation itself. It scans every config: Annotated[..., InjectedToolArg] parameter in the source and fails if any is not bare RunnableConfig.
Plain ruff check --fix — the command people run without reading the diff — converts a working authorization boundary into a no‑op.
- Дата записи: 2026-09-22T08:15:41.077Z