flayer.diagnostics.contracts¶
flayer.diagnostics.contracts ¶
Provider-independent diagnostic results and output safety contracts.
SECRET_KEY
module-attribute
¶
SECRET_KEY = re.compile('password|passwd|secret|token|credential|authorization|cookie|private.?key|api.?key|ssh.?key|client.?key|access.?key|refresh.?key', re.IGNORECASE)
SECRET_VALUE
module-attribute
¶
SECRET_VALUE = re.compile('(?:bearer\\s+\\S+|-----BEGIN[^\\n]*PRIVATE KEY-----[\\s\\S]*|(?:password|passwd|secret|token|api[_-]?key)\\s*[=:][^\\n]*|https?://[^\\s]*|(?:\\d{1,3}\\.){3}\\d{1,3})', re.IGNORECASE)
STATUS_PRIORITY
module-attribute
¶
STATUS_PRIORITY = {DiagnosticStatus.OK: 0, DiagnosticStatus.WARNING: 1, DiagnosticStatus.UNSUPPORTED: 2, DiagnosticStatus.STALE: 3, DiagnosticStatus.FAILED: 4}
EXIT_CODES
module-attribute
¶
EXIT_CODES = {DiagnosticStatus.OK: 0, DiagnosticStatus.WARNING: 1, DiagnosticStatus.FAILED: 1, DiagnosticStatus.STALE: 3, DiagnosticStatus.UNSUPPORTED: 4}
DiagnosticStatus ¶
Bases: str, Enum
Stable outcomes distinguish failure, expired evidence, and missing support.
CheckResult
dataclass
¶
CheckResult(name: str, status: DiagnosticStatus, message: str, details: Mapping[str, object] = dict())
One diagnostic observation with details that are sanitized at serialization.
details
class-attribute
instance-attribute
¶
details: Mapping[str, object] = field(default_factory=dict)
AsDict ¶
AsDict() -> dict[str, object]
Return stable JSON-compatible fields without arbitrary raw provider output.
源代码位于: installed/flayer/diagnostics/contracts.py
99 100 101 102 103 104 105 106 107 | |
DiagnosticReport
dataclass
¶
DiagnosticReport(command: str, checks: tuple[CheckResult, ...])
Versioned report whose aggregate outcome never hides failed checks.
Status
property
¶
Status: DiagnosticStatus
Return the most severe result, treating an empty report as unsupported.
ExitCode ¶
ExitCode() -> int
Return zero only when every requested observation succeeds.
源代码位于: installed/flayer/diagnostics/contracts.py
154 155 156 157 | |
AsDict ¶
AsDict() -> dict[str, object]
Expose the report schema and sanitized observations in deterministic order.
源代码位于: installed/flayer/diagnostics/contracts.py
159 160 161 162 163 164 165 166 167 | |
Redact ¶
Redact(value: object, _depth: int = 0) -> object
Recursively redact credential fields and common sensitive text before output.
源代码位于: installed/flayer/diagnostics/contracts.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |