Skip to content

Commit db3cac3

Browse files
author
worker-4-b
committed
docs(vuln): document --refresh, --max-age, and cache_info
Issue #30 — document the new vuln-scan staleness flags and the cache_info output block. - README.md: expand the vuln-scan command row with --refresh / --max-age and the cache_info block. - SKILL-QUICK.md: add the flags + cache_info note to the Security command list. - CHANGELOG.md: new 'OSV Cache Staleness Flag + Refresh Flags (issue #30)' section under [8.2.0] with Added / Changed / Non-Breaking subsections.
1 parent 81e93c4 commit db3cac3

3 files changed

Lines changed: 57 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,61 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [8.2.0] — Unreleased
99

10+
### OSV Cache Staleness Flag + Refresh Flags (issue #30)
11+
12+
`vuln-scan` now reports OSV cache freshness and lets agents force fresh
13+
data. Previously the 24h OSV cache had no staleness indicator and no way
14+
to force a re-fetch short of deleting the cache — agents relying on
15+
`vuln-scan` for security posture had no way to know whether the CVE
16+
results were minutes or 23 hours old.
17+
18+
### Added (vuln-scan staleness)
19+
20+
- **`cache_info` block in `vuln-scan` output** — additive top-level field:
21+
```json
22+
"cache_info": {
23+
"last_refresh": "2026-06-28T10:00:00Z",
24+
"age_hours": 23.5,
25+
"ttl_hours": 24,
26+
"is_stale": false,
27+
"stale_packages": ["requests@2.20.0"]
28+
}
29+
```
30+
`is_stale` is true when any cached entry is past the effective TTL, the
31+
newest entry's age ≥ the effective TTL, or there are OSV-queriable
32+
packages but none are cached (no fresh coverage). `stale_packages` lists
33+
the `"name@version"` of cached entries past the effective TTL.
34+
- **`vuln-scan --refresh`** — bypasses the OSV cache and forces fresh
35+
OSV.dev API calls for every package, then updates the cache with the new
36+
results. No-op in `--offline` mode.
37+
- **`vuln-scan --max-age Nh`** — treats cache entries older than `N` hours
38+
as stale for this run only (overrides the default 24h TTL without
39+
changing the stored TTL). Accepts `6h`/`30m`/`2d`/`90s`/bare-integer
40+
(hours). `cache_info.ttl_hours` and the staleness threshold honour this
41+
override so they stay consistent. Ignored with `--refresh` and in
42+
`--offline` mode.
43+
44+
### Changed (vuln-scan staleness)
45+
46+
- `scripts/osv_client.py`: new `OSVCache.peek(key)` — pure inspection
47+
returning `(timestamp, ttl)` without mutating the cache (unlike `get()`,
48+
which deletes expired entries). New `OSVClient.get_cache_info(packages,
49+
max_age=None)`. `OSVClient.query_packages()` gained `force_refresh` and
50+
`max_age` parameters (default behaviour unchanged).
51+
- `scripts/vulnscan_engine.py`: `scan_vulnerabilities()` gained `refresh`
52+
and `max_age` parameters and now attaches `cache_info` to its result.
53+
- `scripts/commands/vuln_scan.py`: new `--refresh` and `--max-age` flags
54+
plus a `_parse_max_age()` helper. Invalid `--max-age` values return an
55+
`error` result instead of crashing.
56+
57+
### Non-Breaking (vuln-scan staleness)
58+
59+
- `cache_info` is additive — no existing `vuln-scan` output field is
60+
changed or removed.
61+
- Default network behaviour is unchanged: the API is only contacted for
62+
uncached packages, or when `--refresh` is set, or when `--max-age`
63+
marks cached entries stale.
64+
1065
### Confidence Fields on Non-Deep Output (test fix)
1166

1267
Previously, the `confidence` / `confidence_distribution` fields were only

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ python3 scripts/codelens.py query "myFunction" --lite
121121
| Command | Description |
122122
|---------|-------------|
123123
| `secrets [workspace] [--severity ...]` | Detect hardcoded API keys, passwords, tokens |
124-
| `vuln-scan [workspace]` | Scan dependencies for known CVEs (OSV.dev + native audit) |
124+
| `vuln-scan [workspace] [--refresh] [--max-age Nh]` | Scan dependencies for known CVEs (OSV.dev + native audit). `--refresh` bypasses the OSV cache; `--max-age Nh` treats cache entries older than N hours as stale for this run. Output includes a `cache_info` block (`last_refresh`, `age_hours`, `ttl_hours`, `is_stale`, `stale_packages`) — issue #30 |
125125
| `taint [workspace]` | Run AST-based taint analysis for vulnerability detection |
126126
| `dataflow [workspace] [--source] [--sink]` | Data flow taint analysis with cross-file call graph |
127127
| `env-check [workspace] [--var NAME]` | Audit environment variables |

SKILL-QUICK.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ $CLI list --limit 5 --offset 10 --format compact # → paginated + co
126126
`entrypoints` · `api-map` · `state-map` · `detect` · `handbook` · `diff [--git-aware]` · `dashboard` · `history` · `graph-schema` · `resolve-types`
127127

128128
### Security (5)
129-
`secrets [--severity ...]` · `taint` (AST-based) · `dataflow [--source ...] [--sink ...]` (cross-file) · `vuln-scan` (OSV.dev + native audit) · `env-check [--var NAME]`
129+
`secrets [--severity ...]` · `taint` (AST-based) · `dataflow [--source ...] [--sink ...]` (cross-file) · `vuln-scan [--refresh] [--max-age Nh]` (OSV.dev + native audit; output includes `cache_info` staleness block — issue #30) · `env-check [--var NAME]`
130130

131131
### Quality (9)
132132
`smell [--categories ...] [--severity ...]` · `complexity [--name FN] [--threshold N] [--sort ...]` · `dead-code [--categories ...]` · `debug-leak [--category ...]` · `circular [--domain ...]` · `missing-refs` · `side-effect [--name FN]` · `perf-hint [--severity ...] [--category ...]` · `fix [--apply]`

0 commit comments

Comments
 (0)