From 8e57cdd87fe6b0c0e55df6c6517806769b079e0d Mon Sep 17 00:00:00 2001 From: hahwul Date: Mon, 21 Aug 2023 23:53:27 +0900 Subject: [PATCH 1/7] Change filename --- .github/workflows/{ghcr.yml => ghcr_publish.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{ghcr.yml => ghcr_publish.yml} (100%) diff --git a/.github/workflows/ghcr.yml b/.github/workflows/ghcr_publish.yml similarity index 100% rename from .github/workflows/ghcr.yml rename to .github/workflows/ghcr_publish.yml From f8ecc761e57b3bd232959c5f6bfd302764f40964 Mon Sep 17 00:00:00 2001 From: hahwul Date: Mon, 21 Aug 2023 23:57:59 +0900 Subject: [PATCH 2/7] Add homebrew publish workflow --- .github/workflows/homebrew_publish.yml | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/homebrew_publish.yml diff --git a/.github/workflows/homebrew_publish.yml b/.github/workflows/homebrew_publish.yml new file mode 100644 index 00000000..19719c73 --- /dev/null +++ b/.github/workflows/homebrew_publish.yml @@ -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: hahwul@gmail.com + + 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 \ No newline at end of file From 53e81b63c520d973cfe28274085d0b1aa46a6397 Mon Sep 17 00:00:00 2001 From: hahwul Date: Tue, 22 Aug 2023 00:00:39 +0900 Subject: [PATCH 3/7] Fixed --- .github/workflows/homebrew_publish.yml | 58 +++++++++++++------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/homebrew_publish.yml b/.github/workflows/homebrew_publish.yml index 19719c73..3325e558 100644 --- a/.github/workflows/homebrew_publish.yml +++ b/.github/workflows/homebrew_publish.yml @@ -1,35 +1,35 @@ name: Homebrew tab Publish on: - release: - types: [published] + 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 +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: hahwul@gmail.com - - depends_on: | - "crystal" - - install: | - system "shards install" - system "shards build --release --no-debug --production" - bin.install "bin/noir" + github_token: ${{ secrets.NOIR_PUBLISH_TOKEN }} + + commit_owner: hahwul + commit_email: hahwul@gmail.com + + 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 \ No newline at end of file + test: 'system "{bin}/noir", "-v"' + update_readme_table: true + skip_commit: false + debug: false \ No newline at end of file From 6291f6a9b248f7e4a80775190d7eaaaeb0f4ea8f Mon Sep 17 00:00:00 2001 From: hahwul Date: Tue, 22 Aug 2023 00:16:00 +0900 Subject: [PATCH 4/7] Update example of analyzer --- src/analyzer/analyzers/analyzer_example.cr | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/analyzer/analyzers/analyzer_example.cr b/src/analyzer/analyzers/analyzer_example.cr index d4e34479..e21600e2 100644 --- a/src/analyzer/analyzers/analyzer_example.cr +++ b/src/analyzer/analyzers/analyzer_example.cr @@ -16,3 +16,8 @@ class AnalyzerExample < Analyzer @result end end + +def analyzer_example(options : Hash(Symbol, String)) + instance = AnalyzerExample.new(options) + instance.analyze +end \ No newline at end of file From a2b76c8bd602bb7a65b67eb6233f06b46f550cab Mon Sep 17 00:00:00 2001 From: hahwul Date: Tue, 22 Aug 2023 00:27:22 +0900 Subject: [PATCH 5/7] Add header in sinatra --- README.md | 2 +- spec/analyzer/analyzer_sinatra_spec.cr | 27 ++++++++++++++++++++++ src/analyzer/analyzers/analyzer_example.cr | 2 +- src/analyzer/analyzers/analyzer_sinatra.cr | 15 ++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 spec/analyzer/analyzer_sinatra_spec.cr diff --git a/README.md b/README.md index 9bfd1e9e..943af6db 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ | 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 | diff --git a/spec/analyzer/analyzer_sinatra_spec.cr b/spec/analyzer/analyzer_sinatra_spec.cr new file mode 100644 index 00000000..744f771b --- /dev/null +++ b/spec/analyzer/analyzer_sinatra_spec.cr @@ -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 diff --git a/src/analyzer/analyzers/analyzer_example.cr b/src/analyzer/analyzers/analyzer_example.cr index e21600e2..5fbf2ac9 100644 --- a/src/analyzer/analyzers/analyzer_example.cr +++ b/src/analyzer/analyzers/analyzer_example.cr @@ -20,4 +20,4 @@ end def analyzer_example(options : Hash(Symbol, String)) instance = AnalyzerExample.new(options) instance.analyze -end \ No newline at end of file +end diff --git a/src/analyzer/analyzers/analyzer_sinatra.cr b/src/analyzer/analyzers/analyzer_sinatra.cr index db33b23d..c6e91c88 100644 --- a/src/analyzer/analyzers/analyzer_sinatra.cr +++ b/src/analyzer/analyzers/analyzer_sinatra.cr @@ -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 From 3c412f3b13d601ce7496e145e6c50e4225c6b2d7 Mon Sep 17 00:00:00 2001 From: hahwul Date: Tue, 22 Aug 2023 00:32:28 +0900 Subject: [PATCH 6/7] Add header in kemal --- README.md | 2 +- spec/analyzer/analyzer_kemal_spec.cr | 27 ++++++++++++++++++++++++ src/analyzer/analyzers/analyzer_kemal.cr | 5 +++++ 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 spec/analyzer/analyzer_kemal_spec.cr diff --git a/README.md b/README.md index 943af6db..9c6ff018 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ | 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 | diff --git a/spec/analyzer/analyzer_kemal_spec.cr b/spec/analyzer/analyzer_kemal_spec.cr new file mode 100644 index 00000000..a0276a1f --- /dev/null +++ b/spec/analyzer/analyzer_kemal_spec.cr @@ -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 diff --git a/src/analyzer/analyzers/analyzer_kemal.cr b/src/analyzer/analyzers/analyzer_kemal.cr index 78833a82..485ad1dd 100644 --- a/src/analyzer/analyzers/analyzer_kemal.cr +++ b/src/analyzer/analyzers/analyzer_kemal.cr @@ -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 From 5dd1a8572e9b0bf1236b139fc77c3ee5eaebad12 Mon Sep 17 00:00:00 2001 From: hahwul Date: Tue, 22 Aug 2023 00:35:10 +0900 Subject: [PATCH 7/7] Tap v0.5.0 --- src/noir.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/noir.cr b/src/noir.cr index 1134d5f5..e7482408 100644 --- a/src/noir.cr +++ b/src/noir.cr @@ -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()