diff --git a/.Rbuildignore b/.Rbuildignore index 8989c62f..9594f251 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -24,3 +24,7 @@ ^\.jules(/.*)?$ ^\.trivyignore\.yaml$ ^trivy\.yaml$ +^\.markdownlint\.json$ +^\.semgrepignore$ +^test_dummy\.R$ +^test_validation\.R$ diff --git a/.jules/sentinel.md b/.jules/sentinel.md index a8207a48..9b6d5480 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-08-28 - 정수 오버플로우 취약점 및 readline 유효성 검사 수정 +**Vulnerability:** 대화형 `readline()` 숫자 입력 시 상한 없는 숫자 클래스(예: `^[0-9]+$`)에 대해 정규식 확인을 통과한 지나치게 큰 숫자 문자열이 `as.integer()`에서 `NA`로 평가되어 후속 프로세스 충돌을 유발하는 정수 오버플로우 강제 변환 취약점이 발생할 수 있습니다. +**Learning:** R 스크립트에서 입력값을 검증할 때는 넓은 범위의 정규식보다 정확한 예상 값과 엄격하게 일치시키는 것이 안전합니다. +**Prevention:** 대화형 `readline()` 숫자 입력을 검증할 때, `^[0-9]+$`와 같은 상한 없는 숫자 클래스 대신 `^[12]$`처럼 정확히 기대하는 값과 엄격하게 일치하는지 확인해야 합니다. diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 00000000..5f720e68 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1 @@ +{"MD013": false, "MD022": false, "MD041": false} diff --git a/R/aFIPC.R b/R/aFIPC.R index 62546519..918e19b1 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)) } }