diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..a15e317 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,6 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^test_dummy\.R$ +^test_validation\.R$ +^\.semgrepignore$ diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a4..e07631a 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -2,3 +2,18 @@ **Vulnerability:** Unvalidated inputs passed to `if()` statements can cause process crashes (`condition has length > 1`) or unexpected coercion vulnerabilities. **Learning:** In R, optional boolean parameters that default to `NULL` should be validated using explicit runtime type validation (e.g., `if (!is.null(flag) && (!is.logical(flag) || length(flag) != 1 || is.na(flag)))`). **Prevention:** Always implement explicit runtime type validation for optional boolean parameters. + +## 2024-08-01 - Fix Integer Overflow Coercion Vulnerability +**Vulnerability:** Unbounded numeric regular expressions (`^[0-9]+$`) were used to validate interactive inputs before coercing them to integer using `as.integer()`. If excessively large numbers were provided, they would pass the regex check but coercion would produce `NA`, which could cause unexpected downstream failures or crashes. +**Learning:** In R scripts, validating inputs using `^[0-9]+$` does not account for the limits of R's integer representation. This can lead to integer overflow coercion vulnerabilities. +**Prevention:** Strictly match against exact expected values (e.g., `^[12]$`) instead of unbounded digit classes to ensure the input fits safely within R's integer bounds. + +## 2026-08-01 - Avoid committing tarball files downloaded during CI scripts +**Vulnerability:** Inadvertently committing `.tar.gz` and extracted binaries (like `actionlint` or `gitleaks`) into the repository. +**Learning:** During test runs or script execution, tools might be downloaded into the root directory. If the tree isn't cleaned up (or if they are not explicitly gitignored), they can accidentally be committed via blind `git commit -a` or tracked if created locally. +**Prevention:** Avoid explicitly `git add`ing them. Also, use temporary directories to download binaries instead of the repo root or make sure to delete them after use. + +## 2026-08-01 - Delete temporary binaries and archives after use +**Vulnerability:** Inadvertently leaving downloaded script files and archives (like `actionlint` or `gitleaks`) in the repository during agent runs. +**Learning:** Tools or archives downloaded during intermediate verification steps (like linting or secrets scanning) can persist and cause unexpected CI verification failures (like R CMD check reporting undeclared executable files). +**Prevention:** Remove any downloaded temporary files (e.g., `rm actionlint actionlint_1.7.10_linux_amd64.tar.gz`) from the repository root immediately after their respective tasks are completed. diff --git a/R/aFIPC.R b/R/aFIPC.R index 6254651..918e19b 100644 --- a/R/aFIPC.R +++ b/R/aFIPC.R @@ -141,7 +141,7 @@ autoFIPC <- } for (attempt in seq_len(3)) { n <- readline(prompt = "Is it correct? (1: Yes 2: No) : ") - if (grepl("^[0-9]+$", n)) { + if (grepl("^[12]$", n)) { return(as.integer(n)) } } @@ -171,7 +171,7 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for oldform Data? (1: Yes 2: No) : " ) - if (grepl("^[0-9]+$", n)) { + if (grepl("^[12]$", n)) { return(as.integer(n)) } } @@ -390,7 +390,7 @@ autoFIPC <- readline( prompt = "Do you want to use default BILOG-MG priors for newform Data? (1: Yes 2: No) : " ) - if (grepl("^[0-9]+$", n)) { + if (grepl("^[12]$", n)) { return(as.integer(n)) } }