Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
MergeXML merges the XML sources (files, strings, objects) into single DOM XML object. The merging is performed recursively on the node level adding new elements and replacing existing ones. The nodes with the same path/name are replaced/added sequentially and the modification can be controlled by the options.
MergeXML could be useful in cases where it is necessary to gather XML data from multiple sources. For example, to combine configuration files of different subsystems depending on the application logic.
Main browsers (Chrome, Edge, IE, Firefox, Safari, Opera) and NodeJS (see below) are supported. The MergeXML is realized also in PHP (see php-merge-xml).
MergeXML class can be included:
const MergeXML = require('./mergexml');
<script src="mergexml.js"></script>
The class instantiation:
var oMX = new MergeXML([opts]);
or loading and instantiating at once:
const oMX = new (require('./mergexml.js'))([opts]);
opts - the options object:
oMX.AddSource(source);
source - XML string or DOM object
oMX.AddFile(elem);
elem - FileList element of the XML file (browsers only)
The methods merge a sequent source and return the final object or false if failed (see error property below).
oMX.Init([opts]);
Clear existing result to restart.
opts - the options object as above (except path)
You can search in the result object:
oMX.Query(expr);
expr - XPath query expression
You can get the XML result tree:
oMX.Get([0|1|2]);
The result object can be accessed also via oMX.dom property. The properties available:
The sources must have the same default namespace (if have at all). Prefix '_' is reserved to handle the default namespace. IE doesn't allow replacement of the root node attributes.
Run from the appropriate directory:
npm install mergexml
Or manually download the js-merge-xml package from Github and unzip the files into installation directory.
Run the sample in your browser (HTML5 compatible):
To run the browsers' tests from the CLI:
npm install --dev
npm test
npm prune --prod
The browser window objects' (DOMParser, XPathEvaluator, XMLSerializer) functionality is implemented by the xpath, xmldom modules as node global objects. The sample requires also the formidable module.
Install the dependent modules:
npm install --prod
Start NodeJS with the sample script:
node examplen.js
Run the sample in your browser:
The following files are included:
June/July 2015 (Martijn van de Rijdt)
October 2016 (Martijn van de Rijdt)
August 2019 (Vallo Reima)
September 2021 (eyelidlessness)
FAQs
Merge multiple XML sources
The npm package mergexml receives a total of 70,526 weekly downloads. As such, mergexml popularity was classified as popular.
We found that mergexml demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.