Skip to content
Closed
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.
## 2024-08-23 - [μž…λ ₯κ°’ 검증 μ‹œ μ •κ·œμ‹ λ²”μœ„ 초과 취약점(Integer Overflow) μˆ˜μ •]
**Vulnerability:** λŒ€ν™”ν˜• ν”„λ‘¬ν”„νŠΈ(예: `readline`) μž…λ ₯값을 검증할 λ•Œ `^[0-9]+$`와 같이 경계가 μ—†λŠ” 숫자 μ •κ·œμ‹μ„ μ‚¬μš©ν•˜λ©΄, μ‚¬μš©μžκ°€ 맀우 큰 숫자λ₯Ό μž…λ ₯ν•˜μ—¬ 검증을 ν†΅κ³Όν•œ ν›„ `as.integer()`μ—μ„œ `NA`둜 κ°•μ œ λ³€ν™˜λ˜μ–΄ 후속 λ‘œμ§μ—μ„œ μ˜ˆμ™Έκ°€ λ°œμƒν•  수 μžˆμŠ΅λ‹ˆλ‹€.
**Learning:** Rμ—μ„œ μ •μˆ˜λ₯Ό μ²˜λ¦¬ν•  λ•Œ λ¬΄μ œν•œ 길이λ₯Ό ν—ˆμš©ν•˜λŠ” μ •κ·œμ‹μ€ νƒ€μž… λ³€ν™˜ 쀑 integer overflow 문제λ₯Ό μœ λ°œν•˜μ—¬ μ‹œμŠ€ν…œ μž₯μ• λ‚˜ μ˜ˆμƒμΉ˜ λͺ»ν•œ μ—λŸ¬λ₯Ό λ°œμƒμ‹œν‚¬ 수 μžˆμŠ΅λ‹ˆλ‹€.
**Prevention:** λŒ€ν™”ν˜• μž…λ ₯ λ“± μ œν•œλœ 선택지λ₯Ό κ°€μ§„ 값을 검증할 λ•ŒλŠ” `^[12]$`와 같이 κΈ°λŒ“κ°’κ³Ό μ •ν™•νžˆ μΌμΉ˜ν•˜λŠ” μ—„κ²©ν•œ μ •κ·œμ‹μ„ μ‚¬μš©ν•˜μ—¬ μž…λ ₯값을 μ œν•œν•΄μ•Ό ν•©λ‹ˆλ‹€.
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 (grepl("^[12]$", n)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Info: Stricter regex changes retry-loop behavior on invalid input

^[0-9]+$ accepted any digit string (e.g. "3", "0") and returned immediately, so an out-of-range answer triggered a prompt stop at once. ^[12]$ now rejects those, giving the user up to 3 retries before failing. Minor behavior change, consistent with the fix intent.

Open in Devin Review

Was this helpful? React with πŸ‘ or πŸ‘Ž to provide feedback.

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 (grepl("^[12]$", n)) {
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 (grepl("^[12]$", n)) {
return(as.integer(n))
}
}
Expand Down
Loading