fix(sc4): surface OSV.dev fallback warnings and add configurable timeout
Summary
Fixes #102: SC4 (Known Vulnerable Dependencies) silently falls back to a small static list when api.osv.dev is unreachable.
Changes
- Configurable timeout via SKILLSPECTOR_OSV_TIMEOUT env var (default raised from 10s to 30s)
- is_available() check timeout raised from 5s to 15s
- Visible fallback warning in scan output when OSV.dev is unreachable
- INFO logging when OSV returns no vulns for a package (was silently cached)
- was_osv_reachable() helper to distinguish API failures from clean results
Testing
All 621 unit tests pass.
Thanks for the thorough review, @rng1995! All three issues addressed:
1. global _last_query_ok (critical fix)
Added global _last_query_ok at the top of query_batch(). Without this, Python creates function-local variables and the module-level _last_query_ok stays at its initial True — the fallback warning in static_patterns_supply_chain.py never fires. Now was_osv_reachable() correctly reflects the last API call's success/failure.
2. Env var validation
Wrapped SKILLSPECTOR_OSV_TIMEOUT parsing in a try/except ValueError with a logged warning, falling back to 30s. No more import-time crash on non-numeric values.
3. Derived fallback count
Changed "(24 packages)" to f"({len(fallback_db)} packages)" — the message now accurately reflects the actual DB size and won't drift.
Tests
test_was_osv_reachable_after_success— assertsTrueafter successful querytest_was_osv_reachable_after_failure— assertsFalseafterConnectError- Patched
_analyze_deps()helper to mockwas_osv_reachable()→Trueso existing tests aren't affected by module-level state bleed - All 623 tests pass