dependagrab 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e32432885a4421f53fc65a7ffca2b8fef05e8738088b437eb8e9aa9a98d8f0b
4
- data.tar.gz: 8cbbc87b9c80d5a81a6f3fe36a9758e57d43e60ac2fb1aecc291ac11b712962a
3
+ metadata.gz: 5571861c796d4c513f1e881285ae3d4fab353067bbaed3ff29e7b20373073bbb
4
+ data.tar.gz: 52868e44912d13efcf51b653a93fff2bcbf9f0c57b7e6397b7536f8f4856338f
5
5
  SHA512:
6
- metadata.gz: b41b50249738a6d4df018e21f4f64c69eb7e1f052be98d5cad399202e66e97a4734db2d3da359f43fe60b058b817b3cbb9c3483efad37ef70d6fc09c697d5b77
7
- data.tar.gz: 0ba5284cde0e3291400001ae6137a50529da56ea758b8d309cfc48f6a7b4f6cad713b8f36234113209da5533b9e765e077811bceb83f2b877ba39970cbb9acfc
6
+ metadata.gz: e9a9a6bafc2df8a2f23cf45b8f3fd9aa7b5e166da1149434fa08b48a0bf9935acff636c15d40496507aa78d13e4538e0e9a4123a23a037bb64994ab9d93c59db
7
+ data.tar.gz: f9b483d0fcba971dfb2dacc154058d25b07a6e27ddafc31f5731f2baeee1f2d7a41c3be3c7cfec8b225f91dd3b0ad52070c1a742f625f8cefb62586428ace35d
data/CHANGE_LOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # V0.1.7
2
+ Refactor to better support integration into other applications
3
+ Change case on source name
4
+ make cvsScore to string
5
+
1
6
  # V0.1.6
2
7
  Handle interrupt and exceptions output nicer
3
8
  Change source name in json output to dependabot
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dependagrab (0.1.6)
4
+ dependagrab (0.1.7)
5
5
  graphql-client (= 0.17.0)
6
6
 
7
7
  GEM
data/bin/dependagrab CHANGED
@@ -5,7 +5,11 @@ begin
5
5
  Dependagrab::CLI.start
6
6
  rescue SignalException => e
7
7
  # exit
8
+ rescue SystemExit => e
9
+ # exit
8
10
  rescue Exception => e
9
11
  STDERR.puts "Error: Something went wrong (set DEBUG=true for detailed backtrace)"
12
+
13
+ STDERR.puts e.message if ENV['DEBUG']
10
14
  STDERR.puts e.backtrace if ENV['DEBUG']
11
15
  end
@@ -46,7 +46,8 @@ module Dependagrab
46
46
  end
47
47
 
48
48
  begin
49
- run(options)
49
+ options.merge!(print: true)
50
+ Dependagrab.run(options)
50
51
  rescue => e
51
52
  STDERR.puts "Error: #{e.message} (set DEBUG=true for detailed backtrace)"
52
53
  STDERR.puts e.backtrace if ENV['DEBUG']
@@ -56,24 +57,6 @@ module Dependagrab
56
57
 
57
58
  private
58
59
 
59
- def self.run(options)
60
- result = Dependagrab::GithubClient.new(options).grab
61
-
62
- if options[:output]
63
- begin
64
- FileWriter.new(options[:output]).write!(result[:alerts])
65
- puts "#{result[:alerts].count} dependency warnings written to '#{options.fetch(:output)}'"
66
- rescue => e
67
- STDERR.puts "Failed to write file '#{options.fetch(:output)}'"
68
- STDERR.puts "Error: #{e.message} (set DEBUG=true for detailed backtrace)"
69
- STDERR.puts e.backtrace if ENV['DEBUG']
70
- exit 1
71
- end
72
- else
73
- ConsoleWriter.new.write!(result[:alerts])
74
- end
75
- end
76
-
77
60
  def self.print_usage
78
61
  puts "Usage: dependagrab <REPO> [Options]"
79
62
  puts
@@ -25,6 +25,8 @@ module Dependagrab
25
25
  File.open(output_file, "w") do |f|
26
26
  f.write(scan.to_json)
27
27
  end
28
+
29
+ output_file
28
30
  end
29
31
 
30
32
 
@@ -35,7 +37,7 @@ module Dependagrab
35
37
  id: SecureRandom.uuid,
36
38
  created: Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'),
37
39
  exported: Time.now.strftime('%Y-%m-%dT%H:%M:%SZ'),
38
- source: "dependagrab",
40
+ source: "DependAGrab",
39
41
  collectionType: "DEPENDENCY",
40
42
  findings: [],
41
43
  }
@@ -49,7 +51,7 @@ module Dependagrab
49
51
  severity: alert[:severity].gsub("MODERATE", "MEDIUM"),
50
52
  nativeSeverity: alert[:severity].gsub("MODERATE", "MEDIUM"),
51
53
  summary: alert[:summary],
52
- cvsScore: alert[:cvss],
54
+ cvsScore: alert[:cvss].to_s,
53
55
  description: alert[:description],
54
56
  dependencyDetails: {
55
57
  library: alert[:package_name],
@@ -1,3 +1,3 @@
1
1
  module Dependagrab
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/dependagrab.rb CHANGED
@@ -8,4 +8,30 @@ module Dependagrab
8
8
  class Error < StandardError; end
9
9
  class MissingConfigError < Dependagrab::Error; end
10
10
  class GhApiError < Dependagrab::Error; end
11
+
12
+
13
+ def self.run(options)
14
+ result = Dependagrab::GithubClient.new(options).grab
15
+
16
+ if options[:output]
17
+ begin
18
+ output_file = FileWriter.new(options[:output]).write!(result[:alerts])
19
+ if options[:print]
20
+ puts "#{result[:alerts].count} dependency warnings written to '#{options.fetch(:output)}'"
21
+ end
22
+ output_file
23
+ rescue => e
24
+ STDERR.puts "Failed to write file '#{options.fetch(:output)}'"
25
+ STDERR.puts "Error: #{e.message} (set DEBUG=true for detailed backtrace)"
26
+ STDERR.puts e.backtrace if ENV['DEBUG']
27
+ exit 1
28
+ end
29
+ else
30
+ if options[:print]
31
+ ConsoleWriter.new.write!(result[:alerts])
32
+ else
33
+ result[:alerts]
34
+ end
35
+ end
36
+ end
11
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependagrab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Elliott
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-07 00:00:00.000000000 Z
11
+ date: 2022-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql-client