Class: ActiveStix::IntrusionSet
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ActiveStix::IntrusionSet
- Defined in:
- app/models/active_stix/intrusion_set.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.ingest_json(obj) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/active_stix/intrusion_set.rb', line 21 def self.ingest_json(obj) intrusion_set = find_or_create_by(stix_id: obj['id'], name: obj['name']) if obj.has_key?('description') intrusion_set.description = obj['description'] end if obj.has_key?('external_references') obj['external_references'].each do |er| external_reference = ActiveStix::ExternalReference.ingest_json(er, obj['id']) intrusion_set.external_references << external_reference unless ActiveStix::ReferenceItem.find_by(external_reference: external_reference, referrer: intrusion_set) end end if obj.has_key?('object_marking_refs') # obj['object_marking_refs'].each do |mr| # marking_definition = ActiveStix::MarkingDefinition.create_by_id(mr) # intrusion_set.marking_definitions << marking_definition unless ActiveStix::ReferenceObjectMarkingIntrusionSet.find_by(stix_marking_definition_id: marking_definition.id, stix_intrusion_set_id: intrusion_set.id) # end todo end if obj.has_key?('aliases') intrusion_set.aliases = obj['aliases'] end intrusion_set.save intrusion_set end |
Instance Method Details
#as_stix(classification = nil, chess = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'app/models/active_stix/intrusion_set.rb', line 49 def as_stix(classification = nil, chess = nil) as_json(only: [:name]).tap do |hash| hash["type"] = type hash["description"] = description if description hash["created"] = created_at.utc.iso8601(3) hash["modified"] = updated_at.utc.iso8601(3) hash["id"] = stix_id hash["spec_version"] = "2.0" end end |
#convert_to_json ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'app/models/active_stix/intrusion_set.rb', line 60 def convert_to_json { :type => "intrusion-set", :name => name, :id => stix_id, :created => created_at.to_s, :modified => updated_at.to_s } end |
#type ⇒ Object
16 17 18 |
# File 'app/models/active_stix/intrusion_set.rb', line 16 def type 'intrusion-set' end |