ronin 1.1.0 → 1.2.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.
Files changed (44) hide show
  1. data/ChangeLog.md +23 -0
  2. data/README.md +19 -13
  3. data/Rakefile +2 -1
  4. data/gemspec.yml +18 -17
  5. data/lib/bond/completions/ronin.rb +147 -0
  6. data/lib/ronin/auto_load.rb +30 -28
  7. data/lib/ronin/database/migrations/1.0.0.rb +1 -0
  8. data/lib/ronin/model/has_authors.rb +92 -2
  9. data/lib/ronin/model/has_description.rb +54 -2
  10. data/lib/ronin/model/has_license.rb +101 -2
  11. data/lib/ronin/model/has_name.rb +72 -2
  12. data/lib/ronin/model/has_title.rb +52 -2
  13. data/lib/ronin/model/has_unique_name.rb +93 -2
  14. data/lib/ronin/model/has_version.rb +58 -2
  15. data/lib/ronin/model/model.rb +91 -52
  16. data/lib/ronin/os.rb +30 -15
  17. data/lib/ronin/repository.rb +1 -1
  18. data/lib/ronin/ronin.rb +0 -15
  19. data/lib/ronin/script/script.rb +257 -2
  20. data/lib/ronin/ui/console.rb +2 -199
  21. data/lib/ronin/ui/console/commands.rb +164 -0
  22. data/lib/ronin/ui/console/console.rb +215 -0
  23. data/lib/ronin/ui/console/context.rb +95 -0
  24. data/lib/ronin/version.rb +1 -1
  25. data/spec/os_spec.rb +18 -13
  26. metadata +206 -239
  27. data/lib/ronin/class_methods.rb +0 -49
  28. data/lib/ronin/model/class_methods.rb +0 -58
  29. data/lib/ronin/model/has_authors/class_methods.rb +0 -60
  30. data/lib/ronin/model/has_authors/has_authors.rb +0 -70
  31. data/lib/ronin/model/has_description/class_methods.rb +0 -49
  32. data/lib/ronin/model/has_description/has_description.rb +0 -49
  33. data/lib/ronin/model/has_license/class_methods.rb +0 -68
  34. data/lib/ronin/model/has_license/has_license.rb +0 -71
  35. data/lib/ronin/model/has_name/class_methods.rb +0 -48
  36. data/lib/ronin/model/has_name/has_name.rb +0 -62
  37. data/lib/ronin/model/has_title/class_methods.rb +0 -48
  38. data/lib/ronin/model/has_title/has_title.rb +0 -48
  39. data/lib/ronin/model/has_unique_name/class_methods.rb +0 -51
  40. data/lib/ronin/model/has_unique_name/has_unique_name.rb +0 -78
  41. data/lib/ronin/model/has_version/class_methods.rb +0 -54
  42. data/lib/ronin/model/has_version/has_version.rb +0 -48
  43. data/lib/ronin/script/class_methods.rb +0 -84
  44. data/lib/ronin/script/instance_methods.rb +0 -217
