fix(security): honour Pods field restrictions (audit M4)
PodsFieldSource maps hidden, read_only, admin_only and restrict_role/-capability like Pods' own view: hidden -> new status HIDDEN, read_only -> READONLY, restricted and not permitted -> READONLY with read_only_restricted, else HIDDEN. HIDDEN fields are not described, read out, queried or written (they look unknown) but stay in the schema for the media usage search; write() re-checks before Pods' save(). Required-but-restricted fields no longer block a create. Pods is not active on DDEV: covered by unit tests with a field-option fixture. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -27,7 +27,7 @@ final class FieldValidator
|
||||
foreach ($values as $key => $value) {
|
||||
$key = (string) $key;
|
||||
$field = $definitions[$key] ?? null;
|
||||
if ($field === null) {
|
||||
if ($field === null || $field->status === FieldDefinition::HIDDEN) {
|
||||
$errors[$key] = 'Unbekanntes Feld; verfügbare Felder über lit/content-types (direkt: '
|
||||
. 'lit-content-types) abrufen.';
|
||||
continue;
|
||||
@@ -55,7 +55,9 @@ final class FieldValidator
|
||||
}
|
||||
|
||||
foreach ($definitions as $key => $field) {
|
||||
if (! $field->required || isset($errors[$key])) {
|
||||
// A field the user cannot write (readonly, hidden) cannot be required from them either.
|
||||
$writable = in_array($field->status, [FieldDefinition::WRITABLE, FieldDefinition::UNKNOWN], true);
|
||||
if (! $field->required || ! $writable || isset($errors[$key])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user