Metadata-Version: 2.4
Name: osv-dedupe
Version: 0.1.0
Summary: Score whether a security finding already overlaps a published OSV/NVD advisory for a PyPI package, so scanners can skip known vulnerabilities.
Project-URL: Homepage, https://github.com/krc7169/osv-dedupe
Project-URL: Issues, https://github.com/krc7169/osv-dedupe/issues
Author-email: krc7169 <krc7169@gmail.com>
License: MIT License
        
        Copyright (c) 2026 krc7169
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: advisory,cve,deduplication,nvd,osv,pypi,security,vulnerability
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: requests>=2.20
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# osv-dedupe

Given a security finding for a PyPI package, decide whether it's **already a
published vulnerability** before you spend time (or LLM tokens) triaging it.
`osv-dedupe` queries [OSV](https://osv.dev) (and optionally
[NVD](https://nvd.nist.gov)), then scores each candidate advisory against your
finding using source reliability, package-name presence, CWE overlap, and
file/function hints.

## Install

```bash
pip install osv-dedupe
```

## Library usage

```python
from osv_dedupe import find_known_advisory_matches

finding = {"cwe": "CWE-22", "path": "demo/tarfile_utils.py"}
matches = find_known_advisory_matches("demo", "1.0.0", finding)

for m in matches:
    print(m["confidence"], m["source"], m["id"], m["url"])
    print(m["reason"])
```

Each match is a dict with `source`, `id`, `url`, `confidence` (0.0–1.0),
`reason`, `aliases`, `cwes`, and `summary`. A confidence `>= 0.70` is generally
strong enough to treat the finding as already reported.

Options:

- `min_confidence` (default `0.70`) — threshold for returned matches.
- `include_nvd` (default `False`) — also keyword-search NVD (slower, noisier).
- `limit` (default `3`) — max matches returned.

## CLI

```bash
osv-dedupe requests 2.0.0 --cwe CWE-22
osv-dedupe django 3.2 --include-nvd --json
```

## Scoring

| Signal | Weight |
| --- | --- |
| OSV returned the advisory | +0.45 |
| NVD keyword hit | +0.30 |
| Package name in advisory text | +0.15 |
| CWE matches finding | +0.25 |
| CWE differs | −0.10 |
| File/function hint appears | +0.10 |

Confidence is clamped to `[0.0, 1.0]`. All network calls are best-effort: if OSV
or NVD are unreachable, you get an empty list, never an exception. Results are
cached in-process; call `clear_cache()` to reset.

## License

MIT
