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.
= Formalizer
{}[https://badge.fury.io/rb/formalizer] {}[https://travis-ci.org/talyaniv/formalizer.svg?branch=master] {}[https://gemnasium.com/talyaniv/formalizer]
== About
Formalizer is an open-source gem for simplifying HTML-form filling and exporting:
name: ________
name: ________
== Install gem install 'formalizer' or add to your Gemfile: gem 'formalizer'
== Demo
Clone this repo and start the demo: $ cd test/dummy $ bundle install $ rails server $ open http://localhost:3000
== Usage
=== Configuration
Formalizer looks for +formalizer.yml+ YAML file in config directory. If exists, it will load the configuration, otherwise, it can be configured programatically.
=== Very basic example
form_fields: name: name: Your full name gender: name: Your gender field_type: enum enumeration: - Male - Female - Irellevant default_value: 2 forms: simple_form_example: path: 'An HTML template that requires a name:_____ (required), and an optional gender:[male, female, irrelevant] (optional)'
To fill the (only) form template, we need user input for name and gender. Here is a quick flow from user data to filled PDF file:
formalizer = Formalizer.new # will load YAML configuration
formalizer.fill_fields({name: 'Michelle Markus', gender: 1})
pdf_file = formalizer.export_form_to_pdf(:simple_form_example)
send_data pdf_file, {filename: 'simple_form_example.pdf', disposition: 'attachment'}
== Under the hood === Forms, Form Fields and tags Let's say we have three different form templates:
All three forms require personal user input: Full name and address. NDA and Purchase agreement also require recipient's full name and address. We end up with four fields:
By having user input for all four fields, we can fill the three templates altogether and export as filled PDF or HTML files.
Since Cover Page doesn't require recipient fields, we can group our forms and fields in tags:
=== Form Fields In YAML configuration: form_fields: [field_unique_id]: name: (required) Text that will be displayed to user when generating an input form. field_type: (optional) One of the following: text, boolean, number, enum or multiple. Default - text tags: (optional) one or more tag that this field belongs to, e.g. 'without_recipient' default_value: (optional) default value for filling templates without user input. Boolean field_type: true/false. Enum field_type: the selected value, zero-based. enumeration: (required if field_type is enum) a list of at least two options
forms: [form_unique_id]: path: (required) a file path to the form, or actual form html. The file path can be absolute or relative to config directory. tags: (optional) one or more tags that this form belongs to, e.g. 'without_recipient'
Localization: form_field name and enumeration can have localized version. If not stated, Formalizer will use Application's locale (+I18n.locale+). Otherwise, use this syntax: form_fields gender: name: en: gender es: género field_type: enum enumeration: en: - Male - Female - Irrelevant es: - Masculino - Feminino - Irrelevante
== Generating user details form
In the above example, we had four fields to be filled with user data. We can generate an html form for receiving input data:
formalizer = Formalizer.new
simple_form = formalizer.generate_fields_form
localized_form = formalizer.generate_fields_form(:es) form_with_action = formalizer.generate_fields_form(I18n.locale, 'post_fields') partial_form = formalizer.generate_fields_form(I18n.locale, '', 'without_recipient')
== HTML images and styles
Binding happens at the server, so we need absolute file paths to images and css files. See the demo for specific code examples. Basically your html can look like this:
Cover PageFormalizer will know how to use external URLs or find files (css and images) inside your app's assets directory. If your files reside elsewhere, you will need to give an absolute file:// link. Formalizer does not convert style/css url()s in the current version.
== Advanced: Using Formalizer programatically
So you want to skip the config file and DIY:
formalizer = Formalizer.new
formalizer.add_form(:form1, {path: 'form1.html'})
formalizer.add_form_field({id: :field1, name: 'email'})
formalizer.fill_field :field1, 'john@doe.com'
formalizer.export_form_to_pdf(:form1)
== Contributing to Formazlizer
== TODO:
== Copyright
Copyright (c) 2015 Tal Yaniv. See MIT-LICENSE for further details.
FAQs
Unknown package
We found that formalizer 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
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.