Index
security
¶
Security guardrails — scanners, engine wrapper, audit, SSRF.
Classes¶
BaseScanner
¶
Bases: ABC
Base class for all security scanners.
Subclasses implement pattern-based scanning for secrets, PII, or other sensitive content.
Functions¶
scan
abstractmethod
¶
scan(text: str) -> ScanResult
AuditLogger
¶
AuditLogger(db_path: Union[str, Path] = DEFAULT_CONFIG_DIR / 'audit.db', bus: Optional[EventBus] = None)
Append-only SQLite audit log for security events.
| PARAMETER | DESCRIPTION |
|---|---|
db_path
|
Path to the SQLite database file.
TYPE:
|
bus
|
Optional event bus — if provided, subscribes to security events
(
TYPE:
|
Source code in src/openjarvis/security/audit.py
Functions¶
log
¶
log(event: SecurityEvent) -> None
Insert a security event into the audit log with Merkle hash chain.
Source code in src/openjarvis/security/audit.py
query
¶
query(*, event_type: Optional[str] = None, since: Optional[float] = None, limit: int = 100) -> List[SecurityEvent]
Query logged security events with optional filters.
Source code in src/openjarvis/security/audit.py
tail_hash
¶
Return the hash of the last row in the chain, or empty string.
Source code in src/openjarvis/security/audit.py
verify_chain
¶
Verify the Merkle hash chain integrity.
| RETURNS | DESCRIPTION |
|---|---|
tuple
|
|
Source code in src/openjarvis/security/audit.py
count
¶
Return the total number of logged security events.
GuardrailsEngine
¶
GuardrailsEngine(engine: InferenceEngine, *, scanners: Optional[List[BaseScanner]] = None, mode: RedactionMode = WARN, scan_input: bool = True, scan_output: bool = True, bus: Optional[EventBus] = None)
Bases: InferenceEngine
Wraps an existing InferenceEngine with security scanning.
Not registered in EngineRegistry — instantiated dynamically to wrap
any engine at runtime.
| PARAMETER | DESCRIPTION |
|---|---|
engine
|
The wrapped inference engine.
TYPE:
|
scanners
|
List of scanners to run. Defaults to
TYPE:
|
mode
|
Action taken on findings: WARN, REDACT, or BLOCK.
TYPE:
|
scan_input
|
Whether to scan input messages.
TYPE:
|
scan_output
|
Whether to scan output content.
TYPE:
|
bus
|
Optional event bus for publishing security events.
TYPE:
|
Source code in src/openjarvis/security/guardrails.py
Attributes¶
Functions¶
generate
¶
generate(messages: Sequence[Message], *, model: str, temperature: float = 0.7, max_tokens: int = 1024, **kwargs: Any) -> Dict[str, Any]
Scan input, call wrapped engine, scan output.
Source code in src/openjarvis/security/guardrails.py
stream
async
¶
stream(messages: Sequence[Message], *, model: str, temperature: float = 0.7, max_tokens: int = 1024, **kwargs: Any) -> AsyncIterator[str]
Yield tokens in real-time, scan accumulated output post-hoc.
Source code in src/openjarvis/security/guardrails.py
list_models
¶
SecurityBlockError
¶
Bases: Exception
Raised when mode is BLOCK and security findings are detected.
PIIScanner
¶
Bases: BaseScanner
Detect personally identifiable information in text.
Source code in src/openjarvis/security/scanner.py
Functions¶
scan
¶
scan(text: str) -> ScanResult
SecretScanner
¶
Bases: BaseScanner
Detect API keys, tokens, passwords, and other secrets in text.
Source code in src/openjarvis/security/scanner.py
Functions¶
scan
¶
scan(text: str) -> ScanResult
RedactionMode
¶
Bases: str, Enum
Action mode when findings are detected.
ScanFinding
dataclass
¶
ScanFinding(pattern_name: str, matched_text: str, threat_level: ThreatLevel, start: int, end: int, description: str = '')
A single finding from a security scanner.
ScanResult
dataclass
¶
ScanResult(findings: List[ScanFinding] = list())
Aggregated result from one or more scanners.
Attributes¶
highest_threat
property
¶
highest_threat: Optional[ThreatLevel]
Return the highest threat level among findings, or None.
SecurityEvent
dataclass
¶
SecurityEvent(event_type: SecurityEventType, timestamp: float, findings: List[ScanFinding] = list(), content_preview: str = '', action_taken: str = '')
A recorded security event for audit logging.
SecurityEventType
¶
Bases: str, Enum
Categories of security events.
ThreatLevel
¶
Bases: str, Enum
Severity classification for security findings.
Functions¶
filter_sensitive_paths
¶
is_sensitive_file
¶
Return True if path matches a sensitive file pattern.
Checks both the filename and the full name against
DEFAULT_SENSITIVE_PATTERNS using :func:fnmatch.fnmatch.
Source code in src/openjarvis/security/file_policy.py
check_ssrf
¶
Check a URL for SSRF vulnerabilities — always via Rust backend.
is_private_ip
¶
Check if an IP address is private/reserved.