Browse Source

Fixed bug in post-request processor for /topic API request.

(Reported by @kwlin-r7)
master
boB Rudis 4 years ago
parent
commit
bfc018c695
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      DESCRIPTION
  2. 4
      NEWS.md
  3. 2
      R/assessments.R
  4. 2
      R/contributor.R
  5. 4
      R/topics.R
  6. 27
      R/utils.R

4
DESCRIPTION

@ -1,8 +1,8 @@
Package: attackerkb Package: attackerkb
Type: Package Type: Package
Title: Tools to Query the Rapid7 AttackerKB API Title: Tools to Query the Rapid7 AttackerKB API
Version: 0.1.1 Version: 0.1.2
Date: 2020-04-18 Date: 2020-05-21
Authors@R: c( Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")) comment = c(ORCID = "0000-0001-5670-2640"))

4
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 0.1.1
* Fixed an issue where errors wld be thrown if zero API results came back * Fixed an issue where errors wld be thrown if zero API results came back
* Added progress spinner for API calls vs the hacky dots * Added progress spinner for API calls vs the hacky dots

2
R/assessments.R

@ -64,7 +64,7 @@ kb_assessments <- function(assessment_id = NULL,
out <- httr::content(res, as = "text", encoding = "UTF-8") out <- httr::content(res, as = "text", encoding = "UTF-8")
out <- jsonlite::fromJSON(out) out <- jsonlite::fromJSON(out)
out <- handle_response(out) out <- handle_response(out, api_key = api_key, came_from = "kb_assessments")
out out

2
R/contributor.R

@ -51,7 +51,7 @@ kb_contributors <- function(contributor_id = NULL,
out <- httr::content(res, as = "text", encoding = "UTF-8") out <- httr::content(res, as = "text", encoding = "UTF-8")
out <- jsonlite::fromJSON(out) out <- jsonlite::fromJSON(out)
out <- handle_response(out) out <- handle_response(out, api_key = api_key, came_from = "kb_contributors")
out out

4
R/topics.R

@ -70,7 +70,7 @@ kb_topics <- function(topic_id = NULL,
out <- httr::content(res, as = "text", encoding = "UTF-8") out <- httr::content(res, as = "text", encoding = "UTF-8")
out <- jsonlite::fromJSON(out) out <- jsonlite::fromJSON(out)
out <- handle_response(out) out <- handle_response(out, api_key = api_key, came_from = "kb_topics")
out 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 <- httr::content(res, as = "text", encoding = "UTF-8")
out <- jsonlite::fromJSON(out) out <- jsonlite::fromJSON(out)
out <- handle_response(out) out <- handle_response(out, api_key = api_key, came_from = "kb_topic")
out out

27
R/utils.R

@ -53,6 +53,30 @@ date_convert <- function(.x) {
easy_cols 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") { } else if (path == "/contributors") {
.x[["created"]] <- date_convert(.x[["created"]]) .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 <- progress::progress_bar$new(format = "(:spin)", total = NA)
.pb$tick() .pb$tick()
path <- .x[["links"]][["self"]][["href"]] path <- .x[["links"]][["self"]][["href"]]
if (length(path) == 0) path <- sub("^kb_", "/", came_from)
ret <- .x[["data"]] ret <- .x[["data"]]

Loading…
Cancel
Save