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
12 changes: 12 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,15 @@
^\.jules(/.*)?$
^\.trivyignore\.yaml$
^trivy\.yaml$
^mockery$
^\.semgrepignore$
^\.gitleaks\.toml$
^\.yamllint\.yml$
^trivy\.yaml$
^\.Jules$
^AGENTS\.md$
^ARCHITECTURE\.md$
^CLAUDE\.md$
^CONTRIBUTING\.md$
^\.jules$
^\.markdownlint\.json$
2 changes: 2 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ updates:
commit-message:
prefix: "chore"
include: "scope"
cooldown:
default-days: 7
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-07-25 - λŒ€ν™”ν˜• μž…λ ₯κ°’ 검증 κ°•ν™”
**Vulnerability:** `readline()`으둜 받은 μž…λ ₯을 `grepl("^[0-9]+$", n)`κ³Ό 같은 μ •κ·œμ‹μœΌλ‘œλ§Œ 검증할 경우, 맀우 κΈ΄ 숫자 λ¬Έμžμ—΄ μž…λ ₯ μ‹œ `as.integer()`μ—μ„œ μ •μˆ˜ μ˜€λ²„ν”Œλ‘œκ°€ λ°œμƒν•˜μ—¬ `NA`κ°€ λ°˜ν™˜λ˜κ³  μ΄λŠ” ν”„λ‘œμ„ΈμŠ€ ν¬λž˜μ‹œ(DoS)둜 μ΄μ–΄μ§ˆ 수 있음.
**Learning:** μ œν•œλœ μ˜΅μ…˜μ„ κ°–λŠ” λŒ€ν™”ν˜• 숫자λ₯Ό 검증할 λ•ŒλŠ” μ˜€λ²„ν”Œλ‘œμš° 우회 곡격 및 μ˜λ„μΉ˜ μ•Šμ€ μΊμŠ€νŒ… 였λ₯˜λ₯Ό λ°©μ§€ν•˜κΈ° μœ„ν•΄ λ°˜λ“œμ‹œ μ™„μ „ 일치 검사(예: `n %in% c("1", "2")`)λ₯Ό μ‚¬μš©ν•΄μ•Ό 함.
**Prevention:** λŒ€ν™”ν˜• μž…λ ₯값에 λŒ€ν•΄ 항상 ν—ˆμš©λœ κ°’λ“€μ˜ μ§‘ν•©κ³Ό μ™„μ „ μΌμΉ˜ν•˜λŠ”μ§€ μ—„κ²©νžˆ κ²€μ¦ν•˜λ„λ‘ 함.
5 changes: 5 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"MD013": false,
"MD041": false,
"MD022": false
}
3 changes: 3 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ rules:
max: 140
truthy:
allowed-values: ["true", "false", "on", "off"]

ignore: |
packrat/
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Description: Automates fixed item parameter linking for test linking under
the item response theory paradigm using mirt package estimates.
License: GPL-3 | file LICENSE
Imports: mirt, methods
Suggests: testthat (>= 3.0.0)
Suggests: testthat (>= 3.0.0), mockery
Encoding: UTF-8
Config/testthat/edition: 3
Config/roxygen2/version: 8.0.0
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
21 changes: 21 additions & 0 deletions tests/testthat/test-sentinel-validation.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,24 @@ test_that("autoFIPC validates boolean flags for newformBILOGprior, oldformBILOGp
"Security Error: confirmCommonItems must be a single non-NA logical value or NULL"
)
})

test_that("interactive readline validation prevents integer overflow coercion DOS", {
# We test this behavior by verifying that the function checkCorrect requires exact match,
# but since readline is mocked/not available here, we will test the exact match logic indirectly.
# If we replace readline with a mock that returns an invalid string, it should exhaust attempts
# and stop with an error, not crash with a condition > 1 error.

mockery::stub(aFIPC::autoFIPC, "interactive", TRUE)
mockery::stub(aFIPC::autoFIPC, "readline", "1000000000000000000000000000000000")

expect_error(
aFIPC::autoFIPC(
newformXData = data.frame(A=1),
oldformYData = data.frame(A=2),
newformCommonItemNames = c('A'),
oldformCommonItemNames = c('A'),
confirmCommonItems = NULL
),
"Too many invalid common item confirmation attempts"
)
})
Loading