Commit f376d0cf48a69f59fbd8dd784b772a3057c4860c

Authored by Miguel Tuñón
1 parent 274ef06d

Cambias parser hackmaggedon

Showing 78 changed files with 125 additions and 11 deletions
ISO27001effectiveness/DESCRIPTION
... ... @@ -8,4 +8,5 @@ Description: More about what it does (maybe more than one line)
8 8 Use four spaces when indenting paragraphs within the Description.
9 9 License: What license is it under?
10 10 Encoding: UTF-8
11   -LazyData: true
12 11 \ No newline at end of file
  12 +LazyData: true
  13 +RoxygenNote: 5.0.1
... ...
ISO27001effectiveness/Main.R
... ... @@ -6,6 +6,8 @@ Cert_PerCountry <- ParseExcelFileRaw("./data/ISO/iso_27001_iso_survey2015_prepro
6 6 Sites_PerCountry <- ParseExcelFileRaw("./data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", 2)
7 7 Cert_PerSector <- ParseExcelFileRaw("./data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", 3)
8 8  
9   -Cert_PerCountry <- ProccesISOSurveyByCountryRaw(Cert_PerCountry, c("X2010", "X2011", "X2012", "X2013", "X2014", "X2015"))
10   -Sites_PerCountry <- ProccesISOSurveyByCountryRaw(Sites_PerCountry, c("X2010", "X2011", "X2012", "X2013", "X2014", "X2015"))
11   -#Cert_PerSector <- ProccesISOSurveyRaw(Cert_PerSector, c("X2010", "X2011", "X2012", "X2013", "X2014", "X2015"))
  9 +Cert_PerCountry <- ProccesISOSurveyByCountryRaw(Cert_PerCountry, c("X2012", "X2013", "X2014", "X2015"))
  10 +Sites_PerCountry <- ProccesISOSurveyByCountryRaw(Sites_PerCountry, c( "X2012", "X2013", "X2014", "X2015"))
  11 +#Cert_PerSector <- ProccesISOSurveyRaw(Cert_PerSector, c("X2012", "X2013", "X2014", "X2015"))
  12 +
  13 +Attacks <- GetAttacksData()
... ...
ISO27001effectiveness/NAMESPACE
1   -exportPattern("^[[:alpha:]]+")
  1 +# Generated by roxygen2: do not edit by hand
  2 +
... ...
ISO27001effectiveness/R/Hackmageddon_Parser.R
... ... @@ -4,33 +4,62 @@
4 4  
5 5  
6 6  
7   -ParseHMExcel <- function(file){
  7 +ParseHMExcel <- function(file, cols){
8 8 print(file)
9 9 if (!file.exists(file)) {
10 10 stop(paste("Error, file [", file, "] not found"))
11 11 }
12   - dataset <- read.xlsx2(file, 1, header = TRUE,colIndex = 2:10, colClasses = c("Date", "character", "character", "character", "character", "character", "character", "character"))
  12 + dataset <- xlsx::read.xlsx2(file, 1, header = TRUE,colIndex = cols, colClasses = c("numeric", "character", "character", "character"))
  13 +
  14 + if (is.null(dataset$Date)) {
  15 + dataset <- xlsx::read.xlsx2(file, 1, header = TRUE,colIndex = cols, colClasses = c("numeric", "character", "character", "character"), startRow = 2)
  16 + }
  17 +
13 18 dataset
14 19 }
15 20  
16 21 ProccesHMRaw <- function(dataset.raw){
17 22  
18 23 #Remove rows with Date NA
  24 + print(class(dataset.raw$Date))
19 25 dataset <- dataset.raw[!is.na(dataset.raw$Date),]
  26 + dataset$Date <- as.POSIXct(dataset$Date*86400, tz ="GMT", origin ="1904-01-01")
20 27  
21 28 dataset
22 29 }
23 30  
24   -ParseHMFolder <- function(folder){
  31 +#' Title
  32 +#'
  33 +#' @param folder
  34 +#' @param cols
  35 +#'
  36 +#' @return
  37 +#' @export
  38 +#'
  39 +#' @examples
  40 +ParseHMFolder <- function(folder, cols){
25 41 filelist <- list.files(folder)
26 42 #frames <- lapply(paste(folder,filelist,sep = ""),ParseHMExcel)
27   - dataset <- ProccesHMRaw(ParseHMExcel(paste(folder,filelist[1],sep = "/")))
  43 +
  44 + myFile <- paste(folder,filelist[1],sep = "")
  45 + dataset <- ProccesHMRaw(ParseHMExcel(myFile, cols))
28 46  
29 47 for (i in 2:length(filelist)) {
30   - dataset <- rbind(dataset, ProccesHMRaw(ParseHMExcel(paste(folder,filelist[i],sep = "/"))))
  48 + dataset <- rbind(dataset, ProccesHMRaw(ParseHMExcel(paste(folder,filelist[i],sep = ""), cols)))
31 49 }
32 50  
33 51 dataset
34 52 }
35 53  
  54 +GetAttacksData <- function() {
  55 +
  56 + format1 <- ParseHMFolder("./data/hackmageddon/Format1/", c(2, 9, 7, 6))
  57 + format2 <- ParseHMFolder("./data/hackmageddon/Format2/", c(2,7, 5, 6))
  58 + format3 <- ParseHMFolder("./data/hackmageddon/Format3/", c(2, 9, 7, 6))
  59 + format4 <- ParseHMFolder("./data/hackmageddon/Format4/", c(1, 9, 5, 3))
  60 +
  61 + dataset <- rbind(format1, format2, format3, format4)
  62 +
  63 + dataset
  64 +}
36 65  
... ...
ISO27001effectiveness/R/ISOSurvey_Parser.R
... ... @@ -21,7 +21,7 @@ ParseExcelFileRaw &lt;- function(file, sheet){
21 21 stop(paste("Error, file [", file, "] not found"))
22 22 }
23 23  
24   - dataset <- read.xlsx2(file, sheet,colClasses = c("character","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric"), header = TRUE, as.data.frame = TRUE)
  24 + dataset <- xlsx::read.xlsx2(file, sheet,colClasses = c("character","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric","numeric"), header = TRUE, as.data.frame = TRUE)
25 25  
26 26 dataset
27 27 }
... ...
ISO27001effectiveness/data/hackmageddon/2016/1-15 April 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 April 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/1-15 August 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 August 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format1/1-15 December 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 February 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 February 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 January 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 January 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format1/1-15 Jul 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 July 2016 Cyber Attacks Timelines.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 July 2016 Cyber Attacks Timelines.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 June 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 June 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 March 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 March 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 May 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 May 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/1-15 November 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 November 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/1-15 October 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 October 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 October 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 October 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/1-15 September 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 September 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-15 September 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-15 September 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/1-16 August 2016 Cyber Attacks Timelines.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/1-16 August 2016 Cyber Attacks Timelines.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-29 February 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-29 February 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-30 July 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-30 July 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-30 June 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-30 June 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/16-30 November 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-30 November 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/16-30 September 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-30 September 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-30 September 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-30 September 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-31 April 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 April 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/16-31 August 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 August 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-31 August 2016 Cyber Attacks Timelines.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 August 2016 Cyber Attacks Timelines.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format1/16-31 December 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-31 January 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 January 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format1/16-31 July Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-31 March 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 March 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-31 May 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 May 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2015/16-31 October 2015 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 October 2015 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/2016/16-31 October 2016 Cyber Attacks Timeline.xlsx renamed to ISO27001effectiveness/data/hackmageddon/Format1/16-31 October 2016 Cyber Attacks Timeline.xlsx
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format2/16-30 Apr 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format2/Stats May 2015.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Apr 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Apr 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 August 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 December 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Feb 2014 Cyber Attacks Timeline XLS.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Feb 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Jan 2014 Cyber Attacks Timeline.xls 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Jan 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 June 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Mar 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 Mar 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 May 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 November 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 October 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/1-15 September 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-28 Feb 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-28 Feb 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-30 Apr 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-30 Sep 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Aug 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 December 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Jan 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Jan 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Jul 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Jun 2014 Cyber Attacks Timeline(1).xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Jun 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Mar 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Mar 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 May 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Nov 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format3/16-31 Oct 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format4/Hackmageddon2013 Def3.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/hackmageddon/Format4/hackmageddon 2012 def.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/test/16-31 Mar 2014 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/data/test/16-31 Mar 2015 Cyber Attacks Timeline.xlsx 0 → 100644
No preview for this file type
ISO27001effectiveness/man/GetCountryAbrev.Rd 0 → 100644
  1 +% Generated by roxygen2: do not edit by hand
  2 +% Please edit documentation in R/Util.R
  3 +\name{GetCountryAbrev}
  4 +\alias{GetCountryAbrev}
  5 +\title{Return the 2 letter code of a country relation}
  6 +\usage{
  7 +GetCountryAbrev()
  8 +}
  9 +\value{
  10 +data.frame
  11 +}
  12 +\description{
  13 +Relation of country names included in the ISO Survey input file with 2 letter code
  14 +included on the hackmaggedon input files
  15 +}
  16 +
... ...
ISO27001effectiveness/man/LoadParserLibraries.Rd 0 → 100644
  1 +% Generated by roxygen2: do not edit by hand
  2 +% Please edit documentation in R/Util.R
  3 +\name{LoadParserLibraries}
  4 +\alias{LoadParserLibraries}
  5 +\title{Install and load required libraries}
  6 +\usage{
  7 +LoadParserLibraries()
  8 +}
  9 +\description{
  10 +This function checks if every required library is installed to be loaded, if not they will be installed and then loaded.
  11 +Libraries installed:
  12 + xlsx to parse excel files like ISO survey source format
  13 +}
  14 +
... ...
ISO27001effectiveness/man/ParseExcelFileRaw.Rd 0 → 100644
  1 +% Generated by roxygen2: do not edit by hand
  2 +% Please edit documentation in R/ISOSurvey_Parser.R
  3 +\name{ParseExcelFileRaw}
  4 +\alias{ParseExcelFileRaw}
  5 +\title{Get data frame from an excel file}
  6 +\usage{
  7 +ParseExcelFileRaw(file, sheet)
  8 +}
  9 +\arguments{
  10 +\item{file}{path to excel file}
  11 +
  12 +\item{sheet}{index of sheet to parse}
  13 +}
  14 +\value{
  15 +data.frame
  16 +}
  17 +\description{
  18 +Check if the file exists and then parse it into a data.frame
  19 +}
  20 +\examples{
  21 +Cert_PerCountry <- ParseExcelFileRaw("./data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", 1)
  22 +Sites_PerCountry <- ParseExcelFileRaw("./data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", 2)
  23 +Cert_PerSector <- ParseExcelFileRaw("./data/ISO/iso_27001_iso_survey2015_preprocessed.xlsx", 3)
  24 +}
  25 +
... ...
ISO27001effectiveness/man/ProccesISOSurveyByCountryRaw.Rd 0 → 100644
  1 +% Generated by roxygen2: do not edit by hand
  2 +% Please edit documentation in R/ISOSurvey_Parser.R
  3 +\name{ProccesISOSurveyByCountryRaw}
  4 +\alias{ProccesISOSurveyByCountryRaw}
  5 +\title{Process raw data from ISO survey}
  6 +\usage{
  7 +ProccesISOSurveyByCountryRaw(dataset.raw, years)
  8 +}
  9 +\arguments{
  10 +\item{dataset.raw}{raw data from ISO Survey excel file}
  11 +
  12 +\item{years}{List of years to return, c("X2006", "X2010", ...)}
  13 +}
  14 +\value{
  15 +data.frame
  16 +}
  17 +\description{
  18 +Proccess the raw data from ISO survey to replace NAs, normalizate country names and filter years
  19 +}
  20 +\examples{
  21 +
  22 +Cert_PerCountry <- ProccesISOSurveyRaw(Cert_PerCountry, c("X2010", "X2011", "X2012", "X2013", "X2014", "X2015"))
  23 +Sites_PerCountry <- ProccesISOSurveyRaw(Sites_PerCountry, c("X2010", "X2011", "X2012", "X2013", "X2014", "X2015"))
  24 +Cert_PerSector <- ProccesISOSurveyRaw(Cert_PerSector, c("X2010", "X2011", "X2012", "X2013", "X2014", "X2015"))
  25 +}
  26 +
... ...