use of org.parosproxy.paros.db.RecordAlert in project zaproxy by zaproxy.
the class ExtensionAlert method writeAlertToDB.
private void writeAlertToDB(Alert alert, HistoryReference ref) throws HttpMalformedHeaderException, DatabaseException {
TableAlert tableAlert = getModel().getDb().getTableAlert();
int scanId = 0;
if (recordScan != null) {
scanId = recordScan.getScanId();
}
RecordAlert recordAlert = tableAlert.write(scanId, alert.getPluginId(), alert.getName(), alert.getRisk(), alert.getConfidence(), alert.getDescription(), alert.getUri(), alert.getParam(), alert.getAttack(), alert.getOtherInfo(), alert.getSolution(), alert.getReference(), alert.getEvidence(), alert.getCweId(), alert.getWascId(), ref.getHistoryId(), alert.getSourceHistoryId(), alert.getSource().getId());
alert.setAlertId(recordAlert.getAlertId());
}
use of org.parosproxy.paros.db.RecordAlert in project zaproxy by zaproxy.
the class SqlTableAlert method read.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableAlert#read(int)
*/
@Override
public synchronized RecordAlert read(int alertId) throws DatabaseException {
SqlPreparedStatementWrapper psRead = null;
try {
psRead = DbSQL.getSingleton().getPreparedStatement("alert.ps.read");
psRead.getPs().setInt(1, alertId);
try (ResultSet rs = psRead.getPs().executeQuery()) {
RecordAlert ra = build(rs);
return ra;
}
} catch (Exception e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psRead);
}
}
use of org.parosproxy.paros.db.RecordAlert in project zaproxy by zaproxy.
the class SqlTableAlert method getAlertsBySourceHistoryId.
/* (non-Javadoc)
* @see org.parosproxy.paros.db.paros.TableAlert#getAlertsBySourceHistoryId(int)
*/
@Override
public List<RecordAlert> getAlertsBySourceHistoryId(int historyId) throws DatabaseException {
SqlPreparedStatementWrapper psGetAlertsForHistoryId = null;
try {
psGetAlertsForHistoryId = DbSQL.getSingleton().getPreparedStatement("alert.ps.getalertsforhistoryid");
List<RecordAlert> result = new ArrayList<>();
psGetAlertsForHistoryId.getPs().setLong(1, historyId);
try (ResultSet rs = psGetAlertsForHistoryId.getPs().executeQuery()) {
RecordAlert ra = build(rs);
while (ra != null) {
result.add(ra);
ra = build(rs);
}
}
return result;
} catch (SQLException e) {
throw new DatabaseException(e);
} finally {
DbSQL.getSingleton().releasePreparedStatement(psGetAlertsForHistoryId);
}
}
Aggregations