노현종
...@@ -16,28 +16,19 @@ namespace VulnCrawler ...@@ -16,28 +16,19 @@ namespace VulnCrawler
16 /// </summary> 16 /// </summary>
17 public class VulnPython : VulnAbstractCrawler 17 public class VulnPython : VulnAbstractCrawler
18 { 18 {
19 -
20 protected override string Extension => ".py"; 19 protected override string Extension => ".py";
21 protected override string RegexFuncPattern => $@"@@ \-(?<{OldStart}>\d+),(?<{OldLines}>\d+) \+(?<{NewStart}>\d+),(?<{NewLines}>\d+) @@ def (?<{MethodName}>\w+)"; 20 protected override string RegexFuncPattern => $@"@@ \-(?<{OldStart}>\d+),(?<{OldLines}>\d+) \+(?<{NewStart}>\d+),(?<{NewLines}>\d+) @@ def (?<{MethodName}>\w+)";
22 -
23 -
24 protected override string ReservedFileName => "PyReserved.txt"; 21 protected override string ReservedFileName => "PyReserved.txt";
25 -
26 - // protected override Regex MethodExtractor => new Regex(RegexFuncPattern);
27 -
28 -
29 public override MatchCollection GetMatches(string patchCode) { 22 public override MatchCollection GetMatches(string patchCode) {
30 //var regs = Regex.Matches(patchCode, RegexFuncPattern); 23 //var regs = Regex.Matches(patchCode, RegexFuncPattern);
31 var regs = MethodExtractor.Matches(patchCode); 24 var regs = MethodExtractor.Matches(patchCode);
32 return regs; 25 return regs;
33 } 26 }
34 -
35 protected override string GetOriginalFunc(Stream oldStream, string methodName) { 27 protected override string GetOriginalFunc(Stream oldStream, string methodName) {
36 StringBuilder oldBuilder = new StringBuilder(); 28 StringBuilder oldBuilder = new StringBuilder();
37 using (var reader = new StreamReader(oldStream)) { 29 using (var reader = new StreamReader(oldStream)) {
38 int defSpace = 0; 30 int defSpace = 0;
39 while (!reader.EndOfStream) { 31 while (!reader.EndOfStream) {
40 -
41 string line = reader.ReadLine(); 32 string line = reader.ReadLine();
42 if (defSpace > 0) { 33 if (defSpace > 0) {
43 if (line.Length < defSpace) { 34 if (line.Length < defSpace) {
...@@ -65,12 +56,8 @@ namespace VulnCrawler ...@@ -65,12 +56,8 @@ namespace VulnCrawler
65 } 56 }
66 return oldBuilder.ToString(); 57 return oldBuilder.ToString();
67 } 58 }
68 -
69 -
70 public override string RemoveComment(string original) { 59 public override string RemoveComment(string original) {
71 -
72 string txt = Regex.Replace(original, Environment.NewLine, ""); 60 string txt = Regex.Replace(original, Environment.NewLine, "");
73 -
74 StringBuilder sb = new StringBuilder(); 61 StringBuilder sb = new StringBuilder();
75 sb.Append("\"\"\""); 62 sb.Append("\"\"\"");
76 sb.Append(@".*"); 63 sb.Append(@".*");
...@@ -81,7 +68,5 @@ namespace VulnCrawler ...@@ -81,7 +68,5 @@ namespace VulnCrawler
81 } 68 }
82 return replace; 69 return replace;
83 } 70 }
84 -
85 -
86 } 71 }
87 } 72 }
......