made a separate console and fixed an issue with the size_for method in scansioindex parser

This commit is contained in:
booboy 2019-05-19 23:25:35 -05:00
parent 5c04cfc11e
commit 567355f7b7
4 changed files with 34 additions and 22 deletions

16
.pryrc
View file

@ -1,5 +1,3 @@
require 'require_all'
class Array
# group elements by their identity, and count each distinct item
def counts
@ -18,17 +16,3 @@ end
Pry::Commands.command /^$/, "repeat last command" do
_pry_.run_command Pry.history.to_a.last
end
# Obtain the present woking directory
current_dir = Dir.pwd
if current_dir =~ /^(.*?\/misc_rbtools)/
require_all './modules'
require_all './classes'
end
nvd_downloader = NvdTools::NvdDownloader.new
scans_io_downloader = ScansIoTools::ScansIoDownloader.new
scans_io_parser = ScansIoTools::ScansIoIndexParser.new(scans_io_downloader.get_json_index.body)

View file

@ -1,7 +1,15 @@
# uncomment the version of ruby that you want to run
#FROM ruby:2.4
#FROM ruby:2.5
FROM ruby:2.6
#FROM ruby:2.6
FROM quay.io/kennasecurity/ruby
#---
# FEDORA with kennasecurity/ruby
USER root
RUN dnf install less -y && dnf clean all -y
#---
ENV PAGER less
RUN mkdir /usr/src/misc_rbtools
ADD . /usr/src/misc_rbtools/
@ -13,8 +21,6 @@ RUN gem install rest-client
RUN gem install require_all
RUN gem install pry
RUN apt -y install less
WORKDIR /usr/src/misc_rbtools
CMD pry
CMD command_line/console.rb

View file

@ -59,7 +59,11 @@ module ScansIoTools
end
def size_for(study_name)
file_info(study_name).first['size']
if file_info(study_name).count >= 2
file_info(study_name).select {|name| name['size']}
else
file_info(study_name).first['size']
end
end
end
end

18
command_line/console.rb Executable file
View file

@ -0,0 +1,18 @@
#!/usr/bin/env ruby
require "require_all"
require "pry"
# Obtain the present woking directory
current_dir = Dir.pwd
if current_dir =~ /^(.*?\/misc_rbtools)/
require_all '../modules'
require_all '../classes'
end
# different downloading tools
nvd_downloader = NvdTools::NvdDownloader.new
scans_io_downloader = ScansIoTools::ScansIoDownloader.new
scans_io_parser = ScansIoTools::ScansIoIndexParser.new(scans_io_downloader.get_json_index.body)
Pry.start