一键导入
check-orgid
Audit backend code to ensure all queries properly filter by OrgId for multi-tenant security
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Audit backend code to ensure all queries properly filter by OrgId for multi-tenant security
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | check-orgid |
| description | Audit backend code to ensure all queries properly filter by OrgId for multi-tenant security |
| disable-model-invocation | false |
| allowed-tools | Read, Grep, Glob |
Audit backend services to ensure proper OrgId filtering for multi-tenant data isolation.
This skill performs a security audit to verify that all database queries properly filter by OrgId.
backend/omsapi/Services/ ending with Service.csCRITICAL: The OmsContext does NOT have global query filters enabled. All queries MUST manually filter by OrgId.
Must include: .Where(x => x.OrgId == currentOrgId)
Example:
public async Task<List<EntityDto>> GetListAsync()
{
var currentOrgId = _httpContextAccessor.HttpContext!.GetCurrentOrgId();
var entities = await _context.Entities
.Where(x => x.OrgId == currentOrgId) // ✓ REQUIRED
.ToListAsync();
return entities.Select(MapToDto).ToList();
}
Must verify OrgId ownership before modification:
public async Task<EntityDto> UpdateAsync(long id, UpdateEntityDto dto)
{
var currentOrgId = _httpContextAccessor.HttpContext!.GetCurrentOrgId();
var entity = await _context.Entities
.Where(x => x.Id == id && x.OrgId == currentOrgId) // ✓ REQUIRED
.FirstOrDefaultAsync();
if (entity == null)
throw new Exception("Entity not found or access denied");
// Update logic...
}
Find all service files:
Glob pattern: backend/omsapi/Services/*Service.cs
For each service file:
_contextLook for violations:
.Where(x => x.OrgId == currentOrgId).Find() or .FirstOrDefault() without OrgId filterReport findings:
❌ Missing OrgId filter:
var entities = await _context.Entities.ToListAsync(); // WRONG!
✓ Correct:
var currentOrgId = _httpContextAccessor.HttpContext!.GetCurrentOrgId();
var entities = await _context.Entities
.Where(x => x.OrgId == currentOrgId)
.ToListAsync();
❌ Update without verification:
var entity = await _context.Entities.FindAsync(id); // WRONG!
✓ Correct:
var currentOrgId = _httpContextAccessor.HttpContext!.GetCurrentOrgId();
var entity = await _context.Entities
.Where(x => x.Id == id && x.OrgId == currentOrgId)
.FirstOrDefaultAsync();
Some services may legitimately skip OrgId filtering:
For these exceptions, verify they have proper role-based authorization checks.
Provide a report with:
Example:
OrgId Security Audit Report
===========================
Summary:
- Services checked: 15
- Violations found: 3
- Critical issues: 2
- Warnings: 1
Critical Issues:
1. ProductService.cs:45 - GetListAsync()
Missing OrgId filter on query
Fix: Add .Where(x => x.OrgId == currentOrgId)
2. OrderService.cs:78 - DeleteAsync()
No OrgId verification before delete
Fix: Add OrgId check in Where clause
Warnings:
1. UserService.cs:120 - GetAllUsersAsync()
Cross-org query detected - verify authorization
If user approves, can automatically add OrgId filters to violations:
var currentOrgId = _httpContextAccessor.HttpContext!.GetCurrentOrgId(); if missing.Where(x => x.OrgId == currentOrgId) to the queryAlways ask for confirmation before modifying code.
Add a new API endpoint with controller, service, and DTOs following OMS patterns
Add a new database entity with migrations for all three databases (MySQL, MSSQL, PostgreSQL)
Add a new mobile page to frontend.h5 using Vant 4 components
Add a new frontend page with proper layout, table, and API integration following OMS UI standards
Debug and troubleshoot issues in the OMS system with systematic approach
Create database migration files for all three databases (MySQL, MSSQL, PostgreSQL) when schema changes are needed