Class: Hachi::Models::Artifact
- Defined in:
- lib/hachi/models/artifact.rb
Constant Summary collapse
- DATA_TYPES =
%w(filename file fqdn hash uri_path ip domain mail autonomous-system registry mail_subject regexp user-agent other url).freeze
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#data_type ⇒ Object
readonly
Returns the value of attribute data_type.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#tlp ⇒ Object
readonly
Returns the value of attribute tlp.
Instance Method Summary collapse
-
#initialize(data:, data_type:, message: nil, tlp: nil, tags: nil) ⇒ Artifact
constructor
A new instance of Artifact.
- #payload ⇒ Object
- #validate_for_creation ⇒ Object
Constructor Details
#initialize(data:, data_type:, message: nil, tlp: nil, tags: nil) ⇒ Artifact
Returns a new instance of Artifact.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hachi/models/artifact.rb', line 10 def initialize(data:, data_type:, message: nil, tlp: nil, tags: nil) @data = data @data_type = data_type @message = @tlp = tlp @tags = raise(ArgumentError, "data is required") unless data raise(ArgumentError, "data_type is required") unless data_type raise(ArgumentError, "invalid data type") unless DATA_TYPES.include?(data_type) if validate_tlp if tlp end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/hachi/models/artifact.rb', line 8 def data @data end |
#data_type ⇒ Object (readonly)
Returns the value of attribute data_type.
8 9 10 |
# File 'lib/hachi/models/artifact.rb', line 8 def data_type @data_type end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
8 9 10 |
# File 'lib/hachi/models/artifact.rb', line 8 def @message end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
8 9 10 |
# File 'lib/hachi/models/artifact.rb', line 8 def @tags end |
#tlp ⇒ Object (readonly)
Returns the value of attribute tlp.
8 9 10 |
# File 'lib/hachi/models/artifact.rb', line 8 def tlp @tlp end |
Instance Method Details
#payload ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/hachi/models/artifact.rb', line 25 def payload { data: data, dataType: data_type, message: , tlp: tlp, tags: }.compact end |
#validate_for_creation ⇒ Object
35 36 37 |
# File 'lib/hachi/models/artifact.rb', line 35 def validate_for_creation raise(ArgumentError, "message or tags is requried for artifact creation") unless || end |