From: Rodrigo Kumpera Date: Wed, 15 Mar 2017 20:48:08 +0000 (-0700) Subject: [tools] Update nuget-hash-extractor to spew the new ban table. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=mono.git;a=commitdiff_plain;h=8a83c3eb2c0b26a465cf25efcf63a54a81243197 [tools] Update nuget-hash-extractor to spew the new ban table. --- diff --git a/tools/nuget-hash-extractor/Makefile b/tools/nuget-hash-extractor/Makefile index 1d52b77c0cf..6a74c0d2783 100644 --- a/tools/nuget-hash-extractor/Makefile +++ b/tools/nuget-hash-extractor/Makefile @@ -10,4 +10,11 @@ download: run: nuget-hash-extractor.exe mono nuget-hash-extractor.exe nugets + +run-asm: nuget-hash-extractor.exe + mono nuget-hash-extractor.exe nugets asm + +run-ver: nuget-hash-extractor.exe + mono nuget-hash-extractor.exe nugets ver + .PHONY: download run diff --git a/tools/nuget-hash-extractor/nuget-hash-extractor.cs b/tools/nuget-hash-extractor/nuget-hash-extractor.cs index 013097f83c8..96b4b7c8c91 100644 --- a/tools/nuget-hash-extractor/nuget-hash-extractor.cs +++ b/tools/nuget-hash-extractor/nuget-hash-extractor.cs @@ -33,7 +33,16 @@ class Driver { LoadAndDump (et, version); } } + + static bool dump_asm, dump_ver; static void Main (string[] args) { + + if (args.Length > 1) { + dump_asm = args [1].Equals ("asm"); + dump_ver = args [1].Equals ("ver"); + } else { + dump_asm = true; + } foreach (var f in Directory.GetFiles (args [0], "*.nupkg")) { DumpNuget (f); } @@ -52,12 +61,13 @@ class Driver { var data = StreamToArray (entry.Open ()); AppDomain ad = AppDomain.CreateDomain ("parse_" + ++domain_id); DoParse p = (DoParse)ad.CreateInstanceAndUnwrap (typeof (DoParse).Assembly.FullName, typeof (DoParse).FullName); - p.ParseAssembly (data, version, entry.Name, entry.FullName); + p.ParseAssembly (data, version, entry.Name, entry.FullName, dump_asm, dump_ver); AppDomain.Unload (ad); } } class DoParse : MarshalByRefObject { + static int Hash (string str) { int h = 5381; for (int i = 0; i < str.Length; ++i) @@ -82,7 +92,7 @@ class DoParse : MarshalByRefObject { return parts[parts.Length - 2]; } - public void ParseAssembly (byte[] data, string version, string name, string fullname) { + public void ParseAssembly (byte[] data, string version, string name, string fullname, bool dump_asm, bool dump_ver) { var a = Assembly.ReflectionOnlyLoad (data); var m = a.GetModules ()[0]; var id = m.ModuleVersionId.ToString ().ToUpper (); @@ -91,6 +101,13 @@ class DoParse : MarshalByRefObject { string ver_str = version + " " + FileToMoniker (fullname); - Console.WriteLine ($"IGNORED_ASSEMBLY (0x{hash_code}, {str}, \"{id}\", \"{ver_str}\"),"); + if (dump_asm) + Console.WriteLine ($"IGNORED_ASSEMBLY (0x{hash_code}, {str}, \"{id}\", \"{ver_str}\"),"); + + //IGNORED_ASM_VER (SYS_IO_COMPRESSION, 4, 1, 2, 0), + var ver = a.GetName ().Version; + if (dump_ver) + Console.WriteLine ($"IGNORED_ASM_VER ({str}, {ver.Major}, {ver.Minor}, {ver.Build}, {ver.Revision}),"); + } } \ No newline at end of file