ronin 1.0.0.rc1 → 1.0.0.rc2

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.
Files changed (76) hide show
  1. data/ChangeLog.md +24 -26
  2. data/Gemfile +24 -12
  3. data/README.md +39 -22
  4. data/Rakefile +2 -4
  5. data/gemspec.yml +27 -30
  6. data/lib/ronin/address.rb +3 -6
  7. data/lib/ronin/cached_file.rb +4 -3
  8. data/lib/ronin/campaign.rb +2 -1
  9. data/lib/ronin/credential.rb +3 -2
  10. data/lib/ronin/database/database.rb +3 -0
  11. data/lib/ronin/database/migrations/create_addresses_table.rb +1 -3
  12. data/lib/ronin/database/migrations/create_open_ports_table.rb +0 -3
  13. data/lib/ronin/database/migrations/create_organizations_table.rb +1 -6
  14. data/lib/ronin/database/migrations/create_urls_table.rb +1 -4
  15. data/lib/ronin/database/migrations.rb +0 -2
  16. data/lib/ronin/email_address.rb +5 -3
  17. data/lib/ronin/environment.rb +1 -1
  18. data/lib/ronin/host_name.rb +4 -3
  19. data/lib/ronin/host_name_ip_address.rb +3 -2
  20. data/lib/ronin/ip_address.rb +5 -4
  21. data/lib/ronin/ip_address_mac_address.rb +3 -2
  22. data/lib/ronin/mac_address.rb +3 -1
  23. data/lib/ronin/model/has_authors/class_methods.rb +2 -2
  24. data/lib/ronin/model/has_authors/has_authors.rb +1 -1
  25. data/lib/ronin/model/has_license/class_methods.rb +22 -5
  26. data/lib/ronin/{database/migrations/create_tags_table.rb → model/has_unique_name/class_methods.rb} +20 -15
  27. data/lib/ronin/model/has_unique_name/has_unique_name.rb +72 -0
  28. data/lib/ronin/model/has_unique_name.rb +2 -51
  29. data/lib/ronin/model/model.rb +1 -1
  30. data/lib/ronin/open_port.rb +5 -8
  31. data/lib/ronin/organization.rb +2 -5
  32. data/lib/ronin/os.rb +3 -2
  33. data/lib/ronin/os_guess.rb +3 -2
  34. data/lib/ronin/password.rb +2 -1
  35. data/lib/ronin/port.rb +2 -1
  36. data/lib/ronin/repository.rb +2 -1
  37. data/lib/ronin/service.rb +2 -1
  38. data/lib/ronin/service_credential.rb +2 -1
  39. data/lib/ronin/software.rb +2 -1
  40. data/lib/ronin/spec/database.rb +4 -0
  41. data/lib/ronin/target.rb +3 -2
  42. data/lib/ronin/tcp_port.rb +4 -2
  43. data/lib/ronin/ui/cli/cli.rb +2 -3
  44. data/lib/ronin/ui/cli/command.rb +48 -16
  45. data/lib/ronin/ui.rb +0 -1
  46. data/lib/ronin/url.rb +9 -10
  47. data/lib/ronin/url_scheme.rb +15 -1
  48. data/lib/ronin/version.rb +1 -1
  49. data/lib/ronin/web_credential.rb +3 -2
  50. data/ronin.gemspec +2 -2
  51. data/spec/model/cacheable_spec.rb +9 -6
  52. data/spec/model/has_authors_spec.rb +60 -0
  53. data/spec/model/has_description_spec.rb +8 -6
  54. data/spec/model/has_license_spec.rb +31 -12
  55. data/spec/model/has_name_spec.rb +12 -10
  56. data/spec/model/has_title_spec.rb +8 -6
  57. data/spec/model/has_version_spec.rb +58 -0
  58. data/spec/model/model_spec.rb +1 -3
  59. data/spec/model/models/authored_model.rb +11 -0
  60. data/spec/model/models/described_model.rb +0 -1
  61. data/spec/model/models/licensed_model.rb +0 -1
  62. data/spec/model/models/named_model.rb +0 -1
  63. data/spec/model/models/titled_model.rb +0 -1
  64. data/spec/model/models/versioned_model.rb +11 -0
  65. data/spec/model/spec_helper.rb +2 -2
  66. data/spec/ui/cli/classes/test_command.rb +7 -1
  67. data/spec/ui/cli/command_spec.rb +6 -0
  68. metadata +94 -267
  69. data/lib/ronin/database/migrations/create_taggings_table.rb +0 -45
  70. data/lib/ronin/ui/hexdump/extensions/file.rb +0 -39
  71. data/lib/ronin/ui/hexdump/extensions/kernel.rb +0 -31
  72. data/lib/ronin/ui/hexdump/extensions.rb +0 -21
  73. data/lib/ronin/ui/hexdump/hexdump.rb +0 -92
  74. data/lib/ronin/ui/hexdump.rb +0 -21
  75. data/spec/model/models/lazy_model.rb +0 -9
  76. data/spec/support/inflector_spec.rb +0 -20
