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.
A mountable mock server for your RAML specifications based on Rack.
Note: This is not intended for use in production environments.
Add this line to your application's Gemfile:
gem 'rack-raml'
Rack::Raml implements a Rack compatible application that responds to #call
. Therefore, it can be used with any Rack-based web framework.
To use with Rails, simply point specific URLs at an instance of Rack::Raml::App
like so:
MyApplication.routes.draw do
# ...
Rack::Raml.routes Rails.root.join('path/to/spec.raml') do |raml_app|
get '/api/v1/users/:id', to: raml_app
end
end
To use with Sinatra, you have a few options. The easiest way is to define your route, and invoke #process
.
raml_file = File.expand_path('../path/to/spec.raml', __FILE__)
raml_app = Rack::Raml.create(raml_file)
get '/api/v1/users/:id' do
raml_app.process(request)
end
Otherwise, you might configure Rack::Raml
in your config.ru
.
#%RAML 0.8
---
title: Dummy API
baseUri: https://dummy-api.com/api/{version}
version: v1
/users:
/{id}:
displayName: Find a user
get:
responses:
200:
description: User was found.
body:
application/json:
example: |-
{
"id": 1,
"first_name": "John",
"last_name": "Doe"
}
In RAML, you'll often specify multiple status codes that your server might respond with. By default, Rack::Raml will respond with the lowest status code that you've specified. So, for example, if you've declared a 200 and a 401 response, it will respond with the 200 response code unless otherwise instructed.
You can force Rack::Raml to use a specific status code by requesting the url with the _code
query parameter. For example:
$ curl http://localhost:3000/api/v1/users?_code=401
The server will respond with the content type that matches the request. If the request does not specify a content type, Rack::Raml will assume you want application/json
.
You can force Rack::Raml to use a specific content type by requesting the url with the _type
query parameter. For example:
$ curl http://localhost:3000/api/v1/users?_type=text/plain
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rack-raml.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that rack-raml 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.