diff --git a/NAMESPACE b/NAMESPACE index 12b77a5..1477037 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,9 @@ export(get_endpoint_data) export(get_root_certs_raw) export(get_status_codes) export(ssllabs_api_info) -import(httr) -import(jsonlite) -import(openssl) +importFrom(httr,GET) +importFrom(httr,content) +importFrom(httr,stop_for_status) +importFrom(httr,user_agent) +importFrom(jsonlite,fromJSON) +importFrom(openssl,read_cert) diff --git a/R/analyze.r b/R/analyze.r index 83e0c81..6229f67 100644 --- a/R/analyze.r +++ b/R/analyze.r @@ -32,20 +32,19 @@ #' cached report is returned. #' @references \url{https://github.com/ssllabs/ssllabs-scan/blob/stable/ssllabs-api-docs.md} #' @export -analyze_site <- function(host, publish="off", start_new=NULL, - from_cache="off", max_age=NULL, - all="on", ignore_mismatch="off") { +analyze_site <- function(host, publish = "off", start_new = NULL, + from_cache = "off", max_age = NULL, + all = "on", ignore_mismatch = "off") { res <- httr::GET("https://api.ssllabs.com/api/v2/analyze", - query=list(host=host, - publish=publish, - startNew=start_new, - fromCache=from_cache, - maxAge=max_age, - all=all, - ignoreMismatch=ignore_mismatch)) - + query=list(host = host, + publish = publish, + startNew = start_new, + fromCache = from_cache, + maxAge = max_age, + all = all, + ignoreMismatch = ignore_mismatch)) + httr::stop_for_status(res) dat <- httr::content(res, as="text") - jsonlite::fromJSON(dat, flatten=TRUE) - + return(jsonlite::fromJSON(dat, flatten=TRUE)) } diff --git a/R/api-info.r b/R/api-info.r index 629389f..bc7d468 100644 --- a/R/api-info.r +++ b/R/api-info.r @@ -9,7 +9,7 @@ ssllabs_api_info <- function() { res <- httr::GET("https://api.ssllabs.com/api/v2/info") - dat <- httr::content(res, as="text") - jsonlite::fromJSON(dat, flatten=TRUE) - + httr::stop_for_status(res) + dat <- httr::content(res, as = "text") + return(jsonlite::fromJSON(dat, flatten = TRUE)) } diff --git a/R/endpoint.r b/R/endpoint.r index 7d48dc2..94e6c1d 100644 --- a/R/endpoint.r +++ b/R/endpoint.r @@ -13,14 +13,13 @@ #' time as the start_new parameter. #' @references \url{https://github.com/ssllabs/ssllabs-scan/blob/stable/ssllabs-api-docs.md} #' @export -get_endpoint_data <- function(host, ip, from_cache="off") { +get_endpoint_data <- function(host, ip, from_cache = "off") { res <- httr::GET("https://api.ssllabs.com/api/v2/getEndpointData", - query=list(host=host, - s=ip, - fromCache=from_cache)) - - dat <- httr::content(res, as="text") - jsonlite::fromJSON(dat, flatten=TRUE) - + query = list(host = host, + s = ip, + fromCache = from_cache)) + httr::stop_for_status(res) + dat <- httr::content(res, as = "text") + return(jsonlite::fromJSON(dat, flatten = TRUE)) } diff --git a/R/root.r b/R/root.r index 51434e3..9a39db2 100644 --- a/R/root.r +++ b/R/root.r @@ -7,7 +7,7 @@ get_root_certs_raw <- function() { res <- httr::GET("https://api.ssllabs.com/api/v2/getRootCertsRaw") - dat <- httr::content(res, as="text") - openssl::read_cert(dat) - + httr::stop_for_status(res) + dat <- httr::content(res, as = "text") + return(openssl::read_cert(dat)) } diff --git a/R/ssllabs-package.r b/R/ssllabs-package.r index 80da3f8..8beebac 100644 --- a/R/ssllabs-package.r +++ b/R/ssllabs-package.r @@ -1,4 +1,4 @@ -#' Tools to Work with the `SSL Labs` `API` +#' @title Tools to Work with the `SSL Labs` `API` #' #' SSL Labs APIs are provided free of charge, subject to our terms and conditions: #' \url{https://www.ssllabs.com/about/terms.html}. The spirit of the license is that the @@ -45,5 +45,7 @@ #' @name ssllabs #' @docType package #' @author Bob Rudis (@@hrbrmstr) -#' @import httr jsonlite openssl +#' @importFrom httr stop_for_status GET user_agent content +#' @importFrom jsonlite fromJSON +#' @importFrom openssl read_cert NULL diff --git a/man/ssllabs.Rd b/man/ssllabs.Rd index 7b699c0..f2af830 100644 --- a/man/ssllabs.Rd +++ b/man/ssllabs.Rd @@ -4,8 +4,8 @@ \name{ssllabs} \alias{ssllabs} \alias{ssllabs-package} -\title{Tools to Work with the `SSL Labs` `API`} -\description{ +\title{Tools to Work with the `SSL Labs` `API` + SSL Labs APIs are provided free of charge, subject to our terms and conditions: \url{https://www.ssllabs.com/about/terms.html}. The spirit of the license is that the APIs are made available so that system operators can test their own infrastructure. @@ -13,8 +13,7 @@ Please read the actual terms and conditions, which are more involved and cover t such as integrating with open source projects, and so on. For example, it's important (for reasons of privacy, compliance, etc.) for end users to understand that assessments are carried out by Qualys's servers, not locally. -} -\details{ + Commercial use is generally not allowed, except with an explicit permission from Qualys. That said, we're usually happy to support good causes, even uses by commercial organizations that help improve the security of their customers. If you're a CA, CDN, @@ -47,8 +46,7 @@ to be in. If you encounter it, take a break and come back later. All successful API calls contain response headers X-Max-Assessments and X-Current-Assessments. They can be used to calculate how many new assessments can be submitted. It is recommended that clients update their internal state after each -complete response. -} +complete response.} \author{ Bob Rudis (@hrbrmstr) }