@@ -20,6 +20,8 @@
20
20
  require 'ronin/model'
21
21
  require 'ronin/model/has_unique_name'
22
22
 
23
+ require 'dm-is-predefined'
24
+
23
25
  module Ronin
24
26
  #
25
27
  # Represents a {URL} scheme.
@@ -28,12 +30,24 @@ module Ronin
28
30
 
29
31
  include Model
30
32
  include Model::HasUniqueName
33
+
34
+ is :predefined
31
35
 
32
36
  # primary key of the URL Scheme
33
37
  property :id, Serial
34
38
 
35
39
  # The URLs that use the scheme
36
- has 1..n, :urls, :model => 'URL'
40
+ has 0..n, :urls, :model => 'URL',
41
+ :child_key => [:scheme_id]
42
+
43
+ # Predefines the HTTP URL Scheme
44
+ predefine :http, :name => 'http'
45
+
46
+ # Predefines the HTTPS URL Scheme
47
+ predefine :https, :name => 'https'
48
+
49
+ # Predefines the FTP URL Scheme
50
+ predefine :ftp, :name => 'ftp'
37
51
 
38
52
  end
39
53
  end
data/lib/ronin/version.rb CHANGED
@@ -19,5 +19,5 @@
19
19
 
20
20
  module Ronin
21
21
  # Ronin version
22
- VERSION = '1.0.0.rc1'
22
+ VERSION = '1.0.0.rc2'
23
23
  end
@@ -18,10 +18,11 @@
18
18
  #
19
19
 
20
20
  require 'ronin/credential'
21
- require 'ronin/email_address'
22
- require 'ronin/url'
23
21
 
24
22
  module Ronin
23
+ autoload :EmailAddress, 'ronin/email_address'
24
+ autoload :URL, 'ronin/url'
25
+
25
26
  #
26
27
  # Represents Credentials used to access websites at specified {URL}s.
27
28
  #
data/ronin.gemspec CHANGED
@@ -9,7 +9,7 @@ rescue NameError
9
9
  require 'ore/specification'
10
10
  retry
11
11
  rescue LoadError
12
- STDERR.puts "The 'ronin.gemspec' file requires Ore."
13
- STDERR.puts "Run `gem install ore` to install Ore."
12
+ STDERR.puts "The '#{__FILE__}' file requires Ore."
13
+ STDERR.puts "Run `gem install ore-core` to install Ore."
14
14
  end
15
15
  end
@@ -8,22 +8,25 @@ describe Model::Cacheable do
8
8
  include Helpers::Repositories
9
9
 
10
10
  let(:repo) { repository('test1') }
11
- let(:cacheable_model) { CacheableModel }
12
11
 
13
- before(:all) do
14
- repo.cache_files!
12
+ subject { CacheableModel }
13
+
14
+ before(:all) { repo.cache_files! }
15
+
16
+ it "should include Ronin::Model" do
17
+ subject.ancestors.should include(Model)
15
18
  end
16
19
 
17
20
  it "should add the type property to the model" do
18
- cacheable_model.properties.should be_named(:type)
21
+ subject.properties.should be_named(:type)
19
22
  end
20
23
 
21
24
  it "should add a relation between CachedFile and the model" do
22
- cacheable_model.relationships.should have_key(:cached_file)
25
+ subject.relationships.should be_named(:cached_file)
23
26
  end
24
27
 
25
28
  it "should add the class to Cacheable.models" do
26
- Model::Cacheable.models.should include(cacheable_model)
29
+ Model::Cacheable.models.should include(subject)
27
30
  end
