Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Lightweight schema-based XML data extraction to plain objects (JSON)
To read the data from the following XML
<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
<channel>
<title>MRSS Title</title>
<item>
<title>Item 1</title>
<media:content url="http://example.com/1.mp4" medium="video"/>
<media:comment>Item 1 Comment</media:comment>
</item>
<item>
<title>Item 2</title>
<media:content url="http://example.com/2.mp4" medium="video"/>
<media:comment>Item 2 Comment</media:comment>
</item>
</channel>
</rss>
Data extraction schema:
import { attribute, content, string, readXML, prefixNamespace } from "xmldom-js";
var rssSchema = {
rss: {
channel: {
title: content(string),
item: [{
title: content(string),
"media:content": { url: attribute() },
"media:comment": content(string)
}]
}
}
};
First xml is parsed using the browser DOMParser and then read into plain JS objects using the schema:
var rssXml = new DOMParser().parseFromString(rssString, "text/xml");
var rssJSON = readXML(rssXml, rssSchema, prefixNamespace);
The resulting JSON:
{
"rss": {
"channel": {
"title": "MRSS Title",
"item": [
{
"title": "Item 1",
"media:content": {
"url": "http://example.com/1.mp4"
},
"media:comment": "Item 1 Comment"
},
{
"title": "Item 2",
"media:content": {
"url": "http://example.com/2.mp4"
},
"media:comment": "Item 2 Comment"
}
]
}
}
}
A few modes for handling of the namespace are available:
Npm compatible packager (webpack) is required. CommonJS and ES6 modules are provided, transpiled to es5.
FAQs
Lightweight schema-based XML data extraction to plain objects (JSON)
The npm package xmldom-js receives a total of 26 weekly downloads. As such, xmldom-js popularity was classified as not popular.
We found that xmldom-js demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.