
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
fluent-plugin-xml-parser
Advanced tools
Fluent plugin for Parsing XML Input
fluent-plugin-xml-parser | Fluentd | Ruby |
---|---|---|
>= 1.0.0 | >= v0.14.0 | >= 2.1 |
< 1.0.0 | >= v0.12.0 | >= 1.9 |
Add this line to your application's Gemfile:
gem 'fluent-plugin-xml-parser'
And then execute:
$ bundle
Or install it yourself as:
$ gem install fluent-plugin-xml-parser
Fluent::Plugin::XmlParser provides input data conversion from simple XML data like sensor data into Ruby hash structure for emitting next procedure in fluentd. In order to enable Fluent::Plugin::XmlParser, 'format xml' option needs to be specified at 'source' directive.
The followings are an example configuration for reformatting Libelium SmartCity sensor data to fit ElasticSearch received via MQTT protocol(fluent-plugin-mqtt-io).
Put configuration options in <parse>
tag
<source>
type mqtt
bind 127.0.0.1
port 11883
topic 'Libelium/+/#'
@label @MQTT_OUT
<parse>
type @xml
time_xpath '["cap:alert/cap:info/cap:onset", "text"]'
time_key '@timestamp'
attr_xpaths '[["cap:alert/cap:info/cap:parameter/cap:valueName", "text"]]'
value_xpaths '[["cap:alert/cap:info/cap:parameter/cap:value", "text"]]'
</parse>
</source>
Use format
instead of <parse></parse
and put configuration options in <source>
tag
<source>
type mqtt
bind 127.0.0.1
port 11883
topic 'Libelium/+/#'
format xml
time_xpath '["cap:alert/cap:info/cap:onset", "text"]'
time_key '@timestamp'
attr_xpaths '[["cap:alert/cap:info/cap:parameter/cap:valueName", "text"]]'
value_xpaths '[["cap:alert/cap:info/cap:parameter/cap:value", "text"]]'
@label @MQTT_OUT
</source>
The target XML file of this example is as follows (an old style of Libelium sensor data):
<?xml version="1.0" encoding="UTF-8"?>
<cap:alert xmlns:cap="urn:oasis:names:tc:emergency:cap:1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:oasis:names:tc:emergency:cap:1.2 CAP-v1.2-os.xsd">
<cap:identifier>Libelium_2015-09-21T18:54:24+:00:00495</cap:identifier>
<cap:sender>Libelium_SmartCity_387243170</cap:sender>
<cap:sent>2015-09-21T18:54:24+:00:00</cap:sent>
<cap:status>Actual</cap:status>
<cap:msgType>Alert</cap:msgType>
<cap:scope>Public</cap:scope>
<cap:code>KPI</cap:code>
<cap:info>
<cap:category>Other</cap:category>
<cap:event>Libelium</cap:event>
<cap:urgency>Inmediate</cap:urgency>
<cap:severity>Unknown</cap:severity>
<cap:certainty>Observed</cap:certainty>
<cap:onset>2015-09-21T18:54:24+:00:00</cap:onset>
<cap:senderName>Libelium</cap:senderName>
<cap:headline>Waspmote sensors</cap:headline>
<cap:description>Sensor data from Waspmote devices: MCP</cap:description>
<cap:parameter>
<cap:valueName>MCP</cap:valueName>
<cap:value>50</cap:value>
</cap:parameter>
</cap:info>
</cap:alert>
Configurable options are the following:
The extracted fields are packed into Hash structure (record field) to emit the next procedure in fluentd.
You can check your own XML data structure by using irb or pry
require 'rexml/document'
doc = REXML::Document.new(open("test.xml"))
doc.elements['cap:alert/cap:info'].children
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that fluent-plugin-xml-parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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 researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.