[DBA] add KB VPD admin full access condition

This commit is contained in:
devmrko
2026-07-08 13:02:11 +09:00
parent fbeb18ccec
commit 403298d474
5 changed files with 236 additions and 4 deletions

View File

@@ -281,6 +281,13 @@ public class PermissionService {
throw new AppException("정적 SQL 조건에는 다른 테이블·스키마를 참조할 수 없습니다.");
}
// The VPD function makes the same narrowly-scoped exception. It lets an
// administrator express the auditable physical condition "1 = 1" for a
// full-access permission instead of relying on an implicit ALL marker.
if (predicate.matches("(?i)^1\\s*=\\s*1$")) {
return;
}
boolean hasObjectColumn = false;
Matcher matcher = SQL_IDENTIFIER.matcher(lexical.toUpperCase(Locale.ROOT));
while (matcher.find()) {

View File

@@ -2,6 +2,7 @@ package com.cloudhandson.vpdbackoffice.service;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.groups.Tuple.tuple;
import com.cloudhandson.vpdbackoffice.domain.audit.AuditEvent;
import com.cloudhandson.vpdbackoffice.domain.permission.AppRole;
@@ -271,6 +272,25 @@ class PermissionServiceTest {
.containsExactly("", "DEPT_CODE IN ('HR', 'FIN')");
}
@Test
void acceptsExplicitUnconditionalStaticSqlPredicateForAdminRole() {
var command = new PermissionSetCommand(
10L,
1L,
"SELECT",
"ALLOW",
List.of(new RuleCommand(null, "STATIC_SQL", "1 = 1")),
List.of()
);
permissionService.savePermissionSet(command);
FakePermissionMapper mapper = (FakePermissionMapper) permissionMapper;
assertThat(mapper.insertedRules)
.extracting(PermissionRule::ruleType, PermissionRule::ruleValue)
.containsExactly(tuple("STATIC_SQL", "1 = 1"));
}
@Test
void rejectsStaticSqlStatementOrUnknownColumn() {
var statementCommand = new PermissionSetCommand(