private bool TryReadSandboxedProcessExecutorTestHook(out SandboxedProcessExecutorTestHook sandboxedProcessExecutorTestHook) { if (string.IsNullOrEmpty(m_configuration.SandboxedProcessExecutorTestHookFile)) { sandboxedProcessExecutorTestHook = null; return(true); } SandboxedProcessExecutorTestHook localSandboxedProcessExecutorTestHook = null; string sandboxedProcessTestHook = Path.GetFullPath(m_configuration.SandboxedProcessExecutorTestHookFile); m_logger.LogInfo($"Reading sandboxed process test hook from '{sandboxedProcessTestHook}'"); bool success = Helpers.RetryOnFailure( attempt => { using FileStream stream = File.OpenRead(sandboxedProcessTestHook); // TODO: Custom DetoursEventListener? localSandboxedProcessExecutorTestHook = SandboxedProcessExecutorTestHook.Deserialize(stream); return(true); }, onException: e => m_logger.LogError(e.ToStringDemystified())); sandboxedProcessExecutorTestHook = localSandboxedProcessExecutorTestHook; return(true); }
/// <summary> /// Creates an instance of <see cref="ExternalSandboxedProcess"/>. /// </summary> protected ExternalSandboxedProcess( SandboxedProcessInfo sandboxedProcessInfo, string workingDirectoryRoot, SandboxedProcessExecutorTestHook sandboxedProcessExecutorTestHook = null) { Contract.Requires(sandboxedProcessInfo != null); Contract.Requires(!string.IsNullOrEmpty(workingDirectoryRoot)); SandboxedProcessInfo = sandboxedProcessInfo; SandboxedProcessExecutorTestHook = sandboxedProcessExecutorTestHook; WorkingDirectory = Path.Combine(workingDirectoryRoot, $"Pip{SandboxedProcessInfo.PipSemiStableHash:X16}"); }
/// <summary> /// Creates an instance of <see cref="ExternalVmSandboxedProcess"/>. /// </summary> public ExternalVmSandboxedProcess( SandboxedProcessInfo sandboxedProcessInfo, VmInitializer vmInitializer, ExternalToolSandboxedProcessExecutor tool, string externalSandboxedProcessDirectory, SandboxedProcessExecutorTestHook sandboxedProcessExecutorTestHook = null) : base(sandboxedProcessInfo, Path.Combine(externalSandboxedProcessDirectory, nameof(ExternalVmSandboxedProcess)), sandboxedProcessExecutorTestHook) { Contract.Requires(vmInitializer != null); Contract.Requires(tool != null); m_vmInitializer = vmInitializer; m_tool = tool; }
private bool TryReadSandboxedProcessExecutorTestHook(out SandboxedProcessExecutorTestHook sandboxedProcessExecutorTestHook) { if (string.IsNullOrEmpty(m_configuration.SandboxedProcessExecutorTestHookFile)) { sandboxedProcessExecutorTestHook = null; return(true); } SandboxedProcessExecutorTestHook localSandboxedProcessExecutorTestHook = null; bool success = Helpers.RetryOnFailure( attempt => { using (FileStream stream = File.OpenRead(Path.GetFullPath(m_configuration.SandboxedProcessExecutorTestHookFile))) { // TODO: Custom DetoursEventListener? localSandboxedProcessExecutorTestHook = SandboxedProcessExecutorTestHook.Deserialize(stream); return(true); } }); sandboxedProcessExecutorTestHook = localSandboxedProcessExecutorTestHook; return(true); }