Search code examples
owaspzap

Can I access to Alerts Object of OWASP ZAP?


In Stand Alone Script, how can I access to Alerts Object (mean get all info of Alerts show in the screenshot below)?

enter image description here

Thanks,


Solution

  • I've just submitted a PR for the ZAP community-scripts for a script that does this :) https://github.com/zaproxy/community-scripts/pull/100/files

    extAlert = org.parosproxy.paros.control.Control.getSingleton().
        getExtensionLoader().getExtension(
            org.zaproxy.zap.extension.alert.ExtensionAlert.NAME) 
    if (extAlert != null) {
        var Alert = org.parosproxy.paros.core.scanner.Alert
        var alerts = extAlert.getAllAlerts()
        for (var i = 0; i < alerts.length; i++) {
            var alert = alerts[i]
            print (alert.uri)
            print ('\tName:\t' + alert.name)
            print ('\tRisk:\t' + Alert.MSG_RISK[alert.risk])
            print ('\tConfidence:\t' + Alert.MSG_CONFIDENCE[alert.confidence])
            // For more alert properties see https://static.javadoc.io/org.zaproxy/zap/2.7.0/org/parosproxy/paros/core/scanner/Alert.html
        }
    }