Пример #1
0
        internal static MutablePipState Deserialize(BuildXLReader reader, PipType pipType, long semiStableHash, PageableStoreId storeId)
        {
            ServiceInfo   serviceInfo              = reader.ReadNullable(ServiceInfo.InternalDeserialize);
            int           options                  = reader.ReadInt32();
            RewritePolicy rewritePolicy            = (RewritePolicy)reader.ReadByte();
            AbsolutePath  executablePath           = reader.ReadAbsolutePath();
            int           priority                 = reader.ReadInt32();
            int           preserveOutputTrustLevel = reader.ReadInt32();
            ModuleId      moduleId                 = reader.ReadModuleId();

            return(new ProcessMutablePipState(pipType, semiStableHash, storeId, serviceInfo, (Process.Options)options, rewritePolicy, executablePath, priority, moduleId, preserveOutputTrustLevel));
        }
Пример #2
0
        /// <nodoc />
        protected static ModuleLiteralId ReadModuleLiteralId(BuildXLReader reader)
        {
            var name = reader.ReadFullSymbol();
            var path = reader.ReadAbsolutePath();

            // Name and Id could be invalid in case of a fake type or namespace.
            if (!name.IsValid && !path.IsValid)
            {
                return(default(ModuleLiteralId));
            }

            return(ModuleLiteralId.Create(path).WithName(name));
        }
        /// <summary>
        /// Deserializes
        /// </summary>
        public static ExecutablePathAllowlistEntry Deserialize(BuildXLReader reader)
        {
            Contract.Requires(reader != null);

            var          state = ReadState(reader);
            AbsolutePath path  = reader.ReadAbsolutePath();

            return(new ExecutablePathAllowlistEntry(
                       path,
                       state.PathRegex,
                       state.AllowsCaching,
                       state.Name));
        }
Пример #4
0
        /// <summary>
        /// Deserialize symlink definitions serialized using <see cref="Serialize(BuildXLWriter, SymlinkDefinitions)"/>
        /// </summary>
        public static Possible <SymlinkDefinitions> Deserialize(LoggingContext loggingContext, PathTable pathTable, BuildXLReader reader)
        {
            try
            {
                bool isNull = reader.ReadBoolean();
                if (isNull)
                {
                    return((SymlinkDefinitions)null);
                }

                var pathMap = ConcurrentBigMap <AbsolutePath, AbsolutePath> .Deserialize(
                    reader,
                    () => new KeyValuePair <AbsolutePath, AbsolutePath>(
                        key : reader.ReadAbsolutePath(),
                        value : reader.ReadAbsolutePath()));

                return(new SymlinkDefinitions(pathTable, pathMap));
            }
            catch (Exception ex)
            {
                Logger.Log.FailedLoadSymlinkFile(loggingContext, ex.GetLogEventMessage());
                return(new Failure <string>("Failed loading symlink definition file"));
            }
        }
Пример #5
0
        /// <nodoc/>
        public static DirectoryMembershipFingerprinterRule Deserialize(BuildXLReader reader)
        {
            string        name = reader.ReadString();
            AbsolutePath  root = reader.ReadAbsolutePath();
            bool          disableFilesystemEnumeration = reader.ReadBoolean();
            int           count     = reader.ReadInt32Compact();
            List <string> wildcards = new List <string>(count);

            for (int i = 0; i < count; i++)
            {
                wildcards.Add(reader.ReadString());
            }

            return(new DirectoryMembershipFingerprinterRule(name, root, disableFilesystemEnumeration, wildcards));
        }
