이지윤

vuln_Detail 추가

...@@ -53,6 +53,16 @@ namespace VulnCrawler ...@@ -53,6 +53,16 @@ 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 CveName { get; set; } = "NULL"; /* cve name */
64 +
65 + }
56 //connect 66 //connect
57 public static void Connect(AWS.Account account, string dbName) 67 public static void Connect(AWS.Account account, string dbName)
58 { 68 {
...@@ -214,6 +224,44 @@ namespace VulnCrawler ...@@ -214,6 +224,44 @@ namespace VulnCrawler
214 Console.ReadLine(); 224 Console.ReadLine();
215 } 225 }
216 } 226 }
227 + public static void InsertVulnDetail(Vuln_detail vuln)
228 + {
229 + String sql = string.Empty;
230 + MySqlCommand cmd = null;
231 + Retry:
232 + //DB insert
233 + try
234 + {
235 + cmd = new MySqlCommand
236 + {
237 + Connection = Conn,
238 + //db에 추가
239 + CommandText = "INSERT INTO vulnDetail(type, year, level, userName, cveName) VALUES(@type, @year, @level, @userName, @cveName)"
240 + };
241 + cmd.Parameters.AddWithValue("@type", $"{vuln.Type}");
242 + cmd.Parameters.AddWithValue("@year", $"{vuln.Year}");
243 + cmd.Parameters.AddWithValue("@level", $"{vuln.Level}");
244 + cmd.Parameters.AddWithValue("@userName", $"{vuln.UserName}");
245 + cmd.Parameters.AddWithValue("@cveName", $"{vuln.CveName}");
246 + cmd.ExecuteNonQuery();
247 + //콘솔출력용
248 + sql = "INSERT INTO vulnDetail(type, year, level, userName, cveName) " +
249 + $"VALUES({vuln.Type}, {vuln.Year}, {vuln.Level}, {vuln.UserName}, {vuln.CveName})";
250 + Console.WriteLine(sql);
251 +
252 + }
253 + catch (Exception e)
254 + {
255 + Console.WriteLine(e.ToString());
256 + string es = e.ToString();
257 + if (es.Contains("Connection must be valid and open"))
258 + {
259 + Connect(Account, DbName);
260 + goto Retry;
261 + }
262 + }
263 + }
264 +
217 public static void UpdateVulnData(int _vulnId, _Vuln vuln) { 265 public static void UpdateVulnData(int _vulnId, _Vuln vuln) {
218 String sql = string.Empty; 266 String sql = string.Empty;
219 MySqlCommand cmd = null; 267 MySqlCommand cmd = null;
......