cvelist 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +3 -0
- data/.github/workflows/ruby.yml +29 -0
- data/.gitignore +6 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +10 -0
- data/Gemfile +13 -0
- data/LICENSE.txt +20 -0
- data/README.md +82 -0
- data/Rakefile +13 -0
- data/benchmark.rb +38 -0
- data/cvelist.gemspec +61 -0
- data/gemspec.yml +21 -0
- data/lib/cvelist.rb +2 -0
- data/lib/cvelist/cve.rb +83 -0
- data/lib/cvelist/directory.rb +80 -0
- data/lib/cvelist/exceptions.rb +31 -0
- data/lib/cvelist/malformed_cve.rb +42 -0
- data/lib/cvelist/range_dir.rb +121 -0
- data/lib/cvelist/repository.rb +240 -0
- data/lib/cvelist/version.rb +4 -0
- data/lib/cvelist/year_dir.rb +178 -0
- data/spec/cve_methods_examples.rb +130 -0
- data/spec/cve_spec.rb +51 -0
- data/spec/cvelist_spec.rb +8 -0
- data/spec/directory_spec.rb +83 -0
- data/spec/fixtures/CVE-2020-1994.json +140 -0
- data/spec/fixtures/cvelist/.gitkeep +0 -0
- data/spec/fixtures/cvelist/1999/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2000/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2001/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2002/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2003/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2004/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2005/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2006/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2007/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2008/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2009/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2010/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2011/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2012/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2013/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2014/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2015/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2016/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2017/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2018/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2019/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2020/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/0xxx/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/1xxx/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/20xxx/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/21xxx/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/2xxx/.gitkeep +0 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2000.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2001.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2002.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2003.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2004.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2005.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2006.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2007.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2008.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2009.json +18 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2998.json +3 -0
- data/spec/fixtures/cvelist/2021/2xxx/CVE-2021-2999.json +2 -0
- data/spec/range_dir_spec.rb +55 -0
- data/spec/repository_spec.rb +248 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/year_dir_spec.rb +96 -0
- metadata +165 -0
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'cvelist/year_dir'
|
3
|
+
|
4
|
+
describe YearDir do
|
5
|
+
let(:year_number) { 2021 }
|
6
|
+
|
7
|
+
let(:fixture_dir) { File.expand_path('../fixtures',__FILE__) }
|
8
|
+
let(:cvelist_dir) { File.join(fixture_dir,'cvelist') }
|
9
|
+
let(:path) { File.join(cvelist_dir,year_number.to_s) }
|
10
|
+
|
11
|
+
subject { described_class.new(path) }
|
12
|
+
|
13
|
+
describe "#initialize" do
|
14
|
+
it "must set #year" do
|
15
|
+
expect(subject.year).to eq(year_number)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#has_range?" do
|
20
|
+
let(:xxx_range) { '1xxx' }
|
21
|
+
|
22
|
+
it "must test whether the year directory contains the '*xxx' range dir" do
|
23
|
+
expect(subject.has_range?(xxx_range)).to eq(true)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "when the year directory does not have the given '*xxx' range dir" do
|
27
|
+
let(:xxx_range) { '9xxx' }
|
28
|
+
|
29
|
+
it "must return false" do
|
30
|
+
expect(subject.has_range?(xxx_range)).to eq(false)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "#range" do
|
36
|
+
context "when the year directory has the given '*xxx' range dir" do
|
37
|
+
let(:xxx_range) { '1xxx' }
|
38
|
+
|
39
|
+
subject { super().range(xxx_range) }
|
40
|
+
|
41
|
+
it "must return a RangeDir object for the given '*xxx' range" do
|
42
|
+
expect(subject).to be_kind_of(RangeDir)
|
43
|
+
expect(subject.path).to eq(File.join(path,xxx_range))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when the year directory does not have the given '*xxx' range dir" do
|
48
|
+
let(:xxx_range) { '9xxx' }
|
49
|
+
|
50
|
+
it do
|
51
|
+
expect {
|
52
|
+
subject.range(xxx_range)
|
53
|
+
}.to raise_error(RangeDirNotFound)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
let(:xxx_ranges) { %w[0xxx 1xxx 20xxx 21xxx 2xxx] }
|
59
|
+
let(:xxx_range_paths) do
|
60
|
+
xxx_ranges.map { |dir| File.join(path,dir) }
|
61
|
+
end
|
62
|
+
|
63
|
+
let(:sorted_xxx_ranges) { xxx_ranges.sort }
|
64
|
+
let(:sorted_xxx_range_paths) do
|
65
|
+
sorted_xxx_ranges.map { |dir| File.join(path,dir) }
|
66
|
+
end
|
67
|
+
|
68
|
+
describe "#directories" do
|
69
|
+
subject { super().directories }
|
70
|
+
|
71
|
+
it "must find all '*xxx' range directories" do
|
72
|
+
expect(subject).to all(be =~ /\/\d+xxx$/)
|
73
|
+
end
|
74
|
+
|
75
|
+
it "must return the paths to '*xxx' range directories within the year directory" do
|
76
|
+
expect(subject).to match_array(xxx_range_paths)
|
77
|
+
end
|
78
|
+
|
79
|
+
it "must sort the '*xxx' range directories" do
|
80
|
+
expect(subject).to eq(sorted_xxx_range_paths)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#ranges" do
|
85
|
+
it do
|
86
|
+
expect(subject.ranges).to_not be_empty
|
87
|
+
expect(subject.ranges).to all(be_kind_of(RangeDir))
|
88
|
+
end
|
89
|
+
|
90
|
+
it "must map #directories to RangeDir objects" do
|
91
|
+
expect(subject.ranges.map(&:path)).to eq(sorted_xxx_range_paths)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
include_examples "CVE methods"
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cvelist
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Postmodern
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-01-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cve_schema
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
description: 'A Ruby library for parsing the CVE JSON in the cvelist git repository.
|
56
|
+
|
57
|
+
'
|
58
|
+
email: postmodern.mod3@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files:
|
62
|
+
- ChangeLog.md
|
63
|
+
- LICENSE.txt
|
64
|
+
- README.md
|
65
|
+
files:
|
66
|
+
- ".document"
|
67
|
+
- ".github/workflows/ruby.yml"
|
68
|
+
- ".gitignore"
|
69
|
+
- ".rspec"
|
70
|
+
- ".yardopts"
|
71
|
+
- ChangeLog.md
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- benchmark.rb
|
77
|
+
- cvelist.gemspec
|
78
|
+
- gemspec.yml
|
79
|
+
- lib/cvelist.rb
|
80
|
+
- lib/cvelist/cve.rb
|
81
|
+
- lib/cvelist/directory.rb
|
82
|
+
- lib/cvelist/exceptions.rb
|
83
|
+
- lib/cvelist/malformed_cve.rb
|
84
|
+
- lib/cvelist/range_dir.rb
|
85
|
+
- lib/cvelist/repository.rb
|
86
|
+
- lib/cvelist/version.rb
|
87
|
+
- lib/cvelist/year_dir.rb
|
88
|
+
- spec/cve_methods_examples.rb
|
89
|
+
- spec/cve_spec.rb
|
90
|
+
- spec/cvelist_spec.rb
|
91
|
+
- spec/directory_spec.rb
|
92
|
+
- spec/fixtures/CVE-2020-1994.json
|
93
|
+
- spec/fixtures/cvelist/.gitkeep
|
94
|
+
- spec/fixtures/cvelist/1999/.gitkeep
|
95
|
+
- spec/fixtures/cvelist/2000/.gitkeep
|
96
|
+
- spec/fixtures/cvelist/2001/.gitkeep
|
97
|
+
- spec/fixtures/cvelist/2002/.gitkeep
|
98
|
+
- spec/fixtures/cvelist/2003/.gitkeep
|
99
|
+
- spec/fixtures/cvelist/2004/.gitkeep
|
100
|
+
- spec/fixtures/cvelist/2005/.gitkeep
|
101
|
+
- spec/fixtures/cvelist/2006/.gitkeep
|
102
|
+
- spec/fixtures/cvelist/2007/.gitkeep
|
103
|
+
- spec/fixtures/cvelist/2008/.gitkeep
|
104
|
+
- spec/fixtures/cvelist/2009/.gitkeep
|
105
|
+
- spec/fixtures/cvelist/2010/.gitkeep
|
106
|
+
- spec/fixtures/cvelist/2011/.gitkeep
|
107
|
+
- spec/fixtures/cvelist/2012/.gitkeep
|
108
|
+
- spec/fixtures/cvelist/2013/.gitkeep
|
109
|
+
- spec/fixtures/cvelist/2014/.gitkeep
|
110
|
+
- spec/fixtures/cvelist/2015/.gitkeep
|
111
|
+
- spec/fixtures/cvelist/2016/.gitkeep
|
112
|
+
- spec/fixtures/cvelist/2017/.gitkeep
|
113
|
+
- spec/fixtures/cvelist/2018/.gitkeep
|
114
|
+
- spec/fixtures/cvelist/2019/.gitkeep
|
115
|
+
- spec/fixtures/cvelist/2020/.gitkeep
|
116
|
+
- spec/fixtures/cvelist/2021/.gitkeep
|
117
|
+
- spec/fixtures/cvelist/2021/0xxx/.gitkeep
|
118
|
+
- spec/fixtures/cvelist/2021/1xxx/.gitkeep
|
119
|
+
- spec/fixtures/cvelist/2021/20xxx/.gitkeep
|
120
|
+
- spec/fixtures/cvelist/2021/21xxx/.gitkeep
|
121
|
+
- spec/fixtures/cvelist/2021/2xxx/.gitkeep
|
122
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2000.json
|
123
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2001.json
|
124
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2002.json
|
125
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2003.json
|
126
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2004.json
|
127
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2005.json
|
128
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2006.json
|
129
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2007.json
|
130
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2008.json
|
131
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2009.json
|
132
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2998.json
|
133
|
+
- spec/fixtures/cvelist/2021/2xxx/CVE-2021-2999.json
|
134
|
+
- spec/range_dir_spec.rb
|
135
|
+
- spec/repository_spec.rb
|
136
|
+
- spec/spec_helper.rb
|
137
|
+
- spec/year_dir_spec.rb
|
138
|
+
homepage: https://github.com/postmodern/cvelist.rb#readme
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata:
|
142
|
+
documentation_uri: https://rubydoc.info/gems/cvelist
|
143
|
+
source_code_uri: https://github.com/postmodern/cvelist.rb
|
144
|
+
bug_tracker_uri: https://github.com/postmodern/cvelist.rb/issues
|
145
|
+
changelog_uri: https://github.com/postmodern/cvelist.rb/blob/main/ChangeLog.md
|
146
|
+
post_install_message:
|
147
|
+
rdoc_options: []
|
148
|
+
require_paths:
|
149
|
+
- lib
|
150
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
requirements: []
|
161
|
+
rubygems_version: 3.1.4
|
162
|
+
signing_key:
|
163
|
+
specification_version: 4
|
164
|
+
summary: Parses cvelist JSON
|
165
|
+
test_files: []
|