jets 正在参加 2021 年度 OSC 中国开源项目评选,请投票支持!
jets 在 2021 年度 OSC 中国开源项目评选 中已获得 {{ projectVoteCount }} 票,请投票支持!
2021 年度 OSC 中国开源项目评选 正在火热进行中,快来投票支持你喜欢的开源项目!
2021 年度 OSC 中国开源项目评选 >>> 中场回顾
jets 获得 2021 年度 OSC 中国开源项目评选「最佳人气项目」 !
授权协议 MIT License
开发语言 JavaScript
操作系统 跨平台
软件类型 开源软件
所属分类 云计算Serverless 系统
开源组织
地区 不详
投 递 者 首席测试
适用人群 未知
收录时间 2021-12-02

软件简介

Ruby and Lambda splat out a baby and that child's name is Jets.

Build Status CircleCI Gem Version Support Gitter Chat

BoltOps Badge

Please watch/star this repo to help grow and support the project.

Upgrading: If you are upgrading Jets, please check on the Upgrading Notes.

Sponsors

What is Ruby on Jets?

Jets is a Ruby Serverless Framework. Jets allows you to create serverless applications with a beautiful language: Ruby. It includes everything required to build an application and deploy it to AWS Lambda.

It is key to understand AWS Lambda and API Gateway to understand Jets conceptually. Jets maps your code to Lambda functions and API Gateway resources.

  • AWS Lambda is Functions as a Service. It allows you to upload and run functions without worrying about the underlying infrastructure.
  • API Gateway is the routing layer for Lambda. It is used to route REST URL endpoints to Lambda functions.

The official documentation is at Ruby on Jets.

Refer to the official docs for more info, but here's a quick intro.

Jets Functions

Jets supports writing AWS Lambda functions with Ruby. You define them in the app/functions folder. A function looks like this:

app/functions/simple.rb:

def lambda_handler(event:, context:)
  puts "hello world"
  {hello: "world"}
end

Here's the function in the Lambda console:

Code Example in AWS Lambda console

Though simple functions are supported by Jets, they do not add much value as other ways to write Ruby code with Jets. Classes like Controllers and Jobs add many conveniences and are more powerful to use. We’ll cover them next.

Jets Controllers

A Jets controller handles a web request and renders a response. Here's an example:

app/controllers/posts_controller.rb:

class PostsController < ApplicationController
  def index
    # renders Lambda Proxy structure compatible with API Gateway
    render json: {hello: "world", action: "index"}
  end

  def show
    id = params[:id] # params available
    # puts goes to the lambda logs
    puts event # raw lambda event available
    render json: {action: "show", id: id}
  end
end

Helper methods like params provide the parameters from the API Gateway event. The render method renders a Lambda Proxy structure back that API Gateway understands.

Jets creates Lambda functions for each public method in your controller. Here they are in the Lambda console:

Lambda Functions for each public method in AWS Console

Jets Routing

You connect Lambda functions to API Gateway URL endpoints with a routes file:

config/routes.rb:

Jets.application.routes.draw do
  get  "posts", to: "posts#index"
  get  "posts/new", to: "posts#new"
  get  "posts/:id", to: "posts#show"
  post "posts", to: "posts#create"
  get  "posts/:id/edit", to: "posts#edit"
  put  "posts", to: "posts#update"
  delete  "posts", to: "posts#delete"

  resources :comments # expands to the RESTful routes above

  any "posts/hot", to: "posts#hot" # GET, POST, PUT, etc request all work
end

The routes.rb gets translated to API Gateway resources:

API Gateway Resources generated from routes in AWS console

Test your API Gateway endpoints with curl or postman. Note, replace the URL endpoint with the one that is created:

$ curl -s "https://quabepiu80.execute-api.us-east-1.amazonaws.com/dev/posts" | jq .
{
  "hello": "world",
  "action": "index"
}

Jets Jobs

A Jets job handles asynchronous background jobs performed outside of the web request/response cycle. Here's an example:

app/jobs/hard_job.rb:

class HardJob < ApplicationJob
  rate "10 hours" # every 10 hours
  def dig
    puts "done digging"
  end

  cron "0 */12 * * ? *" # every 12 hours
  def lift
    puts "done lifting"
  end
end

HardJob#dig runs every 10 hours and HardJob#lift runs every 12 hours. The rate and cron methods created CloudWatch Event Rules. Example:

CloudWatch Event Rules in AWS Console

Jets Deployment

You can test your application with a local server that mimics API Gateway: Jets Local Server. Once ready, deploying to AWS Lambda is a single command.

jets deploy

