Exemplo n.º 1
0
        /// <nodoc />
        public static SandboxedProcessInfo Deserialize(Stream stream, LoggingContext loggingContext, IDetoursEventListener detoursEventListener)
        {
            using (var reader = new BuildXLReader(false, stream, true))
            {
                string           arguments             = reader.ReadNullableString();
                string           commandLine           = reader.ReadNullableString();
                bool             disableConHostSharing = reader.ReadBoolean();
                string           fileName = reader.ReadNullableString();
                Encoding         standardInputEncoding  = reader.ReadNullable(r => r.ReadEncoding());
                Encoding         standardOutputEncoding = reader.ReadNullable(r => r.ReadEncoding());
                Encoding         standardErrorEncoding  = reader.ReadNullable(r => r.ReadEncoding());
                string           workingDirectory       = reader.ReadNullableString();
                IBuildParameters buildParameters        = null;
                var envVars = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => new KeyValuePair <string, string>(r2.ReadString(), r2.ReadString())));
                if (envVars != null)
                {
                    buildParameters = BuildParameters.GetFactory().PopulateFromDictionary(envVars.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
                }

                string[]    allowedSurvivingChildNames = reader.ReadNullable(r => r.ReadReadOnlyList(r2 => r2.ReadString()))?.ToArray();
                int         maxLengthInMemory          = reader.ReadInt32();
                TimeSpan?   timeout = reader.ReadNullableStruct(r => r.ReadTimeSpan());
                TimeSpan    nestedProcessTerminationTimeout = reader.ReadTimeSpan();
                long        pipSemiStableHash    = reader.ReadInt64();
                string      timeoutDumpDirectory = reader.ReadNullableString();
                SandboxKind sandboxKind          = (SandboxKind)reader.ReadByte();
                string      pipDescription       = reader.ReadNullableString();
                SandboxedProcessStandardFiles sandboxedProcessStandardFiles = SandboxedProcessStandardFiles.Deserialize(reader);
                StandardInputInfo             standardInputSourceInfo       = reader.ReadNullable(r => StandardInputInfo.Deserialize(r));
                SandboxObserverDescriptor     standardObserverDescriptor    = reader.ReadNullable(r => SandboxObserverDescriptor.Deserialize(r));

                FileAccessManifest fam = reader.ReadNullable(r => FileAccessManifest.Deserialize(stream));

                return(new SandboxedProcessInfo(
                           new PathTable(),
                           new StandardFileStorage(sandboxedProcessStandardFiles),
                           fileName,
                           fam,
                           disableConHostSharing,
                           // TODO: serialize/deserialize container configuration.
                           containerConfiguration: ContainerConfiguration.DisabledIsolation,
                           loggingContext: loggingContext,
                           detoursEventListener: detoursEventListener)
                {
                    m_arguments = arguments,
                    m_commandLine = commandLine,
                    StandardInputEncoding = standardInputEncoding,
                    StandardOutputEncoding = standardOutputEncoding,
                    StandardErrorEncoding = standardErrorEncoding,
                    WorkingDirectory = workingDirectory,
                    EnvironmentVariables = buildParameters,
                    AllowedSurvivingChildProcessNames = allowedSurvivingChildNames,
                    MaxLengthInMemory = maxLengthInMemory,
                    Timeout = timeout,
                    NestedProcessTerminationTimeout = nestedProcessTerminationTimeout,
                    PipSemiStableHash = pipSemiStableHash,
                    TimeoutDumpDirectory = timeoutDumpDirectory,
                    SandboxKind = sandboxKind,
                    PipDescription = pipDescription,
                    SandboxedProcessStandardFiles = sandboxedProcessStandardFiles,
                    StandardInputSourceInfo = standardInputSourceInfo,
                    StandardObserverDescriptor = standardObserverDescriptor
                });
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Checks for equality.
 /// </summary>
 public bool Equals(SandboxObserverDescriptor descriptor)
 {
     return(!(descriptor is null) &&
            (ReferenceEquals(this, descriptor) ||
             (LogErrorToConsole == descriptor.LogErrorToConsole && LogOutputToConsole == descriptor.LogOutputToConsole && WarningRegex == descriptor.WarningRegex)));
 }