
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
github.com/qiuchengxuan/xml-builder
xml-builder is a metaprogramming approach to build XML document like lxml in Python.
Creating a XML document
The following example creates an XML document from scratch using the xml-builder package and outputs its indented contents to stdout.
e := Tags(struct{ person, gender, firstname, lastname Tag }{})
doc := Doc(e.person(
e.gender("female"),
e.firstname("Anna"),
e.lastname("Smith"),
))
bytes, _ := xml.MarshalIndent(doc, "", " ")
fmt.Println(string(bytes))
Will output:
<person>
<gender>female</gender>
<firstname>Anna</firstname>
<lastname>Smith</lastname>
</person>
Attributes
This example illustrates how to define attributes in element
e := Tags(struct{ person, gender Tag }{})
doc := Doc(e.person(
e.gender("female", Attrs{"a": "b", "xmlns:c": "xml.builder"}),
))
bytes, _ := xml.MarshalIndent(doc, "", " ")
fmt.Println(string(bytes))
Will output:
<person>
<gender a="b" xmlns:c="xml.builder">female</gender>
</person>
InstantElement
When unable to define tags, you can create as instant element as following:
person := E("person")
gender := E("gender", "female")
person.Append(gender)
Hook
When element name is snakecase or kebabcase, assuming you already had a function named snakecase, you can add a hook when creating tags as following:
e := Tags(struct{ firstName, lastName Tag }{}, func(name *xml.Name) {
name.Local = snakecase(name.Local)
})
FAQs
Unknown package
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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.