Class: Neetob::CLI::Github::Repositories::GetSecurityDetails
- Defined in:
- lib/neetob/cli/github/repositories/get_security_details.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#repos ⇒ Object
Returns the value of attribute repos.
-
#sandbox ⇒ Object
Returns the value of attribute sandbox.
Attributes inherited from Base
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(repos, sandbox = false) ⇒ GetSecurityDetails
constructor
A new instance of GetSecurityDetails.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize(repos, sandbox = false) ⇒ GetSecurityDetails
Returns a new instance of GetSecurityDetails.
12 13 14 15 16 |
# File 'lib/neetob/cli/github/repositories/get_security_details.rb', line 12 def initialize(repos, sandbox = false) super() @repos = repos @sandbox = sandbox end |
Instance Attribute Details
#repos ⇒ Object
Returns the value of attribute repos.
10 11 12 |
# File 'lib/neetob/cli/github/repositories/get_security_details.rb', line 10 def repos @repos end |
#sandbox ⇒ Object
Returns the value of attribute sandbox.
10 11 12 |
# File 'lib/neetob/cli/github/repositories/get_security_details.rb', line 10 def sandbox @sandbox end |
Instance Method Details
#run ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/neetob/cli/github/repositories/get_security_details.rb', line 18 def run matching_repos = find_all_matching_apps_or_repos(repos, :github, sandbox) data = [] matching_repos.each do |repo| begin uri = URI("https://api.github.com/repos/#{repo}/code-security-configuration") request = Net::HTTP::Get.new(uri) headers = { "Accept" => "application/vnd.github+json", "Authorization" => "Bearer #{@access_token}" } headers.each { |key, value| request[key] = value } response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http| http.request(request) end JSON.parse(response.body, symbolize_names: true) rescue StandardError => e ExceptionHandler.new(e).process end end data end |