diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..498d3ac 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,19 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^test_.*\.R$ +^\.semgrepignore$ +^packrat/ +^\.git/ +^\..*Rcheck/ +^actionlint +^gitleaks +^.*\.tar\.gz$ +^.*_checksums\.txt$ +^AGENTS\.md$ +^ARCHITECTURE\.md$ +^CLAUDE\.md$ +^CONTRIBUTING\.md$ +^aFIPC\.Rproj$ +^docs/ +^trivy\.yaml$ diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a4..b6d1dee 100644 --- a/.jules/sentinel.md +++ b/.jules/sentinel.md @@ -2,3 +2,8 @@ **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-07-19 - Strict input validation for numeric interactive prompts +**Vulnerability:** Interactive `readline()` prompts using unconstrained numeric regex matching (e.g., `^[0-9]+$`) can accept excessively large numbers (like `'9999999999999999999'`). When these strings are coerced using `as.integer()`, they can evaluate to `NA`, leading to integer overflow coercion vulnerabilities and downstream process crashes. +**Learning:** In R, input validation regex for expected numeric inputs should explicitly match the exact expected values rather than generic digit classes. +**Prevention:** When validating interactive `readline()` numeric inputs, strictly match against exact expected values (e.g., `^[12]$`) instead of unbounded digit classes (e.g., `^[0-9]+$`). 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)) } }