forked from cardosofelipe/fast-next-template
refactor(safety): apply consistent formatting across services and tests
Improved code readability and uniformity by standardizing line breaks, indentation, and inline conditions across safety-related services, models, and tests, including content filters, validation rules, and emergency controls.
This commit is contained in:
@@ -266,9 +266,7 @@ class SafetyGuardian:
|
||||
|
||||
except SafetyError as e:
|
||||
# Known safety error
|
||||
return await self._create_denial_result(
|
||||
action, [str(e)], audit_events
|
||||
)
|
||||
return await self._create_denial_result(action, [str(e)], audit_events)
|
||||
except Exception as e:
|
||||
# Unknown error - fail closed in strict mode
|
||||
logger.error("Unexpected error in safety validation: %s", e)
|
||||
@@ -391,7 +389,9 @@ class SafetyGuardian:
|
||||
if action.tool_name:
|
||||
for pattern in policy.denied_tools:
|
||||
if self._matches_pattern(action.tool_name, pattern):
|
||||
reasons.append(f"Tool '{action.tool_name}' denied by pattern '{pattern}'")
|
||||
reasons.append(
|
||||
f"Tool '{action.tool_name}' denied by pattern '{pattern}'"
|
||||
)
|
||||
return GuardianResult(
|
||||
action_id=action.id,
|
||||
allowed=False,
|
||||
@@ -419,7 +419,9 @@ class SafetyGuardian:
|
||||
if action.resource:
|
||||
for pattern in policy.denied_file_patterns:
|
||||
if self._matches_pattern(action.resource, pattern):
|
||||
reasons.append(f"Resource '{action.resource}' denied by pattern '{pattern}'")
|
||||
reasons.append(
|
||||
f"Resource '{action.resource}' denied by pattern '{pattern}'"
|
||||
)
|
||||
return GuardianResult(
|
||||
action_id=action.id,
|
||||
allowed=False,
|
||||
|
||||
Reference in New Issue
Block a user