Skip to content

Commit

Permalink
Move url to summarising users
Browse files Browse the repository at this point in the history
  • Loading branch information
csgillespie committed Oct 18, 2023
1 parent 5d85314 commit c6dcd5e
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 42 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export(create_config)
export(get_quarto_locked_user_apps)
export(get_quarto_old_users)
export(get_quarto_user_roles)
export(sanitize)
export(sanitise)
import(audit.base)
importFrom(dplyr,"%>%")
importFrom(rlang,.data)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# audit.connect 0.7.0 _2023-10-18_
- feat: `audit_object |> audit.connect::sanitize()` removes personal user data
- feat: Add in user URL when summarising users

# audit.connect 0.6.4 _2023-10-01_
- feat: Check for Posit name leakage
Expand Down
16 changes: 16 additions & 0 deletions R/sanitise.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#' Sanitise {audit.connect} object
#'
#' This function removes user-identifying data from an {audit.connect} object
#' @param audit_connect_check An object from audit.connect::check()
#' @export
sanitise = function(audit_connect_check) {
user_list = audit_connect_object_arg$users_details$user_list
# Wipe any user-identifiable data:
user_list$users[, "email"] = NA_character_
user_list$users[, "username"] = NA_character_
user_list$users[, "first_name"] = NA_character_
user_list$users[, "last_name"] = NA_character_
audit_connect_check$users_details$user_list = user_list
# Return the santitized object
audit_connect_check
}
27 changes: 1 addition & 26 deletions R/summarise_users.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ summarise_users = function(server, token, debug_level) {
user_list = list()
user_list$user_account_limit = settings$license$users
user_list$users = suppress(connectapi::get_users(client, limit = Inf))
user_list$users[, "url"] = paste0(server, "connect/#/people/users/", user_list$users$guid)

if (is_evaluation(settings)) {
apps = NA
Expand Down Expand Up @@ -51,29 +52,3 @@ print_audit_user_apps = function(client, debug_level) {
cli::cli_alert_info("{nrow(locked_users)} applications owned by locked users")
apps
}

#' Santitize {audit.connect} object
#'
#' This function wipes any user-identifying data from an {audit.connect} object,
#' but inserts a column which contains the URL for each user in the Posit Connect admin panel
#' @param audit_connect_object_arg An object from audit.connect::check()
#' @export
sanitize = function(audit_connect_object_arg) {
# Retrieve the URL of the server from the audit connect object:
connect_server_url = audit_connect_object_arg$audit_details$server
# Make a copy of the audit connect object:
sanitized_audit_object = audit_connect_object_arg
# Wipe any user-identifiable data:
sanitized_audit_object$users_details$user_list$users[, "email"] = NA
sanitized_audit_object$users_details$user_list$users[, "username"] = NA
sanitized_audit_object$users_details$user_list$users[, "first_name"] = NA
sanitized_audit_object$users_details$user_list$users[, "last_name"] = NA
# The table contains a column `guid`. We can use these GUIDs to create URLs
# If we go to one of these URLs in the browser, we can see the details for the corresponding user:
sanitized_audit_object$users_details$user_list$users[, "url"] =
stringr::str_c(connect_server_url,
"connect/#/people/users/",
sanitized_audit_object$guid)
# Return the santitized object
sanitized_audit_object
}
14 changes: 14 additions & 0 deletions man/sanitise.Rd

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

15 changes: 0 additions & 15 deletions man/sanitize.Rd

This file was deleted.

0 comments on commit c6dcd5e

Please sign in to comment.