Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically look up CVEs #29

Open
csgillespie opened this issue Jun 12, 2024 · 0 comments
Open

Automatically look up CVEs #29

csgillespie opened this issue Jun 12, 2024 · 0 comments

Comments

@csgillespie
Copy link
Contributor

csgillespie commented Jun 12, 2024

Very quick POC - obviously needs tidying

library(httr)
library(jsonlite)

# Function to get CVE details from NVD
get_cve_details <- function(cve_id) {
  base_url <- "https://services.nvd.nist.gov/rest/json/cves/2.0?cveId="
  url <- paste0(base_url, cve_id)
  
  (response <- GET(url))
  
  if (status_code(response) == 200) {
    (content <- content(response, "text", encoding = "UTF-8"))
    json_content <- fromJSON(content, flatten = TRUE)
    
    # Extract CVSS score and severity
    if (!is.null(json_content$vulnerabilities)) {
      return(json_content$vulnerabilities)
    }
    stop("Failed to retrieve CVE details")
  }
  }
  
  # Example usage
  cve_id <- "CVE-2019-1010218"
  cve_details <- get_cve_details(cve_id)
  print(cve_details)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant