diff --git a/.Rbuildignore b/.Rbuildignore index 232504f..28b2d85 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -22,3 +22,6 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^\.semgrepignore$ +^test_dummy\.R$ +^test_validation\.R$ diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a4..c4abb44 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-26 - Strict bounded regex for interactive inputs +**Vulnerability:** Weak regex like `^[0-9]+$` on interactive `readline` inputs allows large integers to be entered, which coerce to `NA` in `as.integer()`, bypassing subsequent logic and causing unhandled exceptions or DoS vulnerabilities. +**Learning:** Using strictly bounded regex, like `^[12]$`, prevents parsing errors and protects the program flow from unexpected user input. +**Prevention:** Always validate interactive inputs with exact bounded regex before coercion. diff --git a/AGENTS.md b/AGENTS.md index b60b03d..a177105 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -70,7 +70,7 @@ Applies to every agent (Claude, Codex, Cursor, opencode, ...) working in this re its `private-key` suppression path-scoped in `.trivyignore.yaml` and do not blanket-ignore the rule. - A local `trivy` scan with a stale DB misses findings: run - `trivy --download-db-only` first, and scan the **merge ref**, not just the PR head. + `trivy --download-db-only` first, and scan the **merge ref**, not the PR head. - The org `code_scanning` ruleset is intentionally **CodeQL-only** (multiple code-scanning tools cannot converge on one PR ref). Gating is by the Security Scan **job result**, not the `code_scanning` rule; do not add tools to that rule. 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)) } }