fix(security): Pods-Feldrechte fail-closed
Fehlt pods_has_permissions() oder pods_permission(), gilt kein Pods-Feld mehr als unbeschränkt, sondern als nicht erlaubt (HIDDEN/READONLY). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
29e73caefb
commit
8f3a4e76eb
+14
-1
@@ -32,7 +32,7 @@ final class PodsFieldSourceTest extends TestCase
|
||||
|
||||
private function source(?object $pod): PodsFieldSource
|
||||
{
|
||||
return new PodsFieldSource(static fn (string $name) => $pod ?? false);
|
||||
return new PodsFieldSource(static fn (string $name) => $pod ?? false, null, static fn (object $field): ?bool => null);
|
||||
}
|
||||
|
||||
/** @return array<string, array<string, mixed>> */
|
||||
@@ -79,6 +79,19 @@ final class PodsFieldSourceTest extends TestCase
|
||||
self::assertSame(FieldDefinition::UNKNOWN, $fields['mystery']['status']);
|
||||
}
|
||||
|
||||
/** Fail-closed: without the Pods permission functions (not loaded in the unit run) no field counts as permitted. */
|
||||
public function testFieldIsHiddenWhenThePodsPermissionFunctionsAreMissing(): void
|
||||
{
|
||||
self::assertFalse(function_exists('pods_has_permissions'));
|
||||
$pod = Mockery::mock();
|
||||
$pod->allows('get_type')->andReturn('post_type');
|
||||
$pod->allows('get_fields')->andReturn(['role' => $this->field('role', 'text')]);
|
||||
|
||||
$fields = (new PodsFieldSource(static fn (string $name) => $pod))->fieldsFor('lit_person');
|
||||
|
||||
self::assertSame(FieldDefinition::HIDDEN, $fields[0]->status);
|
||||
}
|
||||
|
||||
public function testParsesCustomSimpleChoices(): void
|
||||
{
|
||||
self::assertSame(
|
||||
|
||||
Reference in New Issue
Block a user