mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-24 22:28:10 +09:00
Two related audit findings from the May verification swarm:
1. aidefence_scan quick mode missed obvious PII (email + API key combo
returned safe:true). Quick mode used defender.quickScan(input) which
focuses on prompt-injection / jailbreak patterns and skips PII.
Fix: layer a fast defender.hasPII(input) check on top so quick-mode
covers both threat classes; surface piiDetected and
promptInjectionDetected as separate fields so callers can see what
triggered the verdict.
2. aidefence_stats stayed at 0 regardless of has_pii / is_safe / scan-
quick calls. Those tools bypass the underlying defender's stats
tracking — only the full detect() path increments stats.
Fix: added wrapper-level counters (wrapperStats) tracking calls and
hits/threats for each lightweight tool. aidefence_stats now returns
both the underlying defender stats AND a wrapper sub-object so the
user sees real activity from the lightweight paths.
Bonus: aidefence_is_safe previously did `import('@claude-flow/aidefence')
.isSafe(input)` which bypassed the singleton entirely. Now routes
through getAIDefence() and combines the prompt-safety verdict with a
PII check so a safe verdict requires BOTH (matching common defender
expectations).
Build clean.
Co-Authored-By: RuFlo <ruv@ruv.net>