From 54c0c41a3819d752ce6559521bfc3c6234d07335 Mon Sep 17 00:00:00 2001 From: thc202 Date: Fri, 10 May 2024 17:05:48 +0100 Subject: [PATCH] Update APIs of core and release 2.0.0-rc.5 Update core APIs for 2.15.0. Prepare release. Signed-off-by: thc202 --- CHANGELOG.md | 6 +++-- package-lock.json | 4 +-- package.json | 2 +- src/ajaxSpider.js | 2 +- src/ascan.js | 15 +++++++++++ src/core.js | 21 ++++++++++++++++ src/search.js | 63 +++++++++++++++++++++++++++++++++++++++++++++++ src/wappalyzer.js | 2 +- 8 files changed, 108 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8db4ffd..0f72b5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). -## [Unreleased] +## [2.0.0-rc.5] - 2024-04-10 +### Changed +* Update core APIs for 2.15. ## [2.0.0-rc.4] - 2023-11-24 ### Added @@ -100,7 +102,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). ## 0.3.0 - 2017-12-04 -[Unreleased]: https://github.com/zaproxy/zap-api-nodejs/compare/v2.0.0-rc.4...HEAD +[2.0.0-rc.5]: https://github.com/zaproxy/zap-api-nodejs/compare/v2.0.0-rc.4...v2.0.0-rc.5 [2.0.0-rc.4]: https://github.com/zaproxy/zap-api-nodejs/compare/v2.0.0-rc.3...v2.0.0-rc.4 [2.0.0-rc.3]: https://github.com/zaproxy/zap-api-nodejs/compare/v2.0.0-rc.2...v2.0.0-rc.3 [2.0.0-rc.2]: https://github.com/zaproxy/zap-api-nodejs/compare/v2.0.0-rc.1...v2.0.0-rc.2 diff --git a/package-lock.json b/package-lock.json index 97ea52b..c49cdad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "zaproxy", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zaproxy", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "dependencies": { "axios": "^1.3.3" }, diff --git a/package.json b/package.json index 85150d4..8098ad6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zaproxy", "description": "ZAP API Client for Node.js", - "version": "2.0.0-rc.4", + "version": "2.0.0-rc.5", "homepage": "https://github.com/zaproxy/zap-api-nodejs", "author": { "name": "Najam Ul Saqib", diff --git a/src/ajaxSpider.js b/src/ajaxSpider.js index fdf6d69..012fc91 100644 --- a/src/ajaxSpider.js +++ b/src/ajaxSpider.js @@ -337,7 +337,7 @@ AjaxSpider.prototype.setOptionBrowserId = function (args) { } /** - * Sets whether or not the the AJAX Spider will only click on the default HTML elements. + * Sets whether or not the AJAX Spider will only click on the default HTML elements. * This component is optional and therefore the API will only work if it is installed * @param {string} bool - A boolean (true/false) indicating if only default elements such as 'a' 'button' 'input' should be clicked (default is true). **/ diff --git a/src/ascan.js b/src/ascan.js index cf2a812..7363366 100644 --- a/src/ascan.js +++ b/src/ascan.js @@ -259,6 +259,13 @@ Ascan.prototype.optionAllowAttackOnStart = function () { return this.api.request('/ascan/view/optionAllowAttackOnStart/') } +/** + * Tells whether or not the active scanner should encode cookie values. + **/ +Ascan.prototype.optionEncodeCookieValues = function () { + return this.api.request('/ascan/view/optionEncodeCookieValues/') +} + /** * Tells whether or not the active scanner should inject the HTTP request header X-ZAP-Scan-ID, with the ID of the scan rule that's sending the requests. **/ @@ -719,6 +726,14 @@ Ascan.prototype.setOptionDelayInMs = function (args) { return this.api.request('/ascan/action/setOptionDelayInMs/', { Integer: args.integer }) } +/** + * Sets whether or not the active scanner should encode cookie values. + * @param {string} bool + **/ +Ascan.prototype.setOptionEncodeCookieValues = function (args) { + return this.api.request('/ascan/action/setOptionEncodeCookieValues/', { Boolean: args.bool }) +} + /** * * @param {string} bool diff --git a/src/core.js b/src/core.js index 26f3653..78050e7 100644 --- a/src/core.js +++ b/src/core.js @@ -263,6 +263,18 @@ Core.prototype.numberOfAlerts = function (args) { return this.api.request('/core/view/numberOfAlerts/', params) } +/** + * The detailed logging config, optionally filtered based on a name (ex: starts with). + * @param {string} name - The name for which the logger details should be provided (this value will be used as a case insensitive starts with filter). + **/ +Core.prototype.getLogLevel = function (args) { + const params = { } + if (args.name && args.name !== null) { + params.name = args.name + } + return this.api.request('/core/view/getLogLevel/', params) +} + /** * Gets the user agent that ZAP should use when creating HTTP messages (for example, spider messages or CONNECT requests to outgoing proxy). **/ @@ -648,6 +660,15 @@ Core.prototype.deleteAlert = function (args) { return this.api.request('/core/action/deleteAlert/', { id: args.id }) } +/** + * Sets the logging level for a given logger name. + * @param {string} name - The logger name for which the logging level should be set. + * @param {string} loglevel - The logging level which should be set. + **/ +Core.prototype.setLogLevel = function (args) { + return this.api.request('/core/action/setLogLevel/', { name: args.name, logLevel: args.loglevel }) +} + /** * Sets the user agent that ZAP should use when creating HTTP messages (for example, spider messages or CONNECT requests to outgoing proxy). * @param {string} string diff --git a/src/search.js b/src/search.js index 9d42bb9..84f209c 100644 --- a/src/search.js +++ b/src/search.js @@ -47,6 +47,27 @@ Search.prototype.urlsByUrlRegex = function (args) { return this.api.request('/search/view/urlsByUrlRegex/', params) } +/** + * Returns the URLs of the HTTP messages that match the given regular expression in their history Tags optionally filtered by URL and paginated with 'start' position and 'count' of messages. + * @param {string} regex + * @param {string} baseurl - The highest URL in the Sites tree under which URLs should be included. + * @param {string} start + * @param {string} count + **/ +Search.prototype.urlsByTagRegex = function (args) { + const params = { regex: args.regex } + if (args.baseurl && args.baseurl !== null) { + params.baseurl = args.baseurl + } + if (args.start && args.start !== null) { + params.start = args.start + } + if (args.count && args.count !== null) { + params.count = args.count + } + return this.api.request('/search/view/urlsByTagRegex/', params) +} + /** * Returns the URLs of the HTTP messages that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages. * @param {string} regex @@ -131,6 +152,27 @@ Search.prototype.messagesByUrlRegex = function (args) { return this.api.request('/search/view/messagesByUrlRegex/', params) } +/** + * Returns the HTTP messages that match the given regular expression in their history Tags optionally filtered by URL and paginated with 'start' position and 'count' of messages. + * @param {string} regex + * @param {string} baseurl - The highest URL in the Sites tree under which messages should be included. + * @param {string} start + * @param {string} count + **/ +Search.prototype.messagesByTagRegex = function (args) { + const params = { regex: args.regex } + if (args.baseurl && args.baseurl !== null) { + params.baseurl = args.baseurl + } + if (args.start && args.start !== null) { + params.start = args.start + } + if (args.count && args.count !== null) { + params.count = args.count + } + return this.api.request('/search/view/messagesByTagRegex/', params) +} + /** * Returns the HTTP messages that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages. * @param {string} regex @@ -215,6 +257,27 @@ Search.prototype.harByUrlRegex = function (args) { return this.api.request('/search/other/harByUrlRegex/', params, 'other') } +/** + * Returns the HTTP messages, in HAR format, that match the given regular expression in their history Tags optionally filtered by URL and paginated with 'start' position and 'count' of messages. + * @param {string} regex + * @param {string} baseurl - The highest URL in the Sites tree under which URLs should be included. + * @param {string} start + * @param {string} count + **/ +Search.prototype.harByTagRegex = function (args) { + const params = { regex: args.regex } + if (args.baseurl && args.baseurl !== null) { + params.baseurl = args.baseurl + } + if (args.start && args.start !== null) { + params.start = args.start + } + if (args.count && args.count !== null) { + params.count = args.count + } + return this.api.request('/search/other/harByTagRegex/', params, 'other') +} + /** * Returns the HTTP messages, in HAR format, that match the given regular expression in the request optionally filtered by URL and paginated with 'start' position and 'count' of messages. * @param {string} regex diff --git a/src/wappalyzer.js b/src/wappalyzer.js index 1a3e826..70351b3 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -27,7 +27,7 @@ function Wappalyzer (clientApi) { } /** - * Lists all the sites recognized by the wappalyzer addon. + * Lists all the sites recognized by the Technology Detection add-on. * This component is optional and therefore the API will only work if it is installed **/ Wappalyzer.prototype.listSites = function () {