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
6 changes: 6 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@


## 2024-05-18 - Prevent information disclosure in try blocks
Comment on lines +1 to +3
**Vulnerability:** Execution errors (like matrix singularity details) could be leaked to standard error via `try()` blocks defaulting to `silent = FALSE`.
**Learning:** `try()` defaults to `silent = FALSE` in R, meaning any error that occurs within it will still be printed to standard error, potentially exposing sensitive information about the data or internal state.
**Prevention:** Always use `silent = TRUE` with `try()` to gracefully handle mathematical exceptions and prevent information disclosure, or use `tryCatch`.
6 changes: 4 additions & 2 deletions R/llcont.R
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,8 @@ llcont.lavaan <- function(x, ...){
if(length(x.idx) == 1){
tmpll.x <- dnorm(x@Data@X[[g]][,x.idx], Mu.X, sqrt(Sigma.X), log=TRUE)
} else {
tmpll.x <- dmvnorm(x@Data@X[[g]][,x.idx], Mu.X, Sigma.X, log=TRUE)
# Security: prevent information disclosure by explicitly suppressing standard error output via try(silent = TRUE)
tmpll.x <- try(dmvnorm(x@Data@X[[g]][,x.idx], Mu.X, Sigma.X, log=TRUE), silent = TRUE)
}
if(inherits(tmpll.x, "try-error")) tmpll.x <- NA
llvec[grpind] <- llvec[grpind] - tmpll.x
Expand Down Expand Up @@ -468,7 +469,8 @@ llcont.lavaan <- function(x, ...){
if(length(x.idx) == 1){
tmpll.x <- dnorm(X[,x.dat.idx], Mu.X, sqrt(Sigma.X), log=TRUE)
} else {
tmpll.x <- try(dmvnorm(X[,x.dat.idx], Mu.X, Sigma.X, log=TRUE))
# Security: prevent information disclosure by explicitly suppressing standard error output via try(silent = TRUE)
tmpll.x <- try(dmvnorm(X[,x.dat.idx], Mu.X, Sigma.X, log=TRUE), silent = TRUE)
}
if(inherits(tmpll.x, "try-error")) tmpll.x <- NA
tmpll[case.idx] <- tmpll[case.idx] - tmpll.x
Expand Down
8 changes: 5 additions & 3 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
library(testthat)
library(nonnest2)
if (requireNamespace("testthat", quietly = TRUE)) {
library(testthat)
library(nonnest2)

test_check("nonnest2")
test_check("nonnest2")
}
Loading