예제 #1
0
        internal BinarySignData(BinaryName name, FileSignData fileSignData)
        {
            Debug.Assert(name.IsAssembly || fileSignData.StrongName == null);

            BinaryName = name;
            FileSignData = fileSignData;
        }
예제 #2
0
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         int result = base.GetHashCode();
         result = (result * 397) ^ Command?.GetHashCode() ?? 0;
         result = (result * 397) ^ BinaryName?.GetHashCode() ?? 0;
         result = (result * 397) ^ NeedsTerminal.GetHashCode();
         result = (result * 397) ^ Names.GetUnsequencedHashCode();
         result = (result * 397) ^ Summaries.GetUnsequencedHashCode();
         result = (result * 397) ^ Descriptions.GetUnsequencedHashCode();
         result = (result * 397) ^ Icons.GetUnsequencedHashCode();
         return(result);
     }
 }
예제 #3
0
        private VsixData VerifyVsixContentsBeforeSign(BinaryName vsixName, Dictionary<string, BinaryName> checksumToNameMap, ref bool allGood)
        {
            var nestedExternalBinaries = new List<string>();
            var nestedParts = new List<VsixPart>();
            using (var package = Package.Open(vsixName.FullPath, FileMode.Open, FileAccess.Read))
            {
                foreach (var part in package.GetParts())
                {
                    var relativeName = GetPartRelativeFileName(part);
                    var name = Path.GetFileName(relativeName);
                    if (!IsVsix(name) && !IsAssembly(name))
                    {
                        continue;
                    }

                    if (_signData.ExternalBinaryNames.Contains(name))
                    {
                        nestedExternalBinaries.Add(name);
                        continue;
                    }

                    if (!_signData.BinaryNames.Any(x => FilePathComparer.Equals(x.Name, name)))
                    {
                        allGood = false;
                        Console.WriteLine($"VSIX {vsixName} has part {name} which is not listed in the sign or external list");
                        continue;
                    }

                    // This represents a binary that we need to sign.  Ensure the content in the VSIX is the same as the 
                    // content in the binaries directory by doing a chekcsum match.
                    using (var stream = part.GetStream())
                    {
                        string checksum = _contentUtil.GetChecksum(stream);
                        BinaryName checksumName;
                        if (!checksumToNameMap.TryGetValue(checksum, out checksumName))
                        {
                            allGood = false;
                            Console.WriteLine($"{vsixName} has part {name} which does not match the content in the binaries directory");
                            continue;
                        }

                        if (!FilePathComparer.Equals(checksumName.Name, name))
                        {
                            allGood = false;
                            Console.WriteLine($"{vsixName} has part {name} with a different name in the binaries directory: {checksumName}");
                            continue;
                        }

                        nestedParts.Add(new VsixPart(relativeName, checksumName));
                    }
                }
            }

            return new VsixData(vsixName, nestedParts.ToImmutableArray(), nestedExternalBinaries.ToImmutableArray());
        }
예제 #4
0
        /// <summary>
        /// Return all the assembly and VSIX contents nested in the VSIX
        /// </summary>
        private List<string> GetVsixPartRelativeNames(BinaryName vsixName)
        {
            var list = new List<string>();
            using (var package = Package.Open(vsixName.FullPath, FileMode.Open, FileAccess.Read))
            {
                foreach (var part in package.GetParts())
                {
                    var name = GetPartRelativeFileName(part);
                    list.Add(name);
                }
            }

            return list;
        }
예제 #5
0
        private bool AreNestedVsixSigned(BinaryName vsixName, HashSet<string> signedSet)
        {
            foreach (var relativeName in GetNestedVsixRelativeNames(vsixName))
            {
                var name = Path.GetFileName(relativeName);
                if (!signedSet.Contains(name))
                {
                    return false;
                }
            }

            return true;
        }
예제 #6
0
 /// <summary>
 /// Get the name of all VSIX which are nested inside this VSIX.
 /// </summary>
 private IEnumerable<string> GetNestedVsixRelativeNames(BinaryName vsixName)
 {
     return GetVsixPartRelativeNames(vsixName).Where(x => IsVsix(x));
 }
예제 #7
0
파일: VsixData.cs 프로젝트: vslsnap/roslyn
 internal VsixPart(string relativeName, BinaryName binaryName)
 {
     RelativeName = relativeName;
     BinaryName = binaryName;
 }
예제 #8
0
파일: VsixData.cs 프로젝트: vslsnap/roslyn
 internal VsixData(BinaryName name, ImmutableArray<VsixPart> nestedBinaryParts, ImmutableArray<string> nestedExternalNames)
 {
     Name = name;
     NestedBinaryParts = nestedBinaryParts;
     NestedExternalNames = nestedExternalNames;
 }