Skip to content

Commit

Permalink
Merge pull request #30 from hahwul/hahwul-dev
Browse files Browse the repository at this point in the history
Hahwul dev
  • Loading branch information
hahwul authored Aug 21, 2023
2 parents 8dd1391 + 5dd1a85 commit 8c2ac9e
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 3 deletions.
File renamed without changes.
35 changes: 35 additions & 0 deletions .github/workflows/homebrew_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Homebrew tab Publish

on:
release:
types: [published]

jobs:
homebrew-releaser:
runs-on: ubuntu-latest
name: homebrew-releaser
steps:
- name: Release Noir to Homebrew tap
uses: Justintime50/homebrew-releaser@v1
with:
homebrew_owner: hahwul
homebrew_tap: homebrew-noir
formula_folder: Formula

github_token: ${{ secrets.NOIR_PUBLISH_TOKEN }}

commit_owner: hahwul
commit_email: [email protected]

depends_on: |
"crystal"
install: |
system "shards install"
system "shards build --release --no-debug --production"
bin.install "bin/noir"
test: 'system "{bin}/noir", "-v"'
update_readme_table: true
skip_commit: false
debug: false
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
| Python | Django || X | X | X | X |
| Python | Flask || X | X | X | X |
| Ruby | Rails |||| X | X |
| Ruby | Sinatra |||| X | X |
| Ruby | Sinatra |||| | X |
| Php | |||| X | X |
| Java | Spring ||| X | X | X |
| Java | Jsp | X | X | X | X | X |
| Crystal | Kemal |||| X ||
| Crystal | Kemal |||| ||
| JS | Express ||| X | X | X |
| JS | Next | X | X | X | X | X |

Expand Down
27 changes: 27 additions & 0 deletions spec/analyzer/analyzer_kemal_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "../../src/analyzer/analyzers/analyzer_kemal.cr"
require "../../src/options"

describe "mapping_to_path" do
options = default_options()
instance = AnalyzerKemal.new(options)

it "line_to_param - env.params.query" do
line = "env.params.query[\"id\"]"
instance.line_to_param(line).name.should eq("id")
end

it "line_to_param - env.params.json" do
line = "env.params.json[\"id\"]"
instance.line_to_param(line).name.should eq("id")
end

it "line_to_param - env.params.body" do
line = "env.params.body[\"id\"]"
instance.line_to_param(line).name.should eq("id")
end

it "line_to_param - env.response.headers[]" do
line = "env.response.headers[\"x-token\"]"
instance.line_to_param(line).name.should eq("x-token")
end
end
27 changes: 27 additions & 0 deletions spec/analyzer/analyzer_sinatra_spec.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
require "../../src/analyzer/analyzers/analyzer_sinatra.cr"
require "../../src/options"

describe "mapping_to_path" do
options = default_options()
instance = AnalyzerSinatra.new(options)

it "line_to_param - param[]" do
line = "param['id']"
instance.line_to_param(line).name.should eq("id")
end

it "line_to_param - params[]" do
line = "params['id']"
instance.line_to_param(line).name.should eq("id")
end

it "line_to_param - headers[]" do
line = "headers['x-token']"
instance.line_to_param(line).name.should eq("x-token")
end

it "line_to_param - request.env" do
line = "request.env[\"x-token\"]"
instance.line_to_param(line).name.should eq("x-token")
end
end
5 changes: 5 additions & 0 deletions src/analyzer/analyzers/analyzer_example.cr
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ class AnalyzerExample < Analyzer
@result
end
end

def analyzer_example(options : Hash(Symbol, String))
instance = AnalyzerExample.new(options)
instance.analyze
end
5 changes: 5 additions & 0 deletions src/analyzer/analyzers/analyzer_kemal.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class AnalyzerKemal < Analyzer
return Param.new(param, "", "body")
end

if content.includes? "env.response.headers["
param = content.split("env.response.headers[")[1].split("]")[0].gsub("\"", "").gsub("'", "")
return Param.new(param, "", "header")
end

Param.new("", "", "")
end

Expand Down
15 changes: 15 additions & 0 deletions src/analyzer/analyzers/analyzer_sinatra.cr
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ class AnalyzerSinatra < Analyzer
return Param.new(param, "", "query")
end

if content.includes? "params["
param = content.split("params[")[1].split("]")[0].gsub("\"", "").gsub("'", "")
return Param.new(param, "", "query")
end

if content.includes? "request.env["
param = content.split("request.env[")[1].split("]")[0].gsub("\"", "").gsub("'", "")
return Param.new(param, "", "header")
end

if content.includes? "headers["
param = content.split("headers[")[1].split("]")[0].gsub("\"", "").gsub("'", "")
return Param.new(param, "", "header")
end

Param.new("", "", "")
end

Expand Down
2 changes: 1 addition & 1 deletion src/noir.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require "./options.cr"
require "./techs/techs.cr"

module Noir
VERSION = "0.4.0"
VERSION = "0.5.0"
end

noir_options = default_options()
Expand Down

0 comments on commit 8c2ac9e

Please sign in to comment.