Class SandboxedJRT

java.lang.Object
org.metricshub.jawk.jrt.JRT
org.metricshub.jawk.jrt.SandboxedJRT

public class SandboxedJRT extends JRT
Runtime component that raises AwkSandboxException when sandboxed code attempts operations that would escape the sandbox.
  • Constructor Details

  • Method Details

    • jrtGetPrintStream

      public PrintStream jrtGetPrintStream(String filename, boolean append)
      Description copied from class: JRT
      Retrieve the PrintStream which writes to a particular file, creating the PrintStream if necessary.
      Overrides:
      jrtGetPrintStream in class JRT
      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 PrintStream object
    • jrtSpawnForOutput

      public PrintStream jrtSpawnForOutput(String cmd)
      Description copied from class: JRT
      Retrieve 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:
      jrtSpawnForOutput in class JRT
      Parameters:
      cmd - The command to execute.
      Returns:
      The PrintStream which to write to provide input data to the process.
    • jrtConsumeFileInput

      public boolean jrtConsumeFileInput(String filename) throws IOException
      Description copied from class: JRT

      jrtConsumeFileInput.

      Overrides:
      jrtConsumeFileInput in class JRT
      Parameters:
      filename - a String object
      Returns:
      a boolean
      Throws:
      IOException - if any.
    • jrtConsumeCommandInput

      public boolean jrtConsumeCommandInput(String cmd) throws IOException
      Description copied from class: JRT

      jrtConsumeCommandInput.

      Overrides:
      jrtConsumeCommandInput in class JRT
      Parameters:
      cmd - a String object
      Returns:
      a boolean
      Throws:
      IOException - if any.
    • jrtSystem

      public Integer jrtSystem(String cmd)
      Description copied from class: JRT
      Executes 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.
      Overrides:
      jrtSystem in class JRT
      Parameters:
      cmd - The command to execute.
      Returns:
      Integer(return_code) of the created process. Integer(-1) is returned on an IO error.