Class NvdCveClientBuilder
- java.lang.Object
-
- io.github.jeremylong.openvulnerability.client.nvd.NvdCveClientBuilder
-
public final class NvdCveClientBuilder extends java.lang.ObjectUsed to build an NVD CVE API client. As the NvdCveClient client is autocloseable the builder should be used in a try with resources:try (NvdCveClient api = NvdCveClientBuilder.aNvdCveApi().build()) { while (api.hasNext()) { Collection<DefCveItem> items = api.next(); } }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNvdCveClientBuilder.BooleanFilterFilters for the NVD CVE API that are used without parameters.static classNvdCveClientBuilder.CvssV2SeverityThe CVSS V2 Severity.static classNvdCveClientBuilder.CvssV3SeverityThe CVSS V3 Severity.static classNvdCveClientBuilder.FilterParameters to the NVD CVE API used to filter the results.static classNvdCveClientBuilder.VersionType
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static NvdCveClientBuilderaNvdCveApi()Begin building the NVD CVE API Object.NvdCveClientbuild()Build the NVD CVE API client.NvdCveClientBuilderwithAdditionalUserAgent(java.lang.String userAgent)Use an additional identifier as part of the User-Agent when making requests.NvdCveClientBuilderwithApiKey(java.lang.String apiKey)Use an NVD CVE API key.NvdCveClientBuilderwithCvssV2SeverityFilter(NvdCveClientBuilder.CvssV2Severity severity)Filter the results for a specific CVSS V2 Severity.NvdCveClientBuilderwithCvssV3SeverityFilter(NvdCveClientBuilder.CvssV3Severity severity)Filter the results for a specific CVSS V3 Severity.NvdCveClientBuilderwithDelay(long milliseconds)Use a minimum delay in milliseconds between API calls; useful if you run into issues with rate limiting.NvdCveClientBuilderwithEndpoint(java.lang.String endpoint)Use an alternative endpoint for the NVD CVE API.NvdCveClientBuilderwithFilter(NvdCveClientBuilder.BooleanFilter filter)Add a querystring parameter to filter the call to the NVD CVE API.NvdCveClientBuilderwithFilter(NvdCveClientBuilder.Filter filter, java.lang.String value)Add a querystring parameter to filter the call to the NVD CVE API.NvdCveClientBuilderwithFilter(java.lang.String filter, java.lang.String value)Add a querystring parameter to filter the call to the NVD CVE API.NvdCveClientBuilderwithHttpClientSupplier(HttpAsyncClientSupplier httpClientSupplier)Provide a supplier for custom HTTP clients.NvdCveClientBuilderwithLastModifiedFilter(java.time.ZonedDateTime utcStartDate, java.time.ZonedDateTime utcEndDate)Use a range of no more than 120 days on the last modified dates to filter the results.NvdCveClientBuilderwithMaxPageCount(int count)Set the maximum number of pages to retrieve from the NVD API.NvdCveClientBuilderwithMaxRetryCount(int maxRetryCount)Set the maximum number of retries for 503 and 429 responses from the NVD; default is 10.NvdCveClientBuilderwithPublishedDateFilter(java.time.ZonedDateTime utcStartDate, java.time.ZonedDateTime utcEndDate)Filter the results with a range of published date times.NvdCveClientBuilderwithResultsPerPage(int resultsPerPage)Use a specific number of results per page.NvdCveClientBuilderwithThreadCount(int count)Set the number of threads to use when calling the NVD API.NvdCveClientBuilderwithVersionEnd(java.lang.String versionEnd)The virtualMatchString parameter may be combined with versionEnd and versionEndType to return only the CVEs associated with CPEs in specific version ranges.NvdCveClientBuilderwithVersionEnd(java.lang.String versionEnd, NvdCveClientBuilder.VersionType endType)The virtualMatchString parameter may be combined with versionEnd and versionEndType to return only the CVEs associated with CPEs in specific version ranges.NvdCveClientBuilderwithVersionStart(java.lang.String versionStart)The virtualMatchString parameter may be combined with versionStart and versionStartType to return only the CVEs associated with CPEs in specific version ranges.NvdCveClientBuilderwithVersionStart(java.lang.String versionStart, NvdCveClientBuilder.VersionType startType)The virtualMatchString parameter may be combined with versionStart and versionStartType to return only the CVEs associated with CPEs in specific version ranges.NvdCveClientBuilderwithVirtualMatchString(java.lang.String virtualMatchString)This parameter filters CVE more broadly than cpeName.
-
-
-
Method Detail
-
aNvdCveApi
public static NvdCveClientBuilder aNvdCveApi()
Begin building the NVD CVE API Object.- Returns:
- the builder
-
withApiKey
public NvdCveClientBuilder withApiKey(java.lang.String apiKey)
Use an NVD CVE API key.- Parameters:
apiKey- the NVD CVE API key.- Returns:
- the builder
- See Also:
- NVD CVE API Request an API Key
-
withEndpoint
public NvdCveClientBuilder withEndpoint(java.lang.String endpoint)
Use an alternative endpoint for the NVD CVE API.- Parameters:
endpoint- the endpoint for the NVD CVE API- Returns:
- the builder
-
withDelay
public NvdCveClientBuilder withDelay(long milliseconds)
Use a minimum delay in milliseconds between API calls; useful if you run into issues with rate limiting.- Parameters:
milliseconds- the minimum number of milliseconds between API calls to the NVD CVE API- Returns:
- the builder
-
withMaxRetryCount
public NvdCveClientBuilder withMaxRetryCount(int maxRetryCount)
Set the maximum number of retries for 503 and 429 responses from the NVD; default is 10.- Parameters:
maxRetryCount- the maximum number of retries for 503 and 429 responses from the NVD.- Returns:
- the builder
-
withThreadCount
public NvdCveClientBuilder withThreadCount(int count)
Set the number of threads to use when calling the NVD API.- Parameters:
count- the number of threads to use when calling the NVD API- Returns:
- the builder
-
withMaxPageCount
public NvdCveClientBuilder withMaxPageCount(int count)
Set the maximum number of pages to retrieve from the NVD API.- Parameters:
count- the maximum number of pages to retrieve from the NVD API- Returns:
- the builder
-
withResultsPerPage
public NvdCveClientBuilder withResultsPerPage(int resultsPerPage)
Use a specific number of results per page. Value must be between 1 and 2000. The default value is 2000.- Parameters:
resultsPerPage- the number of results per page- Returns:
- the builder
-
withFilter
public NvdCveClientBuilder withFilter(java.lang.String filter, java.lang.String value)
Add a querystring parameter to filter the call to the NVD CVE API.- Parameters:
filter- the querystring parametervalue- the querystring parameter value- Returns:
- the builder
-
withFilter
public NvdCveClientBuilder withFilter(NvdCveClientBuilder.Filter filter, java.lang.String value)
Add a querystring parameter to filter the call to the NVD CVE API.- Parameters:
filter- the querystring parametervalue- the querystring parameter value- Returns:
- the builder
-
withFilter
public NvdCveClientBuilder withFilter(NvdCveClientBuilder.BooleanFilter filter)
Add a querystring parameter to filter the call to the NVD CVE API.- Parameters:
filter- the querystring parameter- Returns:
- the builder
-
withLastModifiedFilter
public NvdCveClientBuilder withLastModifiedFilter(java.time.ZonedDateTime utcStartDate, java.time.ZonedDateTime utcEndDate)
Use a range of no more than 120 days on the last modified dates to filter the results. The ZonedDateTime objects must be set to UTC.- Parameters:
utcStartDate- the UTC date time for the range startutcEndDate- the UTC date time for the range end- Returns:
- the builder
-
withAdditionalUserAgent
public NvdCveClientBuilder withAdditionalUserAgent(java.lang.String userAgent)
Use an additional identifier as part of the User-Agent when making requests.- Parameters:
userAgent- the user agent string to append- Returns:
- the builder
-
withPublishedDateFilter
public NvdCveClientBuilder withPublishedDateFilter(java.time.ZonedDateTime utcStartDate, java.time.ZonedDateTime utcEndDate)
Filter the results with a range of published date times. The ZonedDateTime objects must be set to UTC.- Parameters:
utcStartDate- the UTC date time for the range startutcEndDate- the UTC date time for the range end- Returns:
- the builder
-
withCvssV2SeverityFilter
public NvdCveClientBuilder withCvssV2SeverityFilter(NvdCveClientBuilder.CvssV2Severity severity)
Filter the results for a specific CVSS V2 Severity.- Parameters:
severity- the severity- Returns:
- the builder
-
withCvssV3SeverityFilter
public NvdCveClientBuilder withCvssV3SeverityFilter(NvdCveClientBuilder.CvssV3Severity severity)
Filter the results for a specific CVSS V3 Severity.- Parameters:
severity- the severity- Returns:
- the builder
-
withVirtualMatchString
public NvdCveClientBuilder withVirtualMatchString(java.lang.String virtualMatchString)
This parameter filters CVE more broadly than cpeName. The exact value of {cpe match string} is compared against the CPE Match Criteria present on CVE applicability statements.- Parameters:
virtualMatchString- virtual matching CPE- Returns:
- the builder
- See Also:
- cves-virtualMatchString
-
withVersionStart
public NvdCveClientBuilder withVersionStart(java.lang.String versionStart)
The virtualMatchString parameter may be combined with versionStart and versionStartType to return only the CVEs associated with CPEs in specific version ranges.- Parameters:
versionStart- the version start- Returns:
- the builder
- See Also:
- cves-versionStart
-
withVersionStart
public NvdCveClientBuilder withVersionStart(java.lang.String versionStart, NvdCveClientBuilder.VersionType startType)
The virtualMatchString parameter may be combined with versionStart and versionStartType to return only the CVEs associated with CPEs in specific version ranges.- Parameters:
versionStart- the version startstartType- including or excluding- Returns:
- the builder
- See Also:
- cves-versionStart
-
withVersionEnd
public NvdCveClientBuilder withVersionEnd(java.lang.String versionEnd)
The virtualMatchString parameter may be combined with versionEnd and versionEndType to return only the CVEs associated with CPEs in specific version ranges.- Parameters:
versionEnd- the version end- Returns:
- the builder
- See Also:
- cves-versionEnd
-
withVersionEnd
public NvdCveClientBuilder withVersionEnd(java.lang.String versionEnd, NvdCveClientBuilder.VersionType endType)
The virtualMatchString parameter may be combined with versionEnd and versionEndType to return only the CVEs associated with CPEs in specific version ranges.- Parameters:
versionEnd- the version endendType- including or excluding- Returns:
- the builder
- See Also:
- cves-versionEnd
-
withHttpClientSupplier
public NvdCveClientBuilder withHttpClientSupplier(HttpAsyncClientSupplier httpClientSupplier)
Provide a supplier for custom HTTP clients.Note that
withDelay(long)andwithMaxRetryCount(int)have no effect when a customHttpAsyncClientSupplieris provided. Instead, clients created by the supplier should be configured to useNvdApiRetryStrategywith the desired delay and retry count values.- Parameters:
httpClientSupplier- supplier for custom HTTP clients; ifnulla default client will be used- Returns:
- the builder
-
build
public NvdCveClient build()
Build the NVD CVE API client.- Returns:
- the NVD CVE API client
-
-