@@ -17,5 +17,57 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model/has_description/class_methods'
21
- require 'ronin/model/has_description/has_description'
20
+ require 'ronin/model/types/description'
21
+ require 'ronin/model'
22
+
23
+ module Ronin
24
+ module Model
25
+ #
26
+ # Adds a `description` property to a model.
27
+ #
28
+ module HasDescription
29
+ #
30
+ # Adds the `description` property and {ClassMethods} to the model.
31
+ #
32
+ # @param [Class] base
33
+ # The model.
34
+ #
35
+ # @api semipublic
36
+ #
37
+ def self.included(base)
38
+ base.send :include, Model
39
+ base.send :extend, ClassMethods
40
+
41
+ base.module_eval do
42
+ # The description of the model
43
+ property :description, Model::Types::Description
44
+ end
45
+ end
46
+
47
+ #
48
+ # Class methods that are added when {HasDescription} is included into
49
+ # a model.
50
+ #
51
+ module ClassMethods
52
+ #
53
+ # Finds models with descriptions containing a given fragment of
54
+ # text.
55
+ #
56
+ # @param [String] fragment
57
+ # The fragment of text to match descriptions with.
58
+ #
59
+ # @return [Array<Model>]
60
+ # The found models.
61
+ #
62
+ # @example
63
+ # Exploit.describing 'bypass'
64
+ #
65
+ # @api public
66
+ #
67
+ def describing(fragment)
68
+ all(:description.like => "%#{fragment}%")
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -17,5 +17,104 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model/has_license/class_methods'
21
- require 'ronin/model/has_license/has_license'
20
+ require 'ronin/model'
21
+ require 'ronin/license'
22
+
23
+ module Ronin
24
+ module Model
25
+ #
26
+ # Adds a `license` relationship between a model and the {License} model.
27
+ #
28
+ module HasLicense
29
+ #
30
+ # Adds the `license` relationship and {ClassMethods} to the model.
31
+ #
32
+ # @param [Class] base
33
+ # The model.
34
+ #
35
+ # @api semipublic
36
+ #
37
+ def self.included(base)
38
+ base.send :include, Model, InstanceMethods
39
+ base.send :extend, ClassMethods
40
+
41
+ base.module_eval do
42
+ # The license
43
+ belongs_to :license, Ronin::License, :required => false
44
+
45
+ Ronin::License.has 0..n, self.relationship_name, :model => self
46
+ end
47
+ end
48
+
49
+ #
50
+ # Class methods that are added when {HasLicense} is included into a
51
+ # model.
52
+ #
53
+ module ClassMethods
54
+ #
55
+ # Finds all models associated with a given license.
56
+ #
57
+ # @param [License, Symbol, #to_s] license
58
+ # The license which models are associated with.
59
+ #
60
+ # @return [Array<Model>]
61
+ # The models associated with a given license.
62
+ #
63
+ # @example Query using a predefined {License} resource.
64
+ # LicensedModel.licensed_under(License.mit)
65
+ # # => [#<Ronin::LicensedModel: ...>, ...]
66
+ #
67
+ # @example Query using the name of a predefined {License}.
68
+ # LicensedModel.licensed_under(:cc_by_nc)
69
+ # # => [#<Ronin::LicensedModel: ...>, ...]
70
+ #
71
+ # @example Query using the name of a {License}.
72
+ # LicensedModel.licensed_under('GPL-2')
73
+ # # => [#<Ronin::LicensedModel: ...>, ...]
74
+ #
75
+ # @since 1.0.0
76
+ #
77
+ # @api public
78
+ #
79
+ def licensed_under(license)
80
+ conditions = case license
81
+ when License
82
+ {:license => license}
83
+ when Symbol
84
+ {:license => License.predefined_resource(license)}
85
+ else
86
+ {'license.name' => license.to_s}
87
+ end
88
+
89
+ all(conditions)
90
+ end
91
+ end
92
+
93
+ #
94
+ # Instance methods that are added when {HasLicense} is included into a
95
+ # model.
96
+ #
97
+ module InstanceMethods
98
+ #
99
+ # Sets the license of the model.
100
+ #
101
+ # @param [Symbol, String] name
102
+ # The name of the license to use.
103
+ #
104
+ # @return [License]
105
+ # The new license of the model.
106
+ #
107
+ # @example
108
+ # license! :mit
109
+ #
110
+ # @since 1.0.0
111
+ #
112
+ # @api public
113
+ #
114
+ def license!(name)
115
+ self.license = Ronin::License.predefined_resource(name)
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -17,5 +17,75 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model/has_name/class_methods'
21
- require 'ronin/model/has_name/has_name'
20
+ require 'ronin/model'
21
+
22
+ module Ronin
23
+ module Model
24
+ #
25
+ # Adds a `name` property to a model.
26
+ #
27
+ module HasName
28
+ #
29
+ # Adds the `name` property and {ClassMethods} to the model.
30
+ #
31
+ # @param [Class] base
32
+ # The model.
33
+ #
34
+ # @api semipublic
35
+ #
36
+ def self.included(base)
37
+ base.send :include, Model, InstanceMethods
38
+ base.send :extend, ClassMethods
39
+
40
+ base.module_eval do
41
+ # The name of the model
42
+ property :name, String, :required => true, :index => true
43
+ end
44
+ end
45
+
46
+ #
47
+ # Class methods that are added when {HasName} is included into a
48
+ # model.
49
+ #
50
+ module ClassMethods
51
+ #
52
+ # Finds models with names containing a given fragment of text.
53
+ #
54
+ # @param [String] fragment
55
+ # The fragment of text to search for within the names of models.
56
+ #
57
+ # @return [Array<Model>]
58
+ # The found models.
59
+ #
60
+ # @example
61
+ # Exploit.named 'ProFTP'
62
+ #
63
+ # @api public
64
+ #
65
+ def named(fragment)
66
+ all(:name.like => "%#{fragment}%")
67
+ end
68
+ end
69
+
70
+ #
71
+ # Instance methods that are added when {HasName} is included into a
72
+ # model.
73
+ #
74
+ module InstanceMethods
75
+ #
76
+ # Converts the named resource into a String.
77
+ #
78
+ # @return [String]
79
+ # The name of the resource.
80
+ #
81
+ # @since 1.0.0
82
+ #
83
+ # @api public
84
+ #
85
+ def to_s
86
+ self.name.to_s
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -17,5 +17,55 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model/has_title/class_methods'
21
- require 'ronin/model/has_title/has_title'
20
+ require 'ronin/model'
21
+
22
+ module Ronin
23
+ module Model
24
+ #
25
+ # Adds a `title` property to a model.
26
+ #
27
+ module HasTitle
28
+ #
29
+ # Adds the `title` property and {ClassMethods} to the model.
30
+ #
31
+ # @param [Class] base
32
+ # The model.
33
+ #
34
+ # @api semipublic
35
+ #
36
+ def self.included(base)
37
+ base.send :include, Model
38
+ base.send :extend, ClassMethods
39
+
40
+ base.module_eval do
41
+ # The title of the model
42
+ property :title, String
43
+ end
44
+ end
45
+
46
+ #
47
+ # Class methods that are added when {HasTitle} are included into a
48
+ # model.
49
+ #
50
+ module ClassMethods
51
+ #
52
+ # Finds models with titles containing a given fragment of text.
53
+ #
54
+ # @param [String] fragment
55
+ # The fragment of text to match titles with.
56
+ #
57
+ # @return [Array<Model>]
58
+ # The found models.
59
+ #
60
+ # @example
61
+ # Vuln.titled 'bypass'
62
+ #
63
+ # @api public
64
+ #
65
+ def titled(fragment)
66
+ all(:title.like => "%#{fragment}%")
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -17,5 +17,96 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model/has_unique_name/class_methods'
21
- require 'ronin/model/has_unique_name/has_unique_name'
20
+ require 'ronin/model/has_name'
21
+
22
+ module Ronin
23
+ module Model
24
+ #
25
+ # Adds a unique `name` property to a model.
26
+ #
27
+ module HasUniqueName
28
+ #
29
+ # Adds the unique `name` property and {HasName::ClassMethods} to the
30
+ # model.
31
+ #
32
+ # @param [Class] base
33
+ # The model.
34
+ #
35
+ # @api semipublic
36
+ #
37
+ def self.included(base)
38
+ base.send :include, Model,
39
+ InstanceMethods
40
+
41
+ base.send :extend, HasName::ClassMethods,
42
+ HasUniqueName::ClassMethods
43
+
44
+ base.module_eval do
45
+ # The name of the model
46
+ property :name, String, :required => true, :unique => true
47
+ end
48
+ end
49
+
50
+ #
51
+ # Class methods that will be added when {HasUniqueName} is included.
52
+ #
53
+ module ClassMethods
54
+ #
55
+ # Searches for models with the unique name.
56
+ #
57
+ # @param [String, Symbol, Integer] key
58
+ # The unique name or index to search for.
59
+ #
60
+ # @return [Model, nil]
61
+ # The matching model.
62
+ #
63
+ # @since 1.0.0
64
+ #
65
+ # @api public
66
+ #
67
+ def [](key)
68
+ case key
69
+ when String, Symbol
70
+ first(:name => key.to_s)
71
+ else
72
+ super(key)
73
+ end
74
+ end
75
+ end
76
+
77
+ #
78
+ # Instance methods that will be added when {HasUniqueName} is
79
+ # included.
80
+ #
81
+ module InstanceMethods
82
+ #
83
+ # Converts the named resource into a String.
84
+ #
85
+ # @return [String]
86
+ # The name of the resource.
87
+ #
88
+ # @since 1.0.0
89
+ #
90
+ # @api public
91
+ #
92
+ def to_s
93
+ self.name.to_s
94
+ end
95
+
96
+ #
97
+ # Inspects the resource with the unique name.
98
+ #
99
+ # @return [String]
100
+ # The inspected resource.
101
+ #
102
+ # @since 1.0.0
103
+ #
104
+ # @api public
105
+ #
106
+ def inspect
107
+ "#<#{self.class}: #{self.name}>"
108
+ end
109
+ end
110
+ end
111
+ end
112
+ end
@@ -17,5 +17,61 @@
17
17
  # along with Ronin. If not, see <http://www.gnu.org/licenses/>.
