
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
github.com/printesoi/xml-go
Package github.com/printesoi/xml-go
implements a XML 1.0 marshaler that is a drop in encoding/xml
replacement maintaining full interface compatibility to it but aims to producing C14N Exclusive XML Canonicalization compatible byte sequences. This includes sorting of all rendered element attributes as per the C14N-XML spec.
A Struct defined in the normal way as known from encoding/xml
type Person struct {
XMLName xml.Name `xml:"http://example.com/ns1 person"`
Name string `xml:"name"`
Phone string `xml:"http://example.com/ns2 phone,omitempty"`
}
is marshaled to
<ns1:person xmlns:ns1="http://example.com/ns1">
<ns1:name>Foo</ns1:name>
<ns2:phone xmlns:ns2="http://example.com/ns2">123</ns2:phone>
</ns1:person>
Skip adding xmlns:prefix="url":
type Ambassador struct {
XMLName xml.Name `xml:"example.com:ns1 ambassador"`
Name string `xml:"name"`
Origin string `xml:"example.com:ns2 origin,omitempty"`
}
var b bytes.Buffer
enc := NewEncoder(&b)
prefix1, url1 := "ns1", "example.com:ns1"
enc.AddNamespaceBinding(url1, prefix1)
enc.AddSkipNamespaceAttrForPrefix(url1, prefix1)
prefix2, url2 := "ns2", "example.com:ns2"
enc.AddNamespaceBinding(url2, prefix2)
enc.AddSkipNamespaceAttrForPrefix(url2, prefix2)
v := &Ambassador{
Name: "Mahit Dzmare",
Origin: "Lsel Station",
}
if err := enc.Encode(v); err != nil {
// error
}
if err := enc.Close(); err != nil {
// error
}
ambassadorXML := b.Bytes()
is marshaled to
<ns1:ambassador>
<ns1:name>Mahit Dzmare</ns1:name>
<ns2:origin>Lsel Station</ns2:origin>
</ns1:ambassador>
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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.