Skip to content
Open
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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
**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.
## 2026-09-14 - readline() μž…λ ₯κ°’μ˜ Integer Overflow 취약점 μˆ˜μ •
**Vulnerability:** `readline()`μ—μ„œ 숫자 μž…λ ₯ μ—¬λΆ€λ₯Ό `grepl("^[0-9]+$", n)`둜만 검증할 경우, 맀우 큰 숫자λ₯Ό μž…λ ₯ν–ˆμ„ λ•Œ `as.integer()`μ—μ„œ integer overflow coercion이 λ°œμƒν•˜μ—¬ `NA`λ₯Ό λ°˜ν™˜ν•˜λ©° μ–΄ν”Œλ¦¬μΌ€μ΄μ…˜ ν¬λž˜μ‹œλ₯Ό μœ λ°œν•  수 μžˆμŠ΅λ‹ˆλ‹€.
**Learning:** Rμ—μ„œ μ •κ·œμ‹μ„ μ΄μš©ν•΄ 숫자λ₯Ό κ²€μ¦ν•˜κ³  λ°”λ‘œ λ³€ν™˜ν•˜λŠ” 것은 μ˜€λ²„ν”Œλ‘œμš°λ‚˜ νƒ€μž… μ—λŸ¬μ— μ·¨μ•½ν•©λ‹ˆλ‹€. μ œν•œλœ μ˜΅μ…˜μ„ μž…λ ₯받을 경우 μ—„κ²©ν•œ κ°’ 맀칭을 μ‚¬μš©ν•΄μ•Ό ν•©λ‹ˆλ‹€.
**Prevention:** `n %in% c("1", "2")`와 같이 사전에 μ •μ˜λœ μ•ˆμ „ν•œ μ˜΅μ…˜ κ°’κ³Ό 직접 λ§€μΉ­ν•˜λŠ” 방식을 μ‚¬μš©ν•˜μ—¬ μž…λ ₯값을 검증해야 ν•©λ‹ˆλ‹€.
6 changes: 3 additions & 3 deletions R/aFIPC.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 (n %in% c("1", "2")) {
return(as.integer(n))
}
}
Expand Down Expand Up @@ -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 (n %in% c("1", "2")) {
return(as.integer(n))
}
}
Expand Down Expand Up @@ -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 (n %in% c("1", "2")) {
return(as.integer(n))
}
}
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-sentinel-validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,16 @@ test_that("autoFIPC validates boolean flags for newformBILOGprior, oldformBILOGp
"Security Error: confirmCommonItems must be a single non-NA logical value or NULL"
)
})

test_that("aFIPC handles non-interactive prompt fallbacks and validates input safely to avoid integer overflow", {
expect_error(
aFIPC::autoFIPC(
newformXData = data.frame(A=1),
oldformYData = data.frame(A=2),
newformCommonItemNames = c('A'),
oldformCommonItemNames = c('A'),
confirmCommonItems = FALSE
),
"Please write down pairs correctly"
)
})
Loading