Package io.jawk.jrt
Class SandboxedJRT
java.lang.Object
io.jawk.jrt.JRT
io.jawk.jrt.SandboxedJRT
Runtime component that raises
AwkSandboxException when sandboxed code
attempts operations that would escape the sandbox.-
Constructor Summary
ConstructorsConstructorDescriptionSandboxedJRT(VariableManager vm, Locale locale, AwkSink awkSink, PrintStream error) Creates a sandboxed runtime facade with explicit default output settings. -
Method Summary
Modifier and TypeMethodDescriptionprotected AwkSinkgetFileAwkSink(String filename, boolean append) Resolves the sink used by file redirection.protected AwkSinkgetPipeAwkSink(String cmd) Resolves the sink used by pipe redirection.booleanjrtConsumeCommandInput.booleanjrtConsumeFileInput(String filename) jrtConsumeFileInput.jrtGetPrintStream(String filename, boolean append) Retrieve the PrintStream which writes to a particular file, creating the PrintStream if necessary.jrtSpawnForOutput(String cmd) Retrieve the PrintStream which shuttles data to stdin for a process, executing the process if necessary.Executes the command specified by cmd and waits for termination, returning an Integer object containing the return code.Methods inherited from class io.jawk.jrt.JRT
advanceToNextFile, applyRS, applySpecialVariable, applySpecialVariables, assignEnvironmentVariables, assignInitialVariables, caseAwarePattern, compare2, compare2, consumeCurrentFileInput, consumeCurrentFileInputToTarget, consumeInput, consumeInputForEval, consumeInputToTarget, containsAwkKey, copySpecialVariables, createAwkMap, dec, dynamicPattern, getARGCVar, getARGIND, getAssocArrayValue, getAwkSink, getAwkStringEntry, getCONVFMTString, getCONVFMTVar, getERRNO, getFILENAME, getFNR, getFSString, getFSVar, getIGNORECASEVar, getInputLine, getLocale, getNF, getNR, getOFMTString, getOFSString, getOFSVar, getORSString, getORSVar, getOutputFiles, getPartitioningReader, getReplaceResult, getRLENGTH, getRSString, getRSTART, getRSVar, getSUBSEPString, getSUBSEPVar, hasInputFields, hasPendingInputFileError, inc, index, initializeInputFields, isActuallyLong, isGawkOnlySpecialVariable, isIgnoreCase, isJrtManagedSpecialVariable, isParseableNumber, jrtClose, jrtCloseAll, jrtConsumeCommandInputForGetline, jrtConsumeFileInputForGetline, jrtGetInputField, jrtGetInputField, jrtGetInputString, jrtParseFields, jrtSetInputField, jrtSetNF, matches, matchPosition, newRandom, parseFieldNumber, prepareForExecution, prepareReplacement, prepareReplacement, printDefault, printfDefault, printfNoCatch, printfNoCatch, printfToFile, printfToProcess, printToFile, printToProcess, printWarning, rebuildDollarZeroFromFields, regexpFlags, replaceAll, replaceFirst, setARGC, setARGIND, setAwkSink, setCONVFMT, setERRNO, setErrorStream, setFILENAMEViaJrt, setFNR, setFS, setIGNORECASE, setInputLine, setNF, setNR, setOFMT, setOFS, setORS, setRLENGTH, setRS, setRSTART, setSUBSEP, setWarningStream, split, split, splitTokenizer, sprintfNoCatch, substr, substr, timeSeed, toAwkString, toBoolean, toDouble, toInputScalar, toJavaScalar, toLong, untypedToBlank
-
Constructor Details
-
SandboxedJRT
Creates a sandboxed runtime facade with explicit default output settings.- Parameters:
vm- Variable manager used by the sandboxed runtimelocale- locale to use for runtime formattingawkSink- default output sinkerror- error stream for spawned-process stderr
-
-
Method Details
-
getFileAwkSink
Description copied from class:JRTResolves the sink used by file redirection.- Overrides:
getFileAwkSinkin classJRT- Parameters:
filename- target file nameappend- whether output should be appended- Returns:
- the sink that writes to the requested file
-
getPipeAwkSink
Description copied from class:JRTResolves the sink used by pipe redirection.- Overrides:
getPipeAwkSinkin classJRT- Parameters:
cmd- command to execute- Returns:
- the sink connected to the process stdin
-
jrtGetPrintStream
Description copied from class:JRTRetrieve the PrintStream which writes to a particular file, creating the PrintStream if necessary.- Overrides:
jrtGetPrintStreamin classJRT- Parameters:
filename- The file which to write the contents of the PrintStream.append- true to append to the file, false to overwrite the file.- Returns:
- a
PrintStreamobject
-
jrtSpawnForOutput
Description copied from class:JRTRetrieve the PrintStream which shuttles data to stdin for a process, executing the process if necessary. Threads are created to shuttle the data to/from the process.- Overrides:
jrtSpawnForOutputin classJRT- Parameters:
cmd- The command to execute.- Returns:
- The PrintStream which to write to provide input data to the process.
-
jrtConsumeFileInput
Description copied from class:JRTjrtConsumeFileInput.
- Overrides:
jrtConsumeFileInputin classJRT- Parameters:
filename- aStringobject- Returns:
- a boolean
- Throws:
IOException- if any.
-
jrtConsumeCommandInput
Description copied from class:JRTjrtConsumeCommandInput.
- Overrides:
jrtConsumeCommandInputin classJRT- Parameters:
cmd- aStringobject- Returns:
- a boolean
- Throws:
IOException- if any.
-
jrtSystem
Description copied from class:JRTExecutes the command specified by cmd and waits for termination, returning an Integer object containing the return code. stdin to this process is closed while threads are created to shuttle stdout and stderr of the command to stdout/stderr of the calling process.
-