28
31
 
29
32
  describe "load_from" do
@@ -0,0 +1,60 @@
1
+ require 'model/spec_helper'
2
+ require 'model/models/authored_model'
3
+
4
+ require 'ronin/model/has_authors'
5
+
6
+ describe Model::HasAuthors do
7
+ subject { AuthoredModel }
8
+
9
+ before(:all) do
10
+ subject.auto_migrate!
11
+
12
+ resource = subject.new(:content => 'Test')
13
+ resource.author(
14
+ :name => 'Alice',
15
+ :email => 'alice@example.com',
16
+ :organization => 'Crew'
17
+ )
18
+
19
+ resource.save
20
+ end
21
+
22
+ it "should include Ronin::Model" do
23
+ subject.ancestors.should include(Model)
24
+ end
25
+
26
+ it "should define an authors relationship" do
27
+ relationship = subject.relationships['authors']
28
+
29
+ relationship.should_not be_nil
30
+ relationship.child_model.should == Author
31
+ end
32
+
33
+ it "should define relationships with Author" do
34
+ relationship = Author.relationships['authored_models']
35
+
36
+ relationship.should_not be_nil
37
+ relationship.child_model.should == subject
38
+ end
39
+
40
+ it "should allow adding authors to a resource" do
41
+ resource = subject.new
42
+ resource.author(:name => 'Alice', :email => 'alice@example.com')
43
+
44
+ resource.authors.should_not be_empty
45
+ end
46
+
47
+ it "should allow querying resources based on their Author" do
48
+ resources = subject.written_by('Alice')
49
+
50
+ resources.length.should == 1
51
+ resources[0].authors[0].name.should == 'Alice'
52
+ end
53
+
54
+ it "should allow querying resources based on their Organization" do
55
+ resources = subject.written_for('Crew')
56
+
57
+ resources.length.should == 1
58
+ resources[0].authors[0].organization.should == 'Crew'
59
+ end
60
+ end
@@ -6,8 +6,10 @@ require 'ronin/model/has_description'
6
6
  describe Model::HasDescription do
7
7
  subject { DescribedModel }
8
8
 
9
- before(:all) do
10
- subject.auto_migrate!
9
+ before(:all) { subject.auto_migrate! }
10
+
11
+ it "should include Ronin::Model" do
12
+ subject.ancestors.should include(Model)
11
13
  end
12
14
 
13
15
  it "should define a description property" do
@@ -52,10 +54,10 @@ describe Model::HasDescription do
52
54
  subject.create!(:description => 'foo one')
53
55
  subject.create!(:description => 'foo bar two')
54
56
 
55
- models = subject.describing('foo')
57
+ resources = subject.describing('foo')
56
58
 
57
- models.length.should == 2
58
- models[0].description.should == 'foo one'
59
- models[1].description.should == 'foo bar two'
59
+ resources.length.should == 2
60
+ resources[0].description.should == 'foo one'
61
+ resources[1].description.should == 'foo bar two'
60
62
  end
61
63
  end
@@ -8,6 +8,15 @@ describe Model::HasLicense do
8
8
 
9
9
  before(:all) do
10
10
  subject.auto_migrate!
11
+
12
+ subject.create(
13
+ :content => 'stuff here',
14
+ :license => License.gpl2
15
+ )
16
+ end
17
+
18
+ it "should include Ronin::Model" do
19
+ subject.ancestors.should include(Model)
11
20
  end
12
21
 
13
22
  it "should define a license relationship" do
@@ -24,21 +33,31 @@ describe Model::HasLicense do
24
33
  relationship.child_model.should == subject
25
34
  end
26
35
 
27
- it "should have a license" do
28
- model = subject.create!(
29
- :content => 'bla',
30
- :license => License.gpl2
31
- )
36
+ it "should not require a license" do
37
+ resource = subject.new(:content => 'bla')
32
38
 
33
- model.license.should == License.gpl2
39
+ resource.should be_valid
34
40
  end
35
41
 
