Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brush up #20

Merged
merged 21 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
^_sship.yml$
^\.github$
^\.lintr$
^cran-comments.md$
10 changes: 10 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jobs:
config:
- {os: windows-latest, r: 'release'}
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-18.04, r: '3.6'}
- {os: ubuntu-18.04, r: 'oldrel'}
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
- {os: ubuntu-20.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest", http-user-agent: "R/4.1.0 (ubuntu-20.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
Expand Down Expand Up @@ -64,6 +67,13 @@ jobs:
remotes::install_cran("rcmdcheck")
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
Expand Down
21 changes: 12 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
Package: sship
Title: Tool for Secure Shipment of Content
Version: 0.6.0
Version: 0.7.0
Authors@R:
person(given = "Are",
family = "Edvardsen",
role = c("aut", "cre"),
email = "biorakel@gmail.com",
comment = c(ORCID = "0000-0002-5210-3656"))
Description: This package provide tools for secure shipment. By strong
protection safe passage of any content can be provided even through
hostile environments. Based on asymmetric cryptography no local management
of secrets is needed to make a shipment as long as authentic public keys
are available.
Maintainer: Are Edvardsen <biorakel@gmail.com>
Description: Convenient tools for exchanging files securely from within R. By
encrypting the content safe passage of files (shipment) can be provided by
common but insecure carriers such as ftp and email. Based on asymmetric
cryptography no management of shared secrets is needed to make a secure
shipment as long as authentic public keys are available. Public keys used
for secure shipments may also be obtained from external providers as part of
the overall process. Transportation of files will require that relevant
services such as ftp and email servers are available.
License: GPL-3
Encoding: UTF-8
LazyData: true
Imports:
httr,
jsonlite,
Expand All @@ -26,5 +29,5 @@ Suggests:
rmarkdown,
testthat (>= 2.1.0)
RoxygenNote: 7.1.1
URL: http://github.com/Rapporteket/sship
BugReports: http://github.com/Rapporteket/sship/issues
URL: https://github.com/Rapporteket/sship
BugReports: https://github.com/Rapporteket/sship/issues
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# sship 0.7.0

* adjustments and improvements for proper release ([#20](https://github.com/Rapporteket/sship/pull/20))

# sship 0.6.0

* added option for encryption using a local public key ([#19](https://github.com/Rapporteket/sship/pull/19))
Expand Down
12 changes: 12 additions & 0 deletions R/config.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
#' @return A status message or list of config
#' @name config
#' @aliases create_config get_config check_config
#' @examples
#' # Create a new config file from package default
#' create_config(dir = tempdir())
#'
#' # Get config
#' config <- get_config(system.file("sship.yml", package = "sship"))
#'
#' # Check if config is valid
#' check_config(config)
#'
#' # Write config to file
#' write_config(config, dir = tempdir())
NULL


Expand Down
24 changes: 22 additions & 2 deletions R/dec.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#' systems running R. Possible caveats may be the availability of the
#' (un)tar-function and how binary streams/files are treated.
#'
#' @param tarfile Character string providing full path to the gzip-compressd
#' @param tarfile Character string providing full path to the gzip-compressed
#' tarball holding the shipment payload, including encrypted files
#' @param keyfile Character string providing the full path to the private RSA
#' key to be used for decryption of the encrypted key that is part of the
#' shipment. Default value is set to \code{~/.ssh/id_rsa} which is the usual
#' path for unix-type operating systems.
#' path for unix type operating systems.
#' @param target_dir Character string providing the full path to where the
#' decrypted file is to be written. Defaults to the current directory
#' \code{"."}, \emph{e.g.} where this function is being called from.
Expand All @@ -22,6 +22,26 @@
#'
#' @seealso \link{enc}
#' @export
#' @examples
#' # Make temporary workspace
#' wd <- tempdir()
#'
#' # Make a private-public key pair named "id_rsa" and "id_rsa.pub"
#' sship_keygen(directory = wd)
#'
#' # Make a secured (encrypted) file
#' saveRDS(iris, file = file.path(wd, "secret.rds"), ascii = TRUE)
#' pubkey <- readLines(file.path(wd, "id_rsa.pub"))
#' secure_secret_file <-
#' enc(filename = file.path(wd, "secret.rds"),
#' pubkey_holder = NULL,
#' pubkey = pubkey)
#'
#' # Decrypt secured file using the private key
#' secret_file <-
#' dec(tarfile = secure_secret_file,
#' keyfile = file.path(wd, "id_rsa"),
#' target_dir = wd)

dec <- function(tarfile, keyfile = "~/.ssh/id_rsa", target_dir = ".") {

Expand Down
22 changes: 20 additions & 2 deletions R/enc.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,34 @@
#' @param filename string with fully qualified path to a file
#' @param pubkey_holder string defining the provider of the public key used for
#' encryption of the symmetric key. Currently, 'github' is the only valid
#' option.
#' pubkey holder. If a local pubkey is to be used (see parameter \code{pubkey},
#' \code{pubkey_holder} may be set to NULL or some other value.
#' @param pid string uniquely defining the user at 'pubkey_holder' who is also
#' the owner of the public key
#' @param pubkey String representing a valid public key. Default is NULL in
#' which case the key will be obtained from \code{pukey_holder}.
#' which case the key will be obtained as per \code{pubkey_holder}.
#'
#' @return Character string providing a filename or a key
#' @seealso \link{dec}
#' @name enc
#' @aliases enc_filename random_key make_pubkey_url get_pubkey enc_file
#' @examples
#' # Define temporary working directory and a secret file name
#' wd <- tempdir()
#' secret_file_name <- "secret.rds"
#'
#' # Add content to the secret file
#' saveRDS(iris, file = file.path(wd, secret_file_name), ascii = TRUE)
#'
#' # Make a private-public key pair named "id_rsa" and "id_rsa.pub"
#' sship_keygen(directory = wd)
#'
#' # Load public key
#' pubkey <- readLines(file.path(wd, "id_rsa.pub"))
#'
#' # Make a secured file (ready for shipment)
#' secure_secret_file <- enc(filename = file.path(wd, "secret.rds"),
#' pubkey_holder = NULL, pubkey = pubkey)
NULL


Expand Down
8 changes: 4 additions & 4 deletions R/sship.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#' First, the content (a file) is encrypted and packed and then shipped to the
#' recipient using the specified vessel (transportation method). If the given
#' vessel is not available the function return an error. Optionally, a
#' declaration can also be assosiated with the shipment and dispatched
#' declaration can also be associated with the shipment and dispatched
#' immediately after the actual cargo.
#'
#' Most likely access control will be enforced before docking of the shipment
Expand All @@ -21,16 +21,16 @@
#' @param vessel Character string: means of transportation. Currently one of
#' 'ssh' or 'ftp'.
#' @param declaration Character string: the name of an empty file to be
#' assosiated with shipment of the cargo itself and dispatched immediately
#' associated with shipment of the cargo itself and dispatched immediately
#' after. The most likely usecase is for the recipient to check for this file
#' being present before picking up the cargo itself. Default value is \code{""}
#' in which case no declaration will be used.
#' @param cargo Character vector: all items assosiated with the current
#' @param cargo Character vector: all items associated with the current
#' shipment. Used only internally.
#'
#' @seealso \link{enc}
#'
#' @return TRUE if successsful
#' @return TRUE if successful
#' @name ship
#' @aliases sship dispatch dispatchable make_url make_opts
NULL
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
[![Version](https://img.shields.io/github/v/release/rapporteket/sship?sort=semver)](https://github.com/rapporteket/sship/releases)
[![R build status](https://github.com/Rapporteket/sship/workflows/R-CMD-check/badge.svg)](https://github.com/Rapporteket/sship/actions)
[![Codecov test coverage](https://codecov.io/gh/Rapporteket/sship/branch/main/graph/badge.svg)](https://codecov.io/gh/Rapporteket/sship?branch=main)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![GitHub open issues](https://img.shields.io/github/issues/rapporteket/sship.svg)](https://github.com/rapporteket/sship/issues)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
[![Doc](https://img.shields.io/badge/Doc--grey.svg)](https://rapporteket.github.io/sship/)
<!-- badges: end -->

This package provide tools for secure shipment. By strong protection of content itself safe passage can be provided even through hostile environments. Based on asymmetric cryptography no management of secrets is needed to make a shipment as long as authentic public keys are available. An overview of _sship_ can be found in the article [An overwiev of sship](https://rapporteket.github.io/sship/articles/overview.html).
Convenient tools for exchanging files securely from within R. By encrypting the content safe passage of files (shipment) can be provided by common but insecure carriers such as ftp and email. Based on asymmetric cryptography no management of shared secrets is needed to make a secure shipment as long as authentic public keys are available. Public keys used for secure shipments may also be obtained from external providers as part of the overall process. Transportation of files will require that relevant services such as ftp and email servers are available. An overview of _sship_ can be found in the article [An overwiev of sship](https://rapporteket.github.io/sship/articles/overview.html).

## Install

Expand All @@ -29,7 +29,7 @@ A shipment is secured by applying the recipient's public key. When content, reci
```
sship(content, recipient, pubkey_holder, vessel, declaration)
```
For the time being, the only valid provider of public keys is GitHub and the recipeint must have a corresponding user account that contains a valid RSA public key. Further, the value of _reciepient_ will also be used to get local configuration that may be needed for the shipemnt to be made. Please refere to the the article [Make a secure shipment](https://rapporteket.github.io/sship/articles/ship.html) and the _sship_ function documentation for further details.
For the time being, the only valid provider of public keys is GitHub and the recipient must have a corresponding user account that contains a valid RSA public key. Further, the value of _recipient_ will also be used to get local configuration that may be needed for the shipment to be made. Please refer to the the article [Make a secure shipment](https://rapporteket.github.io/sship/articles/ship.html) and the _sship_ function documentation for further details.

### Extract cargo from a secure shipment
Unwrapping and decryption can be made using the function ```dec()``` in this package by providing the path to the received tar-file and the recipient's private key. It is also possible to specify where the content is to be stored after it is unwrapped and decrypted (if not specified, content will be stored in the working directory):
Expand Down
14 changes: 14 additions & 0 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Test environments
* Microsoft Windows Server 2019 (on github actions), R version 4.1.1 (2021-08-10)
* macOS Catalina 10.15.7 (on github actions), R version 4.1.1 (2021-08-10)
* Ubuntu 18.04 (on github actions), R version 3.6.3 (2020-02-29)
* Ubuntu 18.04 (on github actions), R version 4.0.5 (2021-03-31)
* Ubuntu 20.04 (on github actions), R version 4.1.1 (2021-08-10)
* Ubuntu 20.04 (on github actions), R Under development (unstable) (2021-08-25 r80817)
* CRAN win-builder, R version 4.1.1 (2021-08-10) and R Under development (unstable) (2021-08-25 r80817)

# R CMD check results
There were no ERRORs and WARNINGs.

There were one NOTE:
* New submission
13 changes: 13 additions & 0 deletions man/config.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 23 additions & 2 deletions man/dec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 21 additions & 2 deletions man/enc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions man/ship.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vignettes/ship.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Both encryption and shipment can be obtained in one operation with the R functio
```r
sship(content, recipient, pubkey_holder, vessel, declaration)
```
where ```content``` is the path to the file to be encrypted, ```recipient``` is the unique user id of the recipient at the public key provider, ```pubkey_holder``` is a reference to a known public key provider (see [Configure _sship_](#conf) below), ```vessel``` is a reference to the transportation method (see also [Configure _sship_](#conf) below) and ```declaration``` is an optional "freight paper rubber stamp" to be assosiated with the shipment. A practical example may look something like this:
where ```content``` is the path to the file to be encrypted, ```recipient``` is the unique user id of the recipient at the public key provider, ```pubkey_holder``` is a reference to a known public key provider (see [Configure _sship_](#conf) below), ```vessel``` is a reference to the transportation method (see also [Configure _sship_](#conf) below) and ```declaration``` is an optional "freight paper rubber stamp" to be associated with the shipment. A practical example may look something like this:
```r
sship("secret_data.csv", "myfriend", "github", "ftp", "pickable")
```
Expand Down Expand Up @@ -56,4 +56,4 @@ recipient:
A recipients may require multiple ways of transportation and the configuration allows for this by making additional entries for each method of transportation.

#### Server mode
_ship_ can also be applied as a tool in a centralized or server-like environment where requirements for mangement and configuration may differ from a local instance running R. Every time _sship_ needs information from configuration setting it looks for it in several places. For a server setup the place to look for _sship_'s configuration can be provided by setting the environmental varaiable _R_SSHIP_CONFIG_PATH_ to the directory where the configuration is to be found. Making _R_SSHIP_CONFIG_PATH_ accessible in an R session, _sship_ will abide by its value. However, if a local file named ```_sship.yml``` exists in the current working directory it it will take presedence over the one defined by _R_SSHIP_CONFIG_PATH_.
_ship_ can also be applied as a tool in a centralized or server-like environment where requirements for management and configuration may differ from a local instance running R. Every time _sship_ needs information from configuration setting it looks for it in several places. For a server setup the place to look for _sship_'s configuration can be provided by setting the environmental variable _R_SSHIP_CONFIG_PATH_ to the directory where the configuration is to be found. Making _R_SSHIP_CONFIG_PATH_ accessible in an R session, _sship_ will abide by its value. However, if a local file named ```_sship.yml``` exists in the current working directory it it will take precedence over the one defined by _R_SSHIP_CONFIG_PATH_.