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
4 changes: 4 additions & 0 deletions .jules/sentinel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## 2026-03-31 - Missing Input Validation on Exported Statistical Functions
**Vulnerability:** Core exported functions like `vuongtest` and `icci` lacked proper parameter validation (e.g., `adj` not constrained to specific strings, `nested` not strictly logical, `conf.level` not checked for valid probability bounds). This could lead to unexpected code execution paths, cryptic R errors downstream, or invalid statistical output when users supply bad input.
**Learning:** In R packages, exported functions that accept string arguments for configuration (`adj`) or numeric parameters with bounds (`conf.level`) must explicitly validate them early using `match.arg()`, `is.numeric()`, `is.logical()` and bounds checking, rather than implicitly trusting the input.
**Prevention:** Consistently apply `match.arg()` for multiple-choice string parameters and explicit `if`/`stop` blocks or `stopifnot()` for type/bounds checking on exported function entry points.
3 changes: 3 additions & 0 deletions R/icci.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
#' @export
icci <- function(object1, object2, conf.level=.95, ll1=llcont, ll2=llcont) {

## Input validation
if(!is.numeric(conf.level) || length(conf.level) != 1 || conf.level <= 0 || conf.level >= 1) stop("conf.level must be a numeric value strictly between 0 and 1")

## check objects, issue warnings/errors, get classes/calls
obinfo <- check.obj(object1, object2)
callA <- obinfo$callA; classA <- obinfo$classA
Expand Down
4 changes: 4 additions & 0 deletions R/vuongtest.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
#' @export
vuongtest <- function(object1, object2, nested=FALSE, adj="none", ll1=llcont, ll2=llcont, score1=NULL, score2=NULL, vc1=vcov, vc2=vcov) {

## Input validation
adj <- match.arg(adj, c("none", "aic", "bic"))
if(!is.logical(nested) || length(nested) != 1) stop("nested must be a logical value of length 1")

## check objects, issue warnings/errors, get classes/calls
obinfo <- check.obj(object1, object2)
callA <- obinfo$callA; classA <- obinfo$classA
Expand Down