Merge branch 'master' of https://github.com/yhackerbv/VulnNottiProject
Showing
1 changed file
with
81 additions
and
0 deletions
... | @@ -53,6 +53,22 @@ namespace VulnCrawler | ... | @@ -53,6 +53,22 @@ namespace VulnCrawler |
53 | return 802558182 + EqualityComparer<string>.Default.GetHashCode(BlockHash); | 53 | return 802558182 + EqualityComparer<string>.Default.GetHashCode(BlockHash); |
54 | } | 54 | } |
55 | } | 55 | } |
56 | + public class Vuln_detail | ||
57 | + { | ||
58 | + public int Index { get; set; } = -1; /* index key */ | ||
59 | + public string Type { get; set; } = "NULL"; /* type */ | ||
60 | + public string Year { get; set; } = "NULL"; /* year */ | ||
61 | + public string Level { get; set; } = "NULL"; /* level */ | ||
62 | + public string UserName { get; set; } = "NULL"; /* user name */ | ||
63 | + public string Publish_date { get; set; } = "NULL"; /* Publish_date */ | ||
64 | + public string Update_date { get; set; } = "NULL"; /* Update_date */ | ||
65 | + public string CveDetail { get; set; } = "NULL"; /* cveDetail */ | ||
66 | + public string CveName { get; set; } = "NULL"; /* cve name */ | ||
67 | + public string FileName { get; set; } = "NULL"; /* FileName */ | ||
68 | + public string FuncName { get; set; } = "NULL"; /* funcName */ | ||
69 | + public string Url { get; set; } = "NULL"; /* Url */ | ||
70 | + | ||
71 | + } | ||
56 | //connect | 72 | //connect |
57 | public static void Connect(AWS.Account account, string dbName) | 73 | public static void Connect(AWS.Account account, string dbName) |
58 | { | 74 | { |
... | @@ -214,6 +230,50 @@ namespace VulnCrawler | ... | @@ -214,6 +230,50 @@ namespace VulnCrawler |
214 | Console.ReadLine(); | 230 | Console.ReadLine(); |
215 | } | 231 | } |
216 | } | 232 | } |
233 | + public static void InsertVulnDetail(Vuln_detail vuln) | ||
234 | + { | ||
235 | + String sql = string.Empty; | ||
236 | + MySqlCommand cmd = null; | ||
237 | + Retry: | ||
238 | + //DB insert | ||
239 | + try | ||
240 | + { | ||
241 | + cmd = new MySqlCommand | ||
242 | + { | ||
243 | + Connection = Conn, | ||
244 | + //db에 추가 | ||
245 | + CommandText = "INSERT INTO vulnDetail(type, year, level, userName, cveName, publish_date,update_date, cveDetail,fileName, funcName, url) VALUES(@type, @year, @level, @userName, @cveName, @publish_date,@update_date, @cveDetail,@fileName, @funcName,@url)" | ||
246 | + }; | ||
247 | + cmd.Parameters.AddWithValue("@type", $"{vuln.Type}"); | ||
248 | + cmd.Parameters.AddWithValue("@year", $"{vuln.Year}"); | ||
249 | + cmd.Parameters.AddWithValue("@level", $"{vuln.Level}"); | ||
250 | + cmd.Parameters.AddWithValue("@userName", $"{vuln.UserName}"); | ||
251 | + cmd.Parameters.AddWithValue("@cveName", $"{vuln.CveName}"); | ||
252 | + cmd.Parameters.AddWithValue("@publish_date", $"{vuln.Publish_date}"); | ||
253 | + cmd.Parameters.AddWithValue("@update_date", $"{vuln.Update_date}"); | ||
254 | + cmd.Parameters.AddWithValue("@cveDetail", $"{vuln.CveDetail}"); | ||
255 | + cmd.Parameters.AddWithValue("@fileName", $"{vuln.FileName}"); | ||
256 | + cmd.Parameters.AddWithValue("@funcName", $"{vuln.FuncName}"); | ||
257 | + cmd.Parameters.AddWithValue("@url", $"{vuln.Url}"); | ||
258 | + | ||
259 | + cmd.ExecuteNonQuery(); | ||
260 | + //콘솔출력용 | ||
261 | + sql = "INSERT INTO vulnDetail(type, year, level, userName, cveName, publish_date,update_date, cveDetail,fileName, funcName, url) " + | ||
262 | + $"VALUES({vuln.Type}, {vuln.Year}, {vuln.Level}, {vuln.UserName}, {vuln.CveName},{vuln.Publish_date}, {vuln.Update_date}, {vuln.CveDetail}, {vuln.FileName}, {vuln.FuncName}, {vuln.Url})"; | ||
263 | + Console.WriteLine(sql); | ||
264 | + } | ||
265 | + catch (Exception e) | ||
266 | + { | ||
267 | + Console.WriteLine(e.ToString()); | ||
268 | + string es = e.ToString(); | ||
269 | + if (es.Contains("Connection must be valid and open")) | ||
270 | + { | ||
271 | + Connect(Account, DbName); | ||
272 | + goto Retry; | ||
273 | + } | ||
274 | + } | ||
275 | + } | ||
276 | + | ||
217 | public static void UpdateVulnData(int _vulnId, _Vuln vuln) { | 277 | public static void UpdateVulnData(int _vulnId, _Vuln vuln) { |
218 | String sql = string.Empty; | 278 | String sql = string.Empty; |
219 | MySqlCommand cmd = null; | 279 | MySqlCommand cmd = null; |
... | @@ -452,5 +512,26 @@ namespace VulnCrawler | ... | @@ -452,5 +512,26 @@ namespace VulnCrawler |
452 | yield return vuln; | 512 | yield return vuln; |
453 | } | 513 | } |
454 | } | 514 | } |
515 | + public static IEnumerable<string> SelectRepositbyName(string _username) | ||
516 | + { | ||
517 | + String sql = string.Empty; | ||
518 | + MySqlCommand cmd = new MySqlCommand(); | ||
519 | + cmd.Connection = Conn; | ||
520 | + cmd.CommandText = "SELECT repository FROM vuln.auth_user WHERE username = '" + _username + "'"; | ||
521 | + string a = null; | ||
522 | + | ||
523 | + //sql console write 확인용 | ||
524 | + Console.Write(cmd.CommandText); | ||
525 | + | ||
526 | + System.Data.DataSet ds = new System.Data.DataSet(); | ||
527 | + MySqlDataAdapter da = new MySqlDataAdapter(cmd.CommandText, Conn); | ||
528 | + da.Fill(ds); | ||
529 | + //string을 넣음 | ||
530 | + foreach (System.Data.DataRow row in ds.Tables[0].Rows) | ||
531 | + { | ||
532 | + a = Convert.ToString(row["repository"]); | ||
533 | + yield return a; | ||
534 | + } | ||
535 | + } | ||
455 | } | 536 | } |
456 | } | 537 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment