
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
GreenButton gem is a Ruby wrapper for the Green Button Data. It allows third-party applications to retrieve the GreenButton data in the form of handy Ruby objects hiding the details of the XML representation and parsing.
The GreenButton gem is designed for extendability and scalability. It provides a framework for processing the GreenButton data. It currently supports only the electricity consumption data, but plugins can be easily adapted to support new kinds of data.
The increased size of data by time was a significant factor in designing this module. To support this expected size of data, the [SAX parsing technique] is leveraged in this module.
Unlike DOM, SAX need not to load the whole file into memory for parsing. It is an event driven parsing. As we don't need power features of DOM like XPath for example, so SAX is ideal for data size scalability.
The SAX Machine provides a simple and elegant binding interface that binds xml elements to Ruby objects and properties.
Using bundler, add this line to your application's Gemfile:
gem 'ce-greenbutton'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ce-greenbutton
The parser uses SAX Machine and will install it as dependency.
A typical scenario of the module usage will be like this
The following will download and parse all data for subscription
require 'greenbutton'
GreenButton.config(reg_access_token: "your access token",
application_information_url: "http://app_info_url")
gb = GreenButton.download_data('your access token', 'http://greenbutton.data.url')
The following will download and parse all 2013 data for subscription
```ruby
require 'ce-greenbutton'
GreenButton.config(reg_access_token: "your access token",
application_information_url: "http://app_info_url")
gb = GreenButton.download_data('your access token', 'http://greenbutton.data.url'
Date.new(2013,1,1), Date.new(2013,12,31))
```
The following will download and parse data from FTP
```ruby
require 'ce-greenbutton'
GreenButton.config(reg_access_token: "your access token",
application_information_url: "http://app_info_url",
ftp_host: "your ftp host",
ftp_user: "your ftp user name",
ftp_password: "your ftp password",
ftp_path: "your ftp directory containing data")
gb = GreenButton.download_data_ftp('your application id', Time.new(2015,3,19,1,1,1,0), "your utility name")
```
Note, the call to config
is mandatory before the first usage of the module.
the returning result of the download_data or download_data_ftp call is an array of GbDataDescription and it can be accessed like that.
gb_data_descriptions.each do |gb_data_desc|
gb_data = gb_data_desc.gb_data_array.first
gb_data_reading = gb_data.interval_readings.first
puts gb_data_reading.cost
end
GbDataDescription
, GbData
and GbDataReading
classes in the
model
directory.The module is designed to ease extension in the following paths
SERVICEKIND_NAMES = {
0 => 'electricity',
1 => 'gas',
2 => 'water',
3 => 'time',
4 => 'heat',
5 => 'refuse',
6 => 'sewerage',
7 => 'rates',
8 => 'tvLicence',
9 => 'internet'
}
TomDoc Notation was used to document code in this gem.
To generate the docs:
The latest development version of the TomDoc tool should be used as the published version seems to be out-dated. Refer to [TomDoc Local Development] (https://github.com/defunkt/tomdoc#local-dev) for instructions.
Use the console format (default), the HTML generator will not detect all docs.
To generate the console docs, just issue the following command for each file
$ruby -rubygems /path/to/cloned/tomdoc/bin/tomdoc /path/to/tomdoced/code.rb
Run a local web server on port 8123 and serve files under the test_files
directory.
Using [NodeJS] (www.nodejs.org)
$ npm install http-server -g
$ cd test_files
$ http-server -p 8123
Note You may need admin (root) privilege to install node/http-server
From the base directory of the module (the directory containing the .gemspec file.
$ bundle install
$ bundle exec rspec
Coverage reports will be found under the coverage
subfolder.
tomdoc
was used to generate documentation files for this gem. The generated files are included in docs
directory.
FAQs
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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.