[DBA] add KB VPD admin full access condition
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user