SkillSpector icon indicating copy to clipboard operation
SkillSpector copied to clipboard

fix(sc4): surface OSV.dev fallback warnings and add configurable timeout

Open tcconnally opened this issue 5 months ago • 1 comments

Summary

Fixes #102: SC4 (Known Vulnerable Dependencies) silently falls back to a small static list when api.osv.dev is unreachable.

Changes

  1. Configurable timeout via SKILLSPECTOR_OSV_TIMEOUT env var (default raised from 10s to 30s)
  2. is_available() check timeout raised from 5s to 15s
  3. Visible fallback warning in scan output when OSV.dev is unreachable
  4. INFO logging when OSV returns no vulns for a package (was silently cached)
  5. was_osv_reachable() helper to distinguish API failures from clean results

Testing

All 621 unit tests pass.

tcconnally avatar Jun 20 '26 21:06 tcconnally

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 — asserts True after successful query
  • test_was_osv_reachable_after_failure — asserts False after ConnectError
  • Patched _analyze_deps() helper to mock was_osv_reachable() → True so existing tests aren't affected by module-level state bleed
  • All 623 tests pass

tcconnally avatar Jun 21 '26 19:06 tcconnally