C-6: ConnectorRuntime enforces capability_mask per operation.
READ-only ACs cannot invoke MUTATE operations (wipe, lock, retire).
C-7: AC validated against database (exists, active, not expired)
before connector invocation.
C-9: Delegated AC capability bounded by delegator's capability.
C-10: Command counter uses atomic SQL increment with limit check.
M-23: expire_stale() uses same atomic SQL pattern.
H-1: Sensitive credential fields hidden from repr/logs via repr=False.
H-2: Stub backend requires ALLOW_STUB_CREDENTIALS=true to activate.
H-3: Kerberos backend raises CredentialResolutionError instead of
returning stub ticket.
H-4: Chronicle INTENT emitted before execution, RESULT after.
H-5: device_id validated as UUID before Graph API URL interpolation.
H-8: ConnectorRuntime enforces governance for all connector invocations.
Signed-off-by: Tyler King <tking@guildhouse.dev>
68 lines
1.8 KiB
Cython
68 lines
1.8 KiB
Cython
# cyextension/processors.pyx
|
|
# Copyright (C) 2005-2024 the SQLAlchemy authors and contributors
|
|
# <see AUTHORS file>
|
|
#
|
|
# This module is part of SQLAlchemy and is released under
|
|
# the MIT License: https://www.opensource.org/licenses/mit-license.php
|
|
import datetime
|
|
from datetime import datetime as datetime_cls
|
|
from datetime import time as time_cls
|
|
from datetime import date as date_cls
|
|
import re
|
|
|
|
from cpython.object cimport PyObject_Str
|
|
from cpython.unicode cimport PyUnicode_AsASCIIString, PyUnicode_Check, PyUnicode_Decode
|
|
from libc.stdio cimport sscanf
|
|
|
|
|
|
def int_to_boolean(value):
|
|
if value is None:
|
|
return None
|
|
return True if value else False
|
|
|
|
def to_str(value):
|
|
return PyObject_Str(value) if value is not None else None
|
|
|
|
def to_float(value):
|
|
return float(value) if value is not None else None
|
|
|
|
cdef inline bytes to_bytes(object value, str type_name):
|
|
try:
|
|
return PyUnicode_AsASCIIString(value)
|
|
except Exception as e:
|
|
raise ValueError(
|
|
f"Couldn't parse {type_name} string '{value!r}' "
|
|
"- value is not a string."
|
|
) from e
|
|
|
|
def str_to_datetime(value):
|
|
if value is not None:
|
|
value = datetime_cls.fromisoformat(value)
|
|
return value
|
|
|
|
def str_to_time(value):
|
|
if value is not None:
|
|
value = time_cls.fromisoformat(value)
|
|
return value
|
|
|
|
|
|
def str_to_date(value):
|
|
if value is not None:
|
|
value = date_cls.fromisoformat(value)
|
|
return value
|
|
|
|
|
|
|
|
cdef class DecimalResultProcessor:
|
|
cdef object type_
|
|
cdef str format_
|
|
|
|
def __cinit__(self, type_, format_):
|
|
self.type_ = type_
|
|
self.format_ = format_
|
|
|
|
def process(self, object value):
|
|
if value is None:
|
|
return None
|
|
else:
|
|
return self.type_(self.format_ % value)
|