commit compras2 2811
tests / ci (push) Waiting to run

This commit is contained in:
2026-11-28 15:45:52 +02:00
parent eb32c74c56
commit 060c119ba1
92 changed files with 4936 additions and 43 deletions
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace App\Services;
/** Structured bank coordinates, credentials and storage locations are outside the approved export. */
final class PrivateAuditRedaction
{
public function scrub(mixed $value): mixed
{
if (! is_array($value)) {
return $value;
}
return $this->fields($value);
}
/** @param array<array-key,mixed> $value
* @return array<array-key,mixed>
*/
public function fields(array $value): array
{
$result = [];
foreach ($value as $key => $item) {
if (is_string($key) && $this->excluded($key)) {
continue;
}
$result[$key] = $this->scrub($item);
}
return array_is_list($value) ? array_values($result) : $result;
}
private function excluded(string $key): bool
{
$key = strtolower(preg_replace('/[^a-zA-Z0-9]/', '', $key) ?? '');
return in_array($key, ['bank', 'banks', 'bankaccounts', 'bankaccount', 'banksnapshot', 'bankdetails', 'accountidentifier',
'accountnumber', 'accountholder', 'beneficiary', 'iban', 'nib', 'nuib', 'swift', 'bic', 'swiftbic', 'bankcoordinates',
'password', 'passwordconfirmation', 'passwordhash', 'remembertoken', 'twofactorsecret', 'twofactorrecoverycodes',
'secret', 'apikey', 'token', 'bearertoken', 'accesstoken', 'refreshtoken', 'credentials', 'stateciphertext', 'privatekey',
'path', 'filepath', 'storagepath', 'peopledata', 'candidatedata', 'candidateprofile', 'curriculumvitae'], true)
|| str_ends_with($key, 'password') || str_ends_with($key, 'secret') || str_ends_with($key, 'credentials') || str_ends_with($key, 'token');
}
/** A positive projection of known configuration change payloads, never an arbitrary event dump. */
public function configurationEvent(mixed $value): mixed
{
if (! is_array($value)) {
return null;
}
$keys = ['id', 'name', 'email', 'department_id', 'user_id', 'profile_id', 'profile_ids', 'permissions', 'work_contexts',
'memberships', 'maintenance', 'expires_at', 'reason', 'scope', 'effect', 'active', 'version', 'ready',
'company', 'users', 'administrators', 'profile', 'department', 'center', 'cost_center', 'code',
'first_limit_minor', 'second_limit_minor', 'approval_includes_tax', 'rules_provisional', 'default_tax_rate',
'comparison_policy', 'company_details', 'intelligence_policy', 'work_context_policy', 'requisition_approval_policy',
'geography_reference'];
return $this->scrub(array_intersect_key($value, array_flip($keys)));
}
}