You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Naming injection_ml in Guard(scanners=) blocks every input #199
Naming injection_ml in Guard(scanners=[...]) gives you a Guard that blocks everything.
Guard(scanners=["injection_ml"], model="tiny").scan("What is the capital of France?").risk_score# 1.0Guard(model="tiny").scan("What is the capital of France?").risk_score# 0.0
Two injection_ml scanners get built. One is backed by TransformersSpanProvider and works. The other is backed by NullModelProvider, whose predict() returns None, so injection_ml.py:124 does list(prediction.spans) on None and raises AttributeError. base.py:48 catches it and emits a scanner_error finding with score=1.0, which becomes the risk for every input.
Nothing in the output says the scanner failed unless you are reading logs. The caller sees a confident block on plain text.
injection_ml.py:95 is the part that lets it through:
ifself._model.loadedisFalse:
self._model.load()
A provider that cannot produce a prediction gets asked for one anyway, and the None that comes back is trusted. Same result with scanners=["injection", "injection_ml"].
Two things worth deciding separately. Why a second scanner is constructed with a null provider when a real one is available, and whether NullModelProvider.predict should return an empty SpanPrediction or raise rather than returning None.
Stop the null-backed duplicate from being built: strip injection_ml from scanner_names in guard.py (the Guard already adds the provider-backed scanner itself).
Defensive fallback: have NullModelProvider.predict return an empty SpanPrediction (spans=[], doc_score=0.0) instead of None, so it degrades to allow rather than raising.
Plus a regression test: Guard(scanners=["injection_ml"], model="tiny").scan(...) → allow, not block.
Activity
cookieshop02 commentedon Oct 18, 2026
Hi , I'd like to take this.
My plan is two small changes:
Plus a regression test: Guard(scanners=["injection_ml"], model="tiny").scan(...) → allow, not block.
Does that approach work?