After deployment, you can test the Lambda functions with the AWS Lambda console or the CLI.

AWS Lambda Console

Lambda Console

Live Demos

Here are some demos of Jets applications:

Please feel free to add your own example to the jets-examples repo.

Rails Support

Jets Afterburner Mode provides Rails support with little effort. This allows you to run a Rails application on AWS Lambda. Also here's a Tutorial Blog Post: Jets Afterburner: Rails Support.

More Info

For more documentation, check out the official docs: Ruby on Jets. Here's a list of useful links:

Learning Content

展开阅读全文

代码

评论

点击引领话题📣
暂无内容
发表了博客
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
发表了问答
{{o.pubDate | formatDate}}

{{formatAllHtml(o.title)}}

{{parseInt(o.replyCount) | bigNumberTransform}}
{{parseInt(o.viewCount) | bigNumberTransform}}
没有更多内容
暂无内容
NPM url-parse 安全漏洞
通过用户控制密钥绕过授权机制
Url-Parse是一个跨 Node.js 和浏览器环境无缝工作的小型 Url 解析器。 NPM url-parse 存在安全漏洞,该漏洞源于在1.5.6之前的NPM url-parse中,通过用户控制的密钥绕过授权。
CVE-2022-0512 MPS-2022-3327
2022-08-08 18:59
NPM url-parse授权绕过漏洞
Url-Parse是一个跨Node.js和浏览器环境无缝工作的小型Url解析器。NPM url-parse 1.5.8之前版本存在授权绕过漏洞,攻击者可利用该漏洞通过用户控制的密钥绕过授权。
CVE-2022-0686 MPS-2022-4464
2022-08-08 18:59
Math.js JavaScript引擎任意代码执行漏洞
代码注入
Math.js是一款应用于JavaScript和Node.js的数学库,它支持符号计算,内置大量函数与常量。JavaScript engine是其中的一个JavaScript引擎。 Math.js 3.17.0之前的版本中的JavaScript引擎存在任意代码执行漏洞。攻击者可利用该漏洞执行任意代码。
CVE-2017-1001002 MPS-2017-13367
2022-08-08 18:59
fstream 后置链接漏洞
在文件访问前对链接解析不恰当(链接跟随)
fstream是一个用于读取和写入文件的库。 fstream 1.0.12之前版本中的‘fstream.DirWriter()’函数存在后置链接漏洞。该漏洞源于网络系统或产品未正确过滤表示非预期资源的链接或者快捷方式的文件名。攻击者可利用该漏洞访问非法的文件路径。
CVE-2019-13173 MPS-2019-7423
2022-08-08 18:59
npm url-parse 输入验证错误漏洞
输入验证不恰当
npm url-parse 1.4.4及之前版本中存在输入验证错误漏洞。该漏洞源于网络系统或产品未对输入的数据进行正确的验证。
CVE-2020-8124 MPS-2020-1742
2022-08-08 18:59
Npm Ini 资源管理错误漏洞
拒绝服务
Npm Ini是美国Npm公司的一个基于Javascript的用于解析和序列化Ini格式文件的代码库。 Npm ini before 1.3.6 存在资源管理错误漏洞,该漏洞允许攻击者可利用该漏洞向应用程序提交恶意的INI文件,该应用程序将用INI解析该文件。这可以根据上下文进一步加以利用。
CVE-2020-7788 MPS-2020-17544
2022-08-08 18:59
Elliptic package 输入验证错误漏洞
整数溢出或超界折返
Elliptic package是一款基于JavaScript的椭圆曲线密码库。 Elliptic package 6.5.2版本(Node.js)中存在安全漏洞。攻击者可利用该漏洞提升权限。
CVE-2020-13822 MPS-2020-8202
2022-08-08 18:59
trim-newlines 安全漏洞
拒绝服务
trim-newlines是一个修改换行符的npm包。 trim-newlines 存在安全漏洞,该漏洞源于应用于Node.js在3.0.1与4.0.1版本及之前版本中.end()方法存在相关问题。
CVE-2021-33623 MPS-2021-7398
2022-08-08 18:59
url-parse 安全漏洞
url-parse是一款跨Node.js和浏览器环境的小型URL解析器。 url-parse 1.4.3之前版本中存在安全漏洞,该漏洞源于程序没有进行正确的解析,导致返回错误的主机名。远程攻击者可利用该漏洞实施服务器端请求伪造攻击、开放重定向攻击或绕过身份验证协议。
CVE-2018-3774 MPS-2018-11050
2022-08-08 18:59
LibSass 资源管理错误漏洞
UAF
LibSass是一个开源的使用C语言编写的Sass(CSS扩展语言)解析器。 LibSass 3.4.x版本和3.5.x版本至3.5.4版本中的sass_context.cpp文件的‘handle_error()’函数存在资源管理错误漏洞。该漏洞源于网络系统或产品对系统资源(如内存、磁盘空间、文件等)的管理不当。
CVE-2018-11499 MPS-2018-6523
2022-08-08 18:59
Color-String 安全漏洞
不加限制或调节的资源分配
Color-String是开源的一个库,用于解析和生成 CSS 颜色字符串。 Color-String 1.5.5及之前版本存在安全漏洞,该漏洞源于当应用程序检查一个精心制作的数据时,就会出现正则表达式拒绝服务(ReDOS)。
CVE-2021-29060 MPS-2021-8683
2022-08-08 18:59
Digital Bazaar Forge 输入验证错误漏洞
跨站重定向
Digital Bazaar Forge是美国Digital Bazaar公司的一个 Tls 在 Javascript 中的本机实现以及用于编写基于加密和网络密集型 Web 应用程序的开源工具。 Digital Bazaar Forge 中存在输入验证错误漏洞,该漏洞源于产品允许URL重定向到不受信任的站点。
CVE-2022-0122 MPS-2022-0421
2022-08-08 18:59
js-yaml 存在代码注入漏洞
代码注入
js-yaml 是一种人性化的数据序列化语言。此软件包的受影响版本容易受到任意代码执行的影响。
MPS-2022-13822
2022-08-08 18:59
Digital Bazaar Forge数据伪造问题漏洞
密码学签名的验证不恰当
Digital Bazaar Forge是美国Digital Bazaar公司的一个Tls在Javascript中的本机实现以及用于编写基于加密和网络密集型Web应用程序的开源工具。Digital Bazaar Forge1.3.0之前版本存在数据伪造问题漏洞,该漏洞源于SA PKCS#1 v1.5签名验证码无法正确检查DigestInfo以获得正确的 ASN.1 结构。攻击者可以发送特殊的签名利用该漏洞以验证包含无效结构但有效摘要的签名。
CVE-2022-24773 MPS-2022-3740
2022-08-08 18:59
Eran Hammer cryptiles 安全漏洞
信息熵不充分
Eran Hammer cryptiles是一款通用加密工具。 Eran Hammer cryptiles 4.1.1之前版本中的randomDigits()方法存在安全漏洞。攻击者可利用该漏洞暴力破解随机数。
CVE-2018-1000620 MPS-2018-9401
2022-08-08 18:59
Yargs Y18n 输入验证错误漏洞
动态确定对象属性修改的控制不恰当
Yargs Y18n是Yargs个人开发者的一个类似I18n的由Js编写的代码库。 y18n before 3.2.2, 4.0.1 and 5.0.5版本存在输入验证错误漏洞,该漏洞源于网络系统或产品未对输入的数据进行正确的验证。
CVE-2020-7774 MPS-2020-17543
2022-08-08 18:59
node-tar 路径遍历漏洞
路径遍历
node-tar是一款用于文件压缩/解压缩的软件包。 npm node-tar 存在路径遍历漏洞,该漏洞源于4.4.18、5.0.10和6.1.9之前的npm包“tar”(又名node-tar)存在任意文件创建覆盖和任意代码执行漏洞。攻击者可利用该漏洞访问受限目录之外的位置。
CVE-2021-37713 MPS-2021-28489
2022-08-08 18:59
Async 安全漏洞
原型污染
Async是英国Caolan McMahon个人开发者的一个实用模块。用于使用异步 JavaScript。 Async 3.2.1 及之前版本存在安全漏洞,该漏洞源于 mapValues() 方法。攻击者可通过 mapValues() 方法获取权限。
CVE-2021-43138 MPS-2021-34434
2022-08-08 18:59
node-forge 存在拒绝服务漏洞
node-forge 是 JavaScript 中 TLS(和各种其他加密工具)的本机实现。此软件包的受影响版本容易受到正则表达式拒绝服务 (ReDoS) 攻击。
MPS-2022-13022
2022-08-08 18:59
Math.js存在未明漏洞
输入验证不恰当
Math.js是一款应用于JavaScript和Node.js的数学库,它支持符号计算,内置大量函数与常量。 Math.js 3.17.0之前的版本中存在安全漏洞。在创建对象时,攻击者可利用该漏洞替换私有属性。
CVE-2017-1001003 MPS-2017-13368
2022-08-08 18:59
没有更多内容
加载失败,请刷新页面
点击加载更多
加载中
下一页
0 评论
0 收藏
分享
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部