18
18
  #
19
19
 
20
- require 'ronin/model/has_version/class_methods'
21
- require 'ronin/model/has_version/has_version'
20
+ require 'ronin/model'
21
+
22
+ module Ronin
23
+ module Model
24
+ #
25
+ # Adds a `version` property to a model.
26
+ #
27
+ module HasVersion
28
+ #
29
+ # Adds the `version` property and {ClassMethods} to the model.
30
+ #
31
+ # @param [Class] base
32
+ # The model.
33
+ #
34
+ # @api semipublic
35
+ #
36
+ def self.included(base)
37
+ base.send :include, Model
38
+ base.send :extend, ClassMethods
39
+
40
+ base.module_eval do
41
+ # The version of the model
42
+ property :version, String, :default => '0.1', :index => true
43
+ end
44
+ end
45
+
46
+ #
47
+ # Class methods that are added when {HasVersion} is included into a
48
+ # model.
49
+ #
50
+ module ClassMethods
51
+ #
52
+ # Finds all models with a specific version.
53
+ #
54
+ # @param [String] version
55
+ # The specific version to search for.
56
+ #
57
+ # @return [Array]
58
+ # The models with the specific version.
59
+ #
60
+ # @api public
61
+ #
62
+ def revision(version)
63
+ all(:version => version.to_s)
64
+ end
65
+
66
+ #
67
+ # Finds latest version of the model.
68
+ #
69
+ # @api public
70
+ #
71
+ def latest
72
+ first(:order => [:version.desc])
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end