|
|
@ -1,9 +1,18 @@ |
|
|
|
date_convert <- function(.x) { |
|
|
|
as.POSIXct(.x, format="%Y-%m-%dT%H:%M:%OS", tz="GMT") |
|
|
|
} |
|
|
|
|
|
|
|
.kb_reshape <- function(.x, path) { |
|
|
|
|
|
|
|
if (length(.x) == 0) return(data.frame(stringsAsFactors=FALSE)) |
|
|
|
|
|
|
|
if (path == "/topics") { |
|
|
|
|
|
|
|
easy_cols <- .x[, c("id", "editorId", "name", "created", "revisionDate", "disclosureDate", "document")] |
|
|
|
|
|
|
|
easy_cols[["created"]] <- date_convert(easy_cols[["created"]]) |
|
|
|
easy_cols[["revisionDate"]] <- date_convert(easy_cols[["revisionDate"]]) |
|
|
|
|
|
|
|
easy_cols$references <- .x[["metadata"]][["references"]] |
|
|
|
|
|
|
|
cvss_v3 <- .x[["metadata"]][["baseMetricV3"]][["cvssV3"]] |
|
|
@ -46,12 +55,16 @@ |
|
|
|
|
|
|
|
} else if (path == "/contributors") { |
|
|
|
|
|
|
|
.x[["created"]] <- date_convert(.x[["created"]]) |
|
|
|
.x |
|
|
|
|
|
|
|
} else if (path == "/assessments") { |
|
|
|
|
|
|
|
easy_cols <- .x[,c("id", "editorId", "topicId", "created", "revisionDate", "document", "score")] |
|
|
|
|
|
|
|
easy_cols[["created"]] <- date_convert(easy_cols[["created"]]) |
|
|
|
easy_cols[["revisionDate"]] <- date_convert(easy_cols[["revisionDate"]]) |
|
|
|
|
|
|
|
metadata <- easy_cols[["metadata"]] |
|
|
|
|
|
|
|
easy_cols$tags <- metadata[["tags"]] |
|
|
@ -79,6 +92,9 @@ |
|
|
|
|
|
|
|
handle_response <- function(.x, api_key = attackerkb_api_key()) { |
|
|
|
|
|
|
|
.pb <- progress::progress_bar$new(format = "(:spin)", total = NA) |
|
|
|
.pb$tick() |
|
|
|
|
|
|
|
path <- .x[["links"]][["self"]][["href"]] |
|
|
|
|
|
|
|
ret <- .x[["data"]] |
|
|
@ -89,7 +105,7 @@ handle_response <- function(.x, api_key = attackerkb_api_key()) { |
|
|
|
|
|
|
|
while(length(next_href)) { |
|
|
|
|
|
|
|
cat(".") |
|
|
|
.pb$tick() |
|
|
|
|
|
|
|
httr::GET( |
|
|
|
url = sprintf("https://api.attackerkb.com%s", next_href), |
|
|
@ -108,8 +124,6 @@ handle_response <- function(.x, api_key = attackerkb_api_key()) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cat("\n") |
|
|
|
|
|
|
|
class(ret) <- c("tbl_df", "tbl", "data.frame") |
|
|
|
ret |
|
|
|
|
|
|
|