CVEasy 1.0.0

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.
@@ -0,0 +1,11 @@
1
+ doc
2
+ pkg
3
+ tmp/*
4
+ .DS_Store
5
+ .yardoc
6
+ *.db
7
+ *.log
8
+ *.swp
9
+ *~
10
+ *.gemspec
11
+ *.gem
@@ -0,0 +1,87 @@
1
+ = CVEasy
2
+
3
+ * Source: http://github.com/mephux/CVEasy
4
+ * More: http://www.packetport.net
5
+
6
+ == DESCRIPTION:
7
+
8
+ CVEasy is a ruby interface for the Common Vulnerabilities and Exposures (CVE) database at http://cve.mitre.org. This project is mostly a proof of concept and experiment highlighting how truly powerful nokogiri (http://nokogiri.rubyforge.org) can be.
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Search by Keywords
13
+ * Search by CVE Number and Year.
14
+ * Return CVE Reference Links
15
+
16
+ == INSTALL:
17
+
18
+ sudo gem install CVEasy
19
+
20
+ == SYNOPSIS:
21
+
22
+ You can use CVEasy to search for a particular CVE by using the following:
23
+
24
+ CVEasy::Query.new(:year => '2008', :cve => '1') do |cve|
25
+ puts cve.name #=> "CVE-2008-0001"
26
+ puts cve.description #=> "FS in the Linux kernel before 2.6.22.16, and 2.6.23.x before...."
27
+ puts cve.references #=> ['http://secunia.com/advisories/28664', 'http://xforce.iss.net/xforce/xfdb/39672']
28
+ puts cve.status #=> "Candidate"
29
+ puts cve.phase #=> "Assigned (20071203)"
30
+ puts cve.assigned_at #=> "Candidate assigned on 20071203 and proposed on N/A"
31
+ end
32
+
33
+ If you want to search for CVE by a keyword use the following:
34
+
35
+ CVEasy::Query.new(:keyword => 'ruby') do |cve|
36
+ puts cve.name
37
+ puts cve.description
38
+ puts cve.url
39
+ end
40
+
41
+ You can take the above example even further by querying the returned results:
42
+
43
+ CVEasy::Query.new(:keyword => 'ruby') do |cve|
44
+
45
+ puts cve.name
46
+
47
+ cve.more do |info|
48
+ puts info.references.inspect
49
+ puts info.status
50
+ puts info.phase
51
+ puts info.assigned_at
52
+ end
53
+ end
54
+
55
+ == REQUIREMENTS:
56
+
57
+ * nokogiri http://nokogiri.rubyforge.org >= 1.4.0
58
+
59
+ == TODO
60
+
61
+ * Add Tests
62
+ * Add Documentation
63
+
64
+ == LICENSE:
65
+
66
+ (The MIT License)
67
+
68
+ Copyright (c) 2009 Dustin Willis Webber
69
+
70
+ Permission is hereby granted, free of charge, to any person obtaining
71
+ a copy of this software and associated documentation files (the
72
+ 'Software'), to deal in the Software without restriction, including
73
+ without limitation the rights to use, copy, modify, merge, publish,
74
+ distribute, sublicense, and/or sell copies of the Software, and to
75
+ permit persons to whom the Software is furnished to do so, subject to
76
+ the following conditions:
77
+
78
+ The above copyright notice and this permission notice shall be
79
+ included in all copies or substantial portions of the Software.
80
+
81
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
82
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
83
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
84
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
85
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
86
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
87
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ require './tasks/spec.rb'
5
+ require './tasks/yard.rb'
6
+
7
+ begin
8
+ require 'jeweler'
9
+ Jeweler::Tasks.new do |gem|
10
+ gem.name = "CVEasy"
11
+ gem.summary = "CVEasy is a ruby interface CVE database at http://cve.mitre.org."
12
+ gem.description = "CVEasy is a ruby interface for the Common Vulnerabilities and Exposures (CVE) database at http://cve.mitre.org."
13
+ gem.email = "dustin.webber@gmail.com"
14
+ gem.homepage = "http://github.com/mephux/CVEasy"
15
+ gem.authors = ["Dustin Willis Webber"]
16
+ gem.add_dependency "nokogiri", ">= 1.4.0"
17
+ gem.add_development_dependency "rspec", ">= 1.2.9"
18
+ gem.add_development_dependency "yard", ">=0.2.3.5"
19
+ end
20
+ Jeweler::GemcutterTasks.new
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ # vim: syntax=ruby
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'CVEasy'
@@ -0,0 +1,4 @@
1
+ require "CVEasy/query.rb"
2
+
3
+ module CVEasy
4
+ end
@@ -0,0 +1,42 @@
1
+ module CVEasy
2
+
3
+ class Cve
4
+
5
+ def initialize(html)
6
+ @html = html
7
+ end
8
+
9
+ def name
10
+ @name = @html.at_css('h2').inner_text.strip if @html.at_css('h2')
11
+ end
12
+
13
+ def description
14
+ @description = @html.at_css('tr:nth-child(4)').inner_text.strip if @html.at_css('tr:nth-child(4)')
15
+ end
16
+
17
+ def references
18
+ unless @refs
19
+ @refs = []
20
+ @html.css('li a').each do |link|
21
+ @refs << ["#{link[:href]}"]
22
+ end
23
+ end
24
+ @refs
25
+ end
26
+
27
+ def status
28
+ @status = @html.at_css('tr:nth-child(9) b').inner_text
29
+ end
30
+
31
+ def phase
32
+ @phase = @html.at_css('tr:nth-child(11) td').inner_text
33
+ end
34
+
35
+ def assigned_at
36
+ @assigned_at = @html.at_css('tr:nth-child(16) .note').inner_text.strip
37
+ end
38
+
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,36 @@
1
+ module CVEasy
2
+
3
+ class Keyword
4
+
5
+ def initialize(td, html)
6
+ @td = td
7
+ @html = html
8
+ end
9
+
10
+ def name
11
+ @name = @td.at_css('td:nth-child(1) a').inner_text if @td.at_css('td:nth-child(1) a')
12
+ end
13
+
14
+ def description
15
+ @description = @td.at_css('td:nth-child(2)').inner_text.strip if @td.at_css('td:nth-child(2)')
16
+ end
17
+
18
+ def url
19
+ @url = BASE_URL + @td.at_css('td:nth-child(1) a')[:href] if @td.at_css('td:nth-child(1) a')[:href]
20
+ end
21
+
22
+ def more(&block)
23
+ cve = Nokogiri::HTML(open(url))
24
+ block.call(Cve.new(cve.at_css('#GeneratedTable'))) if block
25
+ end
26
+
27
+ # def count
28
+ # @count ||= @html.at('b:nth-child(2)').inner_text
29
+ # end
30
+ #
31
+ # def to_s
32
+ # @html.at('.smaller').inner_text.strip
33
+ # end
34
+
35
+ end
36
+ end
@@ -0,0 +1,47 @@
1
+ require "CVEasy/keyword"
2
+ require "CVEasy/cve"
3
+ require "nokogiri"
4
+ require "open-uri"
5
+ require "uri"
6
+
7
+ module CVEasy
8
+
9
+ BASE_URL = "http://cve.mitre.org"
10
+ CVE_URL = "#{BASE_URL}/cgi-bin/cvename.cgi?name=CVE-"
11
+ KEYWORD_URL = "#{BASE_URL}/cgi-bin/cvekey.cgi?keyword="
12
+
13
+ class Query < Keyword
14
+
15
+ def initialize(options={}, &block)
16
+
17
+ @year = options[:year]
18
+ @cve = options[:cve]
19
+ @keyword = options[:keyword]
20
+
21
+ if options[:keyword]
22
+
23
+ @url = "#{KEYWORD_URL}#{URI.escape(@keyword)}"
24
+ @html ||= Nokogiri::HTML(open(@url))
25
+
26
+ @html.css('#TableWithRules tr').each do |td|
27
+ # Skip The First TD - Used as TH.
28
+ next if td.at('a').nil?
29
+
30
+ block.call(Keyword.new(td, @html)) if block
31
+
32
+ end
33
+ else
34
+
35
+ @url = "#{CVE_URL}#{@year}-#{URI.escape(@cve)}"
36
+ @html = Nokogiri::HTML(open(@url))
37
+ block.call(Cve.new(@html.at_css('#GeneratedTable'))) if block
38
+
39
+ end
40
+ end
41
+
42
+ def version
43
+ @version ||= @html.at('.smaller , b:nth-child(2)').inner_text
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ # Time to add your specs!
4
+ # http://rspec.info/
5
+ describe "Place your specs here" do
6
+
7
+ it "find this spec in spec directory" do
8
+ # violated "Be sure to write your specs"
9
+ end
10
+
11
+ end
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ gem 'rspec', '>=1.1.12'
3
+ require 'spec'
4
+ require 'spec/autorun'
5
+
6
+ require "ipdb"
@@ -0,0 +1,10 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ desc "Run all specifications"
4
+ Spec::Rake::SpecTask.new(:spec) do |t|
5
+ t.libs += ['lib', 'spec']
6
+ t.spec_opts = ['--colour', '--format', 'specdoc']
7
+ end
8
+
9
+ task :test => :spec
10
+ task :default => :spec
@@ -0,0 +1,12 @@
1
+ require 'yard'
2
+
3
+ YARD::Rake::YardocTask.new do |t|
4
+ t.files = ['lib/**/*.rb']
5
+ t.options = [
6
+ '--protected',
7
+ '--files', 'History.txt',
8
+ '--title', 'Ipdb'
9
+ ]
10
+ end
11
+
12
+ task :docs => :yard
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: CVEasy
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dustin Willis Webber
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-01 00:00:00 -06:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: nokogiri
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.0
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.2.9
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: yard
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.2.3.5
44
+ version:
45
+ description: CVEasy is a ruby interface for the Common Vulnerabilities and Exposures (CVE) database at http://cve.mitre.org.
46
+ email: dustin.webber@gmail.com
47
+ executables: []
48
+
49
+ extensions: []
50
+
51
+ extra_rdoc_files:
52
+ - README.rdoc
53
+ files:
54
+ - .gitignore
55
+ - README.rdoc
56
+ - Rakefile
57
+ - VERSION
58
+ - init.rb
59
+ - lib/CVEasy.rb
60
+ - lib/CVEasy/cve.rb
61
+ - lib/CVEasy/keyword.rb
62
+ - lib/CVEasy/query.rb
63
+ - spec/CVEasy_spec.rb
64
+ - spec/spec_helper.rb
65
+ - tasks/spec.rb
66
+ - tasks/yard.rb
67
+ has_rdoc: true
68
+ homepage: http://github.com/mephux/CVEasy
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --charset=UTF-8
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project:
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: CVEasy is a ruby interface CVE database at http://cve.mitre.org.
95
+ test_files:
96
+ - spec/CVEasy_spec.rb
97
+ - spec/spec_helper.rb