노현종

충돌 해결

...@@ -20,6 +20,7 @@ namespace VulnCrawler ...@@ -20,6 +20,7 @@ namespace VulnCrawler
20 public bool HasCritical { get; set; } 20 public bool HasCritical { get; set; }
21 public string Code { get; set; } 21 public string Code { get; set; }
22 public string Hash { get; set; } 22 public string Hash { get; set; }
23 + public IEnumerable<string> CriticalList { get; set; }
23 24
24 } 25 }
25 protected Regex extractMethodLine; 26 protected Regex extractMethodLine;
...@@ -245,6 +246,7 @@ namespace VulnCrawler ...@@ -245,6 +246,7 @@ namespace VulnCrawler
245 public virtual IEnumerable<(string methodName, IList<Block> blocks)> Process(Blob oldBlob, IDictionary<string, IEnumerable<string>> table) { 246 public virtual IEnumerable<(string methodName, IList<Block> blocks)> Process(Blob oldBlob, IDictionary<string, IEnumerable<string>> table) {
246 foreach (var item in table) 247 foreach (var item in table)
247 { 248 {
249 + // 메서드 이름
248 string methodName = item.Key; 250 string methodName = item.Key;
249 // 패치 전 원본 파일 스트림 251 // 패치 전 원본 파일 스트림
250 Stream oldStream = oldBlob.GetContentStream(); 252 Stream oldStream = oldBlob.GetContentStream();
...@@ -255,18 +257,25 @@ namespace VulnCrawler ...@@ -255,18 +257,25 @@ namespace VulnCrawler
255 string md5 = string.Empty; 257 string md5 = string.Empty;
256 if (item.Value.Count() != 0) 258 if (item.Value.Count() != 0)
257 { 259 {
260 + Console.WriteLine("크리티컬 변수 목록");
261 + Console.ForegroundColor = ConsoleColor.Cyan;
262 + foreach (var c in item.Value)
263 + {
264 + Console.WriteLine(c);
265 + }
266 + Console.ResetColor();
267 + Console.WriteLine("-------------------");
258 // 크리티컬 블록 추출 268 // 크리티컬 블록 추출
259 var blocks = GetCriticalBlocks(func, item.Value).ToList(); 269 var blocks = GetCriticalBlocks(func, item.Value).ToList();
260 if (blocks == null) 270 if (blocks == null)
261 { 271 {
262 continue; 272 continue;
263 } 273 }
264 -
265 foreach (var block in blocks) 274 foreach (var block in blocks)
266 { 275 {
267 block.Hash = MD5HashFunc(block.Code); 276 block.Hash = MD5HashFunc(block.Code);
277 + block.CriticalList = item.Value;
268 } 278 }
269 -
270 yield return (methodName, blocks); 279 yield return (methodName, blocks);
271 } 280 }
272 281
......
...@@ -34,6 +34,8 @@ namespace VulnCrawler ...@@ -34,6 +34,8 @@ namespace VulnCrawler
34 // 현재 커밋에 대한 패치 엔트리 배열을 출력함 34 // 현재 커밋에 대한 패치 엔트리 배열을 출력함
35 PrintPatchEntrys(entrys, crawler, message, cve); 35 PrintPatchEntrys(entrys, crawler, message, cve);
36 } 36 }
37 + Console.ReadLine();
38 +
37 } 39 }
38 } 40 }
39 41
...@@ -87,15 +89,22 @@ namespace VulnCrawler ...@@ -87,15 +89,22 @@ namespace VulnCrawler
87 Console.BackgroundColor = ConsoleColor.DarkRed; 89 Console.BackgroundColor = ConsoleColor.DarkRed;
88 Console.WriteLine($"Patched: \n{entry.Patch}"); 90 Console.WriteLine($"Patched: \n{entry.Patch}");
89 Console.ResetColor(); 91 Console.ResetColor();
90 -
91 var table = self.ExtractGitCriticalMethodTable(entry.Patch); 92 var table = self.ExtractGitCriticalMethodTable(entry.Patch);
92 -
93 foreach (var tuple in self.Process(oldBlob, table)) 93 foreach (var tuple in self.Process(oldBlob, table))
94 { 94 {
95 (var methodName, var blocks) = tuple; 95 (var methodName, var blocks) = tuple;
96 - 96 + Console.BackgroundColor = ConsoleColor.DarkRed;
97 + Console.WriteLine($"메서드 이름 : {methodName}");
98 + Console.ResetColor();
99 + //Console.ForegroundColor = ConsoleColor.Blue;
100 + //foreach (var c in )
101 + //{
102 + // Console.WriteLine(c);
103 + //}
104 + //Console.ResetColor();
97 foreach (var block in blocks) 105 foreach (var block in blocks)
98 { 106 {
107 +
99 if (block.HasCritical) 108 if (block.HasCritical)
100 { 109 {
101 Console.BackgroundColor = ConsoleColor.DarkMagenta; 110 Console.BackgroundColor = ConsoleColor.DarkMagenta;
...@@ -122,7 +131,7 @@ namespace VulnCrawler ...@@ -122,7 +131,7 @@ namespace VulnCrawler
122 // //} 131 // //}
123 132
124 //} 133 //}
125 - Console.ReadLine(); 134 + // Console.ReadLine();
126 } 135 }
127 else 136 else
128 { 137 {
...@@ -168,9 +177,9 @@ namespace VulnCrawler ...@@ -168,9 +177,9 @@ namespace VulnCrawler
168 } 177 }
169 catch (Exception e) 178 catch (Exception e)
170 { 179 {
171 - Console.WriteLine(entry.Patch); 180 + // Console.WriteLine(entry.Patch);
172 - Console.WriteLine(e.ToString()); 181 + // Console.WriteLine(e.ToString());
173 - Console.ReadLine(); 182 + // Console.ReadLine();
174 continue; 183 continue;
175 } 184 }
176 185
......