Search in sources :

Example 6 with RecordAlert

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());
}
Also used : TableAlert(org.parosproxy.paros.db.TableAlert) RecordAlert(org.parosproxy.paros.db.RecordAlert)

Example 7 with RecordAlert

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);
    }
}
Also used : ResultSet(java.sql.ResultSet) DatabaseException(org.parosproxy.paros.db.DatabaseException) RecordAlert(org.parosproxy.paros.db.RecordAlert) SQLException(java.sql.SQLException) DatabaseException(org.parosproxy.paros.db.DatabaseException)

Example 8 with RecordAlert

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);
    }
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) ResultSet(java.sql.ResultSet) DatabaseException(org.parosproxy.paros.db.DatabaseException) RecordAlert(org.parosproxy.paros.db.RecordAlert)

Aggregations

RecordAlert (org.parosproxy.paros.db.RecordAlert)8 DatabaseException (org.parosproxy.paros.db.DatabaseException)6 ArrayList (java.util.ArrayList)5 TableAlert (org.parosproxy.paros.db.TableAlert)5 Alert (org.parosproxy.paros.core.scanner.Alert)4 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 ExtensionAlert (org.zaproxy.zap.extension.alert.ExtensionAlert)2 Enumeration (java.util.Enumeration)1 List (java.util.List)1 RecordHistory (org.parosproxy.paros.db.RecordHistory)1 TableHistory (org.parosproxy.paros.db.TableHistory)1 ExtensionHistory (org.parosproxy.paros.extension.history.ExtensionHistory)1 HistoryReference (org.parosproxy.paros.model.HistoryReference)1 Session (org.parosproxy.paros.model.Session)1 SiteMap (org.parosproxy.paros.model.SiteMap)1 SiteNode (org.parosproxy.paros.model.SiteNode)1 HttpMalformedHeaderException (org.parosproxy.paros.network.HttpMalformedHeaderException)1