diff --git a/README.md b/README.md index e703544..b43edcf 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,14 @@ For now unauthenticated api over localhost:3000 until I put in some basic token get "/github_advisories/:ghsa_id", to: "github_advisories#show" ``` +#### GithubUsers +Create a text file named `./data/github_usernames.txt` with one username per line +There is a seed task that will read this file and perform an API call to github API and store the data in DB for each user. +``` + get "/github_users", to: "github_users#index" + get "/github_users/:username", to: "github_users#show" +``` + #### GithubPocs ``` get "/github_pocs", to: "github_pocs#index" diff --git a/app/controllers/cnas_controller.rb b/app/controllers/cnas_controller.rb index e46164d..9da836c 100644 --- a/app/controllers/cnas_controller.rb +++ b/app/controllers/cnas_controller.rb @@ -1,6 +1,7 @@ class CnasController < ApplicationController def index @cnas = Cna.all + render json: @cnas.to_json end def show diff --git a/app/controllers/cpes_controller.rb b/app/controllers/cpes_controller.rb index bbf7d78..b2cff81 100644 --- a/app/controllers/cpes_controller.rb +++ b/app/controllers/cpes_controller.rb @@ -1,6 +1,7 @@ class CpesController < ApplicationController def index @cpes = Cpe.all + render json: @cpes.to_json end def show diff --git a/app/controllers/cvemon_cves_controller.rb b/app/controllers/cvemon_cves_controller.rb index db19db4..8205191 100644 --- a/app/controllers/cvemon_cves_controller.rb +++ b/app/controllers/cvemon_cves_controller.rb @@ -1,6 +1,7 @@ class CvemonCvesController < ApplicationController def index @pocs = CvemonCve.all + render json: @pocs.to_json end def show diff --git a/app/controllers/cves_controller.rb b/app/controllers/cves_controller.rb index ab4c531..0ad98e7 100644 --- a/app/controllers/cves_controller.rb +++ b/app/controllers/cves_controller.rb @@ -1,6 +1,7 @@ class CvesController < ApplicationController def index @cves = Cve.all + render json: @cves.to_json end def show diff --git a/app/controllers/github_advisories_controller.rb b/app/controllers/github_advisories_controller.rb index 47b4941..7a7ab01 100644 --- a/app/controllers/github_advisories_controller.rb +++ b/app/controllers/github_advisories_controller.rb @@ -1,10 +1,11 @@ class GithubAdvisoriesController < ApplicationController def index @advisories = GithubAdvisory.all + render json: @advisories.to_json end def show - @advisory = GithubAdivsory.find_by_ghsa_id(params[:ghsa_id]) + @advisory = GithubAdvisory.find_by_ghsa_id(params[:ghsa_id]) render json: @advisory.to_json end end diff --git a/app/controllers/github_pocs_controller.rb b/app/controllers/github_pocs_controller.rb index 3f11751..75c2ca1 100644 --- a/app/controllers/github_pocs_controller.rb +++ b/app/controllers/github_pocs_controller.rb @@ -1,6 +1,7 @@ class GithubPocsController < ApplicationController def index @pocs = GithubPoc.all + render json: @pocs.to_json end def show diff --git a/app/controllers/github_users_controller.rb b/app/controllers/github_users_controller.rb new file mode 100644 index 0000000..8dc85ba --- /dev/null +++ b/app/controllers/github_users_controller.rb @@ -0,0 +1,11 @@ +class GithubUsersController < ApplicationController + def index + @users = GithubUser.all + render json: @users.to_json + end + + def show + @user = GithubUser.find_by_username(params[:username]) + render json: @user.to_json + end +end diff --git a/app/controllers/trickest_poc_cves_controller.rb b/app/controllers/trickest_poc_cves_controller.rb index 1e0b876..d35ef46 100644 --- a/app/controllers/trickest_poc_cves_controller.rb +++ b/app/controllers/trickest_poc_cves_controller.rb @@ -1,6 +1,7 @@ class TrickestPocCvesController < ApplicationController def index @pocs = TrickestPocCve.all + render json: @pocs.to_json end def show diff --git a/app/models/github_user.rb b/app/models/github_user.rb new file mode 100644 index 0000000..ed2de26 --- /dev/null +++ b/app/models/github_user.rb @@ -0,0 +1,5 @@ +class GithubUser< ActiveRecord::Base + def self.find_by_username(username) + find_by(login: username) + end +end diff --git a/app/views/github_users/index.html.erb b/app/views/github_users/index.html.erb new file mode 100644 index 0000000..643fbd5 --- /dev/null +++ b/app/views/github_users/index.html.erb @@ -0,0 +1 @@ +