Python API¶
Import scan and its result types from ossiq to run a scan from Python. Part of the
reference.
pip install ossiq installs both the library and the ossiq command. The [cli] extra still
resolves, but it is empty.
from ossiq import scan, ScanResult, ScanRecord, Settings, CVE, Package, VersionsDifference, AbstractProjectSources
Name |
What it is |
|---|---|
Runs one scan and returns a |
|
The whole scan: project facts and three lists of |
|
One package: versions, CVEs, recommendation, maintenance signals |
|
Runtime configuration |
|
One vulnerability on a |
|
Registry metadata for one package |
|
How far apart two versions are |
|
The scan context: which project, which options |
scan(sources)¶
def scan(sources: AbstractProjectSources, progress: ScanProgress | None = None) -> ScanResult
Runs a full scan of the project that sources describes and returns a ScanResult. It fetches
package metadata, CVEs and version history, then runs the solver to produce update
recommendations. Call it inside the sources context manager.
progress is an optional ossiq.service.project.scan.ScanProgress with three callbacks, for
driving a progress indicator:
Callback |
Called with |
When |
|---|---|---|
|
|
A scan step starts: |
|
|
A step that reports an outcome finishes |
|
a tuple of |
Before the fetches that spend an API quota |
from ossiq import scan, Settings
from ossiq.sources.project_sources import ProjectSources
settings = Settings.load()
sources = ProjectSources(settings, project_path=".")
with sources:
result = scan(sources)
ScanResult¶
Aggregated output of a single scan run. Returned by scan().
Field |
Type |
Description |
|---|---|---|
|
|
Name from the project manifest |
|
|
Absolute path to the project root |
|
|
Registry used ( |
|
|
Direct production dependencies |
|
|
Dev / optional dependencies |
|
|
Indirect dependencies |
|
|
Package names where the manifest and lockfile disagree |
|
|
Cross-constraint widening opportunities (library projects only) |
|
|
Packages excluded from the scan (git/URL-hosted, or via |
|
|
Peers installed only out of their requirers’ reach, and how |
|
|
Project-level EPSS summary |
|
|
Project-level maintenance summary |
|
|
Status of each external source for this scan. See Partial data |
|
|
Runtime versions the engine checks ran against, and where they came from |
|
|
The project’s own runtime pin ( |
|
|
The project’s manifest declares |
|
|
Detected npm CLI version, for display |
|
|
Non-fatal problems found while reading the project, such as a tree with more than one registry |
ScanRecord¶
The analysis record for one package. Each entry in the three package lists of a ScanResult is one ScanRecord.
Field |
Type |
Description |
|---|---|---|
|
|
Canonical package name |
|
|
Name the manifest uses. It differs from |
|
|
Whether this is a dev / optional dependency |
|
|
Version currently installed |
|
|
Most recent published version |
|
|
Solver-recommended update target |
|
|
Why this version was chosen |
|
|
Which version-ladder rung |
|
|
The version ladder and what is true of the picked version: |
|
|
The update-strategy selector’s verdict. |
|
|
Releases that would have been recommended but were held back, at most one per ladder rung |
|
|
Days between the publish dates of the installed and the latest version |
|
|
Releases published after |
|
|
Days since |
|
|
Days since |
|
|
Semantic drift classification |
|
|
Known vulnerabilities for the installed version |
|
|
Highest EPSS score among the package’s CVEs |
|
|
Effective version specifier the solver used. For a transitive package it can come from a parent, not from your manifest |
|
|
Version specifier your manifest declares. |
|
|
Extras/features requested for this dependency |
|
|
What controls the version beyond a plain manifest entry. See Constraint types |
|
|
Ancestor chain for transitive packages |
|
|
Source code repository URL |
|
|
Repository activity data (commits, releases) when available |
|
|
Project homepage |
|
|
Registry page URL for the package |
|
|
Installed version is a pre-release |
|
|
Installed version was yanked or unpublished |
|
|
Installed version, or the package, is deprecated |
|
|
The registry’s verdict on the whole package: |
|
|
The maintainer’s note (npm) or the index’s stated reason (PyPI), verbatim |
|
|
The whole package has been removed from the registry |
|
|
Every version specifier from each direct parent (transitive packages only) |
|
|
Every physical copy of the package in the tree, newest first. One entry unless the package manager nests copies (npm) |
|
|
How updating this package affects transitive deps |
|
|
All peer requirements other packages place on this one |
|
|
Peer requirements the installed version fails to satisfy |
|
|
Peers this package declares that nothing installed where it looks can satisfy (npm only; see Unresolved peers) |
|
|
Conflicting constraints that blocked the solver |
|
|
Package URL (PURL) identifier |
|
|
SPDX license identifiers |
|
|
Maintenance-state verdict. |
|
|
Recommended action from the EPSS and maintenance matrix |
|
|
Commit-gap and engagement-flow signals. |
|
|
End-of-life markers found in registry and repository metadata |
|
|
Whether the GitHub activity channels could be read for this package |
|
|
Days since the last push to the upstream repository |
|
|
Installing the version executes code (a build backend, an npm lifecycle script) |
|
|
What indicated |
A None in a measured field means the signal could not be measured, never that the package
carries no risk. Repository stability explains the
maintenance fields.
Settings¶
Pydantic model that holds runtime configuration. Settings.load() reads the config file and the
environment; Settings.load(config_file) reads that file in place of the default one. You can
also construct Settings(...) directly, which reads only the environment.
Field |
Default |
Description |
|---|---|---|
|
|
GitHub token for repository enrichment. Set it with |
|
|
|
|
OSS IQ’s OAuth app |
Client ID of the GitHub OAuth app used for login (public, not a secret) |
|
|
Path to the SQLite HTTP cache |
|
|
Cache time-to-live in hours |
|
|
Hours to keep GitHub stability data (commits, activity, README) |
|
|
Emit detailed progress output |
|
|
Enable debug logging |
|
|
Show full traceback on error instead of logging to file |
|
|
Disable PyPI metadata fetching for transitive constraint enrichment |
|
|
Treat versions published after this date as invisible |
|
|
Days a new version must age before the solver recommends it |
|
|
Measure upstream repository stability |
|
|
The GraphQL engagement-flow channel. |
|
|
Detect the installed Python, Node.js and npm versions |
|
|
Runtime versions to check against in place of the probe, for example |
|
|
Treat the runtime as unknown: no probe, no provided version, the project’s declared floor only |
Every field can also come from an environment variable prefixed with OSSIQ_ (for example
OSSIQ_COOLDOWN_PERIOD), or from the config file. Settings
lists the variable and flag for each one.
CVE¶
A single vulnerability record attached to a ScanRecord.
Field |
Type |
Description |
|---|---|---|
|
|
Primary identifier (CVE, GHSA, or OSV ID) |
|
|
All aliases for this vulnerability |
|
|
Database this record came from |
|
|
Name of the affected package |
|
|
Registry the affected package belongs to ( |
|
|
|
|
|
Human-readable description |
|
|
Versions the advisory enumerates. Always empty for npm, whose advisories publish only ranges |
|
|
Affected version intervals. Use these, not |
|
|
ISO 8601 publication date |
|
|
URL to the upstream advisory |
|
|
EPSS exploitation probability, 0 to 1 |
|
|
A fixed release is published |
|
|
Releases that fix the vulnerability |
|
|
Days a fix has been available |
Package¶
Metadata about a package as returned by its registry.
Field |
Type |
Description |
|---|---|---|
|
|
Registry this package belongs to ( |
|
|
Registry name |
|
|
Normalized name (lowercased, hyphens unified) |
|
|
Most recent stable release |
|
|
Next release after |
|
|
Source code repository URL |
|
|
Project homepage |
|
|
Registry-provided package description |
|
|
Package author |
|
|
Registry page URL for the package |
|
|
SPDX license string |
|
|
The registry’s verdict on the package: |
|
|
The registry reports the package |
|
|
The maintainer’s note (npm) or the index’s stated reason (PyPI), verbatim |
|
|
Package has been removed from the registry |
|
|
Number of registered maintainers |
|
|
Downloads in the most recent reporting period |
|
|
Trove classifiers (PyPI); empty on npm |
|
|
Every release of the package is yanked |
VersionsDifference¶
Semantic drift classification between two versions.
Field |
Type |
Description |
|---|---|---|
|
|
The first version being compared (typically the installed version) |
|
|
The second version being compared (typically the latest version) |
|
|
Numeric severity: 0 = latest (no diff), 1 = build, 2 = prerelease, 3 = patch, 4 = minor, 5 = major, 10 = no diff available (unpublished/unknown) |
|
|
Human-readable label, such as |
AbstractProjectSources¶
Base class for the scan context, exported from ossiq.sources.core. Use ossiq.sources.project_sources.ProjectSources (the concrete implementation) to construct a scan context for a real project on disk.
from ossiq.sources.project_sources import ProjectSources
sources = ProjectSources(
settings=settings,
project_path="/path/to/project",
production=True, # production deps only
ignore_packages=("pytest",),
)
with sources:
result = scan(sources)
The other keyword arguments mirror the CLI’s flags:
Argument |
CLI flag |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Domain model¶
The exported types build on the entities in ossiq.domain. For their full definitions, read
the source:
ossiq/domain/project.py:Project, a name and its direct production and development dependencies.ossiq/domain/package.py:Package, a registry package and its versions.ossiq/domain/version.py:Version, which joins registry data with repository data, plusCommitandUser.