Showing
3 changed files
with
10 additions
and
21 deletions
... | @@ -30,6 +30,8 @@ namespace VulnCrawler | ... | @@ -30,6 +30,8 @@ namespace VulnCrawler |
30 | Repository.Dispose(); | 30 | Repository.Dispose(); |
31 | } | 31 | } |
32 | 32 | ||
33 | + protected virtual Regex MethodExtractor => new Regex(RegexFuncPattern); | ||
34 | + | ||
33 | #region 메서드 패턴 정규식 그룹 | 35 | #region 메서드 패턴 정규식 그룹 |
34 | // 정규식 그룹화 | 36 | // 정규식 그룹화 |
35 | // @@ -oldStart,oldLines +newStart,newLines @@ MethodName(): | 37 | // @@ -oldStart,oldLines +newStart,newLines @@ MethodName(): | ... | ... |
... | @@ -10,10 +10,11 @@ namespace VulnCrawler | ... | @@ -10,10 +10,11 @@ namespace VulnCrawler |
10 | { | 10 | { |
11 | public class VulnC : VulnAbstractCrawler | 11 | public class VulnC : VulnAbstractCrawler |
12 | { | 12 | { |
13 | - protected override string RegexFuncPattern => $@"@@ \-(?<{OldStart}>\d+),(?<{OldLines}>\d+) \+(?<{NewStart}>\d+),(?<{NewLines}>\d+) @@ (?<{MethodName}>.+)"; | 13 | + protected override string RegexFuncPattern => $@"@@ \-(?<{OldStart}>\d+),(?<{OldLines}>\d+) \+(?<{NewStart}>\d+),(?<{NewLines}>\d+) @@ (?<{MethodName}>(static)? [\w]+ [\w]+)\([\w \*\,\t\n]*\)"; |
14 | 14 | ||
15 | protected override string Extension => ".c"; | 15 | protected override string Extension => ".c"; |
16 | 16 | ||
17 | + | ||
17 | public override MatchCollection GetMatches(string patchCode) { | 18 | public override MatchCollection GetMatches(string patchCode) { |
18 | var regs = Regex.Matches(patchCode, RegexFuncPattern); | 19 | var regs = Regex.Matches(patchCode, RegexFuncPattern); |
19 | return regs; | 20 | return regs; |
... | @@ -38,26 +39,8 @@ namespace VulnCrawler | ... | @@ -38,26 +39,8 @@ namespace VulnCrawler |
38 | using (var reader = new StreamReader(oldStream)) { | 39 | using (var reader = new StreamReader(oldStream)) { |
39 | int defSpace = 0; | 40 | int defSpace = 0; |
40 | while (!reader.EndOfStream) { | 41 | while (!reader.EndOfStream) { |
41 | - | ||
42 | string line = reader.ReadLine(); | 42 | string line = reader.ReadLine(); |
43 | - if (defSpace > 0) { | ||
44 | - if (line.Length < defSpace) { | ||
45 | - continue; | ||
46 | - } | ||
47 | - string concat = line.Substring(0, defSpace); | ||
48 | - if (string.IsNullOrWhiteSpace(concat)) { | ||
49 | - string trim = line.Trim(); | ||
50 | - // #으로 시작한다면 주석이니 제거 | ||
51 | - if (trim.StartsWith("#")) { | ||
52 | - continue; | ||
53 | - } | ||
54 | - oldBuilder.AppendLine(line); | ||
55 | - } else { | ||
56 | - continue; | ||
57 | - } | ||
58 | - } | ||
59 | if (Regex.Match(line, $@"{methodName}").Success) { | 43 | if (Regex.Match(line, $@"{methodName}").Success) { |
60 | - | ||
61 | defSpace = line.IndexOf(methodName); | 44 | defSpace = line.IndexOf(methodName); |
62 | oldBuilder.AppendLine(line); | 45 | oldBuilder.AppendLine(line); |
63 | } | 46 | } | ... | ... |
... | @@ -19,9 +19,13 @@ namespace VulnCrawler | ... | @@ -19,9 +19,13 @@ namespace VulnCrawler |
19 | 19 | ||
20 | protected override string Extension => ".py"; | 20 | protected override string Extension => ".py"; |
21 | protected override string RegexFuncPattern => $@"@@ \-(?<{OldStart}>\d+),(?<{OldLines}>\d+) \+(?<{NewStart}>\d+),(?<{NewLines}>\d+) @@ def (?<{MethodName}>\w+)"; | 21 | protected override string RegexFuncPattern => $@"@@ \-(?<{OldStart}>\d+),(?<{OldLines}>\d+) \+(?<{NewStart}>\d+),(?<{NewLines}>\d+) @@ def (?<{MethodName}>\w+)"; |
22 | - | 22 | + |
23 | + // protected override Regex MethodExtractor => new Regex(RegexFuncPattern); | ||
24 | + | ||
25 | + | ||
23 | public override MatchCollection GetMatches(string patchCode) { | 26 | public override MatchCollection GetMatches(string patchCode) { |
24 | - var regs = Regex.Matches(patchCode, RegexFuncPattern); | 27 | + //var regs = Regex.Matches(patchCode, RegexFuncPattern); |
28 | + var regs = MethodExtractor.Matches(patchCode); | ||
25 | return regs; | 29 | return regs; |
26 | } | 30 | } |
27 | 31 | ... | ... |
-
Please register or login to post a comment