yavdb 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8af50e09446ce3b10fc4ab040d61051d822580e08b4c115ac070a88e67cdfab
4
- data.tar.gz: fdffb83c5bbd1f1aa8f4ae78e8c181d16ba11c76f40ac6d5665f379bc54c7741
3
+ metadata.gz: ff43836b6a4618939c8acc53519a9cbc49157a4a0af5767ea10b75173f1208b9
4
+ data.tar.gz: a44416d1a831f5eeb760bb8f28bd51f3a37c0dc0da494d512a097676f0a88011
5
5
  SHA512:
6
- metadata.gz: bef0e177ea672587d23ea447324d33c783bd0467976406b596b088a5356698874af77d196ccadbd564aa5faa0b5dad649622cd0f52d1fdb85fa1e9796cefd4f2
7
- data.tar.gz: f17925ffe91e7ef516d79798ebd54e6a6cfd725a0758b32f253af2a000e909c69d6711d7fd2125a0a9b7a5d3950f03a8f1cf587df6ad89d1a4c9f006743c7d8b
6
+ metadata.gz: de6a6753b1ab427ecd5265f6d813f0d94e2f14bfa80f9b06863ffe2a265afd1531a38aa81b266b319792bd14cc13c5c8dbf55c8efad8600c19cda5e0e43e02c9
7
+ data.tar.gz: 636de41a1dc02772fe0aabfec7fe1cd32849a3fb1fa7e801a3d2a5796657a6bcf8d97d72be7f6886688d841359526cfe71f1468b9a6d05d5156f2b5e775c6be4
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Click on '....'
17
+ 3. Scroll down to '....'
18
+ 4. See error
19
+
20
+ **Expected behavior**
21
+ A clear and concise description of what you expected to happen.
22
+
23
+ **Screenshots**
24
+ If applicable, add screenshots to help explain your problem.
25
+
26
+ **Desktop (please complete the following information):**
27
+ - OS: [e.g. Windows, Linux, Mac]
28
+ - Ruby Version [e.g. 2.5.5]
29
+ - Version [e.g. 22]
30
+
31
+ **Additional context**
32
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want to happen.
15
+
16
+ **Describe alternatives you've considered**
17
+ A clear and concise description of any alternative solutions or features you've considered.
18
+
19
+ **Additional context**
20
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,60 @@
1
+ ## How to contribute to yavdb
2
+
3
+ ### Main rules
4
+
5
+ * Before you open a ticket or send a pull request, [search](https://github.com/rtfpessoa/yavdb/issues) for previous discussions about the same feature or issue. Add to the earlier ticket if you find one.
6
+
7
+ * If you're proposing a new feature, make sure you create an issue to let other contributors know what you are working on.
8
+
9
+ * Before sending a pull request make sure your code is tested.
10
+
11
+ * Before sending a pull request for a feature, be sure to run tests.
12
+
13
+ * Use the same coding style as the rest of the codebase.
14
+
15
+ * Use `git rebase` (not `git merge`) to sync your work from time to time with the master branch.
16
+
17
+ * After creating your pull request make sure the build is passing on [CircleCI](https://circleci.com/gh/rtfpessoa/yavdb)
18
+ and that [Codacy](https://www.codacy.com/app/rtfpessoa/yavdb) is also confident in the code quality.
19
+
20
+ ### Commit Style
21
+
22
+ Writing good commit logs is important. A commit log should describe what changed and why.
23
+ Follow these guidelines when writing one:
24
+
25
+ 1. The first line should be 50 characters or less and contain a short
26
+ description of the change prefixed with the name of the changed
27
+ subsystem (e.g. "net: add localAddress and localPort to Socket").
28
+ 2. Keep the second line blank.
29
+ 3. Wrap all other lines at 72 columns.
30
+
31
+ A good commit log can look something like this:
32
+
33
+ ```
34
+ subsystem: explaining the commit in one line
35
+
36
+ Body of commit message is a few lines of text, explaining things
37
+ in more detail, possibly giving some background about the issue
38
+ being fixed, etc. etc.
39
+
40
+ The body of the commit message can be several paragraphs, and
41
+ please do proper word-wrap and keep columns shorter than about
42
+ 72 characters or so. That way `git log` will show things
43
+ nicely even when it is indented.
44
+ ```
45
+
46
+ ### Developer's Certificate of Origin 1.0
47
+
48
+ By making a contribution to this project, I certify that:
49
+
50
+ * (a) The contribution was created in whole or in part by me and I
51
+ have the right to submit it under the open source license indicated
52
+ in the file; or
53
+ * (b) The contribution is based upon previous work that, to the best
54
+ of my knowledge, is covered under an appropriate open source license
55
+ and I have the right under that license to submit that work with
56
+ modifications, whether created in whole or in part by me, under the
57
+ same open source license (unless I am permitted to submit under a
58
+ different license), as indicated in the file; or
59
+ * (c) The contribution was provided directly to me by some other
60
+ person who certified (a), (b) or (c) and I have not modified it.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yavdb (0.5.2)
4
+ yavdb (0.5.3)
5
5
  execjs (~> 2.7)
6
6
  json (~> 2.2)
7
7
  kramdown (~> 2.1)
@@ -16,12 +16,14 @@ GEM
16
16
  specs:
17
17
  ansi (1.5.0)
18
18
  ast (2.4.0)
19
- bibliothecary (6.6.0)
19
+ bibliothecary (6.8.1)
20
20
  commander
21
21
  deb_control
22
22
  librariesio-gem-parser
23
23
  ox (>= 2.8.1)
24
24
  sdl4r
25
+ strings
26
+ strings-ansi
25
27
  toml-rb (~> 1.0)
26
28
  typhoeus
27
29
  citrus (3.0.2)
@@ -31,20 +33,20 @@ GEM
31
33
  commander (4.4.7)
32
34
  highline (~> 2.0.0)
33
35
  deb_control (0.0.1)
34
- dependency_spy (0.4.1)
36
+ dependency_spy (0.5.0)
35
37
  bibliothecary (~> 6.6)
36
38
  colorize (= 0.8.1)
37
39
  semantic_range (~> 2.2)
38
40
  thor (~> 0.20)
39
41
  yavdb (~> 0.5)
40
42
  diff-lcs (1.3)
41
- docile (1.3.1)
43
+ docile (1.3.2)
42
44
  ethon (0.12.0)
43
45
  ffi (>= 1.3.0)
44
46
  execjs (2.7.0)
45
- ffi (1.11.0)
47
+ ffi (1.11.1)
46
48
  highline (2.0.2)
47
- jaro_winkler (1.5.2)
49
+ jaro_winkler (1.5.3)
48
50
  json (2.2.0)
49
51
  kramdown (2.1.0)
50
52
  librariesio-gem-parser (1.0.0)
@@ -52,49 +54,54 @@ GEM
52
54
  oga (2.15)
53
55
  ast
54
56
  ruby-ll (~> 2.1)
55
- ox (2.10.0)
57
+ ox (2.11.0)
56
58
  parallel (1.17.0)
57
- parser (2.6.3.0)
59
+ parser (2.6.4.0)
58
60
  ast (~> 2.4.0)
59
61
  rainbow (3.0.0)
60
- rake (12.3.2)
62
+ rake (12.3.3)
61
63
  ref (2.0.0)
62
64
  rspec (3.8.0)
63
65
  rspec-core (~> 3.8.0)
64
66
  rspec-expectations (~> 3.8.0)
65
67
  rspec-mocks (~> 3.8.0)
66
- rspec-core (3.8.0)
68
+ rspec-core (3.8.2)
67
69
  rspec-support (~> 3.8.0)
68
- rspec-expectations (3.8.3)
70
+ rspec-expectations (3.8.4)
69
71
  diff-lcs (>= 1.2.0, < 2.0)
70
72
  rspec-support (~> 3.8.0)
71
- rspec-mocks (3.8.0)
73
+ rspec-mocks (3.8.1)
72
74
  diff-lcs (>= 1.2.0, < 2.0)
73
75
  rspec-support (~> 3.8.0)
74
- rspec-support (3.8.0)
76
+ rspec-support (3.8.2)
75
77
  rspec_junit_formatter (0.4.1)
76
78
  rspec-core (>= 2, < 4, != 2.12.0)
77
- rubocop (0.69.0)
79
+ rubocop (0.74.0)
78
80
  jaro_winkler (~> 1.5.1)
79
81
  parallel (~> 1.10)
80
82
  parser (>= 2.6)
81
83
  rainbow (>= 2.2.2, < 4.0)
82
84
  ruby-progressbar (~> 1.7)
83
85
  unicode-display_width (>= 1.4.0, < 1.7)
84
- rubocop-rspec (1.33.0)
86
+ rubocop-rspec (1.35.0)
85
87
  rubocop (>= 0.60.0)
86
88
  ruby-ll (2.1.2)
87
89
  ansi
88
90
  ast
89
- ruby-progressbar (1.10.0)
91
+ ruby-progressbar (1.10.1)
90
92
  sdl4r (0.9.11)
91
93
  semantic_interval (0.1.0)
92
94
  semantic_range (2.2.1)
93
- simplecov (0.16.1)
95
+ simplecov (0.17.0)
94
96
  docile (~> 1.1)
95
97
  json (>= 1.8, < 3)
96
98
  simplecov-html (~> 0.10.0)
97
99
  simplecov-html (0.10.2)
100
+ strings (0.1.6)
101
+ strings-ansi (~> 0.1)
102
+ unicode-display_width (~> 1.5)
103
+ unicode_utils (~> 1.4)
104
+ strings-ansi (0.1.0)
98
105
  therubyracer (0.12.3)
99
106
  libv8 (~> 3.16.14.15)
100
107
  ref
@@ -104,18 +111,19 @@ GEM
104
111
  typhoeus (1.3.1)
105
112
  ethon (>= 0.9.0)
106
113
  unicode-display_width (1.6.0)
114
+ unicode_utils (1.4.0)
107
115
 
108
116
  PLATFORMS
109
117
  ruby
110
118
 
111
119
  DEPENDENCIES
112
120
  codacy-coverage
113
- dependency_spy (~> 0.4)
121
+ dependency_spy
114
122
  rake (~> 12.3)
115
123
  rspec (~> 3.8)
116
124
  rspec_junit_formatter (~> 0.4)
117
- rubocop (~> 0.69)
118
- rubocop-rspec (~> 1.33)
125
+ rubocop (~> 0.74)
126
+ rubocop-rspec (~> 1.35)
119
127
  simplecov
120
128
  yavdb!
121
129
 
@@ -43,7 +43,6 @@ module YAVDB
43
43
  vulns
44
44
  .group_by(&:package_manager)
45
45
  .map do |package_manager, vunerabilities_by_pm|
46
-
47
46
  puts "#{package_manager}: #{vunerabilities_by_pm.length}"
48
47
 
49
48
  vunerabilities_by_pm =
@@ -40,13 +40,13 @@ module YAVDB
40
40
  def fetch_packages_recursive(page_number)
41
41
  page = get_page_html(get_page_url(page_number), false, 'npmjs/feed')
42
42
 
43
- script_tag = page.css('script').find { |script| script.text.include?('window.__context__') }.text
44
- context = ExecJS.compile("var window = {};\n#{script_tag.force_encoding('utf-8')};")
43
+ script_tag = page.css('script').find { |script| script.text.include?('window.__context__') }.text
44
+ context = ExecJS.compile("var window = {};\n#{script_tag.force_encoding('utf-8')};")
45
45
  advisory_data = context.exec('return window.__context__.context.advisoriesData')
46
46
 
47
47
  packages = advisory_data['objects']
48
48
 
49
- next_url = advisory_data['urls']['next']
49
+ next_url = advisory_data['urls']['next']
50
50
  next_packages = if next_url && !next_url&.include?("page=#{page_number}")
51
51
  fetch_packages_recursive(page_number + 1)
52
52
  else
@@ -62,7 +62,7 @@ module YAVDB
62
62
 
63
63
  def create(package)
64
64
  published_date = Date.strptime(package['created'], '%s')
65
- updated_date = Date.strptime(package['updated'], '%s')
65
+ updated_date = Date.strptime(package['updated'], '%s')
66
66
 
67
67
  cves = package['cves'] || []
68
68
 
@@ -108,13 +108,13 @@ module YAVDB
108
108
 
109
109
  def parse_severity(severity)
110
110
  case severity
111
- when 'low' then
111
+ when 'low'
112
112
  'low'
113
- when 'moderate' then
113
+ when 'moderate'
114
114
  'medium'
115
- when 'high' then
115
+ when 'high'
116
116
  'high'
117
- when 'critical' then
117
+ when 'critical'
118
118
  'high'
119
119
  else
120
120
  'high'
@@ -107,9 +107,9 @@ module YAVDB
107
107
 
108
108
  def severity_level(cvss_score)
109
109
  case cvss_score
110
- when 0.0..3.3 then
110
+ when 0.0..3.3
111
111
  'low'
112
- when 3.3..6.6 then
112
+ when 3.3..6.6
113
113
  'medium'
114
114
  else
115
115
  'high'
@@ -25,7 +25,7 @@ module YAVDB
25
25
  module RustSec
26
26
  class Client
27
27
 
28
- REPOSITORY_URL = 'https://github.com/RustSec/advisory-db'.freeze
28
+ REPOSITORY_URL = 'https://github.com/RustSec/advisory-db'.freeze
29
29
  PACKAGE_MANAGER = 'cargo'.freeze
30
30
 
31
31
  def self.advisories
@@ -44,9 +44,9 @@ module YAVDB
44
44
  private
45
45
 
46
46
  def create(advisory_hash)
47
- date = Date.strptime(advisory_hash['date'].to_s, '%Y-%m-%d')
48
- severity = 'high' # since no value is provided will use highest
49
- cve = advisory_hash['aliases']&.select { |a| a.start_with?('CVE') }
47
+ date = Date.strptime(advisory_hash['date'].to_s, '%Y-%m-%d')
48
+ severity = 'high' # since no value is provided will use highest
49
+ cve = advisory_hash['aliases']&.select { |a| a.start_with?('CVE') }
50
50
  references = advisory_hash['url'] && [advisory_hash['url']]
51
51
 
52
52
  vuln_id = "rustsec:cargo:#{advisory_hash['package']}:#{advisory_hash['id']}"
@@ -168,30 +168,22 @@ module YAVDB
168
168
  body = section[:body]
169
169
 
170
170
  case header.text
171
- when 'Overview' then
171
+ when %r{^(Overview|Details)$} then
172
172
  overview_str = body
173
173
  .map(&:to_xml)
174
+ .map { |e| e.force_encoding('UTF-8') }
174
175
  .join("\n")
175
- .force_encoding('UTF-8')
176
176
  begin
177
- data[:description] += '\n' if data[:description]
178
- data[:description] = '' unless data[:description]
177
+ if data[:description]
178
+ data[:description] += '\n'
179
+ else
180
+ data[:description] = ''
181
+ end
182
+
179
183
  data[:description] += utf8(Kramdown::Document.new(overview_str, :html_to_native => true).to_kramdown)
180
184
  rescue StandardError
181
185
  # ignore
182
186
  end
183
- when 'Details' then
184
- details_str = body
185
- .map(&:to_xml)
186
- .join("\n")
187
- .force_encoding('UTF-8')
188
- begin
189
- data[:description] += '\n' if data[:description]
190
- data[:description] = '' unless data[:description]
191
- data[:description] += utf8(Kramdown::Document.new(details_str, :html_to_native => true).to_kramdown)
192
- rescue StandardError
193
- # ignore
194
- end
195
187
  when 'References' then
196
188
  references = []
197
189
  if body.any?
@@ -211,19 +203,19 @@ module YAVDB
211
203
 
212
204
  advisory_page.css('.l-col .card .card__content dl > *').each_slice(2).to_a.map do |key, value|
213
205
  case key.text
214
- when 'Credit' then
206
+ when 'Credit'
215
207
  data[:credit] = utf8(value.text.split(',').map { |str| str.strip.sub(%r{-\s*}, '') }.reject(&:empty?))
216
- when 'CVE' then
208
+ when 'CVE'
217
209
  data[:cve] = value.css('a').map { |a| a.text.strip.split(',') }.flatten.map(&:strip).reject(&:empty?)
218
- when 'CWE' then
210
+ when 'CWE'
219
211
  data[:cwe] = value.css('a').map { |a| a.text.strip.split(',') }.flatten.map(&:strip).reject(&:empty?)
220
- when 'Snyk ID' then
212
+ when 'Snyk ID'
221
213
  data[:id] = value.text.strip
222
- when 'Disclosed' then
214
+ when 'Disclosed'
223
215
  data[:disclosed_date] = value.text.strip
224
- when 'Published' then
216
+ when 'Published'
225
217
  data[:published_date] = value.text.strip
226
- when 'Last modified' then
218
+ when 'Last modified'
227
219
  data[:last_modified_date] = value.text.strip
228
220
  end
229
221
  end
@@ -95,9 +95,9 @@ module YAVDB
95
95
 
96
96
  def severity(cvss_score)
97
97
  case cvss_score
98
- when 0.0..3.3 then
98
+ when 0.0..3.3
99
99
  'low'
100
- when 3.3..6.6 then
100
+ when 3.3..6.6
101
101
  'medium'
102
102
  else
103
103
  'high'
@@ -45,9 +45,9 @@ module YAVDB
45
45
  begin
46
46
  response = Net::HTTP.get_response(url)
47
47
  case response
48
- when Net::HTTPNotFound then
48
+ when Net::HTTPNotFound
49
49
  raise ArgumentError, 'page not found'
50
- when Net::HTTPTooManyRequests then
50
+ when Net::HTTPTooManyRequests
51
51
  raise ArgumentError, 'too many requests'
52
52
  else
53
53
  response.body.lines
@@ -16,6 +16,6 @@
16
16
 
17
17
  module YAVDB
18
18
 
19
- VERSION = '0.5.2'
19
+ VERSION = '0.5.3'
20
20
 
21
21
  end
@@ -31,9 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency 'simplecov'
32
32
 
33
33
  # Linters
34
- spec.add_development_dependency 'dependency_spy', ['~> 0.4']
35
- spec.add_development_dependency 'rubocop', ['~> 0.69']
36
- spec.add_development_dependency 'rubocop-rspec', ['~> 1.33']
34
+ spec.add_development_dependency 'dependency_spy'
35
+ spec.add_development_dependency 'rubocop', ['~> 0.74']
36
+ spec.add_development_dependency 'rubocop-rspec', ['~> 1.35']
37
37
 
38
38
  # Runtime
39
39
  spec.add_runtime_dependency 'execjs', ['~> 2.7']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yavdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Fernandes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-19 00:00:00.000000000 Z
11
+ date: 2019-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codacy-coverage
@@ -84,44 +84,44 @@ dependencies:
84
84
  name: dependency_spy
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '0.4'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '0.4'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.69'
103
+ version: '0.74'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0.69'
110
+ version: '0.74'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rubocop-rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '1.33'
117
+ version: '1.35'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '1.33'
124
+ version: '1.35'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: execjs
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -246,11 +246,14 @@ extensions: []
246
246
  extra_rdoc_files: []
247
247
  files:
248
248
  - ".circleci/config.yml"
249
+ - ".github/ISSUE_TEMPLATE/bug_report.md"
250
+ - ".github/ISSUE_TEMPLATE/feature_request.md"
249
251
  - ".gitignore"
250
252
  - ".rspec"
251
253
  - ".rubocop.yml"
252
254
  - ".ruby-version"
253
255
  - CODE_OF_CONDUCT.md
256
+ - CONTRIBUTING.md
254
257
  - Gemfile
255
258
  - Gemfile.lock
256
259
  - LICENSE