sandboxR (version 0.1)

sandbox: Eval in sandbox

Description

Eval in sandbox

Usage

sandbox(src, envir, time.limit = 10)

Arguments

src
character vector of R commands
envir
the environment where the calls would be tested. This should be omitted or preset with sandbox.env.
time.limit
limit on the elapsed time while running src

Examples

Run this code
## Not run: 
# sandbox('paste(rev(c(")", "whatever", "(", "m", "e", "t", "s", "y", "s")), sep = "", collapse = "")')
# sandbox('get(paste("","y", "tem", sep="s"))("whoami")')
# sandbox(c("x1 <- 's'", "x2 <- 'y'", "x3 <- 't'", "x4 <- 'e'", "x5 <- 'm'", "x <- paste(x1, x2, x1, x3, x4, x5, sep = '')", "lm(sprintf(\"%s('echo hello > /tmp/xxx') ~ 1\", x))"))
# sandbox('paste("as.numeric(system(\'ls -la | wc -l\', intern=T)) ~ 1")')
# sandbox(c("x <- system", "x('ls')"))
# sandbox('lm("as.numeric(system(\'ls -la | wc -l\', intern=T)) ~ 1")')
# ## End(Not run)

Run the code above in your browser using DataCamp Workspace