An R6 class to provide a lower-level interface to the querybatch endpoint of the OSV API. Batches are enforced to only process by commit hash, purl, or name+ecosystem. This avoids some confusion as to which is taken preferentially and simplifies query creation.
An R6 object to operate with OSV querybatch endpoint.
rosv::RosvQuery1
-> RosvQueryBatch
Inherited methods
new()
Set the core request details for subsequent use when called in run()
method.
RosvQueryBatch$new(
commit = NULL,
version = NULL,
name = NULL,
ecosystem = NULL,
purl = NULL
)
commit
Commit hash to query against (do not use when version set).
version
Version of package.
name
Name of package.
ecosystem
Ecosystem package lives within (must be set if using name
).
purl
URL for package (do not use if name
or ecosystem
is set).
run()
Perform the request and return response for OSV API call.
RosvQueryBatch$run()
When no result is found, any empty list is returned by the API, which during parsing will be dropped as the list is flattened. However, the index of the list is still accessible and the dropped items can easily be identified from the results column. Not all contents are parsed.
clone()
The objects of this class are cloneable with this method.
RosvQueryBatch$clone(deep = FALSE)
deep
Whether to make a deep clone.
Pageination is implemented via httr2::req_perform_iterative()
and a private method for
extracting tokens automatically. When initialized, the page_token is set to NULL
;
if a token is generated for large results the process is handled internally. The response object
will contain a list of all returned responses before any formatting occurred. The content field will
contain the list of results with vulnerabilities which may be further parsed into a table format.
pkgs <- c('jinja2', 'dask')
ecosystem <- rep('PyPI', length(pkgs))
batchquery <- RosvQueryBatch$new(name = pkgs, ecosystem = ecosystem)
batchquery
Run the code above in your browser using DataLab