Browse Source

initial data sync

master
boB Rudis 5 years ago
parent
commit
d1a2312911
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 1
      .Rbuildignore
  2. 3
      DESCRIPTION
  3. 1
      NAMESPACE
  4. 5
      R/attckr-package.R
  5. BIN
      data-raw/enterprise-attack.json.xz
  6. BIN
      data-raw/mobile-attack.json.xz
  7. BIN
      data-raw/pre-attack.json.xz
  8. 94
      data-raw/sync-attack.R
  9. BIN
      data/enterprise_attack.rda
  10. BIN
      data/mobile_attack.rda
  11. BIN
      data/pre_attack.rda
  12. BIN
      data/tidy_attack.rda

1
.Rbuildignore

@ -13,3 +13,4 @@
^tmp$
^notes$
^\.gitlab-ci\.yml$
^data-raw$

3
DESCRIPTION

@ -20,6 +20,7 @@ Depends:
R (>= 3.2.0)
Imports:
httr,
jsonlite
jsonlite,
tibble
Roxygen: list(markdown = TRUE)
RoxygenNote: 6.1.1

1
NAMESPACE

@ -1,4 +1,5 @@
# Generated by roxygen2: do not edit by hand
import(httr)
import(tibble)
importFrom(jsonlite,fromJSON)

5
R/attckr-package.R

@ -1,12 +1,13 @@
#' ...
#'
#'
#' - URL: <https://gitlab.com/hrbrmstr/attckr>
#' - BugReports: <https://gitlab.com/hrbrmstr/attckr/issues>
#'
#'
#' @md
#' @name attckr
#' @docType package
#' @author Bob Rudis (bob@@rud.is)
#' @import httr
#' @import tibble
#' @importFrom jsonlite fromJSON
NULL

BIN
data-raw/enterprise-attack.json.xz

Binary file not shown.

BIN
data-raw/mobile-attack.json.xz

Binary file not shown.

BIN
data-raw/pre-attack.json.xz

Binary file not shown.

94
data-raw/sync-attack.R

@ -0,0 +1,94 @@
## code to prepare `enterprise_attack` dataset goes here
library(tidyverse)
unlink(
sprintf("%s.xz", here::here(
"data-raw",
c(
"enterprise-attack.json",
"mobile-attack.json",
"pre-attack.json"
)
))
)
download.file(
url = c(
"https://github.com/mitre/cti/raw/master/enterprise-attack/enterprise-attack.json",
"https://github.com/mitre/cti/raw/master/mobile-attack/mobile-attack.json",
"https://github.com/mitre/cti/raw/master/pre-attack/pre-attack.json"
),
destfile = c(
here::here(
"data-raw",
c(
"enterprise-attack.json",
"mobile-attack.json",
"pre-attack.json"
)
)
),
method = "libcurl"
)
walk(
here::here(
"data-raw",
c(
"enterprise-attack.json",
"mobile-attack.json",
"pre-attack.json"
)
),
~system2("xz", args = .x)
)
jsonlite::fromJSON(
here::here("data-raw/enterprise-attack.json.xz")
) -> enterprise_attack
enterprise_attack[["objects"]] <- tibble::as_tibble(enterprise_attack[["objects"]])
usethis::use_data(enterprise_attack, overwrite = TRUE, compress = "xz")
jsonlite::fromJSON(
here::here("data-raw/mobile-attack.json.xz")
) -> mobile_attack
mobile_attack[["objects"]] <- tibble::as_tibble(mobile_attack[["objects"]])
usethis::use_data(mobile_attack, overwrite = TRUE, compress = "xz")
jsonlite::fromJSON(
here::here("data-raw/pre-attack.json.xz")
) -> pre_attack
pre_attack[["objects"]] <- tibble::as_tibble(pre_attack[["objects"]])
usethis::use_data(pre_attack, overwrite = TRUE, compress = "xz")
bind_rows(
tibble(
technique = enterprise_attack$objects$name,
description = enterprise_attack$objects$x_mitre_detection,
tactic = enterprise_attack$objects$kill_chain_phases
) %>%
filter(lengths(tactic) > 0) %>%
unnest(),
tibble(
technique = mobile_attack$objects$name,
description = mobile_attack$objects$x_mitre_detection,
tactic = mobile_attack$objects$kill_chain_phases
) %>%
filter(lengths(tactic) > 0) %>%
unnest(),
tibble(
technique = pre_attack$objects$name,
description = pre_attack$objects$description,
tactic = pre_attack$objects$kill_chain_phases
) %>%
filter(lengths(tactic) > 0) %>%
unnest()
) -> tidy_attack
usethis::use_data(tidy_attack, overwrite = TRUE, compress = "xz")

BIN
data/enterprise_attack.rda

Binary file not shown.

BIN
data/mobile_attack.rda

Binary file not shown.

BIN
data/pre_attack.rda

Binary file not shown.

BIN
data/tidy_attack.rda

Binary file not shown.
Loading…
Cancel
Save