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

Add centos #27

Merged
merged 4 commits into from
Jun 6, 2024
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
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: audit.base
Title: Base package for Posit Checks
Version: 0.6.14
Version: 0.6.15
Authors@R:
person("Jumping", "Rivers", , "[email protected]", role = c("aut", "cre"))
Description: Base package for sharing classes between posit audit
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# audit.base 0.6.15 _2024-06-06_
- feat: Add support for Centos
- fix: Update software version numbers
- fix: Fix output for Posit drivers

# audit.base 0.6.14 _2024-04-04_
- fix: Improve feedback when checking sys deps

Expand Down
2 changes: 1 addition & 1 deletion R/check_server_headers.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Check server headers
#'
#' In addition to the checks made by {serverHeaders} we also check
#' In addition to the checks made by serverHeaders we also check
#' that Posit isn't in one of the headers.
#' @param server URL of server
#' @export
Expand Down
10 changes: 6 additions & 4 deletions R/check_sys_deps.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ get_os_sys_deps = function(os_release) {
} else if (is_redhat(os_release_df)) {
id = "redhat"
version_id = stringr::str_remove(version_id, "\\..*")
} else if (is_centos(os_release_df)) {
id = "centos"
version_id = stringr::str_remove(version_id, "\\..*")
} else {
stop("Not supported")
cli::cli_abort("This OS isn't supported")
}

reqs = get_pkg_requirements(distribution = id, release = version_id)
reqs[!is.na(reqs$sys_libs), ]
}
Expand All @@ -57,7 +59,7 @@ get_installed_libs = function() {
if (is_ubuntu(os_release_df)) {
libs = processx::run("apt", args = c("list", "--installed"))
libs = stringr::str_split(libs$stdout, "\n")[[1]][-1]
} else if (is_redhat(os_release_df)) {
} else if (is_redhat(os_release_df) || is_centos(os_release_df)) {
libs = processx::run("yum", args = c("list", "installed"))$stdout
libs = stringr::str_split(libs, "\n")[[1]][-(1:2)]
} else {
Expand All @@ -75,7 +77,7 @@ clean_libs = function(os_release, libs) {
os_release_df = os_release_to_df(os_release)
if (is_ubuntu(os_release_df)) {
libs = stringr::str_match(libs, "^[^/]*")[, 1]
} else if (is_redhat(os_release_df)) {
} else if (is_redhat(os_release_df) || is_centos(os_release_df)) {
libs = stringr::str_match(libs, "^[^\\.]*")[, 1]
} else {
cli::cli_abort("We don't support this OS yet")
Expand Down
2 changes: 1 addition & 1 deletion R/get_pkg_requirements.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# https://packagemanager.rstudio.com/__api__/swagger/index.html#/default/get_repos
get_pkg_requirements = function(distribution = c("ubuntu", "redhat"),
get_pkg_requirements = function(distribution = c("ubuntu", "redhat", "centos"),
release = c("18.04", "20.04", "22.04", "7", "8", "9"),
base_url = "https://packagemanager.rstudio.com/__api__/repos/",
repo_id = 2) {
Expand Down
5 changes: 5 additions & 0 deletions R/os-helper-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ is_redhat = function(os_release_df) {
stringr::str_detect(os_name, pattern = "red hat")
}

is_centos = function(os_release_df) {
os_name = os_release_df[os_release_df$name == "name", ]$value
stringr::str_detect(os_name, pattern = "centos")
}

get_os_release = function() {
os_release = readr::read_lines("/etc/os-release")
os_release
Expand Down
9 changes: 5 additions & 4 deletions R/software-versions.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Augments installed software columns
#' @param installed A tibble with columns software and installed_version
#' @param verbose Default TRUE. Out a {cli} summary
#' @param verbose Default TRUE.
#' @export
augment_installed = function(installed, verbose = TRUE) {
installed$installed_major = get_major(installed$installed_version)
Expand All @@ -24,10 +24,11 @@ print_colour_versions = function(installed) {
}

print_colour_version = function(row) {
software_name = glue::glue("{stringr::str_to_title(row$software)} v{row$major}")
latest_version = glue::glue("latest v{row$version}")
major = if ("major" %in% colnames(row)) paste0(" v", row$major) else ""
software_name = glue::glue("{stringr::str_to_title(row$software)}{major}")
latest_version = glue::glue("v{row$version}")
if (is.na(row$installed_version)) {
cli::cli_alert_danger("{software_name}: {latest_version} not installed")
cli::cli_alert_danger("{software_name}: latest {latest_version} not installed")
return(invisible(NULL))
}

Expand Down
11 changes: 11 additions & 0 deletions inst/extdata/versions/connect.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#https://docs.posit.co/connect/news/
version,date,cve
2024.05.0,2024-05-31,CVE-2024-24787
2024.05.0,2024-05-31,CVE-2024-24788
2024.04.1,2024-05-07,
2024.04.0,2024-04-29,CVE-2023-39320
2024.04.0,2024-04-29,CVE-2023-39320
2024.04.0,2024-04-29,CVE-2023-39319
2024.04.0,2024-04-29,CVE-2023-39321
2024.04.0,2024-04-29,CVE-2023-45288
2024.04.0,2024-04-29,CVE-2023-45857
2024.04.0,2024-04-29,CVE-2024-31207
2024.03.0,2024-03-28,
2024.02.0,2024-02-27,CVE-2023-7104
2024.01.0,2024-01-25,CVE-2023-48795
2024.01.0,2024-01-25,CVE-2023-45683
Expand Down
7 changes: 4 additions & 3 deletions inst/extdata/versions/software.csv
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
software,version
python,3.12.2
python,3.11.8
python,3.12.3
python,3.11.9
python,3.10.14
python,3.9.19
python,3.8.19
python,3.7.17
quarto,1.4.552
quarto,1.4.555
quarto,1.2.475
quarto,1.1.189
quarto,1.0.38
r,4.4.0
r,4.3.3
r,4.2.3
r,4.1.3
Expand Down
2 changes: 2 additions & 0 deletions inst/extdata/versions/workbench.csv
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# https://docs.posit.co/ide/news/
version,date,cve
2024.04.1,2024-05-13,
2024.04.0,2024-04-29,
2023.12.1,2024-01-29,
2023.12.0,2023-12-15,
2023.09.1,2023-10-17,
Expand Down
2 changes: 1 addition & 1 deletion man/augment_installed.Rd

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

2 changes: 1 addition & 1 deletion man/check_server_headers.Rd

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

Loading