Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
VerbalExpressions is a Ruby library that helps to construct difficult regular expressions - ported from the awesome JavaScript VerbalExpressions.
Just install with gem install verbal_expressions
, then require the library and you're good to go!
require 'verbal_expressions'
Here's a couple of simple examples to give an idea of how VerbalExpressions works:
# Create an example of how to test for correctly formed URLs
tester = VerEx.new do
start_of_line
find 'http'
maybe 's'
find '://'
maybe 'www.'
anything_but ' '
end_of_line
end
# Create an example URL
test_url = "https://www.google.com"
# Use it just like a regular Ruby regex:
puts 'Hooray! It works!' if tester.match(test_url)
puts 'This works too!' if tester =~ test_url
# Print the generated regex:
puts tester.source # => /^(http)(s)?(\:\/\/)(www\.)?([^\ ]*)$/
# Create a test string
replace_me = "Replace bird with a duck"
# Create an expression that seeks for word "bird"
expression = VerEx.new { find 'bird' }
# Execute the expression like a normal Regexp object
result = replace_me.gsub( expression, "duck" );
puts result # Outputs "Replace duck with a duck"
# Grab the number of goals
tester = VerEx.new do
find 'scored '
begin_capture 'goals' # Can be named or unnamed
word
end_capture
end
match = tester.match('Jerry scored 5 goals!')
puts match['goals'] # => 5
# Alternative capture syntax
tester = VerEx.new do
find 'scored '
capture('goals') { word }
end
I haven't added much documentation to this repo yet, but you can find the documentation for the original JavaScript repo on their wiki. Most of the methods have been ported as of v0.1.0 of the JavaScript repo. Just be sure to use the syntax explained above rather than the dot notation :)
Clone the repo and fork! Pull requests are warmly welcomed!
or
is reserved in Ruby, or
is currently aliased to alternatively
. Unfortunately, then
is also reserved, so you must use find
instead. I'm very open to better name ideas :)Thank you to @jehna for coming up with the awesome original idea!
FAQs
Unknown package
We found that verbal_expressions 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.