zaproxy
Version:
ZAP API Client for Node.js
301 lines (285 loc) • 13.3 kB
JavaScript
/* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2023 the ZAP development team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* This file was automatically generated.
*/
function AlertFilter (clientApi) {
this.api = clientApi
}
/**
* Lists the alert filters of the context with the given ID.
* This component is optional and therefore the API will only work if it is installed
* @param {string} contextid - The numeric ID of the context for which the filters should be listed.
**/
AlertFilter.prototype.alertFilterList = function (args) {
return this.api.request('/alertFilter/view/alertFilterList/', { contextId: args.contextid })
}
/**
* Lists the global alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.globalAlertFilterList = function () {
return this.api.request('/alertFilter/view/globalAlertFilterList/')
}
/**
* Adds a new alert filter for the context with the given ID.
* This component is optional and therefore the API will only work if it is installed
* @param {string} contextid - The numeric ID of the context for which the filter should be added.
* @param {string} ruleid - The numeric ID of the rule for which the filter should apply.
* @param {string} newlevel - The numeric risk representation ('0 - Informational' through '3 - High') ['-1 - False Positive'].
* @param {string} url - The URL for which the filter should apply (can be regex).
* @param {string} urlisregex - A boolean indicating whether or not the URL is a regex.
* @param {string} parameter - The parameter name for which the filter should apply (can be regex).
* @param {string} enabled - A boolean indicating whether or not the filter should be enabled.
* @param {string} parameterisregex - A boolean indicating whether or not the parameter name is a regex.
* @param {string} attack - The attack value for which the filter should apply (can be regex).
* @param {string} attackisregex - A boolean indicating whether or not the attack value is a regex.
* @param {string} evidence - The evidence value for which the filter should apply (can be regex).
* @param {string} evidenceisregex - A boolean indicating whether or not the evidence value is a regex.
* @param {string} methods - The HTTP methods (comma separated) for which the filter should apply.
**/
AlertFilter.prototype.addAlertFilter = function (args) {
const params = { contextId: args.contextid, ruleId: args.ruleid, newLevel: args.newlevel }
if (args.url && args.url !== null) {
params.url = args.url
}
if (args.urlisregex && args.urlisregex !== null) {
params.urlIsRegex = args.urlisregex
}
if (args.parameter && args.parameter !== null) {
params.parameter = args.parameter
}
if (args.enabled && args.enabled !== null) {
params.enabled = args.enabled
}
if (args.parameterisregex && args.parameterisregex !== null) {
params.parameterIsRegex = args.parameterisregex
}
if (args.attack && args.attack !== null) {
params.attack = args.attack
}
if (args.attackisregex && args.attackisregex !== null) {
params.attackIsRegex = args.attackisregex
}
if (args.evidence && args.evidence !== null) {
params.evidence = args.evidence
}
if (args.evidenceisregex && args.evidenceisregex !== null) {
params.evidenceIsRegex = args.evidenceisregex
}
if (args.methods && args.methods !== null) {
params.methods = args.methods
}
return this.api.request('/alertFilter/action/addAlertFilter/', params)
}
/**
* Removes an alert filter from the context with the given ID.
* This component is optional and therefore the API will only work if it is installed
* @param {string} contextid - The numeric ID of the context for which the filter should be removed.
* @param {string} ruleid - The numeric ID of the rule for which the filter applies.
* @param {string} newlevel - The numeric risk representation ('0 - Informational' through '3 - High') ['-1 - False Positive'].
* @param {string} url - The URL for which the filter applies (can be regex).
* @param {string} urlisregex - A boolean indicating whether or not the URL is a regex.
* @param {string} parameter - The parameter name for which the filter applies (can be regex).
* @param {string} enabled - A boolean indicating whether or not the filter should be enabled.
* @param {string} parameterisregex - A boolean indicating whether or not the parameter name is a regex.
* @param {string} attack - The attack value for which the filter applies (can be regex).
* @param {string} attackisregex - A boolean indicating whether or not the attack value is a regex.
* @param {string} evidence - The evidence value for which the filter applies (can be regex).
* @param {string} evidenceisregex - A boolean indicating whether or not the evidence value is a regex.
* @param {string} methods - The HTTP methods (comma separated) for which the filter applies.
**/
AlertFilter.prototype.removeAlertFilter = function (args) {
const params = { contextId: args.contextid, ruleId: args.ruleid, newLevel: args.newlevel }
if (args.url && args.url !== null) {
params.url = args.url
}
if (args.urlisregex && args.urlisregex !== null) {
params.urlIsRegex = args.urlisregex
}
if (args.parameter && args.parameter !== null) {
params.parameter = args.parameter
}
if (args.enabled && args.enabled !== null) {
params.enabled = args.enabled
}
if (args.parameterisregex && args.parameterisregex !== null) {
params.parameterIsRegex = args.parameterisregex
}
if (args.attack && args.attack !== null) {
params.attack = args.attack
}
if (args.attackisregex && args.attackisregex !== null) {
params.attackIsRegex = args.attackisregex
}
if (args.evidence && args.evidence !== null) {
params.evidence = args.evidence
}
if (args.evidenceisregex && args.evidenceisregex !== null) {
params.evidenceIsRegex = args.evidenceisregex
}
if (args.methods && args.methods !== null) {
params.methods = args.methods
}
return this.api.request('/alertFilter/action/removeAlertFilter/', params)
}
/**
* Adds a new global alert filter.
* This component is optional and therefore the API will only work if it is installed
* @param {string} ruleid - The numeric ID of the rule for which the filter should apply.
* @param {string} newlevel - The numeric risk representation ('0 - Informational' through '3 - High') ['-1 - False Positive'].
* @param {string} url - The URL for which the filter should apply (can be regex).
* @param {string} urlisregex - A boolean indicating whether or not the URL is a regex.
* @param {string} parameter - The parameter name for which the filter should apply (can be regex).
* @param {string} enabled - A boolean indicating whether or not the filter should be enabled.
* @param {string} parameterisregex - A boolean indicating whether or not the parameter name is a regex.
* @param {string} attack - The attack value for which the filter should apply (can be regex).
* @param {string} attackisregex - A boolean indicating whether or not the attack value is a regex.
* @param {string} evidence - The evidence value for which the filter should apply (can be regex).
* @param {string} evidenceisregex - A boolean indicating whether or not the evidence value is a regex.
* @param {string} methods - The HTTP methods (comma separated) for which the filter should apply.
**/
AlertFilter.prototype.addGlobalAlertFilter = function (args) {
const params = { ruleId: args.ruleid, newLevel: args.newlevel }
if (args.url && args.url !== null) {
params.url = args.url
}
if (args.urlisregex && args.urlisregex !== null) {
params.urlIsRegex = args.urlisregex
}
if (args.parameter && args.parameter !== null) {
params.parameter = args.parameter
}
if (args.enabled && args.enabled !== null) {
params.enabled = args.enabled
}
if (args.parameterisregex && args.parameterisregex !== null) {
params.parameterIsRegex = args.parameterisregex
}
if (args.attack && args.attack !== null) {
params.attack = args.attack
}
if (args.attackisregex && args.attackisregex !== null) {
params.attackIsRegex = args.attackisregex
}
if (args.evidence && args.evidence !== null) {
params.evidence = args.evidence
}
if (args.evidenceisregex && args.evidenceisregex !== null) {
params.evidenceIsRegex = args.evidenceisregex
}
if (args.methods && args.methods !== null) {
params.methods = args.methods
}
return this.api.request('/alertFilter/action/addGlobalAlertFilter/', params)
}
/**
* Removes a global alert filter.
* This component is optional and therefore the API will only work if it is installed
* @param {string} ruleid - The numeric ID of the rule for which the filter applies.
* @param {string} newlevel - The numeric risk representation ('0 - Informational' through '3 - High') ['-1 - False Positive'].
* @param {string} url - The URL for which the filter applies (can be regex).
* @param {string} urlisregex - A boolean indicating whether or not the URL is a regex.
* @param {string} parameter - The parameter name for which the filter applies (can be regex).
* @param {string} enabled - A boolean indicating whether or not the filter should be enabled.
* @param {string} parameterisregex - A boolean indicating whether or not the parameter name is a regex.
* @param {string} attack - The attack value for which the filter applies (can be regex).
* @param {string} attackisregex - A boolean indicating whether or not the attack value is a regex.
* @param {string} evidence - The evidence value for which the filter applies (can be regex).
* @param {string} evidenceisregex - A boolean indicating whether or not the evidence value is a regex.
* @param {string} methods - The HTTP methods (comma separated) for which the filter applies.
**/
AlertFilter.prototype.removeGlobalAlertFilter = function (args) {
const params = { ruleId: args.ruleid, newLevel: args.newlevel }
if (args.url && args.url !== null) {
params.url = args.url
}
if (args.urlisregex && args.urlisregex !== null) {
params.urlIsRegex = args.urlisregex
}
if (args.parameter && args.parameter !== null) {
params.parameter = args.parameter
}
if (args.enabled && args.enabled !== null) {
params.enabled = args.enabled
}
if (args.parameterisregex && args.parameterisregex !== null) {
params.parameterIsRegex = args.parameterisregex
}
if (args.attack && args.attack !== null) {
params.attack = args.attack
}
if (args.attackisregex && args.attackisregex !== null) {
params.attackIsRegex = args.attackisregex
}
if (args.evidence && args.evidence !== null) {
params.evidence = args.evidence
}
if (args.evidenceisregex && args.evidenceisregex !== null) {
params.evidenceIsRegex = args.evidenceisregex
}
if (args.methods && args.methods !== null) {
params.methods = args.methods
}
return this.api.request('/alertFilter/action/removeGlobalAlertFilter/', params)
}
/**
* Applies all currently enabled Global and Context alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.applyAll = function () {
return this.api.request('/alertFilter/action/applyAll/')
}
/**
* Applies all currently enabled Context alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.applyContext = function () {
return this.api.request('/alertFilter/action/applyContext/')
}
/**
* Applies all currently enabled Global alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.applyGlobal = function () {
return this.api.request('/alertFilter/action/applyGlobal/')
}
/**
* Tests all currently enabled Global and Context alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.testAll = function () {
return this.api.request('/alertFilter/action/testAll/')
}
/**
* Tests all currently enabled Context alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.testContext = function () {
return this.api.request('/alertFilter/action/testContext/')
}
/**
* Tests all currently enabled Global alert filters.
* This component is optional and therefore the API will only work if it is installed
**/
AlertFilter.prototype.testGlobal = function () {
return this.api.request('/alertFilter/action/testGlobal/')
}
module.exports = AlertFilter