feat(firewall): complete rule-match audit context
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -31,6 +31,7 @@ class FirewallLogObject implements \JsonSerializable, JsonDeserializable
|
||||
private ?string $eventType = null;
|
||||
private ?string $result = null; // allowed, blocked
|
||||
private ?string $ruleId = null; // Which rule triggered (if any)
|
||||
private ?string $ruleScope = null; // tenant or system
|
||||
private ?string $identityId = null; // User ID if authenticated
|
||||
private ?\DateTimeImmutable $timestamp = null;
|
||||
private ?array $metadata = null; // Additional context
|
||||
@@ -74,6 +75,9 @@ class FirewallLogObject implements \JsonSerializable, JsonDeserializable
|
||||
if (array_key_exists('ruleId', $data)) {
|
||||
$this->ruleId = $data['ruleId'] !== null ? (string)$data['ruleId'] : null;
|
||||
}
|
||||
if (array_key_exists('ruleScope', $data)) {
|
||||
$this->ruleScope = $data['ruleScope'] !== null ? (string)$data['ruleScope'] : null;
|
||||
}
|
||||
if (array_key_exists('identityId', $data)) {
|
||||
$this->identityId = $data['identityId'] !== null ? (string)$data['identityId'] : null;
|
||||
}
|
||||
@@ -102,6 +106,7 @@ class FirewallLogObject implements \JsonSerializable, JsonDeserializable
|
||||
'eventType' => $this->eventType,
|
||||
'result' => $this->result,
|
||||
'ruleId' => $this->ruleId,
|
||||
'ruleScope' => $this->ruleScope,
|
||||
'identityId' => $this->identityId,
|
||||
'timestamp' => $this->timestamp?->format(\DateTimeInterface::ATOM),
|
||||
'metadata' => $this->metadata,
|
||||
@@ -220,6 +225,24 @@ class FirewallLogObject implements \JsonSerializable, JsonDeserializable
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRuleScope(): ?string
|
||||
{
|
||||
return $this->ruleScope;
|
||||
}
|
||||
|
||||
public function setRuleScope(?string $ruleScope): self
|
||||
{
|
||||
if (
|
||||
$ruleScope !== null
|
||||
&& !in_array($ruleScope, [FirewallRuleObject::SCOPE_TENANT, FirewallRuleObject::SCOPE_SYSTEM], true)
|
||||
) {
|
||||
throw new \InvalidArgumentException("Invalid firewall rule scope: {$ruleScope}");
|
||||
}
|
||||
|
||||
$this->ruleScope = $ruleScope;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIdentityId(): ?string
|
||||
{
|
||||
return $this->identityId;
|
||||
|
||||
Reference in New Issue
Block a user