Learn R Programming

jmvcore (version 2.7.38)

validateSafeFormula: Secure formula validation using allowlist approach Prevents code injection while allowing legitimate statistical formulas

Description

Secure formula validation using allowlist approach Prevents code injection while allowing legitimate statistical formulas

Usage

validateSafeFormula(fmla, additional_allowed_functions = NULL)

Value

Invisibly returns `NULL`. Throws an error if the formula contains security violations.

Arguments

fmla

A formula object to validate.

additional_allowed_functions

Optional character vector of extra function names to permit for this validation call.

Examples

Run this code
# Safe usage:
validateSafeFormula(y ~ x + z)
validateSafeFormula(y ~ I(x^2) + log(z))

if (FALSE) {
# Blocks dangerous code (throws an error):
validateSafeFormula(y ~ I(system('whoami')))
}

Run the code above in your browser using DataLab