diff --git a/.Rbuildignore b/.Rbuildignore index 48b1c8e..c820117 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -6,3 +6,4 @@ ^CONDUCT\.md$ ^README\.Rmd$ ^cran-comments\.md$ +^docs$ diff --git a/DESCRIPTION b/DESCRIPTION index 11675f3..ba10f6d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: gdns Title: Tools to Work with Google DNS Over HTTPS API -Version: 0.2.0 +Version: 0.2.1 Authors@R: c(person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"))) Maintainer: Bob Rudis Description: To address the problem of insecurity of UDP-based DNS requests, @@ -23,5 +23,7 @@ Imports: httr, jsonlite, purrr, - stringi -RoxygenNote: 5.0.1 + stringi, + tibble, + dplyr +RoxygenNote: 6.0.1 diff --git a/NAMESPACE b/NAMESPACE index 752abb9..868f0bc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -13,13 +13,19 @@ export(spf_ipv6s) export(spf_ptrs) export(split_spf) import(httr) +importFrom(dplyr,as_data_frame) +importFrom(dplyr,bind_cols) +importFrom(dplyr,bind_rows) importFrom(jsonlite,fromJSON) +importFrom(purrr,"%>%") importFrom(purrr,"%||%") importFrom(purrr,map) importFrom(purrr,map_df) importFrom(purrr,safely) +importFrom(stringi,stri_detect_fixed) importFrom(stringi,stri_enc_toutf8) importFrom(stringi,stri_replace_all_regex) importFrom(stringi,stri_split_fixed) importFrom(stringi,stri_split_regex) importFrom(stringi,stri_trim) +importFrom(tibble,data_frame) diff --git a/R/dkim.r b/R/dkim.r new file mode 100644 index 0000000..057a539 --- /dev/null +++ b/R/dkim.r @@ -0,0 +1,37 @@ +#' #' Split out all SPF records in a domain's TXT record +#' #' +#' #' Given a vector of TXT records, this function will return a list of vectors +#' #' of all the SPF records for each. If the given TXT record is not an SPF +#' #' record, \code{NA} is returned (which makes it easy to skip with \code{purrr} +#' #' functions). +#' #' +#' #' @param dkim_rec a character vector of DNS TXT records +#' #' @export +#' parse_dkim <- function(dkim_rec) { +#' purrr::map_df(dkim_rec, .parse_dkim) +#' } +#' +#' .parse_dkim <- function(dkim_rec) { +#' +#' if (has_dkim(dkim_rec)) { +#' spf_rec <- stringi::stri_trim(stringi::stri_replace_all_regex(dkim_rec, '"', "")) +#' recs <- stri_trim(unlist(stringi::stri_split_regex(dkim_rec, ";"))) +#' recs <- grep("v=DKIM1", recs, invert=TRUE, value=TRUE) +#' purrr::keep(recs, stringi::stri_detect_fixed, "=") %>% +#' purrr::map_df(~{ +#' x <- stringi::stri_match_all_regex(.x, "(.*)=(.*)")[[1]] +#' data_frame(key=x[,2], value=x[,3]) +#' }) +#' } else { +#' NULL +#' } +#' +#' } +#' +#' #' Test for whether a DNS TXT record is a DKIM record +#' #' +#' #' @param spf_rec a character vector of DNS TXT records +#' #' @export +#' has_dkim <- function(dkim_rec) { +#' grepl("v=DKIM1", dkim_rec) +#' } diff --git a/R/gdns-package.r b/R/gdns-package.r index c6482f7..46eb285 100644 --- a/R/gdns-package.r +++ b/R/gdns-package.r @@ -23,6 +23,9 @@ #' @import httr #' @importFrom stringi stri_split_fixed stri_split_regex stri_trim #' stri_replace_all_regex stri_enc_toutf8 +#' stri_detect_fixed #' @importFrom jsonlite fromJSON -#' @importFrom purrr safely map map_df %||% +#' @importFrom tibble data_frame +#' @importFrom purrr safely map map_df %||% %>% +#' @importFrom dplyr bind_rows bind_cols as_data_frame NULL diff --git a/R/spf.r b/R/spf.r index a7f1114..39b58b2 100644 --- a/R/spf.r +++ b/R/spf.r @@ -2,7 +2,7 @@ #' #' Given a vector of TXT records, this function will return a list of vectors #' of all the SPF records for each. If the given TXT record is not an SPF -#' record, \code{NULL} is returned (which makes it easy to skip with \code{purrr} +#' record, \code{NA} is returned (which makes it easy to skip with \code{purrr} #' functions). #' #' @param spf_rec a character vector of DNS TXT records diff --git a/cran-comments.md b/cran-comments.md index 76f82a0..f6658ad 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,19 +1,17 @@ ## Test environments -* local OS X install, R 3.3.1 -* Travis OS X (R 3.3.1 and oldrel) -* ubuntu 12.04 (on travis-ci), R 3.3.1 & oldrel -* win-builder (devel and release) (caught it today just before the crash) +* local OS X install, R 3.4.0 +* ubuntu 12.04 (on travis-ci), R 3.4.0 & oldrel +* win-builder (devel and release) ## R CMD check results -0 errors | 0 warnings | 1 note (new pkg) - -* This is a new release. +0 errors | 0 warnings | 1 note (maintainer & acronyms) ## Reverse dependencies -This is a new release, so there are no reverse dependencies. +None --- -Added URL ref in DESCRIPTION per note from Kurt (#ty!) +* This is an update release to fix CRAN checks due to the crazy way purrr does dplyr ops. This pkg now Imports the necessary dplyr functions. +* Mis-spelled words aren't mis-spelled. Too many necessary acronyms to use "'" pairs. diff --git a/gdns.Rproj b/gdns.Rproj index 773de7e..9f58d70 100644 --- a/gdns.Rproj +++ b/gdns.Rproj @@ -5,21 +5,19 @@ SaveWorkspace: No AlwaysSaveHistory: Default EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 Encoding: UTF-8 +RnwWeave: Sweave +LaTeX: pdfLaTeX + AutoAppendNewline: Yes StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace - -UseSpacesForTab: Yes -NumSpacesForTab: 2 - -RnwWeave: Sweave -LaTeX: pdfLaTeX - PackageBuildArgs: --resave-data PackageCheckArgs: --as-cran +PackageRoxygenize: rd,collate,namespace diff --git a/man/bulk_query.Rd b/man/bulk_query.Rd index 6a569d4..84c8544 100644 --- a/man/bulk_query.Rd +++ b/man/bulk_query.Rd @@ -41,4 +41,3 @@ gdns::bulk_query(hosts) \references{ \url{https://developers.google.com/speed/public-dns/docs/dns-over-https} } - diff --git a/man/gdns.Rd b/man/gdns.Rd index 531bbf1..64a10cc 100644 --- a/man/gdns.Rd +++ b/man/gdns.Rd @@ -26,4 +26,3 @@ for more information. \author{ Bob Rudis (bob@rud.is) } - diff --git a/man/has_spf.Rd b/man/has_spf.Rd index 40afa79..e0473ab 100644 --- a/man/has_spf.Rd +++ b/man/has_spf.Rd @@ -12,4 +12,3 @@ has_spf(spf_rec) \description{ Test for whether a DNS TXT record is an SPF record } - diff --git a/man/is_soft_fail.Rd b/man/is_soft_fail.Rd index 529a546..2441dec 100644 --- a/man/is_soft_fail.Rd +++ b/man/is_soft_fail.Rd @@ -1,8 +1,8 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/spf.r \name{is_soft_fail} -\alias{is_hard_fail} \alias{is_soft_fail} +\alias{is_hard_fail} \alias{passes_all} \title{SPF "all" type test} \usage{ @@ -18,4 +18,3 @@ passes_all(spf_rec) \description{ SPF "all" type test } - diff --git a/man/query.Rd b/man/query.Rd index ba59463..717dec2 100644 --- a/man/query.Rd +++ b/man/query.Rd @@ -60,4 +60,3 @@ query("17.142.160.59", "PTR") \references{ \url{https://developers.google.com/speed/public-dns/docs/dns-over-https} } - diff --git a/man/spf_ipv4s.Rd b/man/spf_ipv4s.Rd index e35714f..1be580f 100644 --- a/man/spf_ipv4s.Rd +++ b/man/spf_ipv4s.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/spf.r \name{spf_ipv4s} -\alias{spf_exists} -\alias{spf_includes} \alias{spf_ipv4s} \alias{spf_ipv6s} +\alias{spf_includes} \alias{spf_ptrs} +\alias{spf_exists} \title{SPF field extraction functions} \usage{ spf_ipv4s(spf_rec) @@ -24,4 +24,3 @@ spf_exists(spf_rec) \description{ Various helper functions to extract SPF record components. } - diff --git a/man/split_spf.Rd b/man/split_spf.Rd index b94c70c..01c2911 100644 --- a/man/split_spf.Rd +++ b/man/split_spf.Rd @@ -12,7 +12,6 @@ split_spf(spf_rec) \description{ Given a vector of TXT records, this function will return a list of vectors of all the SPF records for each. If the given TXT record is not an SPF -record, \code{NULL} is returned (which makes it easy to skip with \code{purrr} +record, \code{NA} is returned (which makes it easy to skip with \code{purrr} functions). } -