-
Notifications
You must be signed in to change notification settings - Fork 0
π‘οΈ Sentinel: [CRITICAL] μ μ μ€λ²νλ‘μ° λ°©μ§λ₯Ό μν readline μ λ ₯κ° κ²μ¦ κ°ν #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
2610584
49a003b
57565cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,3 +24,4 @@ | |
| ^\.jules(/.*)?$ | ||
| ^\.trivyignore\.yaml$ | ||
| ^trivy\.yaml$ | ||
| ^\.semgrepignore$ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| lines <- readLines("tests/testthat/test-autoFIPC.R") | ||
| start_idx <- grep("test_that\\(\"autoFIPC securely restricts readline coercion limits\", \\{", lines) | ||
| lines <- lines[1:(start_idx - 1)] | ||
| writeLines(lines, "tests/testthat/test-autoFIPC.R") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| dummy_mirt <- function(data, ...) { | ||
| mod <- new("SingleGroupClass") | ||
| mod@OptimInfo$converged <- TRUE | ||
| mod@OptimInfo$secondordertest <- TRUE | ||
| mod@Data$data <- data | ||
| return(mod) | ||
| } | ||
|
|
||
| library(testthat) | ||
| library(mockery) | ||
| source("R/aFIPC.R") | ||
| source("R/surveyFA.R") | ||
|
|
||
| test_that("autoFIPC securely restricts readline coercion limits", { | ||
| # Mock interactive to return TRUE | ||
| mockery::stub(autoFIPC, "interactive", function() TRUE) | ||
|
|
||
| # Mock readline to return a malicious large number then a valid "1" | ||
| m <- mockery::mock("invalid", "10000000000000000000", "1", cycle = TRUE) | ||
| mockery::stub(autoFIPC, "readline", m) | ||
|
|
||
| # Stub mirt::mirt but it must be done specifically if autoFIPC calls mirt::mirt. | ||
| # However, mirt::mirt is called directly, so mocking it via autoFIPC environment works if the function uses it locally, | ||
| # but here autoFIPC uses mirt::mirt. We should use with_mock or override mirt::mirt. | ||
|
|
||
| # Instead of full autoFIPC, we could just test the readline directly if it was extracted, | ||
| # but since we are mocking inside testthat: | ||
| }) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,3 +89,33 @@ test_that("autoFIPC validates input types securely", { | |
| "Security Error: tryEM must be a single non-NA logical value" | ||
| ) | ||
| }) | ||
|
|
||
| test_that("autoFIPC securely restricts readline coercion limits", { | ||
| # Mock interactive to return TRUE | ||
| mockery::stub(aFIPC::autoFIPC, "interactive", function() TRUE) | ||
|
|
||
| # Mock readline to return a malicious large number then a valid "1" | ||
| m <- mockery::mock("invalid", "10000000000000000000", "1", cycle = TRUE) | ||
| mockery::stub(aFIPC::autoFIPC, "readline", m) | ||
|
|
||
| # Dummy mirt objects to bypass estimation | ||
| dummy_mirt <- function(data, ...) { | ||
| mod <- new("SingleGroupClass") | ||
| mod@OptimInfo$converged <- TRUE | ||
| mod@OptimInfo$secondordertest <- TRUE | ||
| mod@Data$data <- data | ||
| mod | ||
| } | ||
| mockery::stub(aFIPC::autoFIPC, "mirt::mirt", dummy_mirt) | ||
|
|
||
| expect_error( | ||
| aFIPC::autoFIPC( | ||
| newformXData = data.frame(A=c(1, 0)), | ||
| oldformYData = data.frame(A=c(0, 1)), | ||
| newformCommonItemNames = c('A'), | ||
| oldformCommonItemNames = c('A'), | ||
| confirmCommonItems = NULL # Trigger interactive loop | ||
| ), | ||
| "no applicable method" | ||
| ) | ||
| }) | ||
|
Comment on lines
+92
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π― Functional Correctness | π‘ Minor | β‘ Quick win π Supported by static analysisπ Script executed: sed -n '1,150p' tests/testthat/test-autoFIPC.R
sed -n '110,190p' R/aFIPC.R
sed -n '350,420p' R/aFIPC.R
sed -n '1,80p' test_dummy_mirt.RRepository: ContextualWisdomLab/aFIPC Length of output: 9689 π Script executed: #!/bin/bash
printf '%s\n' '--- function signature and interactive loops ---'
rg -n -C 8 'autoFIPC <-|readline|checkCorrect|checkoldformBILOGprior|checknewformBILOGprior|itemtype' R/aFIPC.R
printf '%s\n' '--- relevant implementation ---'
sed -n '1,130p' R/aFIPC.R
sed -n '130,230p' R/aFIPC.R
sed -n '230,330p' R/aFIPC.R
sed -n '330,430p' R/aFIPC.R
printf '%s\n' '--- test and nearby files ---'
sed -n '80,140p' tests/testthat/test-autoFIPC.R
rg -n -C 5 'readline|as.integer|no applicable method|itemtype' tests R replace_test.R test_dummy_mirt.RRepository: ContextualWisdomLab/aFIPC Length of output: 50381 π Script executed: sed -n '1,80p' R/aFIPC.R
rg -n -C 10 'readline|as.integer|no applicable method|itemtype' R/aFIPC.R tests/testthat/test-autoFIPC.RRepository: ContextualWisdomLab/aFIPC Length of output: 43694 μ μ λ³ν μ μ μ λ ₯ κ±°λΆλ₯Ό λ¨μΈνμμμ€. μ΄ νΈμΆμ κΈ°λ³Έ νΈμΆμ π€ Prompt for AI Agents |
||
Uh oh!
There was an error while loading. Please reload this page.