test(parity): C2 数据行级权限自举 + 对拍样本(3 实体×3 用户 100% + 负例)

自举 + 对拍证明保真层数据权限真实现与物理事实逐行对齐:

- bootstrap-privilege.sql(幂等):建 SYS_FILTERRULE + 中间表 SYS_FILTERRULEROLE
  (LIST 多值列经 REFERENCEVALUE→中间表落地)+ 自描述元数据;为 EIP4PT_TASK/
  PROJECT/CUSTOMER 各配 1 条 "CREATEBY = {CURRENTUSERID}" 规则,并把 CREATEBY
  重分区到 USER_ALICE/BOB/CAROL 使过滤可判别。
- ParityCli 增 --privilege 模式 + PrivilegeCheckRunner:被测侧经引擎
  GET /list?asUser&roles 触发行级过滤,基线侧 JDBC 同语义 WHERE,RowDiff 逐行比。
- EngineHttpClient 增 asUser/roles 透传 + statusOf(负例取状态码)。
- EntityController.list 增可选 asUser/roles 构造非 ADMIN ctx(引擎仅非 ADMIN 才过滤)。

实测:正例 3 实体×3 用户=9 例 150 行 100% 逐行一致;负例错误角色 3/3 抛
PrivilegeException(HTTP 500)被拒;回归 ParityCli --all 21/21、1108 行 100%。
报告:platform-auth/C2实测报告.md + parity-reports/privilege-parity-*.{json,md}。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-11 00:11:08 +08:00
parent fc867dc110
commit 83c6abb1f9
10 changed files with 1105 additions and 8 deletions

View File

