Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
It generates PDF files for Brazilian DANFE (Documento Auxiliar da Nota Fiscal Eletrônica) from a valid NF-e XML.
It also generates Brazilian DACTE (Documento Auxiliar do Conhecimento de Transporte Eletrônico).
This project is inspired on NFePHP class.
gem install ruby_danfe
If you have the xml saved in a file:
require "ruby_danfe"
RubyDanfe.generate("sample.pdf", "sample.xml")
RubyDanfe.generate("cte.pdf", "cte.xml", "dacte")
RubyDanfe.generate("cteos.pdf", "cteos.xml", "dacteos")
If you have the xml in a variable:
xml = "string xml"
pdf = RubyDanfe.generatePDF(xml)
pdf.render_file "output.pdf"
You can use some options too! In this example, the product's field quantity will be rendered with 4 decimals after comma:
xml = "string xml"
RubyDanfe.options = {"quantity_decimals" => 4}
pdf = RubyDanfe.generatePDF(xml)
pdf.render_file "output.pdf"
If you have some especific option that is global for your project, you can create a file at config/ruby_danfe.yml, then the ruby_danfe always will load this options. Example:
project_name/config/ruby_danfe.yml
ruby_danfe:
options:
quantity_decimals: 3
numerify_prod_qcom: false
You can install all necessaries dependencies using bunder like above:
$ bundle install
At test
folder you will find the generate.rb
file. It shows how to generate a pdf file from a valid xml.
You can use it following the steps above:
$ cd test
$ ruby generate.rb nfe_with_ns.xml
$ ruby generate.rb cte_with_ns.xml 'dacte'
$ ruby generate.rb cteos_with_ns.xml 'dacteos'
You can also use an special version of irb with all classes pre-loaded. Just use:
$ rake console
RubyDanfe.generate("output.pdf", "test/nfe_with_ns.xml")
RubyDanfe.generate("output.pdf", "test/cte.xml", 'dacte')
RubyDanfe.generate("output.pdf", "test/cteos.xml", 'dacteos')
or
$ rake console
my_xml_string = ""
file = File.new("test/nfe_with_ns.xml", "r")
while (line = file.gets)
my_xml_string = my_xml_string + line
end
file.close
xml = RubyDanfe::XML.new(my_xml_string)
pdf = RubyDanfe.generatePDF(xml)
pdf.render_file "output.pdf"
You can run all specs using:
$ rspec
In the spec/fixtures
folder, you are going to find some xml files. Each one represent a different NF-e context.
Each xml file must have its respective pdf file.
If you did some change that caused general visual changes at output pdfs, so you have to rebuild all fixtures pdf files.
You can do this automagically running the following taks:
$ rake spec:fixtures:recreate_pdfs
Code coverage is available through of SimpleCov. Just run rspec
and open the coverage report in your browser.
You can build using one of the above tasks
$ rake build # Build ruby_danfe-X.X.X.gem into the pkg directory
$ rake install # Build and install ruby_danfe-X.X.X.gem into system gems
$ rake release # Create tag vX.X.X and build and push ruby_danfe-X.X.X.gem to Rubygems
We encourage you to contribute to Ruby DANFE!
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)Ruby DANFE is released under the MIT License.
FAQs
Unknown package
We found that ruby_danfe demonstrated a healthy version release cadence and project activity because the last version was released less than 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.