Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
stackprof-route_middleware
Advanced tools
Yet another StackProf::Middleware
which saves dump files by each application route.
Sample configuration:
use StackProf::RouteMiddleware,
enabled: true,
mode: :wall,
interval: 1000,
raw: true,
route_calculator: proc { |env| env['sinatra.route'] }
Results in:
$ ls -alh tmp/
$ ls -alh tmp | head
total 24632
drwxr-xr-x@ 2261 sangenya staff 71K 1 1 22:48 .
drwxr-xr-x 16 sangenya staff 512B 1 1 22:57 ..
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-GET__api_chair__id-wall-97768-1704116922.dump
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-GET__api_chair__id-wall-97768-1704116923.dump
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-GET__api_chair__id-wall-97768-1704116924.dump
...
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-POST__api_estate_req_doc__id-wall-97783-1704116920.dump
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-POST__api_estate_req_doc__id-wall-97783-1704116921.dump
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-POST__api_estate_req_doc__id-wall-97783-1704116922.dump
-rw-r--r-- 1 sangenya staff 109B 1 1 22:48 stackprof-POST__api_estate_req_doc__id-wall-97783-1704116923.dump
So you can analyze a specific route:
$ bundle exec stackprof tmp/stackprof-GET__api_estate_low_priced-wall-* --limit 5
==================================
Mode: wall(1000)
Samples: 85 (1.16% miss rate)
GC: 2 (2.35%)
==================================
TOTAL (pct) SAMPLES (pct) FRAME
71 (83.5%) 71 (83.5%) Mysql2::Client#_query
4 (4.7%) 3 (3.5%) JSON::Ext::Generator::GeneratorMethods::Hash#to_json
3 (3.5%) 3 (3.5%) Mysql2::Result#each
2 (2.4%) 1 (1.2%) App#camelize_keys_for_estate
82 (96.5%) 1 (1.2%) Sinatra::Base#route!
Sample configuration:
use StackProf::RouteMiddleware,
enabled: true,
mode: :wall,
interval: 1000,
raw: true,
route_calculator: proc { |env| "#{env['REQUEST_METHOD']}_#{env['action_dispatch.route_uri_pattern']}" }
Results in:
$ ls -alh tmp/stackprof-*
-rw-r--r-- 1 sangenya staff 109B 1 1 23:36 tmp/stackprof-GET_-wall-3323-1704119802.dump
-rw-r--r-- 1 sangenya staff 207K 1 1 23:36 tmp/stackprof-GET__users___format_-wall-3323-1704119801.dump
-rw-r--r-- 1 sangenya staff 43K 1 1 23:36 tmp/stackprof-GET__users___format_-wall-3323-1704119805.dump
-rw-r--r-- 1 sangenya staff 41K 1 1 23:36 tmp/stackprof-GET__users___format_-wall-3323-1704119812.dump
-rw-r--r-- 1 sangenya staff 54K 1 1 23:36 tmp/stackprof-GET__users__id___format_-wall-3323-1704119804.dump
-rw-r--r-- 1 sangenya staff 41K 1 1 23:36 tmp/stackprof-GET__users__id___format_-wall-3323-1704119807.dump
-rw-r--r-- 1 sangenya staff 39K 1 1 23:36 tmp/stackprof-GET__users__id___format_-wall-3323-1704119810.dump
-rw-r--r-- 1 sangenya staff 51K 1 1 23:36 tmp/stackprof-GET__users__id_edit___format_-wall-3323-1704119809.dump
-rw-r--r-- 1 sangenya staff 59K 1 1 23:36 tmp/stackprof-GET__users_new___format_-wall-3323-1704119806.dump
-rw-r--r-- 1 sangenya staff 40K 1 1 23:36 tmp/stackprof-PATCH__users__id___format_-wall-3323-1704119810.dump
-rw-r--r-- 1 sangenya staff 53K 1 1 23:36 tmp/stackprof-POST__users___format_-wall-3323-1704119807.dump
Add this line to your Gemfile:
gem 'stackprof-route_middleware'
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/genya0407/stackprof-route_middleware.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that stackprof-route_middleware 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.