diff --git a/CHANGELOG.md b/CHANGELOG.md index 767f3b2e80..ff7f38870d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). [#1466](https://github.com/greenbone/gsa/pull/1466) [#1467](https://github.com/greenbone/gsa/pull/1467) ### Changed +- Use fast xml parser by default [#1556](https://github.com/greenbone/gsa/pull/1556) - Updated dependencies [#1555](https://github.com/greenbone/gsa/pull/1555) - Changed schedule dialog (added Now button) to help users jump to current time ASAP [#1519](https://github.com/greenbone/gsa/pull/1519) - Changed the filter dialogues for tasks and overrides [#1511](https://github.com/greenbone/gsa/pull/1511) diff --git a/gsa/CMakeLists.txt b/gsa/CMakeLists.txt index ed584a2460..3b6db09779 100644 --- a/gsa/CMakeLists.txt +++ b/gsa/CMakeLists.txt @@ -104,7 +104,6 @@ set (GSA_JS_SRC_FILES ${GSA_SRC_DIR}/src/gmp/http/response.js ${GSA_SRC_DIR}/src/gmp/http/transform/default.js ${GSA_SRC_DIR}/src/gmp/http/transform/fastxml.js - ${GSA_SRC_DIR}/src/gmp/http/transform/x2js.js ${GSA_SRC_DIR}/src/gmp/http/utils.js ${GSA_SRC_DIR}/src/gmp/index.js ${GSA_SRC_DIR}/src/gmp/locale/date.js diff --git a/gsa/package.json b/gsa/package.json index af2746b611..f00cbfa0f9 100644 --- a/gsa/package.json +++ b/gsa/package.json @@ -64,8 +64,7 @@ "redux-thunk": "^2.3.0", "styled-components": "^4.3.1", "uuid": "^3.3.2", - "whatwg-fetch": "^3.0.0", - "x2js": "^3.2.6" + "whatwg-fetch": "^3.0.0" }, "scripts": { "test": "react-scripts test", diff --git a/gsa/src/gmp/commands/reports.js b/gsa/src/gmp/commands/reports.js index c5160c0a14..449f70a6cd 100644 --- a/gsa/src/gmp/commands/reports.js +++ b/gsa/src/gmp/commands/reports.js @@ -27,7 +27,6 @@ import Report from '../models/report'; import {ALL_FILTER} from '../models/filter'; import DefaultTransform from '../http/transform/default'; -import FastXmlTransform from '../http/transform/fastxml'; import EntitiesCommand from './entities'; import EntityCommand from './entity'; @@ -123,7 +122,7 @@ class ReportCommand extends EntityCommand { filter, ignore_pagination: 1, }, - {...options, transform: FastXmlTransform}, + options, ).then(this.transformResponse); } @@ -134,7 +133,7 @@ class ReportCommand extends EntityCommand { filter, ignore_pagination: 1, }, - {...options, transform: FastXmlTransform}, + options, ).then(this.transformResponse); } diff --git a/gsa/src/gmp/http/gmp.js b/gsa/src/gmp/http/gmp.js index 64479ecacd..49be978dae 100644 --- a/gsa/src/gmp/http/gmp.js +++ b/gsa/src/gmp/http/gmp.js @@ -16,16 +16,16 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ -import Http from './http.js'; -import {buildServerUrl} from './utils.js'; +import Http from './http'; +import {buildServerUrl} from './utils'; -import X2JsTransform from './transform/x2js.js'; +import transform from './transform/fastxml'; class GmpHttp extends Http { constructor(settings) { const {server, protocol, timeout} = settings; const url = buildServerUrl(server, 'gmp', protocol); - super(url, {timeout, transform: X2JsTransform}); + super(url, {timeout, transform}); this.settings = settings; } diff --git a/gsa/src/gmp/http/transform/x2js.js b/gsa/src/gmp/http/transform/x2js.js deleted file mode 100644 index 259d22b498..0000000000 --- a/gsa/src/gmp/http/transform/x2js.js +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2017-2019 Greenbone Networks GmbH - * - * SPDX-License-Identifier: GPL-2.0-or-later - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ -import X2JS2 from 'x2js'; - -import {isDefined} from '../../utils/identity'; - -import {parseEnvelopeMeta} from '../../parser'; - -import {success, rejection} from './xml'; - -const x2js2 = new X2JS2(); - -const xml2json = (...args) => x2js2.dom2js(...args); - -const transformXmlData = response => { - const {envelope} = xml2json(response.plainData('xml')); - const meta = parseEnvelopeMeta(envelope); - return response.set(envelope, meta); -}; - -const transfromRejection = rej => { - const xml = rej.plainData('xml'); - return isDefined(xml) ? xml2json(xml) : undefined; -}; - -export default { - rejection: rejection(transfromRejection), - success: success(transformXmlData), -}; - -// vim: set ts=2 sw=2 tw=80: diff --git a/gsa/yarn.lock b/gsa/yarn.lock index 1db8c476a6..fcbe98a39b 100644 --- a/gsa/yarn.lock +++ b/gsa/yarn.lock @@ -13214,13 +13214,6 @@ ws@^6.1.2: dependencies: async-limiter "~1.0.0" -x2js@^3.2.6: - version "3.2.6" - resolved "https://registry.yarnpkg.com/x2js/-/x2js-3.2.6.tgz#5be54bd5e65972c2886f0dcc178cbc75e9b42219" - integrity sha512-AtIflg7LRYhayFwujlyujD0qi9C9XwMkV6fHFOhc6FPqTvuVSDbUeFimbd91zO9QophYJsnaW4mz6p/U/MQ9rA== - dependencies: - xmldom "^0.1.19" - xml-name-validator@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-3.0.0.tgz#6ae73e06de4d8c6e47f9fb181f78d648ad457c6a" @@ -13236,11 +13229,6 @@ xmlchars@^2.1.1: resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.1.1.tgz#ef1a81c05bff629c2280007f12daca21bd6f6c93" integrity sha512-7hew1RPJ1iIuje/Y01bGD/mXokXxegAgVS+e+E0wSi2ILHQkYAH1+JXARwTjZSM4Z4Z+c73aKspEcqj+zPPL/w== -xmldom@^0.1.19: - version "0.1.27" - resolved "https://registry.yarnpkg.com/xmldom/-/xmldom-0.1.27.tgz#d501f97b3bdb403af8ef9ecc20573187aadac0e9" - integrity sha1-1QH5ezvbQDr4757MIFcxh6rawOk= - xregexp@4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-4.0.0.tgz#e698189de49dd2a18cc5687b05e17c8e43943020"