metasploit-model 0.27.3-java → 0.27.4-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/app/models/metasploit/model/association/reflection.rb +0 -3
- data/app/models/metasploit/model/module/ancestor/spec/template.rb +0 -3
- data/app/models/metasploit/model/module/class/spec/template.rb +0 -4
- data/app/models/metasploit/model/module/instance/spec/template.rb +0 -4
- data/app/models/metasploit/model/search/group/base.rb +0 -3
- data/app/models/metasploit/model/search/group/intersection.rb +0 -3
- data/app/models/metasploit/model/search/group/union.rb +0 -3
- data/app/models/metasploit/model/search/operation/association.rb +0 -2
- data/app/models/metasploit/model/search/operation/base.rb +0 -3
- data/app/models/metasploit/model/search/operation/boolean.rb +0 -2
- data/app/models/metasploit/model/search/operation/date.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/base.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/intersection.rb +0 -2
- data/app/models/metasploit/model/search/operation/group/union.rb +0 -2
- data/app/models/metasploit/model/search/operation/integer.rb +1 -5
- data/app/models/metasploit/model/search/operation/null.rb +0 -2
- data/app/models/metasploit/model/search/operation/set.rb +5 -2
- data/app/models/metasploit/model/search/operation/set/integer.rb +1 -3
- data/app/models/metasploit/model/search/operation/set/string.rb +1 -3
- data/app/models/metasploit/model/search/operation/string.rb +1 -5
- data/app/models/metasploit/model/search/operator/association.rb +0 -2
- data/app/models/metasploit/model/search/operator/attribute.rb +0 -2
- data/app/models/metasploit/model/search/operator/base.rb +0 -4
- data/app/models/metasploit/model/search/operator/delegation.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/app.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/author.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/authority.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/platform.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/ref.rb +0 -2
- data/app/models/metasploit/model/search/operator/deprecated/text.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/base.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/intersection.rb +0 -2
- data/app/models/metasploit/model/search/operator/group/union.rb +0 -2
- data/app/models/metasploit/model/search/operator/null.rb +0 -2
- data/app/models/metasploit/model/search/operator/single.rb +0 -2
- data/app/models/metasploit/model/search/query.rb +0 -3
- data/app/models/metasploit/model/spec/template.rb +0 -3
- data/app/models/metasploit/model/visitation/visitor.rb +0 -3
- data/lib/metasploit/model.rb +14 -8
- data/lib/metasploit/model/architecture.rb +320 -326
- data/lib/metasploit/model/association.rb +43 -46
- data/lib/metasploit/model/association/error.rb +29 -33
- data/lib/metasploit/model/association/tree.rb +119 -125
- data/lib/metasploit/model/author.rb +45 -51
- data/lib/metasploit/model/authority.rb +139 -146
- data/lib/metasploit/model/authority/bid.rb +0 -2
- data/lib/metasploit/model/authority/cve.rb +0 -2
- data/lib/metasploit/model/authority/msb.rb +0 -2
- data/lib/metasploit/model/authority/osvdb.rb +0 -2
- data/lib/metasploit/model/authority/pmasa.rb +0 -2
- data/lib/metasploit/model/authority/secunia.rb +0 -2
- data/lib/metasploit/model/authority/us_cert_vu.rb +0 -2
- data/lib/metasploit/model/authority/waraxe.rb +0 -2
- data/lib/metasploit/model/authority/zdi.rb +0 -2
- data/lib/metasploit/model/base.rb +0 -2
- data/lib/metasploit/model/derivation.rb +95 -99
- data/lib/metasploit/model/derivation/full_name.rb +16 -22
- data/lib/metasploit/model/email_address.rb +122 -128
- data/lib/metasploit/model/engine.rb +26 -21
- data/lib/metasploit/model/error.rb +3 -7
- data/lib/metasploit/model/file.rb +0 -2
- data/lib/metasploit/model/invalid.rb +11 -17
- data/lib/metasploit/model/login.rb +0 -3
- data/lib/metasploit/model/login/status.rb +0 -2
- data/lib/metasploit/model/module.rb +19 -23
- data/lib/metasploit/model/module/action.rb +50 -58
- data/lib/metasploit/model/module/ancestor.rb +456 -465
- data/lib/metasploit/model/module/ancestor/spec.rb +3 -2
- data/lib/metasploit/model/module/architecture.rb +27 -35
- data/lib/metasploit/model/module/author.rb +38 -47
- data/lib/metasploit/model/module/class.rb +358 -366
- data/lib/metasploit/model/module/class/spec.rb +3 -2
- data/lib/metasploit/model/module/handler.rb +28 -34
- data/lib/metasploit/model/module/instance.rb +586 -596
- data/lib/metasploit/model/module/instance/spec.rb +3 -2
- data/lib/metasploit/model/module/path.rb +157 -166
- data/lib/metasploit/model/module/platform.rb +25 -33
- data/lib/metasploit/model/module/rank.rb +71 -79
- data/lib/metasploit/model/module/reference.rb +25 -33
- data/lib/metasploit/model/module/stance.rb +15 -21
- data/lib/metasploit/model/module/target.rb +76 -84
- data/lib/metasploit/model/module/target/architecture.rb +27 -37
- data/lib/metasploit/model/module/target/platform.rb +27 -37
- data/lib/metasploit/model/module/type.rb +35 -41
- data/lib/metasploit/model/nilify_blanks.rb +39 -43
- data/lib/metasploit/model/platform.rb +231 -237
- data/lib/metasploit/model/real_pathname.rb +12 -16
- data/lib/metasploit/model/realm.rb +0 -2
- data/lib/metasploit/model/realm/key.rb +0 -2
- data/lib/metasploit/model/reference.rb +102 -108
- data/lib/metasploit/model/search.rb +94 -97
- data/lib/metasploit/model/search/association.rb +163 -169
- data/lib/metasploit/model/search/attribute.rb +131 -139
- data/lib/metasploit/model/search/group.rb +5 -2
- data/lib/metasploit/model/search/operation.rb +32 -29
- data/lib/metasploit/model/search/operation/group.rb +5 -2
- data/lib/metasploit/model/search/operation/value.rb +7 -0
- data/lib/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +1 -1
- data/lib/metasploit/model/search/operation/{string/value.rb → value/string.rb} +1 -1
- data/lib/metasploit/model/search/operator.rb +65 -65
- data/lib/metasploit/model/search/operator/deprecated.rb +8 -2
- data/lib/metasploit/model/search/operator/group.rb +5 -2
- data/lib/metasploit/model/search/operator/help.rb +71 -79
- data/lib/metasploit/model/search/with.rb +72 -78
- data/lib/metasploit/model/spec.rb +133 -136
- data/lib/metasploit/model/spec/error.rb +3 -9
- data/lib/metasploit/model/spec/i18n_exception_handler.rb +0 -2
- data/lib/metasploit/model/spec/pathname_collision.rb +19 -27
- data/lib/metasploit/model/spec/template/write.rb +0 -2
- data/lib/metasploit/model/spec/temporary_pathname.rb +47 -56
- data/lib/metasploit/model/translation.rb +0 -2
- data/lib/metasploit/model/version.rb +1 -1
- data/lib/metasploit/model/visitation.rb +7 -10
- data/lib/metasploit/model/visitation/visit.rb +79 -85
- data/metasploit-model.gemspec +1 -1
- data/spec/app/models/metasploit/model/search/operation/integer_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/set/integer_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/set/string_spec.rb +1 -1
- data/spec/app/models/metasploit/model/search/operation/string_spec.rb +1 -1
- data/spec/dummy/config/application.rb +1 -0
- data/spec/lib/metasploit/model/search/operation/{integer/value_spec.rb → value/integer_spec.rb} +2 -2
- data/spec/lib/metasploit/model/search/operation/{string/value_spec.rb → value/string_spec.rb} +2 -2
- data/spec/support/shared/examples/metasploit/model/search/operation/{integer/value.rb → value/integer.rb} +2 -2
- data/spec/support/shared/examples/metasploit/model/search/operation/{string/value.rb → value/string.rb} +2 -2
- metadata +16 -13
@@ -1,53 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
extend ActiveSupport::Autoload
|
7
|
-
extend ActiveSupport::Concern
|
1
|
+
# Allows registering the class name of assocations similar to ActiveRecord associations, so that ActiveModel
|
2
|
+
# associations can be reflected with the same API as ActiveRecord associations.
|
3
|
+
module Metasploit::Model::Association
|
4
|
+
extend ActiveSupport::Autoload
|
5
|
+
extend ActiveSupport::Concern
|
8
6
|
|
9
|
-
|
10
|
-
|
7
|
+
autoload :Error
|
8
|
+
autoload :Reflection
|
9
|
+
autoload :Tree
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
11
|
+
# Defines DSL for define associations on ActiveModels with {#association}, which can then be retrieved in bulk
|
12
|
+
# with {#association_by_name} or a single association's reflection by name with {#reflect_on_association}.
|
13
|
+
module ClassMethods
|
14
|
+
# Registers an association.
|
15
|
+
#
|
16
|
+
# @param name [to_sym] Name of the association
|
17
|
+
# @param options [Hash{Symbol => String}]
|
18
|
+
# @option options [String] :class_name Name of association's class.
|
19
|
+
# @return [Metasploit::Model::Association::Reflection] the reflection of the registered association.
|
20
|
+
# @raise [Metasploit::Model::Invalid] if name is blank.
|
21
|
+
# @raise [Metasploit::Model::Invalid] if :class_name is blank.
|
22
|
+
def association(name, options={})
|
23
|
+
association = Metasploit::Model::Association::Reflection.new(
|
24
|
+
:model => self,
|
25
|
+
:name => name.to_sym,
|
26
|
+
:class_name => options[:class_name]
|
27
|
+
)
|
28
|
+
association.valid!
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
association_by_name[association.name] = association
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
# Associations registered with {#association}.
|
34
|
+
#
|
35
|
+
# @return [Hash{Symbol => Metasploit::Model::Association::Reflection}] Maps
|
36
|
+
# {Metasploit::Model::Association::Reflection#name} to {Metasploit::Model::Association::Reflection}.
|
37
|
+
def association_by_name
|
38
|
+
@association_by_name ||= {}
|
39
|
+
end
|
41
40
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
41
|
+
# Returns reflection for association with the given name.
|
42
|
+
#
|
43
|
+
# @param name [#to_sym] name of the association whose reflection to retrieve.
|
44
|
+
# @return [nil] if no association with the given `name`.
|
45
|
+
# @return [Metasploit::Model::Association::Reflection] if association with the given `name`.
|
46
|
+
def reflect_on_association(name)
|
47
|
+
association_by_name[name.to_sym]
|
51
48
|
end
|
52
49
|
end
|
53
|
-
end
|
50
|
+
end
|
@@ -1,40 +1,36 @@
|
|
1
|
-
module Metasploit
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
# Attributes
|
8
|
-
#
|
1
|
+
module Metasploit::Model::Association
|
2
|
+
# Error raised by {Metasploit::Model::Association::ClassMethods#reflect_on_association!}.
|
3
|
+
class Error < Metasploit::Model::Error
|
4
|
+
#
|
5
|
+
# Attributes
|
6
|
+
#
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
# @!attribute [r] model
|
9
|
+
# ActiveModel on which the association with {#name} was not found.
|
10
|
+
#
|
11
|
+
# @return [Class]
|
12
|
+
attr_reader :model
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
# @!attribute [r] name
|
15
|
+
# Name of association that was not registered on {#model}.
|
16
|
+
#
|
17
|
+
# @return [Symbol]
|
18
|
+
attr_reader :name
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
#
|
21
|
+
# Methods
|
22
|
+
#
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
# @param attributes [Hash{Symbol => Object}]
|
25
|
+
# @option attributes [Class] :model ActiveModel that is missing association with :name.
|
26
|
+
# @option attributes [Symbol] :name name of the association that is missing.
|
27
|
+
# @raise [KeyError] if :model is not given
|
28
|
+
# @raise [KeyError] if :name is not given
|
29
|
+
def initialize(attributes={})
|
30
|
+
@model = attributes.fetch(:model)
|
31
|
+
@name = attributes.fetch(:name)
|
34
32
|
|
35
|
-
|
36
|
-
end
|
37
|
-
end
|
33
|
+
super("#{model} does not have #{name} association.")
|
38
34
|
end
|
39
35
|
end
|
40
|
-
end
|
36
|
+
end
|
@@ -1,130 +1,124 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
{association => nil}
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# @note Unlike `Hash#deep_merge`, `second_expanded`'s values aren't favored over `first`'s values. Instead whichever
|
33
|
-
# side is present is used and if both `first` and `second_expanded` are present, then their `Hash#key`s' values are
|
34
|
-
# recursively merged.
|
35
|
-
#
|
36
|
-
# Merges two expanded association trees.
|
37
|
-
#
|
38
|
-
# @param first_expanded [nil, Hash{Symbol => nil,Hash}] An expanded association tree as from {expand}
|
39
|
-
# @param second_expanded [nil, Hash{Symbol => nil,Hash}] An expanded association tree as from {expand}
|
40
|
-
# @return [nil, Hash{Symbol => nil,Hash}] a new expanded association tree.
|
41
|
-
def self.merge(first_expanded, second_expanded)
|
42
|
-
if first_expanded.nil? && second_expanded.nil?
|
43
|
-
nil
|
44
|
-
elsif !first_expanded.nil? && second_expanded.nil?
|
45
|
-
first_expanded
|
46
|
-
elsif first_expanded.nil? && !second_expanded.nil?
|
47
|
-
second_expanded
|
48
|
-
else
|
49
|
-
first_keys = first_expanded.keys
|
50
|
-
key_set = Set.new(first_keys)
|
51
|
-
|
52
|
-
second_keys = second_expanded.keys
|
53
|
-
key_set.merge(second_keys)
|
54
|
-
|
55
|
-
key_set.each_with_object({}) do |key, merged|
|
56
|
-
first_child = first_expanded[key]
|
57
|
-
second_child = second_expanded[key]
|
58
|
-
|
59
|
-
merged[key] = merge(first_child, second_child)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# Calculates association operators for the `expanded` association tree.
|
65
|
-
#
|
66
|
-
# @param expanded [Hash{Symbol => Hash,nil}, nil] An expanded association tree.
|
67
|
-
# @param options [Hash{Symbol => Class}]
|
68
|
-
# @option options [Class, #reflect_on_association] :class The `Class` on which the top-level key associations in
|
69
|
-
# `expanded` are declared.
|
70
|
-
# @return [Array<Metasploit::Model::Search::Operator::Association>]
|
71
|
-
def self.operators(expanded, options={})
|
72
|
-
expanded ||= {}
|
73
|
-
|
74
|
-
options.assert_valid_keys(:class)
|
75
|
-
klass = options.fetch(:class)
|
76
|
-
|
77
|
-
expanded.flat_map { |parent_association, child_tree|
|
78
|
-
reflection = reflect_on_association_on_class(parent_association, klass)
|
79
|
-
association_class = reflection.klass
|
80
|
-
|
81
|
-
association_search_with_operators = association_class.search_with_operator_by_name.each_value
|
82
|
-
|
83
|
-
child_tree_operators = operators(
|
84
|
-
child_tree,
|
85
|
-
class: reflection.klass
|
86
|
-
)
|
1
|
+
# Functions for turning a compact tree of compact as passed to
|
2
|
+
# {Metasploit::Model::Search::Association::ClassMethods#search_associations} into an expanded
|
3
|
+
# {Metasploit::Model::Search::Association::ClassMethods#search_association_tree}.
|
4
|
+
module Metasploit::Model::Association::Tree
|
5
|
+
# Expands a `compact` association into an expanded association tree.
|
6
|
+
#
|
7
|
+
# @param compact [Array, Hash{Symbol => Array,Hash,Symbol}, Symbol] a compact association as passed to
|
8
|
+
# {Metasploit::Model::Search::Association::ClassMethods#search_associations}.
|
9
|
+
# @return [Hash{Symbol => Hash,nil}]
|
10
|
+
def self.expand(compact)
|
11
|
+
case compact
|
12
|
+
when Array
|
13
|
+
compact.reduce({}) { |hash, association|
|
14
|
+
hash.merge(expand(association))
|
15
|
+
}
|
16
|
+
when Hash
|
17
|
+
child_by_parent = compact
|
18
|
+
|
19
|
+
child_by_parent.each_with_object({}) { |(parent, child), hash|
|
20
|
+
hash[parent] = expand(child)
|
21
|
+
}
|
22
|
+
when Symbol
|
23
|
+
association = compact
|
24
|
+
|
25
|
+
{association => nil}
|
26
|
+
end
|
27
|
+
end
|
87
28
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
29
|
+
# @note Unlike `Hash#deep_merge`, `second_expanded`'s values aren't favored over `first`'s values. Instead whichever
|
30
|
+
# side is present is used and if both `first` and `second_expanded` are present, then their `Hash#key`s' values are
|
31
|
+
# recursively merged.
|
32
|
+
#
|
33
|
+
# Merges two expanded association trees.
|
34
|
+
#
|
35
|
+
# @param first_expanded [nil, Hash{Symbol => nil,Hash}] An expanded association tree as from {expand}
|
36
|
+
# @param second_expanded [nil, Hash{Symbol => nil,Hash}] An expanded association tree as from {expand}
|
37
|
+
# @return [nil, Hash{Symbol => nil,Hash}] a new expanded association tree.
|
38
|
+
def self.merge(first_expanded, second_expanded)
|
39
|
+
if first_expanded.nil? && second_expanded.nil?
|
40
|
+
nil
|
41
|
+
elsif !first_expanded.nil? && second_expanded.nil?
|
42
|
+
first_expanded
|
43
|
+
elsif first_expanded.nil? && !second_expanded.nil?
|
44
|
+
second_expanded
|
45
|
+
else
|
46
|
+
first_keys = first_expanded.keys
|
47
|
+
key_set = Set.new(first_keys)
|
48
|
+
|
49
|
+
second_keys = second_expanded.keys
|
50
|
+
key_set.merge(second_keys)
|
51
|
+
|
52
|
+
key_set.each_with_object({}) do |key, merged|
|
53
|
+
first_child = first_expanded[key]
|
54
|
+
second_child = second_expanded[key]
|
55
|
+
|
56
|
+
merged[key] = merge(first_child, second_child)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
117
60
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
61
|
+
# Calculates association operators for the `expanded` association tree.
|
62
|
+
#
|
63
|
+
# @param expanded [Hash{Symbol => Hash,nil}, nil] An expanded association tree.
|
64
|
+
# @param options [Hash{Symbol => Class}]
|
65
|
+
# @option options [Class, #reflect_on_association] :class The `Class` on which the top-level key associations in
|
66
|
+
# `expanded` are declared.
|
67
|
+
# @return [Array<Metasploit::Model::Search::Operator::Association>]
|
68
|
+
def self.operators(expanded, options={})
|
69
|
+
expanded ||= {}
|
70
|
+
|
71
|
+
options.assert_valid_keys(:class)
|
72
|
+
klass = options.fetch(:class)
|
73
|
+
|
74
|
+
expanded.flat_map { |parent_association, child_tree|
|
75
|
+
reflection = reflect_on_association_on_class(parent_association, klass)
|
76
|
+
association_class = reflection.klass
|
77
|
+
|
78
|
+
association_search_with_operators = association_class.search_with_operator_by_name.each_value
|
79
|
+
|
80
|
+
child_tree_operators = operators(
|
81
|
+
child_tree,
|
82
|
+
class: reflection.klass
|
83
|
+
)
|
84
|
+
|
85
|
+
[association_search_with_operators, child_tree_operators].flat_map { |enumerator|
|
86
|
+
enumerator.map { |source_operator|
|
87
|
+
Metasploit::Model::Search::Operator::Association.new(
|
88
|
+
association: parent_association,
|
89
|
+
klass: klass,
|
90
|
+
source_operator: source_operator
|
91
|
+
)
|
92
|
+
}
|
93
|
+
}
|
94
|
+
}
|
95
|
+
end
|
124
96
|
|
125
|
-
|
126
|
-
|
127
|
-
|
97
|
+
private
|
98
|
+
|
99
|
+
# Return the association reflection for `association` on `klass`.
|
100
|
+
#
|
101
|
+
# @param association [Symbol] name of an association on `klass`.
|
102
|
+
# @param klass [#reflect_on_association] `Class` on which `association` is declared.
|
103
|
+
# @return [#klass] Association reflection that can give the `#klass` pointed to by the association.
|
104
|
+
# @raise [Metasploit::Model::Association::Error] if `association` is not declared on `klass`.
|
105
|
+
# @raise [NameError] if `klass` does not respond to `reflect_on_association`.
|
106
|
+
def self.reflect_on_association_on_class(association, klass)
|
107
|
+
begin
|
108
|
+
reflection = klass.reflect_on_association(association)
|
109
|
+
rescue NameError
|
110
|
+
raise NameError,
|
111
|
+
"#{self} does not respond to reflect_on_association. " \
|
112
|
+
"It can be added to ActiveModels by including Metasploit::Model::Association into the class."
|
128
113
|
end
|
114
|
+
|
115
|
+
unless reflection
|
116
|
+
raise Metasploit::Model::Association::Error.new(
|
117
|
+
model: klass,
|
118
|
+
name: association
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
reflection
|
129
123
|
end
|
130
|
-
end
|
124
|
+
end
|
@@ -1,60 +1,54 @@
|
|
1
|
-
|
1
|
+
# Code shared between `Mdm::Author` and `Metasploit::Framework::Author`.
|
2
|
+
module Metasploit::Model::Author
|
3
|
+
extend ActiveModel::Naming
|
4
|
+
extend ActiveSupport::Concern
|
2
5
|
|
3
|
-
|
4
|
-
module Model
|
5
|
-
# Code shared between `Mdm::Author` and `Metasploit::Framework::Author`.
|
6
|
-
module Author
|
7
|
-
extend ActiveModel::Naming
|
8
|
-
extend ActiveSupport::Concern
|
6
|
+
include Metasploit::Model::Translation
|
9
7
|
|
10
|
-
|
8
|
+
included do
|
9
|
+
include ActiveModel::MassAssignmentSecurity
|
10
|
+
include ActiveModel::Validations
|
11
|
+
include Metasploit::Model::Search
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
include Metasploit::Model::Search
|
13
|
+
#
|
14
|
+
# Mass Assignment Security
|
15
|
+
#
|
16
16
|
|
17
|
-
|
18
|
-
# Mass Assignment Security
|
19
|
-
#
|
17
|
+
attr_accessible :name
|
20
18
|
|
21
|
-
|
19
|
+
#
|
20
|
+
# Search Attributes
|
21
|
+
#
|
22
22
|
|
23
|
-
|
24
|
-
# Search Attributes
|
25
|
-
#
|
23
|
+
search_attribute :name, :type => :string
|
26
24
|
|
27
|
-
|
25
|
+
#
|
26
|
+
# Validations
|
27
|
+
#
|
28
28
|
|
29
|
-
|
30
|
-
# Validations
|
31
|
-
#
|
32
|
-
|
33
|
-
validates :name, :presence => true
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
# Associations
|
38
|
-
#
|
39
|
-
|
40
|
-
# @!attribute [r] email_addresses
|
41
|
-
# Email addresses used by this author across all {#module_instances}.
|
42
|
-
#
|
43
|
-
# @return [Array<Metasploit::Model::EmailAddress>]
|
44
|
-
|
45
|
-
# @!attribute [r] module_instances
|
46
|
-
# Modules written by this author.
|
47
|
-
#
|
48
|
-
# @return [Array<Metasploit::Model::Module::Instance>]
|
49
|
-
|
50
|
-
#
|
51
|
-
# Attributes
|
52
|
-
#
|
53
|
-
|
54
|
-
# @!attribute [rw] name
|
55
|
-
# Full name (First + Last name) or handle of author.
|
56
|
-
#
|
57
|
-
# @return [String]
|
58
|
-
end
|
29
|
+
validates :name, :presence => true
|
59
30
|
end
|
60
|
-
|
31
|
+
|
32
|
+
#
|
33
|
+
# Associations
|
34
|
+
#
|
35
|
+
|
36
|
+
# @!attribute [r] email_addresses
|
37
|
+
# Email addresses used by this author across all {#module_instances}.
|
38
|
+
#
|
39
|
+
# @return [Array<Metasploit::Model::EmailAddress>]
|
40
|
+
|
41
|
+
# @!attribute [r] module_instances
|
42
|
+
# Modules written by this author.
|
43
|
+
#
|
44
|
+
# @return [Array<Metasploit::Model::Module::Instance>]
|
45
|
+
|
46
|
+
#
|
47
|
+
# Attributes
|
48
|
+
#
|
49
|
+
|
50
|
+
# @!attribute [rw] name
|
51
|
+
# Full name (First + Last name) or handle of author.
|
52
|
+
#
|
53
|
+
# @return [String]
|
54
|
+
end
|