36
- it "should provide helper methods for querying licensed models" do
37
- model = subject.create!(
38
- :content => 'stuff here',
39
- :license => License.gpl2
40
- )
42
+ describe "licensed_under" do
43
+ let(:license) { License.gpl2 }
44
+
45
+ it "should accept License resources" do
46
+ resource = subject.licensed_under(license).first
47
+
48
+ resource.license.should == license
49
+ end
50
+
51
+ it "should accept the names of predefined Licenses" do
52
+ resource = subject.licensed_under(:gpl2).first
53
+
54
+ resource.license.should == license
55
+ end
56
+
57
+ it "should accept the names of licenses" do
58
+ resource = subject.licensed_under('GPL-2').first
41
59
 
42
- subject.licensed_under(:gpl2).first == model
60
+ resource.license.should == license
61
+ end
43
62
  end
44
63
  end
@@ -6,8 +6,10 @@ require 'ronin/model/has_name'
6
6
  describe Model::HasName do
7
7
  subject { NamedModel }
8
8
 
9
- before(:all) do
10
- subject.auto_migrate!
9
+ before(:all) { subject.auto_migrate! }
10
+
11
+ it "should include Ronin::Model" do
12
+ subject.ancestors.should include(Model)
11
13
  end
12
14
 
13
15
  it "should define a name property" do
@@ -15,21 +17,21 @@ describe Model::HasName do
15
17
  end
16
18
 
17
19
  it "should require a name" do
18
- model = subject.new
19
- model.should_not be_valid
20
+ resource = subject.new
21
+ resource.should_not be_valid
20
22
 
21
- model.name = 'foo'
22
- model.should be_valid
23
+ resource.name = 'foo'
24
+ resource.should be_valid
23
25
  end
24
26
 
25
27
  it "should be able to find resources with similar names" do
26
28
  subject.create!(:name => 'foo1')
27
29
  subject.create!(:name => 'foo2')
28
30
 
29
- models = subject.named('foo')
31
+ resources = subject.named('foo')
30
32
 
31
- models.length.should == 2
32
- models[0].name.should == 'foo1'
33
- models[1].name.should == 'foo2'
33
+ resources.length.should == 2
34
+ resources[0].name.should == 'foo1'
35
+ resources[1].name.should == 'foo2'
34
36
  end
35
37
  end
@@ -6,8 +6,10 @@ require 'ronin/model/has_title'
6
6
  describe Model::HasTitle do
7
7
  subject { TitledModel }
8
8
 
9
- before(:all) do
10
- subject.auto_migrate!
9
+ before(:all) { subject.auto_migrate! }
10
+
11
+ it "should include Ronin::Model" do
12
+ subject.ancestors.should include(Model)
11
13
  end
12
14
 
13
15
  it "should define a title property" do
@@ -18,10 +20,10 @@ describe Model::HasTitle do
18
20
  subject.create!(:title => 'Foo one')
19
21
  subject.create!(:title => 'Foo bar two')
20
22
 
21
- models = subject.titled('Foo')
23
+ resources = subject.titled('Foo')
22
24
 
23
- models.length.should == 2
24
- models[0].title.should == 'Foo one'
25
- models[1].title.should == 'Foo bar two'
25
+ resources.length.should == 2
26
+ resources[0].title.should == 'Foo one'
27
+ resources[1].title.should == 'Foo bar two'
26
28
  end
27
29
  end
@@ -0,0 +1,58 @@
1
+ require 'model/spec_helper'
2
+ require 'model/models/versioned_model'
3
+
4
+ require 'ronin/model/has_version'
5
+
6
+ describe Model::HasVersion do
7
+ subject { VersionedModel }
8
+
9
+ before(:all) do
10
+ subject.auto_migrate!
11
+
12
+ subject.create(
13
+ :version => '1.1',
14
+ :content => 'Foo'
15
+ )
16
+
17
+ subject.create(
18
+ :version => '1.1',
19
+ :content => 'Bar'
20
+ )
21
+
22
+ subject.create(
23
+ :version => '1.2',
24
+ :content => 'Foo'
25
+ )
26
+ end
27
+
28
+ it "should include Ronin::Model" do
29
+ subject.ancestors.should include(Model)
30
+ end
31
+
32
+ it "should define a version property" do
33
+ subject.properties.should be_named(:version)
34
+ end
35
+
36
+ it "should default the version property to '1.0'" do
37
+ resource = subject.new
38
+
39
+ resource.version.should == '0.1'
40
+ end
41
+
42
+ it "should allow querying specific revisions" do
43
+ resources = subject.revision('1.1')
44
+
45
+ resources.length.should == 2
46
+ resources[0].version.should == '1.1'
47
+ resources[0].content.should == 'Foo'
48
+
49
+ resources[1].version.should == '1.1'
50
+ resources[1].content.should == 'Bar'
51
+ end
52
+
53
+ it "should allow querying the latest revision" do
54
+ resource = subject.all(:content => 'Foo').latest
55
+
56
+ resource.version.should == '1.2'
57
+ end
58
+ end
@@ -9,9 +9,7 @@ describe Model do
9
9
 
