diff --git a/DESCRIPTION b/DESCRIPTION index 9cfa2f1..540abc4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: attackerkb Type: Package Title: Tools to Query the Rapid7 AttackerKB API -Version: 0.1.3 +Version: 0.2.0 Date: 2020-05-21 Authors@R: c( person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), @@ -25,4 +25,4 @@ Imports: data.table, progress Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 diff --git a/R/assessments.R b/R/assessments.R index 4bf8ba1..f6988ca 100644 --- a/R/assessments.R +++ b/R/assessments.R @@ -42,7 +42,7 @@ kb_assessments <- function(assessment_id = NULL, if (length(revised)) created <- as.character(as.Date(created[1])) httr::GET( - url = "https://api.attackerkb.com/assessments", + url = "https://api.attackerkb.com/v1/assessments", .ATTACKERKB_UA, query = list( id = assessment_id, @@ -77,7 +77,7 @@ kb_assessment <- function(assessment_id, api_key = attackerkb_api_key()) { assessment_id <- assessment_id[1] httr::GET( - url = sprintf("https://api.attackerkb.com/assessments/%s", assessment_id), + url = sprintf("https://api.attackerkb.com/v1/assessments/%s", assessment_id), .ATTACKERKB_UA, httr::add_headers(`Authorization` = sprintf("basic %s", api_key)) ) -> res diff --git a/R/contributor.R b/R/contributor.R index 4723ad8..a0090b4 100644 --- a/R/contributor.R +++ b/R/contributor.R @@ -32,7 +32,7 @@ kb_contributors <- function(contributor_id = NULL, if (length(created)) created <- as.character(as.Date(created[1])) httr::GET( - url = "https://api.attackerkb.com/contributors", + url = "https://api.attackerkb.com/v1/contributors", .ATTACKERKB_UA, query = list( id = contributor_id, @@ -64,7 +64,7 @@ kd_contributor <- function(contributor_id, api_key = attackerkb_api_key()) { contributor_id <- contributor_id[1] httr::GET( - url = sprintf("https://api.attackerkb.com/contributors/%s", contributor_id), + url = sprintf("https://api.attackerkb.com/v1/contributors/%s", contributor_id), .ATTACKERKB_UA, httr::add_headers(`Authorization` = sprintf("basic %s", api_key)) ) -> res diff --git a/R/topics.R b/R/topics.R index 6863bda..68227ae 100644 --- a/R/topics.R +++ b/R/topics.R @@ -47,7 +47,7 @@ kb_topics <- function(topic_id = NULL, if (length(disclosed)) disclosed <- as.character(as.Date(disclosed[1])) httr::GET( - url = "https://api.attackerkb.com/topics", + url = "https://api.attackerkb.com/v1/topics", .ATTACKERKB_UA, query = list( id = topic_id, @@ -81,7 +81,7 @@ kb_topics <- function(topic_id = NULL, kb_topic <- function(topic_id = "131226a6-a1e9-48a1-a5d0-ac94baf8dfd2", api_key = attackerkb_api_key()) { httr::GET( - url = sprintf("https://api.attackerkb.com/topics/%s", topic_id[1]), + url = sprintf("https://api.attackerkb.com/v1/topics/%s", topic_id[1]), .ATTACKERKB_UA, httr::add_headers(`Authorization` = sprintf("basic %s", api_key)) ) -> res diff --git a/R/utils.R b/R/utils.R index 45b62d3..238dbbf 100644 --- a/R/utils.R +++ b/R/utils.R @@ -10,7 +10,7 @@ date_convert <- function(.x) { if (length(.x) == 0) return(data.frame(stringsAsFactors=FALSE)) - if (path == "/topics") { + if (path == "/v1/topics") { easy_cols <- .x[, c("id", "editorId", "name", "created", "revisionDate", "disclosureDate", "document")] @@ -57,7 +57,7 @@ date_convert <- function(.x) { easy_cols - } else if (path == "/topic") { + } else if (path == "/v1/topic") { ## List of 10 ## $ created : chr "2019-05-14T18:28:19.31074Z" @@ -89,12 +89,12 @@ date_convert <- function(.x) { .x - } else if (path == "/contributors") { + } else if (path == "/v1/contributors") { .x[["created"]] <- date_convert(.x[["created"]]) .x - } else if (path == "/assessments") { + } else if (path == "/v1/assessments") { easy_cols <- .x[,c("id", "editorId", "topicId", "created", "revisionDate", "document", "score")] @@ -132,6 +132,7 @@ handle_response <- function(.x, api_key = attackerkb_api_key(), came_from = NULL .pb$tick() path <- .x[["links"]][["self"]][["href"]] + if (length(path) == 0) path <- sub("^kb_", "/", came_from) ret <- .x[["data"]]