@@ -0,0 +1,262 @@
{
"summary" : {
"entityCount" : 21,
"cleanEntities" : 21,
"totalRows" : 1108,
"entityConsistencyRate" : 1.0,
"allClean" : true
},
"reports" : [ {
"label" : "EIP4PT_ALLTYPE",
"keyColumns" : [ "EIP4PT_ALLTYPE_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_ASSET",
"keyColumns" : [ "EIP4PT_ASSET_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_COMBO",
"keyColumns" : [ "EIP4PT_COMBO_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_CONFIG",
"keyColumns" : [ "EIP4PT_CONFIG_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_CONTRACT",
"keyColumns" : [ "EIP4PT_CONTRACT_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_CUSTOMER",
"keyColumns" : [ "EIP4PT_CUSTOMER_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_DEPT",
"keyColumns" : [ "EIP4PT_DEPT_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_DEVICE",
"keyColumns" : [ "EIP4PT_DEVICE_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_EMPLOYEE",
"keyColumns" : [ "EIP4PT_EMPLOYEE_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_INVOICE",
"keyColumns" : [ "EIP4PT_INVOICE_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_LOG",
"keyColumns" : [ "EIP4PT_LOG_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_ORDER",
"keyColumns" : [ "EIP4PT_ORDER_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_ORDERLINE",
"keyColumns" : [ "EIP4PT_ORDERLINE_ID" ],
"leftRowCount" : 108,
"rightRowCount" : 108,
"matchedRows" : 108,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_PAYMENT",
"keyColumns" : [ "EIP4PT_PAYMENT_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_PRODUCT",
"keyColumns" : [ "EIP4PT_PRODUCT_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_PROJECT",
"keyColumns" : [ "EIP4PT_PROJECT_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_REFER",
"keyColumns" : [ "EIP4PT_REFER_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_STOCK",
"keyColumns" : [ "EIP4PT_STOCK_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_SUPPLIER",
"keyColumns" : [ "EIP4PT_SUPPLIER_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_TASK",
"keyColumns" : [ "EIP4PT_TASK_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_WAREHOUSE",
"keyColumns" : [ "EIP4PT_WAREHOUSE_ID" ],
"leftRowCount" : 50,
"rightRowCount" : 50,
"matchedRows" : 50,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
} ]
}

View File

@@ -0,0 +1,31 @@
# C1 自对拍报告
- 实体数: 21
- 全一致实体: 21
- 总比对行数(JDBC 基线侧): 1108
- 实体级一致率: 1.0000 ✅ 全部逐行一致
| 实体 | 行数 | 内容差异行 | 仅JDBC | 仅引擎 | 逐行一致率 | 结果 |
|---|---|---|---|---|---|---|
| EIP4PT_ALLTYPE | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_ASSET | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_COMBO | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_CONFIG | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_CONTRACT | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_CUSTOMER | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_DEPT | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_DEVICE | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_EMPLOYEE | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_INVOICE | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_LOG | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_ORDER | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_ORDERLINE | 108 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_PAYMENT | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_PRODUCT | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_PROJECT | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_REFER | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_STOCK | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_SUPPLIER | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_TASK | 50 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_WAREHOUSE | 50 | 0 | 0 | 0 | 1.0000 | ✅ |

View File

@@ -0,0 +1,125 @@
{
"summary" : {
"mode" : "privilege",
"positiveCases" : 9,
"positiveClean" : 9,
"totalRows" : 150,
"positiveConsistencyRate" : 1.0,
"negativeStatus" : {
"EIP4PT_CUSTOMER" : 500,
"EIP4PT_PROJECT" : 500,
"EIP4PT_TASK" : 500
},
"allNegativeRejected" : true,
"allPass" : true
},
"positive" : [ {
"label" : "EIP4PT_CUSTOMER[USER_ALICE]",
"keyColumns" : [ "EIP4PT_CUSTOMER_ID" ],
"leftRowCount" : 16,
"rightRowCount" : 16,
"matchedRows" : 16,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_CUSTOMER[USER_BOB]",
"keyColumns" : [ "EIP4PT_CUSTOMER_ID" ],
"leftRowCount" : 17,
"rightRowCount" : 17,
"matchedRows" : 17,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_CUSTOMER[USER_CAROL]",
"keyColumns" : [ "EIP4PT_CUSTOMER_ID" ],
"leftRowCount" : 17,
"rightRowCount" : 17,
"matchedRows" : 17,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_PROJECT[USER_ALICE]",
"keyColumns" : [ "EIP4PT_PROJECT_ID" ],
"leftRowCount" : 16,
"rightRowCount" : 16,
"matchedRows" : 16,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_PROJECT[USER_BOB]",
"keyColumns" : [ "EIP4PT_PROJECT_ID" ],
"leftRowCount" : 17,
"rightRowCount" : 17,
"matchedRows" : 17,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_PROJECT[USER_CAROL]",
"keyColumns" : [ "EIP4PT_PROJECT_ID" ],
"leftRowCount" : 17,
"rightRowCount" : 17,
"matchedRows" : 17,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_TASK[USER_ALICE]",
"keyColumns" : [ "EIP4PT_TASK_ID" ],
"leftRowCount" : 16,
"rightRowCount" : 16,
"matchedRows" : 16,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_TASK[USER_BOB]",
"keyColumns" : [ "EIP4PT_TASK_ID" ],
"leftRowCount" : 17,
"rightRowCount" : 17,
"matchedRows" : 17,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
}, {
"label" : "EIP4PT_TASK[USER_CAROL]",
"keyColumns" : [ "EIP4PT_TASK_ID" ],
"leftRowCount" : 17,
"rightRowCount" : 17,
"matchedRows" : 17,
"mismatchRows" : 0,
"onlyInLeft" : [ ],
"onlyInRight" : [ ],
"clean" : true,
"consistencyRate" : 1.0,
"mismatches" : [ ]
} ]
}

View File

@@ -0,0 +1,29 @@
# C2 数据行级权限对拍报告
- 正例(受控实体 × 用户): 9,全一致: 9
- 总比对行数(JDBC 基线侧): 150
- 正例逐行一致率: 1.0000 ✅ 全部逐行一致
- 负例(错误角色被拒): ✅ 全部被拒
## 正例:引擎行级过滤 vs JDBC 同语义基线
| 实体[用户] | 行数 | 内容差异 | 仅JDBC | 仅引擎 | 一致率 | 结果 |
|---|---|---|---|---|---|---|
| EIP4PT_CUSTOMER[USER_ALICE] | 16 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_CUSTOMER[USER_BOB] | 17 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_CUSTOMER[USER_CAROL] | 17 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_PROJECT[USER_ALICE] | 16 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_PROJECT[USER_BOB] | 17 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_PROJECT[USER_CAROL] | 17 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_TASK[USER_ALICE] | 16 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_TASK[USER_BOB] | 17 | 0 | 0 | 0 | 1.0000 | ✅ |
| EIP4PT_TASK[USER_CAROL] | 17 | 0 | 0 | 0 | 1.0000 | ✅ |
## 负例:错误角色 ROLE_NOBODY 访问受控实体
| 实体 | HTTP 状态 | 期望 | 结果 |
|---|---|---|---|
| EIP4PT_CUSTOMER | 500 | 非200(PrivilegeException) | ✅ 被拒 |
| EIP4PT_PROJECT | 500 | 非200(PrivilegeException) | ✅ 被拒 |
| EIP4PT_TASK | 500 | 非200(PrivilegeException) | ✅ 被拒 |