diff --git a/DESCRIPTION b/DESCRIPTION index fa03ce7..b69c733 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: attackerkb Type: Package Title: Tools to Query the Rapid7 AttackerKB API -Version: 0.1.1 -Date: 2020-04-18 +Version: 0.1.2 +Date: 2020-05-21 Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-5670-2640")) diff --git a/NEWS.md b/NEWS.md index 0960271..de24040 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +0.1.2 +* Fixed bug in the post-request processor for `/topic` API request. + (Reported by @kwlin-r7) + 0.1.1 * Fixed an issue where errors wld be thrown if zero API results came back * Added progress spinner for API calls vs the hacky dots diff --git a/R/assessments.R b/R/assessments.R index fd1295c..4bf8ba1 100644 --- a/R/assessments.R +++ b/R/assessments.R @@ -64,7 +64,7 @@ kb_assessments <- function(assessment_id = NULL, out <- httr::content(res, as = "text", encoding = "UTF-8") out <- jsonlite::fromJSON(out) - out <- handle_response(out) + out <- handle_response(out, api_key = api_key, came_from = "kb_assessments") out diff --git a/R/contributor.R b/R/contributor.R index 66adb61..4723ad8 100644 --- a/R/contributor.R +++ b/R/contributor.R @@ -51,7 +51,7 @@ kb_contributors <- function(contributor_id = NULL, out <- httr::content(res, as = "text", encoding = "UTF-8") out <- jsonlite::fromJSON(out) - out <- handle_response(out) + out <- handle_response(out, api_key = api_key, came_from = "kb_contributors") out diff --git a/R/topics.R b/R/topics.R index ffe0167..6863bda 100644 --- a/R/topics.R +++ b/R/topics.R @@ -70,7 +70,7 @@ kb_topics <- function(topic_id = NULL, out <- httr::content(res, as = "text", encoding = "UTF-8") out <- jsonlite::fromJSON(out) - out <- handle_response(out) + out <- handle_response(out, api_key = api_key, came_from = "kb_topics") out @@ -91,7 +91,7 @@ kb_topic <- function(topic_id = "131226a6-a1e9-48a1-a5d0-ac94baf8dfd2", api_key out <- httr::content(res, as = "text", encoding = "UTF-8") out <- jsonlite::fromJSON(out) - out <- handle_response(out) + out <- handle_response(out, api_key = api_key, came_from = "kb_topic") out diff --git a/R/utils.R b/R/utils.R index 668a668..166aabf 100644 --- a/R/utils.R +++ b/R/utils.R @@ -53,6 +53,30 @@ date_convert <- function(.x) { easy_cols + } else if (path == "/topic") { + + ## List of 10 + ## $ created : chr "2019-05-14T18:28:19.31074Z" + ## $ disclosureDate: chr "2019-05-16T19:29:00Z" + ## $ document : chr "A bug in Windows Remote Desktop protocol allows unauthenticated users to run arbitrary code via a specially cra"| __truncated__ + ## $ editorId : chr "7191a637-aa4e-4885-98a0-f4f2da285b99" + ## $ id : chr "131226a6-a1e9-48a1-a5d0-ac94baf8dfd2" + ## $ metadata :List of 16 + ## $ name : chr "Windows Remote Desktop (RDP) Use-after-free vulnerablility, \"Bluekeep\"" + ## $ revisionDate : chr "2020-03-03T16:18:02.56368Z" + ## $ score :List of 2 + ## $ tags :List of 12 + + .x[["created"]] <- date_convert(.x[["created"]]) + .x[["disclosed"]] <- date_convert(.x[["disclosureDate"]]) + .x[["metadata"]] <- I(list(.x[["metadata"]])) + .x[["score"]] <- I(list(.x[["score"]])) + .x[["tags"]] <- I(list(.x[["tags"]])) + + .x <- as.data.frame(.x, stringsAsFactors = FALSE) + + .x + } else if (path == "/contributors") { .x[["created"]] <- date_convert(.x[["created"]]) @@ -90,12 +114,13 @@ date_convert <- function(.x) { } -handle_response <- function(.x, api_key = attackerkb_api_key()) { +handle_response <- function(.x, api_key = attackerkb_api_key(), came_from = NULL) { .pb <- progress::progress_bar$new(format = "(:spin)", total = NA) .pb$tick() path <- .x[["links"]][["self"]][["href"]] + if (length(path) == 0) path <- sub("^kb_", "/", came_from) ret <- .x[["data"]]