이지윤

db 수정

...@@ -31,7 +31,6 @@ namespace VulnCrawler ...@@ -31,7 +31,6 @@ namespace VulnCrawler
31 public string RepositName { get; set; } = "NULL"; /* 유저 레파지토리 이름 */ 31 public string RepositName { get; set; } = "NULL"; /* 유저 레파지토리 이름 */
32 public int VulnId { get; set; } = -1; /* 취약점 vuln ID */ 32 public int VulnId { get; set; } = -1; /* 취약점 vuln ID */
33 } 33 }
34 - //
35 public class _Vuln 34 public class _Vuln
36 { 35 {
37 public int VulnId { get; set; } = -1; /* 취약점 ID */ 36 public int VulnId { get; set; } = -1; /* 취약점 ID */
...@@ -63,15 +62,14 @@ namespace VulnCrawler ...@@ -63,15 +62,14 @@ namespace VulnCrawler
63 public static void InsertVulnData(Vuln vuln) 62 public static void InsertVulnData(Vuln vuln)
64 { 63 {
65 String sql = string.Empty; 64 String sql = string.Empty;
66 - // vulnId setting (마지막 vulnId +1)
67 MySqlCommand cmd = null; 65 MySqlCommand cmd = null;
68 66
67 + // vulnId setting (마지막 vulnId +1)
69 int last_vulnId = 1; 68 int last_vulnId = 1;
70 try 69 try
71 { 70 {
72 sql = "select max(vulnId) from vulnInfo"; 71 sql = "select max(vulnId) from vulnInfo";
73 cmd = new MySqlCommand(sql, Conn); 72 cmd = new MySqlCommand(sql, Conn);
74 -
75 last_vulnId = (Convert.ToInt32(cmd.ExecuteScalar())) + 1; 73 last_vulnId = (Convert.ToInt32(cmd.ExecuteScalar())) + 1;
76 } 74 }
77 catch(Exception) 75 catch(Exception)
...@@ -133,7 +131,7 @@ namespace VulnCrawler ...@@ -133,7 +131,7 @@ namespace VulnCrawler
133 cmd.Parameters.AddWithValue("@vulnId", last_vulnId); 131 cmd.Parameters.AddWithValue("@vulnId", last_vulnId);
134 cmd.Parameters.AddWithValue("@cve", $"'{vuln.Cve}'"); 132 cmd.Parameters.AddWithValue("@cve", $"'{vuln.Cve}'");
135 cmd.Parameters.AddWithValue("@funcName", $"'{vuln.FuncName}'"); 133 cmd.Parameters.AddWithValue("@funcName", $"'{vuln.FuncName}'");
136 - cmd.Parameters.AddWithValue("@lenFunc", $"'{vuln.LenFunc}'"); 134 + cmd.Parameters.AddWithValue("@lenFunc", $"{vuln.LenFunc}");
137 cmd.Parameters.AddWithValue("@code", $"'{vuln.Code}'"); 135 cmd.Parameters.AddWithValue("@code", $"'{vuln.Code}'");
138 cmd.Parameters.AddWithValue("@blockHash", $"'{vuln.BlockHash}'"); 136 cmd.Parameters.AddWithValue("@blockHash", $"'{vuln.BlockHash}'");
139 cmd.Parameters.AddWithValue("@url", $"'{vuln.Url}'"); 137 cmd.Parameters.AddWithValue("@url", $"'{vuln.Url}'");
...@@ -185,7 +183,7 @@ namespace VulnCrawler ...@@ -185,7 +183,7 @@ namespace VulnCrawler
185 cmd.CommandText = "INSERT INTO userInfo(userId, repositName, vulnId) VALUES(@userId, @repositName, @vulnId)"; 183 cmd.CommandText = "INSERT INTO userInfo(userId, repositName, vulnId) VALUES(@userId, @repositName, @vulnId)";
186 cmd.Parameters.AddWithValue("@userId", last_userId); 184 cmd.Parameters.AddWithValue("@userId", last_userId);
187 cmd.Parameters.AddWithValue("@repositName", $"'{user.RepositName}'"); 185 cmd.Parameters.AddWithValue("@repositName", $"'{user.RepositName}'");
188 - cmd.Parameters.AddWithValue("@vulnInfo", $"'{user.VulnId}'"); 186 + cmd.Parameters.AddWithValue("@vulnInfo", $"{user.VulnId}");
189 cmd.ExecuteNonQuery(); 187 cmd.ExecuteNonQuery();
190 //콘솔출력용 188 //콘솔출력용
191 sql = "INSERT INTO userInfo(userId, repositName, vulnId) " + $"VALUES({last_userId},'{user.RepositName}','{user.VulnId}')"; 189 sql = "INSERT INTO userInfo(userId, repositName, vulnId) " + $"VALUES({last_userId},'{user.RepositName}','{user.VulnId}')";
...@@ -215,11 +213,11 @@ namespace VulnCrawler ...@@ -215,11 +213,11 @@ namespace VulnCrawler
215 cmd = new MySqlCommand(); 213 cmd = new MySqlCommand();
216 cmd.Connection = Conn; 214 cmd.Connection = Conn;
217 //해당 vuln Update 215 //해당 vuln Update
218 - cmd.CommandText = "UPDATE vuln_Info SET cve=@cve,funName=@funName,lenFunc=@lenFunc,code=@code,blockHash=@blockHash,url=@url WHERE vulnId=@vunId"; 216 + cmd.CommandText = "UPDATE vuln_Info SET cve=@cve,funcName=@funcName,lenFunc=@lenFunc,code=@code,blockHash=@blockHash,url=@url WHERE vulnId=@vulnId";
219 cmd.Parameters.AddWithValue("@vulnId", _vulnId); 217 cmd.Parameters.AddWithValue("@vulnId", _vulnId);
220 cmd.Parameters.AddWithValue("@cve", $"'{vuln.Cve}'"); 218 cmd.Parameters.AddWithValue("@cve", $"'{vuln.Cve}'");
221 cmd.Parameters.AddWithValue("@funcName", $"'{vuln.FuncName}'"); 219 cmd.Parameters.AddWithValue("@funcName", $"'{vuln.FuncName}'");
222 - cmd.Parameters.AddWithValue("@lenFunc", $"'{vuln.LenFunc}'"); 220 + cmd.Parameters.AddWithValue("@lenFunc", $"{vuln.LenFunc}");
223 cmd.Parameters.AddWithValue("@code", $"'{vuln.Code}'"); 221 cmd.Parameters.AddWithValue("@code", $"'{vuln.Code}'");
224 cmd.Parameters.AddWithValue("@blockHash", $"'{vuln.BlockHash}'"); 222 cmd.Parameters.AddWithValue("@blockHash", $"'{vuln.BlockHash}'");
225 cmd.Parameters.AddWithValue("@url", $"'{vuln.Url}'"); 223 cmd.Parameters.AddWithValue("@url", $"'{vuln.Url}'");
......