Exemple #1
0
        /// <nodoc />
        public FileAccessWhitelistEntry(IFileAccessWhitelistEntry template, PathRemapper pathRemapper)
            : base(template, pathRemapper)
        {
            Contract.Assume(template != null);
            Contract.Assume(pathRemapper != null);

            Name         = template.Name;
            Value        = template.Value;
            ToolPath     = pathRemapper.Remap(template.ToolPath);
            PathFragment = template.PathFragment;
            PathRegex    = template.PathRegex;
        }
        private void AddWhiteListEntry(IFileAccessWhitelistEntry whitelistEntry, bool allowsCaching)
        {
            SerializableRegex pathRegex;
            string            regexError;

            if (string.IsNullOrEmpty(whitelistEntry.PathRegex))
            {
                if (!TryCreateWhitelistRegex(Regex.Escape(whitelistEntry.PathFragment), out pathRegex, out regexError))
                {
                    throw new BuildXLException("A whitelist regex should never fail to construct from an escaped pattern: " + regexError);
                }
            }
            else
            {
                if (!TryCreateWhitelistRegex(whitelistEntry.PathRegex, out pathRegex, out regexError))
                {
                    throw new BuildXLException("A regex should have already been validated when parsed: " + regexError);
                }
            }

            if (!string.IsNullOrEmpty(whitelistEntry.Value))
            {
                Add(
                    new ValuePathFileAccessWhitelistEntry(
                        outputValue: FullSymbol.Create(m_context.SymbolTable, whitelistEntry.Value),
                        pathRegex: pathRegex,
                        allowsCaching: allowsCaching,
                        name: whitelistEntry.Name));
            }
            else
            {
                Add(
                    new ExecutablePathWhitelistEntry(
                        executablePath: whitelistEntry.ToolPath,
                        pathRegex: pathRegex,
                        allowsCaching: allowsCaching,
                        name: whitelistEntry.Name));
            }
        }