Showing
1 changed file
with
21 additions
and
12 deletions
... | @@ -86,7 +86,7 @@ namespace VulnCrawler | ... | @@ -86,7 +86,7 @@ namespace VulnCrawler |
86 | //DB insert | 86 | //DB insert |
87 | try | 87 | try |
88 | { | 88 | { |
89 | - sql = "INSERT INTO vulnInfo(vulnId, lenBlock, repositName, cve, funcName, numBlock, codeOriBefore, codeOriAfter, codeAbsBefore, codeAbsAfter, blockHash) " + | 89 | + sql = "INSERT INTO vulnInfo(vulnId, lenBlock, cve, funcName, numBlock, codeOriBefore, codeOriAfter, codeAbsBefore, codeAbsAfter, blockHash) " + |
90 | $"VALUES({last_vulnId}, {vuln.LenBlock}, '{vuln.Cve}', '{vuln.FuncName}', {vuln.NumBlock}, '{vuln.CodeOriBefore}', '{vuln.CodeOriAfter}', '{vuln.CodeAbsBefore}', '{vuln.CodeAbsAfter}', '{vuln.BlockHash}')"; | 90 | $"VALUES({last_vulnId}, {vuln.LenBlock}, '{vuln.Cve}', '{vuln.FuncName}', {vuln.NumBlock}, '{vuln.CodeOriBefore}', '{vuln.CodeOriAfter}', '{vuln.CodeAbsBefore}', '{vuln.CodeAbsAfter}', '{vuln.BlockHash}')"; |
91 | Console.WriteLine(sql); | 91 | Console.WriteLine(sql); |
92 | cmd = new MySqlCommand(sql, Conn); | 92 | cmd = new MySqlCommand(sql, Conn); |
... | @@ -147,12 +147,11 @@ namespace VulnCrawler | ... | @@ -147,12 +147,11 @@ namespace VulnCrawler |
147 | Console.WriteLine(e.StackTrace); | 147 | Console.WriteLine(e.StackTrace); |
148 | } | 148 | } |
149 | } | 149 | } |
150 | - public static Vuln SearchVulnCve(string _cve) | 150 | + public static Vuln SearchVulnCve(int _vulnId) |
151 | { | 151 | { |
152 | Vuln vuln = new Vuln(); | 152 | Vuln vuln = new Vuln(); |
153 | - Conn.Open(); | ||
154 | //특정 cve 가 있는지 검사 | 153 | //특정 cve 가 있는지 검사 |
155 | - String sql = "select * from vulnInfo where cve like '" + _cve + "'"; | 154 | + String sql = "select * from vulnInfo where cve like '" + _vulnId + "'"; |
156 | MySqlCommand cmd = new MySqlCommand(sql, Conn); | 155 | MySqlCommand cmd = new MySqlCommand(sql, Conn); |
157 | MySqlDataReader rdr = cmd.ExecuteReader(); | 156 | MySqlDataReader rdr = cmd.ExecuteReader(); |
158 | while (rdr.Read()) | 157 | while (rdr.Read()) |
... | @@ -168,19 +167,29 @@ namespace VulnCrawler | ... | @@ -168,19 +167,29 @@ namespace VulnCrawler |
168 | vuln.CodeAbsAfter = Convert.ToString(rdr["codeAbsAfter"]); | 167 | vuln.CodeAbsAfter = Convert.ToString(rdr["codeAbsAfter"]); |
169 | vuln.BlockHash = Convert.ToString(rdr["blockHash"]); | 168 | vuln.BlockHash = Convert.ToString(rdr["blockHash"]); |
170 | } | 169 | } |
171 | - Conn.Close(); | ||
172 | return vuln; | 170 | return vuln; |
173 | } | 171 | } |
174 | - public static int ReturnUserLastId() | 172 | + |
173 | + public static bool CheckVulnData(int _vulnId) | ||
175 | { | 174 | { |
176 | - Conn.Open(); | 175 | + string sql = "select count(*) from vulnInfo where vulnId like '" + _vulnId+ "'"; |
177 | - String sql = "select max(userId) from userInfo"; | ||
178 | MySqlCommand cmd = new MySqlCommand(sql, Conn); | 176 | MySqlCommand cmd = new MySqlCommand(sql, Conn); |
179 | - int last_userId = (Convert.ToInt32(cmd.ExecuteScalar())) + 1; | 177 | + int RecordCount = Convert.ToInt32(cmd.ExecuteScalar()); |
180 | - Conn.Close(); | 178 | + if (RecordCount > 0) |
181 | - return last_userId; | 179 | + return true; |
180 | + else | ||
181 | + return false; | ||
182 | + } | ||
183 | + public static bool CheckUserData(int _userId) | ||
184 | + { | ||
185 | + string sql = "select count(*) from userInfo where vulnId like '" + _userId + "'"; | ||
186 | + MySqlCommand cmd = new MySqlCommand(sql, Conn); | ||
187 | + int RecordCount = Convert.ToInt32(cmd.ExecuteScalar()); | ||
188 | + if (RecordCount > 0) | ||
189 | + return true; | ||
190 | + else | ||
191 | + return false; | ||
182 | } | 192 | } |
183 | - | ||
184 | //public static IEnumerable<string> SearchVulnData(int _len) | 193 | //public static IEnumerable<string> SearchVulnData(int _len) |
185 | //{ | 194 | //{ |
186 | // | 195 | // | ... | ... |
-
Please register or login to post a comment