Пример #6
0
        public static PipDataEntry Deserialize(BuildXLReader reader)
        {
            Contract.Requires(reader != null);
            var b = reader.ReadByte();

            Contract.Assume((b >> 4) <= (int)PipDataEntryType.NestedDataEnd);
            var entryType = (PipDataEntryType)(b >> 4);
            int data;

            switch (entryType)
            {
            case PipDataEntryType.NestedDataHeader:
            case PipDataEntryType.StringLiteral:
                data = reader.ReadStringId().Value;
                break;

            case PipDataEntryType.NestedDataStart:
            case PipDataEntryType.NestedDataEnd:
            case PipDataEntryType.VsoHashEntry2RewriteCount:
            case PipDataEntryType.FileId2RewriteCount:
            case PipDataEntryType.DirectoryIdHeaderSealId:
                data = reader.ReadInt32Compact();
                break;

            case PipDataEntryType.AbsolutePath:
            case PipDataEntryType.VsoHashEntry1Path:
            case PipDataEntryType.FileId1Path:
                data = reader.ReadAbsolutePath().Value.Value;
                break;

            case PipDataEntryType.Invalid:
                return(default(PipDataEntry));

            case PipDataEntryType.IpcMoniker:
                data = reader.ReadStringId().Value;
                break;

            default:
                Contract.Assert(false, "EntryType not handled: " + entryType);
                data = 0;
                break;
            }

            Contract.Assume((b & 15) <= (int)PipDataFragmentEscaping.CRuntimeArgumentRules);
            var escaping = (PipDataFragmentEscaping)(b & 15);

            return(new PipDataEntry(escaping, entryType, data));
        }
Пример #7
0
        public static ObservedPathEntry Deserialize(BuildXLReader reader)
        {
            AbsolutePath           path  = reader.ReadAbsolutePath();
            ObservedPathEntryFlags flags = (ObservedPathEntryFlags)reader.ReadByte();
            string enumeratePatternRegex = null;

            if ((flags & ObservedPathEntryFlags.DirectoryEnumerationWithCustomPattern) != 0)
            {
                enumeratePatternRegex = reader.ReadString();
            }
            else if ((flags & ObservedPathEntryFlags.DirectoryEnumerationWithAllPattern) != 0)
            {
                enumeratePatternRegex = RegexDirectoryMembershipFilter.AllowAllRegex;
            }

            return(new ObservedPathEntry(path, flags, enumeratePatternRegex));
        }
Пример #8
0
        /// <nodoc />
        public static object ReadConstValue(BuildXLReader reader)
        {
            var kind = (ConstExpressionKind)reader.ReadByte();

            switch (kind)
            {
            case ConstExpressionKind.Number:
                return(reader.ReadInt32Compact());

            case ConstExpressionKind.Boolean:
                return(reader.ReadBoolean());

            case ConstExpressionKind.EnumValue:
                return(new EnumValue(reader.ReadSymbolAtom(), reader.ReadInt32Compact()));

            case ConstExpressionKind.String:
                return(reader.ReadString());

            case ConstExpressionKind.File:
                return(reader.ReadFileArtifact());

            case ConstExpressionKind.Path:
                return(reader.ReadAbsolutePath());

            case ConstExpressionKind.RelativePath:
                return(reader.ReadRelativePath());

            case ConstExpressionKind.UndefinedLiteral:
                return(UndefinedLiteral.Instance);

            case ConstExpressionKind.UndefinedValue:
                return(UndefinedValue.Instance);
            }

            throw new InvalidOperationException(I($"Unknown const expression kind '{kind}'."));
        }
Пример #9
0
 /// <nodoc />
 public static ReportedFileAccess Deserialize(
     BuildXLReader reader,
     IReadOnlyList <ReportedProcess> processes,
     Func <BuildXLReader, AbsolutePath> readPath)
 {
     return(new ReportedFileAccess(
                operation: (ReportedFileOperation)reader.ReadByte(),
                process: processes != null ? processes[reader.ReadInt32Compact()] : ReportedProcess.Deserialize(reader),
                requestedAccess: (RequestedAccess)reader.ReadInt32Compact(),
                status: (FileAccessStatus)reader.ReadInt32Compact(),
                explicitlyReported: reader.ReadBoolean(),
                error: reader.ReadUInt32(),
                // In general if process is executed externally, e.g., in VM, the obtained USN cannot be translated to the host.
                // However, for our low-privilege build, we are going to map the host volumes to the VM, and thus the USN
                // can still be used.
                usn: new Usn(reader.ReadUInt64()),
                desiredAccess: (DesiredAccess)reader.ReadUInt32(),
                shareMode: (ShareMode)reader.ReadUInt32(),
                creationDisposition: (CreationDisposition)reader.ReadUInt32(),
                flagsAndAttributes: (FlagsAndAttributes)reader.ReadUInt32(),
                manifestPath: readPath != null ? readPath(reader) : reader.ReadAbsolutePath(),
                path: reader.ReadNullableString(),
                enumeratePatttern: reader.ReadNullableString()));
 }