Showing
1 changed file
with
63 additions
and
5 deletions
... | @@ -224,7 +224,25 @@ namespace VulnUserCodeAnalyzer | ... | @@ -224,7 +224,25 @@ namespace VulnUserCodeAnalyzer |
224 | Console.WriteLine($"{userName}, {repository}"); | 224 | Console.WriteLine($"{userName}, {repository}"); |
225 | } | 225 | } |
226 | 226 | ||
227 | - Console.ReadLine(); | 227 | + repoPath = repoDir.FullName; |
228 | + userId = userName; | ||
229 | +<<<<<<<<< Temporary merge branch 1 | ||
230 | + } | ||
231 | + if (!string.IsNullOrWhiteSpace(repoPath) && !string.IsNullOrWhiteSpace(userId)) | ||
232 | + { | ||
233 | + break; | ||
234 | + } | ||
235 | +========= | ||
236 | + } | ||
237 | + if (!string.IsNullOrWhiteSpace(repoPath) && !string.IsNullOrWhiteSpace(userId)) | ||
238 | + { | ||
239 | + break; | ||
240 | + } | ||
241 | +>>>>>>>>> Temporary merge branch 2 | ||
242 | + repoWatch.Restart(); | ||
243 | + } | ||
244 | + //Console.WriteLine("엔터를 누르세요"); | ||
245 | + //Console.ReadLine(); | ||
228 | 246 | ||
229 | /* hashDict = 사용된 사용자 함수 정보 */ | 247 | /* hashDict = 사용된 사용자 함수 정보 */ |
230 | var hashDict = new Dictionary<int, HashSet<VulnAbstractCrawler.UserBlock>>(); | 248 | var hashDict = new Dictionary<int, HashSet<VulnAbstractCrawler.UserBlock>>(); |
... | @@ -283,7 +301,11 @@ namespace VulnUserCodeAnalyzer | ... | @@ -283,7 +301,11 @@ namespace VulnUserCodeAnalyzer |
283 | * CVE를 가지고 있다고 인정하는 프로그램 정책 때문 | 301 | * CVE를 가지고 있다고 인정하는 프로그램 정책 때문 |
284 | */ | 302 | */ |
285 | var searchedCveHashList = VulnRDS.SelectVulnbyCve(cve); | 303 | var searchedCveHashList = VulnRDS.SelectVulnbyCve(cve); |
304 | +<<<<<<<<< Temporary merge branch 1 | ||
286 | Console.WriteLine($"cve:{cve}, {searchedCveHashList.Count()}개 가져옴"); | 305 | Console.WriteLine($"cve:{cve}, {searchedCveHashList.Count()}개 가져옴"); |
306 | +========= | ||
307 | + Console.WriteLine($"CVE:{cve}, Received Count : {searchedCveHashList.Count()}"); | ||
308 | +>>>>>>>>> Temporary merge branch 2 | ||
287 | foreach (var s in searchedCveHashList) | 309 | foreach (var s in searchedCveHashList) |
288 | { | 310 | { |
289 | vulnHashSet.Add(s); | 311 | vulnHashSet.Add(s); |
... | @@ -297,7 +319,7 @@ namespace VulnUserCodeAnalyzer | ... | @@ -297,7 +319,7 @@ namespace VulnUserCodeAnalyzer |
297 | /* 본격적인 취약점 매칭 부분 */ | 319 | /* 본격적인 취약점 매칭 부분 */ |
298 | foreach (var vulnSet in vulnDict) | 320 | foreach (var vulnSet in vulnDict) |
299 | { | 321 | { |
300 | - //Console.WriteLine($"-----cve:{vulnSet.Key}"); | 322 | + Console.WriteLine($"-----cve:{vulnSet.Key}"); |
301 | bool match = false; | 323 | bool match = false; |
302 | foreach (var vuln in vulnSet.Value) | 324 | foreach (var vuln in vulnSet.Value) |
303 | { | 325 | { |
... | @@ -309,6 +331,11 @@ namespace VulnUserCodeAnalyzer | ... | @@ -309,6 +331,11 @@ namespace VulnUserCodeAnalyzer |
309 | { | 331 | { |
310 | if (hashDict.ContainsKey(vuln.LenFunc)) | 332 | if (hashDict.ContainsKey(vuln.LenFunc)) |
311 | { | 333 | { |
334 | +<<<<<<<<< Temporary merge branch 1 | ||
335 | + Console.WriteLine("찾음"); | ||
336 | +========= | ||
337 | + //Console.WriteLine("찾음"); | ||
338 | +>>>>>>>>> Temporary merge branch 2 | ||
312 | /* Bloom Filter는 아쉽게도 포함 여부만 알 수 있기에 | 339 | /* Bloom Filter는 아쉽게도 포함 여부만 알 수 있기에 |
313 | * 포함되었음을 알았다면 검색해서 정보를 구한다. */ | 340 | * 포함되었음을 알았다면 검색해서 정보를 구한다. */ |
314 | var userBlock = hashDict[vuln.LenFunc].FirstOrDefault(b => b.Hash == vuln.BlockHash); | 341 | var userBlock = hashDict[vuln.LenFunc].FirstOrDefault(b => b.Hash == vuln.BlockHash); |
... | @@ -337,13 +364,21 @@ namespace VulnUserCodeAnalyzer | ... | @@ -337,13 +364,21 @@ namespace VulnUserCodeAnalyzer |
337 | /* 취약점 레코드가 전부 있어야 CVE 찾음 인정 */ | 364 | /* 취약점 레코드가 전부 있어야 CVE 찾음 인정 */ |
338 | if (match) | 365 | if (match) |
339 | { | 366 | { |
367 | +<<<<<<<<< Temporary merge branch 1 | ||
340 | Console.WriteLine($"CVE 찾음 {vulnSet.Key}"); | 368 | Console.WriteLine($"CVE 찾음 {vulnSet.Key}"); |
369 | +========= | ||
370 | + Console.WriteLine($"Matched CVE : {vulnSet.Key}"); | ||
371 | +>>>>>>>>> Temporary merge branch 2 | ||
341 | /* 찾았으면 cve값을 기록함 밑에서 찾은 cve 정보 전송하기 위해 */ | 372 | /* 찾았으면 cve값을 기록함 밑에서 찾은 cve 정보 전송하기 위해 */ |
342 | findCveList.Add(vulnSet.Key); | 373 | findCveList.Add(vulnSet.Key); |
343 | } | 374 | } |
344 | else | 375 | else |
345 | { | 376 | { |
377 | +<<<<<<<<< Temporary merge branch 1 | ||
346 | Console.WriteLine("없음"); | 378 | Console.WriteLine("없음"); |
379 | +========= | ||
380 | + Console.WriteLine("Not"); | ||
381 | +>>>>>>>>> Temporary merge branch 2 | ||
347 | } | 382 | } |
348 | } | 383 | } |
349 | stopwatch.Stop(); | 384 | stopwatch.Stop(); |
... | @@ -351,8 +386,15 @@ namespace VulnUserCodeAnalyzer | ... | @@ -351,8 +386,15 @@ namespace VulnUserCodeAnalyzer |
351 | var hours = stopwatch.Elapsed.Hours; | 386 | var hours = stopwatch.Elapsed.Hours; |
352 | var minutes = stopwatch.Elapsed.Minutes; | 387 | var minutes = stopwatch.Elapsed.Minutes; |
353 | var seconds = stopwatch.Elapsed.Seconds; | 388 | var seconds = stopwatch.Elapsed.Seconds; |
389 | +<<<<<<<<< Temporary merge branch 1 | ||
354 | Console.WriteLine($"경과 시간 {hours.ToString("00")}:{minutes.ToString("00")}:{seconds.ToString("00")}"); | 390 | Console.WriteLine($"경과 시간 {hours.ToString("00")}:{minutes.ToString("00")}:{seconds.ToString("00")}"); |
355 | Console.WriteLine($"찾은 CVE 개수 : {findCveList.Count}"); | 391 | Console.WriteLine($"찾은 CVE 개수 : {findCveList.Count}"); |
392 | +========= | ||
393 | + Console.WriteLine($"Elapsed Time : {hours.ToString("00")}:{minutes.ToString("00")}:{seconds.ToString("00")}"); | ||
394 | + Console.WriteLine($"Matched CVE Count : {findCveList.Count}"); | ||
395 | +>>>>>>>>> Temporary merge branch 2 | ||
396 | + //Console.ReadLine(); | ||
397 | + | ||
356 | var yearMatch = new Regex(@"CVE-(\d{4})-(\d+)"); | 398 | var yearMatch = new Regex(@"CVE-(\d{4})-(\d+)"); |
357 | foreach (var cve in findCveList) | 399 | foreach (var cve in findCveList) |
358 | { | 400 | { |
... | @@ -406,9 +448,15 @@ namespace VulnUserCodeAnalyzer | ... | @@ -406,9 +448,15 @@ namespace VulnUserCodeAnalyzer |
406 | 448 | ||
407 | var urlBytes = Convert.FromBase64String(findCveDict[cve].FirstOrDefault().Url); | 449 | var urlBytes = Convert.FromBase64String(findCveDict[cve].FirstOrDefault().Url); |
408 | string url = Encoding.Unicode.GetString(urlBytes); | 450 | string url = Encoding.Unicode.GetString(urlBytes); |
409 | - | 451 | +<<<<<<<<< Temporary merge branch 1 |
452 | + Console.WriteLine(findCveDict[cve].FirstOrDefault().Path.Replace(repoPath, "")); | ||
410 | /* DB 전송 */ | 453 | /* DB 전송 */ |
411 | VulnRDS.InsertVulnDetail(new VulnRDS.Vuln_detail | 454 | VulnRDS.InsertVulnDetail(new VulnRDS.Vuln_detail |
455 | +========= | ||
456 | + //Console.WriteLine(findCveDict[cve].FirstOrDefault().Path.Replace(repoPath, "")); | ||
457 | + | ||
458 | + var vulnDetail = new VulnRDS.Vuln_detail | ||
459 | +>>>>>>>>> Temporary merge branch 2 | ||
412 | { | 460 | { |
413 | CveName = data.Code, | 461 | CveName = data.Code, |
414 | Type = type, | 462 | Type = type, |
... | @@ -417,13 +465,23 @@ namespace VulnUserCodeAnalyzer | ... | @@ -417,13 +465,23 @@ namespace VulnUserCodeAnalyzer |
417 | CveDetail = data.Detail, | 465 | CveDetail = data.Detail, |
418 | Publish_date = data.Publish_Date.ToString("yyyy-MM-dd"), | 466 | Publish_date = data.Publish_Date.ToString("yyyy-MM-dd"), |
419 | Update_date = data.Update_Date.ToString("yyyy-MM-dd"), | 467 | Update_date = data.Update_Date.ToString("yyyy-MM-dd"), |
420 | - UserName = "samsung", | 468 | + UserName = userId, |
421 | Url = url, | 469 | Url = url, |
422 | - FileName = findCveDict[cve].FirstOrDefault().Path.Replace(@"C:\code", ""), | 470 | + FileName = findCveDict[cve].FirstOrDefault().Path.Replace(repoPath, ""), |
423 | FuncName = findCveDict[cve].FirstOrDefault().FuncName, | 471 | FuncName = findCveDict[cve].FirstOrDefault().FuncName, |
424 | Product = data.Type, | 472 | Product = data.Type, |
473 | +<<<<<<<<< Temporary merge branch 1 | ||
425 | }); | 474 | }); |
426 | Console.WriteLine("추가 완료"); | 475 | Console.WriteLine("추가 완료"); |
476 | +========= | ||
477 | + }; | ||
478 | + | ||
479 | + /* DB 전송 */ | ||
480 | + VulnRDS.InsertVulnDetail(vulnDetail); | ||
481 | + | ||
482 | + Console.WriteLine($"Added CVE: {vulnDetail.CveName}, Type: {vulnDetail.Type}, CVSS: {vulnDetail.Level}"); | ||
483 | +>>>>>>>>> Temporary merge branch 2 | ||
484 | + } | ||
427 | } | 485 | } |
428 | } | 486 | } |
429 | } | 487 | } | ... | ... |
-
Please register or login to post a comment