
Product
Socket Now Protects the Chrome Extension Ecosystem
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
by Neil Smith
This generates text-based CATPCHAs that are "nice", by my own personal subjective definition!
Questions are purposely simple, and examples would include:
There are plenty of choices out there, but none quite met my personal needs (or some client's needs) for one reason or another:
You call a method in your view which both generates a random question, and places the possible answers into a flash[] object, stored in a SHA2 hash.
(It's stored in a flash, as Rails handles ageing the data after a request - if we used the session, it would hang around for the duration of the session.)
Then, in your controller action, you call a method which extracts the answers from the flash, and injects them into your model.
A validation method on the model finally checks the answer against the hashed possible answers, and pushes an error onto the base of your model if the answer doesn't match.
For numerical answers ("What is 'two' plus 'three'?"), both numbers ("3") and words ("three") are accepted.
Simply add:
config.gem 'nice_text_captcha'
to your environment.rb file, and install the gem via your preferred method.
In your model, you need to add some validation:
class Thing < ActiveRecord::Base
validate :check_nice_text_captcha
end
In your controller, you need to add a call to populate the answers from the data in the session:
class ThingsController < ActiveRecord::Base
def create
@thing = Thing.new(params[:thing]) # as normal
validate_nice_text_captcha_for(@thing)
end
end
Finally, in your view, you need to render the question by calling nice_text_captcha, and give the user a text box for their answer:
<% form_for(@thing) do |f| %>
<!-- normal form elements here -->
<%= f.nice_text_captcha %> <!-- this will generate a label with the catcha text inside -->
<%= f.text_field :nice_text_captcha %>
<!-- probably a submit button here -->
<% end %>
FAQs
Unknown package
We found that nice_text_captcha demonstrated a not healthy version release cadence and project activity because the last version was released 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.
Product
Socket is launching experimental protection for Chrome extensions, scanning for malware and risky permissions to prevent silent supply chain attacks.
Product
Add secure dependency scanning to Claude Desktop with Socket MCP, a one-click extension that keeps your coding conversations safe from malicious packages.
Product
Socket now supports Scala and Kotlin, bringing AI-powered threat detection to JVM projects with easy manifest generation and fast, accurate scans.