diff --git a/spec/unit_test/detector/detect_crystal_kemal_spec.cr b/spec/unit_test/detector/crystal/kemal_spec.cr similarity index 66% rename from spec/unit_test/detector/detect_crystal_kemal_spec.cr rename to spec/unit_test/detector/crystal/kemal_spec.cr index 7ffafc68..611f2d19 100644 --- a/spec/unit_test/detector/detect_crystal_kemal_spec.cr +++ b/spec/unit_test/detector/crystal/kemal_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/crystal/*" describe "Detect Crystal Kemal" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorCrystalKemal.new options + instance = Detector::Crystal::Kemal.new options it "shard.yml" do instance.detect("shard.yml", "kemalcr/kemal").should eq(true) diff --git a/spec/unit_test/detector/detect_crystal_lucky_spec.cr b/spec/unit_test/detector/crystal/lucky_spec.cr similarity index 67% rename from spec/unit_test/detector/detect_crystal_lucky_spec.cr rename to spec/unit_test/detector/crystal/lucky_spec.cr index a5271a7f..c4e4b331 100644 --- a/spec/unit_test/detector/detect_crystal_lucky_spec.cr +++ b/spec/unit_test/detector/crystal/lucky_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/crystal/*" describe "Detect Crystal Lucky" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorCrystalLucky.new options + instance = Detector::Crystal::Lucky.new options it "shard.yml" do instance.detect("shard.yml", "luckyframework/lucky").should eq(true) diff --git a/spec/unit_test/detector/detect_cs_aspnet_mvc_spec.cr b/spec/unit_test/detector/csharp/aspnet_mvc_spec.cr similarity index 67% rename from spec/unit_test/detector/detect_cs_aspnet_mvc_spec.cr rename to spec/unit_test/detector/csharp/aspnet_mvc_spec.cr index 0191efa1..0b7c92e1 100644 --- a/spec/unit_test/detector/detect_cs_aspnet_mvc_spec.cr +++ b/spec/unit_test/detector/csharp/aspnet_mvc_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/csharp/*" describe "Detect C# ASP.Net MVC" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorCSharpAspNetMvc.new options + instance = Detector::CSharp::AspNetMvc.new options it "packages" do instance.detect("packages.config", "Microsoft.AspNet.Mvc").should eq(true) diff --git a/spec/unit_test/detector/detect_elixir_phoenix_spec.cr b/spec/unit_test/detector/elixir/phoenix_spec.cr similarity index 66% rename from spec/unit_test/detector/detect_elixir_phoenix_spec.cr rename to spec/unit_test/detector/elixir/phoenix_spec.cr index 5c62a4a6..bd0bfb7e 100644 --- a/spec/unit_test/detector/detect_elixir_phoenix_spec.cr +++ b/spec/unit_test/detector/elixir/phoenix_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/elixir/*" describe "Detect Elixir Phoenix" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorElixirPhoenix.new options + instance = Detector::Elixir::Phoenix.new options it "mix" do instance.detect("mix.exs", "ElixirPhoenix").should eq(true) diff --git a/spec/unit_test/detector/detect_go_beego_spec.cr b/spec/unit_test/detector/go/beego_spec.cr similarity index 69% rename from spec/unit_test/detector/detect_go_beego_spec.cr rename to spec/unit_test/detector/go/beego_spec.cr index ac72d2d8..60cbc61b 100644 --- a/spec/unit_test/detector/detect_go_beego_spec.cr +++ b/spec/unit_test/detector/go/beego_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/go/*" describe "Detect Go BeegoEcho" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorGoBeego.new options + instance = Detector::Go::Beego.new options it "go.mod" do instance.detect("go.mod", "github.com/beego/beego").should eq(true) diff --git a/spec/unit_test/detector/detect_go_echo_spec.cr b/spec/unit_test/detector/go/echo_spec.cr similarity index 69% rename from spec/unit_test/detector/detect_go_echo_spec.cr rename to spec/unit_test/detector/go/echo_spec.cr index 9567bdcf..854e0f13 100644 --- a/spec/unit_test/detector/detect_go_echo_spec.cr +++ b/spec/unit_test/detector/go/echo_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/go/*" describe "Detect Go Echo" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorGoEcho.new options + instance = Detector::Go::Echo.new options it "go.mod" do instance.detect("go.mod", "github.com/labstack/echo").should eq(true) diff --git a/spec/unit_test/detector/detect_go_fiber_spec.cr b/spec/unit_test/detector/go/fiber_spec.cr similarity index 68% rename from spec/unit_test/detector/detect_go_fiber_spec.cr rename to spec/unit_test/detector/go/fiber_spec.cr index f11064cf..26e1eaae 100644 --- a/spec/unit_test/detector/detect_go_fiber_spec.cr +++ b/spec/unit_test/detector/go/fiber_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/go/*" describe "Detect Go Fiber" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorGoFiber.new options + instance = Detector::Go::Fiber.new options it "go.mod" do instance.detect("go.mod", "github.com/gofiber/fiber").should eq(true) diff --git a/spec/unit_test/detector/detect_go_gin_spec.cr b/spec/unit_test/detector/go/gin_spec.cr similarity index 69% rename from spec/unit_test/detector/detect_go_gin_spec.cr rename to spec/unit_test/detector/go/gin_spec.cr index 2fe4f96d..868893f8 100644 --- a/spec/unit_test/detector/detect_go_gin_spec.cr +++ b/spec/unit_test/detector/go/gin_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/go/*" describe "Detect Go Gin" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorGoGin.new options + instance = Detector::Go::Gin.new options it "go.mod" do instance.detect("go.mod", "github.com/gin-gonic/gin").should eq(true) diff --git a/spec/unit_test/detector/detect_java_armeria_spec.cr b/spec/unit_test/detector/java/armeria_spec.cr similarity index 76% rename from spec/unit_test/detector/detect_java_armeria_spec.cr rename to spec/unit_test/detector/java/armeria_spec.cr index 8b559335..9519bb35 100644 --- a/spec/unit_test/detector/detect_java_armeria_spec.cr +++ b/spec/unit_test/detector/java/armeria_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Java Armeria" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorJavaArmeria.new options + instance = Detector::Java::Armeria.new options it "pom.xml" do instance.detect("pom.xml", "com.linecorp.armeria").should eq(true) diff --git a/spec/unit_test/detector/detect_java_jsp_spec.cr b/spec/unit_test/detector/java/jsp_spec.cr similarity index 68% rename from spec/unit_test/detector/detect_java_jsp_spec.cr rename to spec/unit_test/detector/java/jsp_spec.cr index d376b583..26d02bae 100644 --- a/spec/unit_test/detector/detect_java_jsp_spec.cr +++ b/spec/unit_test/detector/java/jsp_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Java JSP" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorJavaJsp.new options + instance = Detector::Java::Jsp.new options it "case1" do instance.detect("1.jsp", "<% info(); %>").should eq(true) diff --git a/spec/unit_test/detector/detect_java_spring_spec.cr b/spec/unit_test/detector/java/spring_spec.cr similarity index 72% rename from spec/unit_test/detector/detect_java_spring_spec.cr rename to spec/unit_test/detector/java/spring_spec.cr index 33aba869..62a3086a 100644 --- a/spec/unit_test/detector/detect_java_spring_spec.cr +++ b/spec/unit_test/detector/java/spring_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Java Spring" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorJavaSpring.new options + instance = Detector::Java::Spring.new options it "test.java" do instance.detect("test.java", "import org.springframework.boot.SpringApplication;").should eq(true) diff --git a/spec/unit_test/detector/detect_js_express_spec.cr b/spec/unit_test/detector/javascript/express_spec.cr similarity index 76% rename from spec/unit_test/detector/detect_js_express_spec.cr rename to spec/unit_test/detector/javascript/express_spec.cr index e01d3570..5db01eae 100644 --- a/spec/unit_test/detector/detect_js_express_spec.cr +++ b/spec/unit_test/detector/javascript/express_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect JS Express" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorJsExpress.new options + instance = Detector::Javascript::Express.new options it "require_single_quot" do instance.detect("index.js", "require('express')").should eq(true) diff --git a/spec/unit_test/detector/detect_js_restify_spec.cr b/spec/unit_test/detector/javascript/restify_spec.cr similarity index 76% rename from spec/unit_test/detector/detect_js_restify_spec.cr rename to spec/unit_test/detector/javascript/restify_spec.cr index 39bc825a..c38275f7 100644 --- a/spec/unit_test/detector/detect_js_restify_spec.cr +++ b/spec/unit_test/detector/javascript/restify_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect JS Restify" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorJsRestify.new options + instance = Detector::Javascript::Restify.new options it "require_single_quot" do instance.detect("index.js", "require('restify')").should eq(true) diff --git a/spec/unit_test/detector/detect_kotlin_spring_spe_spec.cr b/spec/unit_test/detector/kotlin/spring_spec.cr similarity index 71% rename from spec/unit_test/detector/detect_kotlin_spring_spe_spec.cr rename to spec/unit_test/detector/kotlin/spring_spec.cr index d1757a32..fcace85e 100644 --- a/spec/unit_test/detector/detect_kotlin_spring_spe_spec.cr +++ b/spec/unit_test/detector/kotlin/spring_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Kotlin Spring" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorKotlinSpring.new options + instance = Detector::Kotlin::Spring.new options it "test.kt" do instance.detect("test.kt", "import org.springframework.boot.SpringApplication").should eq(true) diff --git a/spec/unit_test/detector/detect_php_pure_spec.cr b/spec/unit_test/detector/php/php_spec.cr similarity index 82% rename from spec/unit_test/detector/detect_php_pure_spec.cr rename to spec/unit_test/detector/php/php_spec.cr index 4f59fe90..dc4430ff 100644 --- a/spec/unit_test/detector/detect_php_pure_spec.cr +++ b/spec/unit_test/detector/php/php_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Php Pure" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorPhpPure.new options + instance = Detector::Php::Php.new options it "detect_php 1" do instance.detect("1.php", "").should eq(true) diff --git a/spec/unit_test/detector/detect_python_django_spec.cr b/spec/unit_test/detector/python/django_spec.cr similarity index 70% rename from spec/unit_test/detector/detect_python_django_spec.cr rename to spec/unit_test/detector/python/django_spec.cr index 5c1afac0..e42506d7 100644 --- a/spec/unit_test/detector/detect_python_django_spec.cr +++ b/spec/unit_test/detector/python/django_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Python Django" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorPythonDjango.new options + instance = Detector::Python::Django.new options it "settings.py" do instance.detect("settings.py", "from django.apps import AppConfig").should eq(true) diff --git a/spec/unit_test/detector/detect_python_fastapi_spec.cr b/spec/unit_test/detector/python/fastapi_spec.cr similarity index 68% rename from spec/unit_test/detector/detect_python_fastapi_spec.cr rename to spec/unit_test/detector/python/fastapi_spec.cr index 3e0abbed..1ba19f26 100644 --- a/spec/unit_test/detector/detect_python_fastapi_spec.cr +++ b/spec/unit_test/detector/python/fastapi_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Python FastAPI" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorPythonFastAPI.new options + instance = Detector::Python::FastAPI.new options it "settings.py" do instance.detect("settings.py", "from fastapi").should eq(true) diff --git a/spec/unit_test/detector/detect_python_flask_spec.cr b/spec/unit_test/detector/python/flask_spec.cr similarity index 70% rename from spec/unit_test/detector/detect_python_flask_spec.cr rename to spec/unit_test/detector/python/flask_spec.cr index b98f2b56..ae9ecf86 100644 --- a/spec/unit_test/detector/detect_python_flask_spec.cr +++ b/spec/unit_test/detector/python/flask_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Python Flask" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorPythonFlask.new options + instance = Detector::Python::Flask.new options it "detect_flask - app.py" do instance.detect("app.py", "from flask import Flask").should eq(true) diff --git a/spec/unit_test/detector/detect_ruby_hanami_spec.cr b/spec/unit_test/detector/ruby/hanami_spec.cr similarity index 76% rename from spec/unit_test/detector/detect_ruby_hanami_spec.cr rename to spec/unit_test/detector/ruby/hanami_spec.cr index 0f0237f5..7f6de1ab 100644 --- a/spec/unit_test/detector/detect_ruby_hanami_spec.cr +++ b/spec/unit_test/detector/ruby/hanami_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Ruby Hanami" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorRubyHanami.new options + instance = Detector::Ruby::Hanami.new options it "gemfile/single_quot" do instance.detect("Gemfile", "gem 'hanami'").should eq(true) diff --git a/spec/unit_test/detector/detect_ruby_rails_spec.cr b/spec/unit_test/detector/ruby/rails_spec.cr similarity index 76% rename from spec/unit_test/detector/detect_ruby_rails_spec.cr rename to spec/unit_test/detector/ruby/rails_spec.cr index 8963656a..cf9a0a3f 100644 --- a/spec/unit_test/detector/detect_ruby_rails_spec.cr +++ b/spec/unit_test/detector/ruby/rails_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Ruby Rails" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorRubyRails.new options + instance = Detector::Ruby::Rails.new options it "gemfile/single_quot" do instance.detect("Gemfile", "gem 'rails'").should eq(true) diff --git a/spec/unit_test/detector/detect_ruby_sinatra_spec.cr b/spec/unit_test/detector/ruby/sinatra_spec.cr similarity index 76% rename from spec/unit_test/detector/detect_ruby_sinatra_spec.cr rename to spec/unit_test/detector/ruby/sinatra_spec.cr index 473578e6..a257cc00 100644 --- a/spec/unit_test/detector/detect_ruby_sinatra_spec.cr +++ b/spec/unit_test/detector/ruby/sinatra_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Ruby Sinatra" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorRubySinatra.new options + instance = Detector::Ruby::Sinatra.new options it "gemfile/single_quot" do instance.detect("Gemfile", "gem 'sinatra'").should eq(true) diff --git a/spec/unit_test/detector/detect_rust_axum_spec.cr b/spec/unit_test/detector/rust/axum_spec.cr similarity index 70% rename from spec/unit_test/detector/detect_rust_axum_spec.cr rename to spec/unit_test/detector/rust/axum_spec.cr index 5048242a..dca4db69 100644 --- a/spec/unit_test/detector/detect_rust_axum_spec.cr +++ b/spec/unit_test/detector/rust/axum_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Rust Axum" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorRustAxum.new options + instance = Detector::Rust::Axum.new options it "Gargo.toml" do instance.detect("Cargo.toml", "[dependencies]\naxum = {}").should eq(true) diff --git a/spec/unit_test/detector/detect_rust_rocket_spec.cr b/spec/unit_test/detector/rust/rocket_spec.cr similarity index 70% rename from spec/unit_test/detector/detect_rust_rocket_spec.cr rename to spec/unit_test/detector/rust/rocket_spec.cr index a4621c33..a1cf53b3 100644 --- a/spec/unit_test/detector/detect_rust_rocket_spec.cr +++ b/spec/unit_test/detector/rust/rocket_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect Rust Rocket" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorRustRocket.new options + instance = Detector::Rust::Rocket.new options it "Gargo.toml" do instance.detect("Cargo.toml", "[dependencies]\nrocket = {}").should eq(true) diff --git a/spec/unit_test/detector/detect_oas2_spec.cr b/spec/unit_test/detector/specification/oas2_spec.cr similarity index 83% rename from spec/unit_test/detector/detect_oas2_spec.cr rename to spec/unit_test/detector/specification/oas2_spec.cr index 031223bb..cbbaa056 100644 --- a/spec/unit_test/detector/detect_oas2_spec.cr +++ b/spec/unit_test/detector/specification/oas2_spec.cr @@ -1,10 +1,10 @@ -require "../../../src/detector/detectors/*" -require "../../../src/models/code_locator" +require "../../../../src/detector/detectors/*" +require "../../../../src/models/code_locator" describe "Detect OAS 2.0(Swagger) Docs" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorOas2.new options + instance = Detector::Specification::Oas2.new options it "json format" do content = <<-EOS diff --git a/spec/unit_test/detector/detect_oas3_spec.cr b/spec/unit_test/detector/specification/oas3_spec.cr similarity index 83% rename from spec/unit_test/detector/detect_oas3_spec.cr rename to spec/unit_test/detector/specification/oas3_spec.cr index 6570c71b..01f039fa 100644 --- a/spec/unit_test/detector/detect_oas3_spec.cr +++ b/spec/unit_test/detector/specification/oas3_spec.cr @@ -1,10 +1,10 @@ -require "../../../src/detector/detectors/*" -require "../../../src/models/code_locator" +require "../../../../src/detector/detectors/*" +require "../../../../src/models/code_locator" describe "Detect OAS 3.0 Docs" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorOas3.new options + instance = Detector::Specification::Oas3.new options it "json format" do content = <<-EOS diff --git a/spec/unit_test/detector/detect_raml_spec.cr b/spec/unit_test/detector/specification/raml_spec.cr similarity index 79% rename from spec/unit_test/detector/detect_raml_spec.cr rename to spec/unit_test/detector/specification/raml_spec.cr index 1149cac0..e72bb492 100644 --- a/spec/unit_test/detector/detect_raml_spec.cr +++ b/spec/unit_test/detector/specification/raml_spec.cr @@ -1,9 +1,9 @@ -require "../../../src/detector/detectors/*" +require "../../../../src/detector/detectors/*" describe "Detect RAML" do config_init = ConfigInitializer.new options = config_init.default_options - instance = DetectorRAML.new options + instance = Detector::Specification::RAML.new options it "raml" do instance.detect("app.yaml", "#%RAML\nApp: 1").should eq(true) diff --git a/spec/unit_test/models/noir_spec.cr b/spec/unit_test/models/noir_spec.cr index c9a61b44..653866ec 100644 --- a/spec/unit_test/models/noir_spec.cr +++ b/spec/unit_test/models/noir_spec.cr @@ -45,23 +45,23 @@ describe "set-pvalue" do it "applies pvalue to query parameter" do runner.apply_pvalue("query", "name", "value").should eq("FUZZ") end - + it "applies pvalue to header parameter with '=' delimiter" do runner.apply_pvalue("header", "name", "value").should eq("FUZZ") end - + it "does not apply pvalue to header parameter when name does not match" do runner.apply_pvalue("header", "name2", "value").should eq("value") end - + it "applies pvalue to cookie parameter with ':' delimiter" do runner.apply_pvalue("cookie", "name", "value").should eq("FUZZ") end - + it "does not apply pvalue to cookie parameter when name does not match" do runner.apply_pvalue("cookie", "name2", "value").should eq("value") end - + it "includes '=' in the pvalue for JSON parameter" do runner.apply_pvalue("json", "name", "value").should eq("FUZZ=FUZZ") end diff --git a/src/detector/detector.cr b/src/detector/detector.cr index 9dfb3ec3..35b79d72 100644 --- a/src/detector/detector.cr +++ b/src/detector/detector.cr @@ -1,10 +1,10 @@ -require "./detectors/*" +require "./detectors/**" require "../models/detector" require "yaml" macro defind_detectors(detectors) {% for detector, index in detectors %} - instance = {{detector}}.new(options) + instance = Detector::{{detector}}.new(options) instance.set_name detector_list << instance {% end %} @@ -16,33 +16,33 @@ def detect_techs(base_path : String, options : Hash(String, YAML::Any), logger : # Define detectors defind_detectors([ - DetectorCSharpAspNetMvc, - DetectorCrystalKemal, - DetectorCrystalLucky, - DetectorElixirPhoenix, - DetectorGoBeego, - DetectorGoEcho, - DetectorGoFiber, - DetectorGoGin, - DetectorHar, - DetectorJavaArmeria, - DetectorJavaJsp, - DetectorJavaSpring, - DetectorJsExpress, - DetectorJsRestify, - DetectorKotlinSpring, - DetectorOas2, - DetectorOas3, - DetectorPhpPure, - DetectorPythonDjango, - DetectorPythonFastAPI, - DetectorPythonFlask, - DetectorRAML, - DetectorRubyHanami, - DetectorRubyRails, - DetectorRubySinatra, - DetectorRustAxum, - DetectorRustRocket, + CSharp::AspNetMvc, + Crystal::Kemal, + Crystal::Lucky, + Elixir::Phoenix, + Go::Beego, + Go::Echo, + Go::Fiber, + Go::Gin, + Specification::Har, + Java::Armeria, + Java::Jsp, + Java::Spring, + Javascript::Express, + Javascript::Restify, + Kotlin::Spring, + Specification::Oas2, + Specification::Oas3, + Php::Php, + Python::Django, + Python::FastAPI, + Python::Flask, + Specification::RAML, + Ruby::Hanami, + Ruby::Rails, + Ruby::Sinatra, + Rust::Axum, + Rust::Rocket, ]) channel = Channel(String).new diff --git a/src/detector/detectors/crystal/kemal.cr b/src/detector/detectors/crystal/kemal.cr new file mode 100644 index 00000000..f02816ff --- /dev/null +++ b/src/detector/detectors/crystal/kemal.cr @@ -0,0 +1,16 @@ +require "../../../models/detector" + +module Detector::Crystal + class Kemal < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("kemalcr/kemal") + check = check && filename.includes?("shard.yml") + + check + end + + def set_name + @name = "crystal_kemal" + end + end +end diff --git a/src/detector/detectors/crystal/lucky.cr b/src/detector/detectors/crystal/lucky.cr new file mode 100644 index 00000000..51e375eb --- /dev/null +++ b/src/detector/detectors/crystal/lucky.cr @@ -0,0 +1,16 @@ +require "../../../models/detector" + +module Detector::Crystal + class Lucky < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("luckyframework/lucky") + check = check && filename.includes?("shard.yml") + + check + end + + def set_name + @name = "crystal_lucky" + end + end +end diff --git a/src/detector/detectors/crystal_kemal.cr b/src/detector/detectors/crystal_kemal.cr deleted file mode 100644 index 5374a075..00000000 --- a/src/detector/detectors/crystal_kemal.cr +++ /dev/null @@ -1,14 +0,0 @@ -require "../../models/detector" - -class DetectorCrystalKemal < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("kemalcr/kemal") - check = check && filename.includes?("shard.yml") - - check - end - - def set_name - @name = "crystal_kemal" - end -end diff --git a/src/detector/detectors/crystal_lucky.cr b/src/detector/detectors/crystal_lucky.cr deleted file mode 100644 index 42fcf46a..00000000 --- a/src/detector/detectors/crystal_lucky.cr +++ /dev/null @@ -1,14 +0,0 @@ -require "../../models/detector" - -class DetectorCrystalLucky < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("luckyframework/lucky") - check = check && filename.includes?("shard.yml") - - check - end - - def set_name - @name = "crystal_lucky" - end -end diff --git a/src/detector/detectors/cs_aspnet_mvc.cr b/src/detector/detectors/cs_aspnet_mvc.cr deleted file mode 100644 index f5f7e24b..00000000 --- a/src/detector/detectors/cs_aspnet_mvc.cr +++ /dev/null @@ -1,24 +0,0 @@ -require "../../models/detector" - -class DetectorCSharpAspNetMvc < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("Microsoft.AspNet.Mvc") - check = check && filename.includes?("packages.config") - check_routeconfig filename, file_contents - - check - end - - def check_routeconfig(filename : String, file_contents : String) - check = file_contents.includes?(".MapRoute") - check = check && filename.includes?("RouteConfig.cs") - if check - locator = CodeLocator.instance - locator.set("cs-apinet-mvc-routeconfig", filename) - end - end - - def set_name - @name = "c#-aspnet-mvc" - end -end diff --git a/src/detector/detectors/csharp/aspnet_mvc.cr b/src/detector/detectors/csharp/aspnet_mvc.cr new file mode 100644 index 00000000..e2f5b16e --- /dev/null +++ b/src/detector/detectors/csharp/aspnet_mvc.cr @@ -0,0 +1,26 @@ +require "../../../models/detector" + +module Detector::CSharp + class AspNetMvc < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("Microsoft.AspNet.Mvc") + check = check && filename.includes?("packages.config") + check_routeconfig filename, file_contents + + check + end + + def check_routeconfig(filename : String, file_contents : String) + check = file_contents.includes?(".MapRoute") + check = check && filename.includes?("RouteConfig.cs") + if check + locator = CodeLocator.instance + locator.set("cs-apinet-mvc-routeconfig", filename) + end + end + + def set_name + @name = "c#-aspnet-mvc" + end + end +end diff --git a/src/detector/detectors/elixir/phoenix.cr b/src/detector/detectors/elixir/phoenix.cr new file mode 100644 index 00000000..e356f7f1 --- /dev/null +++ b/src/detector/detectors/elixir/phoenix.cr @@ -0,0 +1,16 @@ +require "../../../models/detector" + +module Detector::Elixir + class Phoenix < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("ElixirPhoenix") + check = check && filename.includes?("mix.exs") + + check + end + + def set_name + @name = "elixir_phoenix" + end + end +end diff --git a/src/detector/detectors/elixir_phoenix.cr b/src/detector/detectors/elixir_phoenix.cr deleted file mode 100644 index 1010f1bf..00000000 --- a/src/detector/detectors/elixir_phoenix.cr +++ /dev/null @@ -1,14 +0,0 @@ -require "../../models/detector" - -class DetectorElixirPhoenix < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("ElixirPhoenix") - check = check && filename.includes?("mix.exs") - - check - end - - def set_name - @name = "elixir_phoenix" - end -end diff --git a/src/detector/detectors/go/beego.cr b/src/detector/detectors/go/beego.cr new file mode 100644 index 00000000..ba1b59c9 --- /dev/null +++ b/src/detector/detectors/go/beego.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Go + class Beego < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? "go.mod") && (file_contents.includes? "github.com/beego/beego") + true + else + false + end + end + + def set_name + @name = "go_beego" + end + end +end diff --git a/src/detector/detectors/go/echo.cr b/src/detector/detectors/go/echo.cr new file mode 100644 index 00000000..d8360b84 --- /dev/null +++ b/src/detector/detectors/go/echo.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Go + class Echo < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? "go.mod") && (file_contents.includes? "github.com/labstack/echo") + true + else + false + end + end + + def set_name + @name = "go_echo" + end + end +end diff --git a/src/detector/detectors/go/fiber.cr b/src/detector/detectors/go/fiber.cr new file mode 100644 index 00000000..c14152a6 --- /dev/null +++ b/src/detector/detectors/go/fiber.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Go + class Fiber < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? "go.mod") && (file_contents.includes? "github.com/gofiber/fiber") + true + else + false + end + end + + def set_name + @name = "go_fiber" + end + end +end diff --git a/src/detector/detectors/go/gin.cr b/src/detector/detectors/go/gin.cr new file mode 100644 index 00000000..52f72b10 --- /dev/null +++ b/src/detector/detectors/go/gin.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Go + class Gin < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? "go.mod") && (file_contents.includes? "github.com/gin-gonic/gin") + true + else + false + end + end + + def set_name + @name = "go_gin" + end + end +end diff --git a/src/detector/detectors/go_beego.cr b/src/detector/detectors/go_beego.cr deleted file mode 100644 index 9e74b57a..00000000 --- a/src/detector/detectors/go_beego.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorGoBeego < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? "go.mod") && (file_contents.includes? "github.com/beego/beego") - true - else - false - end - end - - def set_name - @name = "go_beego" - end -end diff --git a/src/detector/detectors/go_echo.cr b/src/detector/detectors/go_echo.cr deleted file mode 100644 index c5a77418..00000000 --- a/src/detector/detectors/go_echo.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorGoEcho < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? "go.mod") && (file_contents.includes? "github.com/labstack/echo") - true - else - false - end - end - - def set_name - @name = "go_echo" - end -end diff --git a/src/detector/detectors/go_fiber.cr b/src/detector/detectors/go_fiber.cr deleted file mode 100644 index 62863251..00000000 --- a/src/detector/detectors/go_fiber.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorGoFiber < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? "go.mod") && (file_contents.includes? "github.com/gofiber/fiber") - true - else - false - end - end - - def set_name - @name = "go_fiber" - end -end diff --git a/src/detector/detectors/go_gin.cr b/src/detector/detectors/go_gin.cr deleted file mode 100644 index 90fddbf9..00000000 --- a/src/detector/detectors/go_gin.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorGoGin < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? "go.mod") && (file_contents.includes? "github.com/gin-gonic/gin") - true - else - false - end - end - - def set_name - @name = "go_gin" - end -end diff --git a/src/detector/detectors/har.cr b/src/detector/detectors/har.cr deleted file mode 100644 index 44cc53ae..00000000 --- a/src/detector/detectors/har.cr +++ /dev/null @@ -1,29 +0,0 @@ -require "../../models/detector" -require "../../utils/json" -require "../../utils/yaml" -require "../../models/code_locator" -require "har" - -class DetectorHar < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? ".har") || (filename.includes? ".json") - if valid_json? file_contents - begin - data = HAR.from_string(file_contents) - if data.version.to_s.includes? "1." - locator = CodeLocator.instance - locator.push("har-path", filename) - return true - end - rescue - end - end - end - - false - end - - def set_name - @name = "har" - end -end diff --git a/src/detector/detectors/java/armeria.cr b/src/detector/detectors/java/armeria.cr new file mode 100644 index 00000000..7ba8f11f --- /dev/null +++ b/src/detector/detectors/java/armeria.cr @@ -0,0 +1,20 @@ +require "../../../models/detector" + +module Detector::Java + class Armeria < Detector + def detect(filename : String, file_contents : String) : Bool + if ( + (filename.includes? "pom.xml") || (filename.includes? "build.gradle") || + (filename.includes? "build.gradle.kts") || (filename.includes? "settings.gradle.kts") + ) && (file_contents.includes? "com.linecorp.armeria") + true + else + false + end + end + + def set_name + @name = "java_armeria" + end + end +end diff --git a/src/detector/detectors/java/jsp.cr b/src/detector/detectors/java/jsp.cr new file mode 100644 index 00000000..d4292507 --- /dev/null +++ b/src/detector/detectors/java/jsp.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Java + class Jsp < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("<%") + check = check && file_contents.includes?("%>") + check = check && filename.includes?(".jsp") + + check + end + + def set_name + @name = "java_jsp" + end + end +end diff --git a/src/detector/detectors/java/spring.cr b/src/detector/detectors/java/spring.cr new file mode 100644 index 00000000..295d27ca --- /dev/null +++ b/src/detector/detectors/java/spring.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Java + class Spring < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.ends_with? ".java") && (file_contents.includes? "org.springframework") + return true + end + + false + end + + def set_name + @name = "java_spring" + end + end +end diff --git a/src/detector/detectors/java_armeria.cr b/src/detector/detectors/java_armeria.cr deleted file mode 100644 index 773f8d16..00000000 --- a/src/detector/detectors/java_armeria.cr +++ /dev/null @@ -1,18 +0,0 @@ -require "../../models/detector" - -class DetectorJavaArmeria < Detector - def detect(filename : String, file_contents : String) : Bool - if ( - (filename.includes? "pom.xml") || (filename.includes? "build.gradle") || - (filename.includes? "build.gradle.kts") || (filename.includes? "settings.gradle.kts") - ) && (file_contents.includes? "com.linecorp.armeria") - true - else - false - end - end - - def set_name - @name = "java_armeria" - end -end diff --git a/src/detector/detectors/java_jsp.cr b/src/detector/detectors/java_jsp.cr deleted file mode 100644 index e0cca03f..00000000 --- a/src/detector/detectors/java_jsp.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorJavaJsp < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("<%") - check = check && file_contents.includes?("%>") - check = check && filename.includes?(".jsp") - - check - end - - def set_name - @name = "java_jsp" - end -end diff --git a/src/detector/detectors/java_spring.cr b/src/detector/detectors/java_spring.cr deleted file mode 100644 index f5466e5b..00000000 --- a/src/detector/detectors/java_spring.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorJavaSpring < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.ends_with? ".java") && (file_contents.includes? "org.springframework") - return true - end - - false - end - - def set_name - @name = "java_spring" - end -end diff --git a/src/detector/detectors/javascript/express.cr b/src/detector/detectors/javascript/express.cr new file mode 100644 index 00000000..b5bcb0ee --- /dev/null +++ b/src/detector/detectors/javascript/express.cr @@ -0,0 +1,19 @@ +require "../../../models/detector" + +module Detector::Javascript + class Express < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? ".js") && (file_contents.includes? "require('express')") + true + elsif (filename.includes? ".js") && (file_contents.includes? "require(\"express\")") + true + else + false + end + end + + def set_name + @name = "js_express" + end + end +end diff --git a/src/detector/detectors/javascript/restify.cr b/src/detector/detectors/javascript/restify.cr new file mode 100644 index 00000000..b8322507 --- /dev/null +++ b/src/detector/detectors/javascript/restify.cr @@ -0,0 +1,23 @@ +require "../../../models/detector" + +module Detector::Javascript + class Restify < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? ".js") && (file_contents.includes? "require('restify')") + true + elsif (filename.includes? ".js") && (file_contents.includes? "require(\"restify\")") + true + elsif (filename.includes? ".ts") && (file_contents.includes? "server") + true + elsif (filename.includes? ".ts") && (file_contents.includes? "require(\"restify\")") + true + else + false + end + end + + def set_name + @name = "js_restify" + end + end +end diff --git a/src/detector/detectors/js_express.cr b/src/detector/detectors/js_express.cr deleted file mode 100644 index ada6c9d2..00000000 --- a/src/detector/detectors/js_express.cr +++ /dev/null @@ -1,17 +0,0 @@ -require "../../models/detector" - -class DetectorJsExpress < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? ".js") && (file_contents.includes? "require('express')") - true - elsif (filename.includes? ".js") && (file_contents.includes? "require(\"express\")") - true - else - false - end - end - - def set_name - @name = "js_express" - end -end diff --git a/src/detector/detectors/js_restify.cr b/src/detector/detectors/js_restify.cr deleted file mode 100644 index eea22a90..00000000 --- a/src/detector/detectors/js_restify.cr +++ /dev/null @@ -1,21 +0,0 @@ -require "../../models/detector" - -class DetectorJsRestify < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? ".js") && (file_contents.includes? "require('restify')") - true - elsif (filename.includes? ".js") && (file_contents.includes? "require(\"restify\")") - true - elsif (filename.includes? ".ts") && (file_contents.includes? "server") - true - elsif (filename.includes? ".ts") && (file_contents.includes? "require(\"restify\")") - true - else - false - end - end - - def set_name - @name = "js_restify" - end -end diff --git a/src/detector/detectors/kotlin/spring.cr b/src/detector/detectors/kotlin/spring.cr new file mode 100644 index 00000000..e6e06459 --- /dev/null +++ b/src/detector/detectors/kotlin/spring.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Kotlin + class Spring < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.ends_with? ".kt") && (file_contents.includes? "org.springframework") + return true + end + + false + end + + def set_name + @name = "kotlin_spring" + end + end +end diff --git a/src/detector/detectors/kotlin_spring.cr b/src/detector/detectors/kotlin_spring.cr deleted file mode 100644 index 9fa3ad41..00000000 --- a/src/detector/detectors/kotlin_spring.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorKotlinSpring < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.ends_with? ".kt") && (file_contents.includes? "org.springframework") - return true - end - - false - end - - def set_name - @name = "kotlin_spring" - end -end diff --git a/src/detector/detectors/oas2.cr b/src/detector/detectors/oas2.cr deleted file mode 100644 index 232776d2..00000000 --- a/src/detector/detectors/oas2.cr +++ /dev/null @@ -1,37 +0,0 @@ -require "../../models/detector" -require "../../utils/json" -require "../../utils/yaml" -require "../../models/code_locator" - -class DetectorOas2 < Detector - def detect(filename : String, file_contents : String) : Bool - check = false - if valid_json? file_contents - data = JSON.parse(file_contents) - begin - if data["swagger"].as_s.includes? "2." - check = true - locator = CodeLocator.instance - locator.push("swagger-json", filename) - end - rescue - end - elsif valid_yaml? file_contents - data = YAML.parse(file_contents) - begin - if data["swagger"].as_s.includes? "2." - check = true - locator = CodeLocator.instance - locator.push("swagger-yaml", filename) - end - rescue - end - end - - check - end - - def set_name - @name = "oas2" - end -end diff --git a/src/detector/detectors/oas3.cr b/src/detector/detectors/oas3.cr deleted file mode 100644 index b47d66b6..00000000 --- a/src/detector/detectors/oas3.cr +++ /dev/null @@ -1,37 +0,0 @@ -require "../../models/detector" -require "../../utils/json" -require "../../utils/yaml" -require "../../models/code_locator" - -class DetectorOas3 < Detector - def detect(filename : String, file_contents : String) : Bool - check = false - if valid_json? file_contents - data = JSON.parse(file_contents) - begin - if data["openapi"].as_s.includes? "3." - check = true - locator = CodeLocator.instance - locator.push("oas3-json", filename) - end - rescue - end - elsif valid_yaml? file_contents - data = YAML.parse(file_contents) - begin - if data["openapi"].as_s.includes? "3." - check = true - locator = CodeLocator.instance - locator.push("oas3-yaml", filename) - end - rescue - end - end - - check - end - - def set_name - @name = "oas3" - end -end diff --git a/src/detector/detectors/php/php.cr b/src/detector/detectors/php/php.cr new file mode 100644 index 00000000..fe4ac883 --- /dev/null +++ b/src/detector/detectors/php/php.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Php + class Php < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("") + check = check && filename.includes?(".php") + + check + end + + def set_name + @name = "php_pure" + end + end +end diff --git a/src/detector/detectors/php_pure.cr b/src/detector/detectors/php_pure.cr deleted file mode 100644 index feb86f4f..00000000 --- a/src/detector/detectors/php_pure.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorPhpPure < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("") - check = check && filename.includes?(".php") - - check - end - - def set_name - @name = "php_pure" - end -end diff --git a/src/detector/detectors/python/django.cr b/src/detector/detectors/python/django.cr new file mode 100644 index 00000000..4b5a8e1a --- /dev/null +++ b/src/detector/detectors/python/django.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Python + class Django < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? ".py") && (file_contents.includes? "from django.") + true + else + false + end + end + + def set_name + @name = "python_django" + end + end +end diff --git a/src/detector/detectors/python/fastapi.cr b/src/detector/detectors/python/fastapi.cr new file mode 100644 index 00000000..6055ac66 --- /dev/null +++ b/src/detector/detectors/python/fastapi.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Python + class FastAPI < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.ends_with? ".py") && (file_contents.includes? "from fastapi") + true + else + false + end + end + + def set_name + @name = "python_fastapi" + end + end +end diff --git a/src/detector/detectors/python/flask.cr b/src/detector/detectors/python/flask.cr new file mode 100644 index 00000000..f955682f --- /dev/null +++ b/src/detector/detectors/python/flask.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Python + class Flask < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? ".py") && (file_contents.includes? "from flask") + true + else + false + end + end + + def set_name + @name = "python_flask" + end + end +end diff --git a/src/detector/detectors/python_django.cr b/src/detector/detectors/python_django.cr deleted file mode 100644 index 0cc8af4c..00000000 --- a/src/detector/detectors/python_django.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorPythonDjango < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? ".py") && (file_contents.includes? "from django.") - true - else - false - end - end - - def set_name - @name = "python_django" - end -end diff --git a/src/detector/detectors/python_fastapi.cr b/src/detector/detectors/python_fastapi.cr deleted file mode 100644 index c7358cd0..00000000 --- a/src/detector/detectors/python_fastapi.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorPythonFastAPI < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.ends_with? ".py") && (file_contents.includes? "from fastapi") - true - else - false - end - end - - def set_name - @name = "python_fastapi" - end -end diff --git a/src/detector/detectors/python_flask.cr b/src/detector/detectors/python_flask.cr deleted file mode 100644 index ed675566..00000000 --- a/src/detector/detectors/python_flask.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorPythonFlask < Detector - def detect(filename : String, file_contents : String) : Bool - if (filename.includes? ".py") && (file_contents.includes? "from flask") - true - else - false - end - end - - def set_name - @name = "python_flask" - end -end diff --git a/src/detector/detectors/raml.cr b/src/detector/detectors/raml.cr deleted file mode 100644 index 903006ab..00000000 --- a/src/detector/detectors/raml.cr +++ /dev/null @@ -1,26 +0,0 @@ -require "../../models/detector" -require "../../utils/yaml" -require "../../models/code_locator" - -class DetectorRAML < Detector - def detect(filename : String, file_contents : String) : Bool - check = false - if valid_yaml? file_contents - if file_contents.includes? "#%RAML" - begin - YAML.parse(file_contents) - check = true - locator = CodeLocator.instance - locator.push("raml-spec", filename) - rescue - end - end - end - - check - end - - def set_name - @name = "raml" - end -end diff --git a/src/detector/detectors/ruby/hanami.cr b/src/detector/detectors/ruby/hanami.cr new file mode 100644 index 00000000..1dfad0c6 --- /dev/null +++ b/src/detector/detectors/ruby/hanami.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Ruby + class Hanami < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("gem 'hanami'") + check = check || file_contents.includes?("gem \"hanami\"") + check = check && filename.includes?("Gemfile") + + check + end + + def set_name + @name = "ruby_hanami" + end + end +end diff --git a/src/detector/detectors/ruby/rails.cr b/src/detector/detectors/ruby/rails.cr new file mode 100644 index 00000000..d0c6fe3d --- /dev/null +++ b/src/detector/detectors/ruby/rails.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Ruby + class Rails < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("gem 'rails'") + check = check || file_contents.includes?("gem \"rails\"") + check = check && filename.includes?("Gemfile") + + check + end + + def set_name + @name = "ruby_rails" + end + end +end diff --git a/src/detector/detectors/ruby/sinatra.cr b/src/detector/detectors/ruby/sinatra.cr new file mode 100644 index 00000000..90eb67ff --- /dev/null +++ b/src/detector/detectors/ruby/sinatra.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Ruby + class Sinatra < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("gem 'sinatra'") + check = check || file_contents.includes?("gem \"sinatra\"") + check = check && filename.includes?("Gemfile") + + check + end + + def set_name + @name = "ruby_sinatra" + end + end +end diff --git a/src/detector/detectors/ruby_hanami.cr b/src/detector/detectors/ruby_hanami.cr deleted file mode 100644 index 8ce9c0fd..00000000 --- a/src/detector/detectors/ruby_hanami.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorRubyHanami < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("gem 'hanami'") - check = check || file_contents.includes?("gem \"hanami\"") - check = check && filename.includes?("Gemfile") - - check - end - - def set_name - @name = "ruby_hanami" - end -end diff --git a/src/detector/detectors/ruby_rails.cr b/src/detector/detectors/ruby_rails.cr deleted file mode 100644 index 4dc665ff..00000000 --- a/src/detector/detectors/ruby_rails.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorRubyRails < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("gem 'rails'") - check = check || file_contents.includes?("gem \"rails\"") - check = check && filename.includes?("Gemfile") - - check - end - - def set_name - @name = "ruby_rails" - end -end diff --git a/src/detector/detectors/ruby_sinatra.cr b/src/detector/detectors/ruby_sinatra.cr deleted file mode 100644 index 19b6e06e..00000000 --- a/src/detector/detectors/ruby_sinatra.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorRubySinatra < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("gem 'sinatra'") - check = check || file_contents.includes?("gem \"sinatra\"") - check = check && filename.includes?("Gemfile") - - check - end - - def set_name - @name = "ruby_sinatra" - end -end diff --git a/src/detector/detectors/rust/axum.cr b/src/detector/detectors/rust/axum.cr new file mode 100644 index 00000000..335dca40 --- /dev/null +++ b/src/detector/detectors/rust/axum.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Rust + class Axum < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("axum") + check = check && file_contents.includes?("dependencies") + check = check && filename.includes?("Cargo.toml") + + check + end + + def set_name + @name = "rust_axum" + end + end +end diff --git a/src/detector/detectors/rust/rocket.cr b/src/detector/detectors/rust/rocket.cr new file mode 100644 index 00000000..28599007 --- /dev/null +++ b/src/detector/detectors/rust/rocket.cr @@ -0,0 +1,17 @@ +require "../../../models/detector" + +module Detector::Rust + class Rocket < Detector + def detect(filename : String, file_contents : String) : Bool + check = file_contents.includes?("rocket") + check = check && file_contents.includes?("dependencies") + check = check && filename.includes?("Cargo.toml") + + check + end + + def set_name + @name = "rust_rocket" + end + end +end diff --git a/src/detector/detectors/rust_axum.cr b/src/detector/detectors/rust_axum.cr deleted file mode 100644 index 4977385c..00000000 --- a/src/detector/detectors/rust_axum.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorRustAxum < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("axum") - check = check && file_contents.includes?("dependencies") - check = check && filename.includes?("Cargo.toml") - - check - end - - def set_name - @name = "rust_axum" - end -end diff --git a/src/detector/detectors/rust_rocket.cr b/src/detector/detectors/rust_rocket.cr deleted file mode 100644 index e7bc77d2..00000000 --- a/src/detector/detectors/rust_rocket.cr +++ /dev/null @@ -1,15 +0,0 @@ -require "../../models/detector" - -class DetectorRustRocket < Detector - def detect(filename : String, file_contents : String) : Bool - check = file_contents.includes?("rocket") - check = check && file_contents.includes?("dependencies") - check = check && filename.includes?("Cargo.toml") - - check - end - - def set_name - @name = "rust_rocket" - end -end diff --git a/src/detector/detectors/specification/har.cr b/src/detector/detectors/specification/har.cr new file mode 100644 index 00000000..7da41c7a --- /dev/null +++ b/src/detector/detectors/specification/har.cr @@ -0,0 +1,31 @@ +require "../../../models/detector" +require "../../../utils/json" +require "../../../utils/yaml" +require "../../../models/code_locator" +require "har" + +module Detector::Specification + class Har < Detector + def detect(filename : String, file_contents : String) : Bool + if (filename.includes? ".har") || (filename.includes? ".json") + if valid_json? file_contents + begin + data = HAR.from_string(file_contents) + if data.version.to_s.includes? "1." + locator = CodeLocator.instance + locator.push("har-path", filename) + return true + end + rescue + end + end + end + + false + end + + def set_name + @name = "har" + end + end +end diff --git a/src/detector/detectors/specification/oas2.cr b/src/detector/detectors/specification/oas2.cr new file mode 100644 index 00000000..59494c07 --- /dev/null +++ b/src/detector/detectors/specification/oas2.cr @@ -0,0 +1,39 @@ +require "../../../models/detector" +require "../../../utils/json" +require "../../../utils/yaml" +require "../../../models/code_locator" + +module Detector::Specification + class Oas2 < Detector + def detect(filename : String, file_contents : String) : Bool + check = false + if valid_json? file_contents + data = JSON.parse(file_contents) + begin + if data["swagger"].as_s.includes? "2." + check = true + locator = CodeLocator.instance + locator.push("swagger-json", filename) + end + rescue + end + elsif valid_yaml? file_contents + data = YAML.parse(file_contents) + begin + if data["swagger"].as_s.includes? "2." + check = true + locator = CodeLocator.instance + locator.push("swagger-yaml", filename) + end + rescue + end + end + + check + end + + def set_name + @name = "oas2" + end + end +end diff --git a/src/detector/detectors/specification/oas3.cr b/src/detector/detectors/specification/oas3.cr new file mode 100644 index 00000000..5202a6d6 --- /dev/null +++ b/src/detector/detectors/specification/oas3.cr @@ -0,0 +1,39 @@ +require "../../../models/detector" +require "../../../utils/json" +require "../../../utils/yaml" +require "../../../models/code_locator" + +module Detector::Specification + class Oas3 < Detector + def detect(filename : String, file_contents : String) : Bool + check = false + if valid_json? file_contents + data = JSON.parse(file_contents) + begin + if data["openapi"].as_s.includes? "3." + check = true + locator = CodeLocator.instance + locator.push("oas3-json", filename) + end + rescue + end + elsif valid_yaml? file_contents + data = YAML.parse(file_contents) + begin + if data["openapi"].as_s.includes? "3." + check = true + locator = CodeLocator.instance + locator.push("oas3-yaml", filename) + end + rescue + end + end + + check + end + + def set_name + @name = "oas3" + end + end +end diff --git a/src/detector/detectors/specification/raml.cr b/src/detector/detectors/specification/raml.cr new file mode 100644 index 00000000..a206c619 --- /dev/null +++ b/src/detector/detectors/specification/raml.cr @@ -0,0 +1,28 @@ +require "../../../models/detector" +require "../../../utils/yaml" +require "../../../models/code_locator" + +module Detector::Specification + class RAML < Detector + def detect(filename : String, file_contents : String) : Bool + check = false + if valid_yaml? file_contents + if file_contents.includes? "#%RAML" + begin + YAML.parse(file_contents) + check = true + locator = CodeLocator.instance + locator.push("raml-spec", filename) + rescue + end + end + end + + check + end + + def set_name + @name = "raml" + end + end +end