| 31 | import org.parosproxy.paros.db.TableAlert; |
| 32 | |
| 33 | public class SqlTableAlert extends SqlAbstractTable implements TableAlert { |
| 34 | |
| 35 | private static final String TABLE_NAME = DbSQL.getSQL("alert.table_name"); |
| 36 | |
| 37 | private static final String ALERT_INDEX = DbSQL.getSQL("alert.field.alert_index"); |
| 38 | private static final String ALERTID = DbSQL.getSQL("alert.field.alertid"); |
| 39 | private static final String SCANID = DbSQL.getSQL("alert.field.scanid"); |
| 40 | private static final String PLUGINID = DbSQL.getSQL("alert.field.pluginid"); |
| 41 | private static final String ALERT = DbSQL.getSQL("alert.field.alert"); |
| 42 | private static final String RISK = DbSQL.getSQL("alert.field.risk"); |
| 43 | private static final String RELIABILITY = DbSQL.getSQL("alert.field.reliability"); |
| 44 | private static final String DESCRIPTION = DbSQL.getSQL("alert.field.description"); |
| 45 | private static final String URI = DbSQL.getSQL("alert.field.uri"); |
| 46 | private static final String PARAM = DbSQL.getSQL("alert.field.param"); |
| 47 | private static final String ATTACK = DbSQL.getSQL("alert.field.attack"); |
| 48 | private static final String OTHERINFO = DbSQL.getSQL("alert.field.otherinfo"); |
| 49 | private static final String SOLUTION = DbSQL.getSQL("alert.field.solution"); |
| 50 | private static final String REFERENCE = DbSQL.getSQL("alert.field.reference"); |
| 51 | private static final String EVIDENCE = DbSQL.getSQL("alert.field.evidence"); |
| 52 | private static final String INPUT_VECTOR = DbSQL.getSQL("alert.field.inputvector"); |
| 53 | private static final String CWEID = DbSQL.getSQL("alert.field.cweid"); |
| 54 | private static final String WASCID = DbSQL.getSQL("alert.field.wascid"); |
| 55 | private static final String HISTORYID = DbSQL.getSQL("alert.field.historyid"); |
| 56 | private static final String SOURCEHISTORYID = DbSQL.getSQL("alert.field.sourcehistoryid"); |
| 57 | private static final String SOURCEID = DbSQL.getSQL("alert.field.sourceid"); |
| 58 | private static final String ALERTREF = DbSQL.getSQL("alert.field.alertref"); |
| 59 | private static final String NODENAME = DbSQL.getSQL("alert.field.nodename"); |
| 60 | |
| 61 | public SqlTableAlert() {} |
| 62 | |
| 63 | @Override |
| 64 | protected void reconnect(Connection conn) throws DatabaseException { |
| 65 | try { |
| 66 | updateTable(conn); |
| 67 | } catch (Exception e) { |
| 68 | throw new DatabaseException(e); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | // ZAP: Added the method. |
| 73 | private void updateTable(Connection connection) throws DatabaseException { |
| 74 | try { |
| 75 | // Add the SOURCEHISTORYID column to the db if necessary |
| 76 | if (!DbUtils.hasColumn(connection, TABLE_NAME, SOURCEHISTORYID)) { |
| 77 | DbUtils.execute(connection, DbSQL.getSQL("alert.ps.addsourcehistoryid")); |
| 78 | } |
| 79 | |
| 80 | // Add the ATTACK column to the db if necessary |
| 81 | if (!DbUtils.hasColumn(connection, TABLE_NAME, ATTACK)) { |
| 82 | DbUtils.execute(connection, DbSQL.getSQL("alert.ps.addattack")); |
| 83 | } |
| 84 | |
| 85 | if (!DbUtils.hasColumn(connection, TABLE_NAME, EVIDENCE)) { |
| 86 | // Evidence, cweId and wascId all added at the same time |
| 87 | DbUtils.execute(connection, DbSQL.getSQL("alert.ps.addevidence")); |
| 88 | DbUtils.execute(connection, DbSQL.getSQL("alert.ps.addcweid")); |
| 89 | DbUtils.execute(connection, DbSQL.getSQL("alert.ps.addwascid")); |
| 90 | } |