diff --git a/.pryrc b/.pryrc index 0d985d2..7129e54 100644 --- a/.pryrc +++ b/.pryrc @@ -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) - diff --git a/Dockerfile b/Dockerfile index f7d5a55..1918cf7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/classes/scans_io_index_parser.rb b/classes/scans_io_index_parser.rb index bba4788..e0f4aae 100644 --- a/classes/scans_io_index_parser.rb +++ b/classes/scans_io_index_parser.rb @@ -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 +end \ No newline at end of file diff --git a/command_line/console.rb b/command_line/console.rb new file mode 100755 index 0000000..7629999 --- /dev/null +++ b/command_line/console.rb @@ -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