diff --git a/open-vulnerability-clients/src/main/java/io/github/jeremylong/openvulnerability/client/nvd/NvdCveClient.java b/open-vulnerability-clients/src/main/java/io/github/jeremylong/openvulnerability/client/nvd/NvdCveClient.java index 2c403143..9afd13bd 100644 --- a/open-vulnerability-clients/src/main/java/io/github/jeremylong/openvulnerability/client/nvd/NvdCveClient.java +++ b/open-vulnerability-clients/src/main/java/io/github/jeremylong/openvulnerability/client/nvd/NvdCveClient.java @@ -392,11 +392,14 @@ private Collection _next(int retryCount) { LOG.debug("Response: {}", new String(response.getBodyBytes(), StandardCharsets.UTF_8)); if (msg != null) { if (msg.contains("Invalid apiKey")) { - LOG.error("Invalid API Key: key length {}", this.apiKey.length()); if (this.apiKey.length() > 30) { - LOG.error("Invalid API Key: '{}-*****-{}", this.apiKey.substring(0, 5), + String masked = String.format("Invalid API Key: %s-*****-%s", + this.apiKey.substring(0, 5), this.apiKey.substring(this.apiKey.length() - 5, this.apiKey.length())); + throw new NvdApiException(masked); } + String masked = String.format("Invalid API Key: %s-*****", this.apiKey.substring(0, 5)); + throw new NvdApiException(masked); } throw new NvdApiException("NVD Returned Status Code: " + lastStatusCode + " - " + msg); }