10
10
  let(:custom_model) { CustomModel }
11
11
 
12
- before(:all) do
13
- subject.auto_migrate!
14
- end
12
+ before(:all) { subject.auto_migrate! }
15
13
 
16
14
  it "should have a default repository name" do
17
15
  subject.default_repository_name.should == :default
@@ -0,0 +1,11 @@
1
+ require 'ronin/model/has_authors'
2
+
3
+ class AuthoredModel
4
+
5
+ include Ronin::Model::HasAuthors
6
+
7
+ property :id, Serial
8
+
9
+ property :content, String
10
+
11
+ end
@@ -2,7 +2,6 @@ require 'ronin/model/has_description'
2
2
 
3
3
  class DescribedModel
4
4
 
5
- include Ronin::Model
6
5
  include Ronin::Model::HasDescription
7
6
 
8
7
  property :id, Serial
@@ -2,7 +2,6 @@ require 'ronin/model/has_license'
2
2
 
3
3
  class LicensedModel
4
4
 
5
- include Ronin::Model
6
5
  include Ronin::Model::HasLicense
7
6
 
8
7
  property :id, Serial
@@ -2,7 +2,6 @@ require 'ronin/model/has_name'
2
2
 
3
3
  class NamedModel
4
4
 
5
- include Ronin::Model
6
5
  include Ronin::Model::HasName
7
6
 
8
7
  property :id, Serial
@@ -2,7 +2,6 @@ require 'ronin/model/has_title'
2
2
 
3
3
  class TitledModel
4
4
 
5
- include Ronin::Model
6
5
  include Ronin::Model::HasTitle
7
6
 
8
7
  property :id, Serial
@@ -0,0 +1,11 @@
1
+ require 'ronin/model/has_version'
2
+
3
+ class VersionedModel
4
+
5
+ include Ronin::Model::HasVersion
6
+
7
+ property :id, Serial
8
+
9
+ property :content, String
10
+
11
+ end
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
  require 'model/models/basic_model'
3
3
  require 'model/models/cacheable_model'
4
4
  require 'model/models/custom_model'
5
+ require 'model/models/authored_model'
5
6
  require 'model/models/described_model'
6
- require 'model/models/lazy_model'
7
7
  require 'model/models/licensed_model'
8
8
  require 'model/models/named_model'
9
9
  require 'model/models/titled_model'
@@ -13,8 +13,8 @@ RSpec.configure do |spec|
13
13
  BasicModel.auto_migrate!
14
14
  CacheableModel.auto_migrate!
15
15
  CustomModel.auto_migrate!
16
+ AuthoredModel.auto_migrate!
16
17
  DescribedModel.auto_migrate!
17
- LazyModel.auto_migrate!
18
18
  LicensedModel.auto_migrate!
19
19
  NamedModel.auto_migrate!
20
20
  TitledModel.auto_migrate!
@@ -4,8 +4,14 @@ class TestCommand < Ronin::UI::CLI::Command
4
4
 
5
5
  desc 'Tests the default task'
6
6
 
7
+ class_option :foo, :type => :boolean
8
+
7
9
  def execute
8
- 'default task'
10
+ if options.foo?
11
+ 'foo task'
12
+ else
13
+ 'default task'
14
+ end
9
15
  end
10
16
 
11
17
  end
@@ -14,6 +14,12 @@ describe UI::CLI::Command do
14
14
  subject.start([]).should == ['default task']
15
15
  end
16
16
 
17
+ it "should allow running the task with options" do
18
+ command = subject.run({:foo => true})
19
+
20
+ command.options.foo.should == true
21
+ end
22
+
17
23
  it "should have zero indentation by default" do
18
24
  command = subject.new
19
25
  command.instance_variable_get('@indent').should == 0