~hrbrmstr/attackerkb

b455b99857524fb799a99eb3cd6d8eb7e676f977 — hrbrmstr 4 years ago bfc018c
Fix disclosure date and rapid7 analysis NULL bugs
2 files changed, 15 insertions(+), 3 deletions(-)

M DESCRIPTION
M R/utils.R
M DESCRIPTION => DESCRIPTION +1 -1
@@ 1,7 1,7 @@
Package: attackerkb
Type: Package
Title: Tools to Query the Rapid7 AttackerKB API
Version: 0.1.2
Version: 0.1.3
Date: 2020-05-21
Authors@R: c(
    person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"), 

M R/utils.R => R/utils.R +14 -2
@@ 1,5 1,9 @@
date_convert <- function(.x) {
  as.POSIXct(.x, format="%Y-%m-%dT%H:%M:%OS", tz="GMT")
  if (length(.x)) {
    as.POSIXct(.x, format="%Y-%m-%dT%H:%M:%OS", tz="GMT")
  } else {
    as.POSIXct(NA)
  }
}

.kb_reshape <- function(.x, path) {


@@ 68,11 72,19 @@ date_convert <- function(.x) {
    ## $ tags          :List of 12

    .x[["created"]] <- date_convert(.x[["created"]])
    .x[["disclosed"]] <- date_convert(.x[["disclosureDate"]])
    .x[["disclosureDate"]] <- date_convert(.x[["disclosureDate"]])
    .x[["metadata"]] <- I(list(.x[["metadata"]]))
    .x[["score"]] <- I(list(.x[["score"]]))
    .x[["tags"]] <- I(list(.x[["tags"]]))

    if ("rapid7Analysis" %in% names(.x)) {
      if (length(.x[["rapid7Analysis"]])) {
        .x[["rapid7Analysis"]] <- paste0(.x[["rapid7Analysis"]], collapse = " ")
      } else {
        .x[["rapid7Analysis"]] <- NA_character_
      }
    }

    .x <- as.data.frame(.x, stringsAsFactors = FALSE)

    .x