boB Rudis 3 years ago
parent
commit
d1a35d4db4
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      DESCRIPTION
  2. 4
      R/assessments.R
  3. 4
      R/contributor.R
  4. 4
      R/topics.R
  5. 9
      R/utils.R

4
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

4
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

4
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

4
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

9
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"]]

Loading…
Cancel
Save