Class: ActiveStix::IdentitiesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ActiveStix::IdentitiesController
- Defined in:
- app/controllers/active_stix/identities_controller.rb
Instance Method Summary collapse
- #attribution ⇒ Object
- #corpus ⇒ Object
-
#create ⇒ Object
POST /stix/identities POST /stix/identities.json.
-
#destroy ⇒ Object
DELETE /stix/identities/1 DELETE /stix/identities/1.json.
-
#edit ⇒ Object
GET /stix/identities/1/edit.
- #employment ⇒ Object
-
#index ⇒ Object
GET /stix/identities GET /stix/identities.json.
-
#new ⇒ Object
GET /stix/identities/new.
-
#show ⇒ Object
GET /stix/identities/1 GET /stix/identities/1.json.
-
#update ⇒ Object
PATCH/PUT /stix/identities/1 PATCH/PUT /stix/identities/1.json.
Instance Method Details
#attribution ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'app/controllers/active_stix/identities_controller.rb', line 99 def attribution organization = ActiveStix::Identity.find(params[:identity_id]) threat_actor = ActiveStix::ThreatActor.find(params[:threat_actor_id]) ActiveStix::Relationship.relate(threat_actor, organization, "attributed-to") respond_to do |format| format.html {redirect_to organization, notice: 'Identity was successfully updated.'} format.json {render :show, status: :ok, location: organization} end end |
#corpus ⇒ Object
111 112 113 114 |
# File 'app/controllers/active_stix/identities_controller.rb', line 111 def corpus #download all the email attachments in an evaluation send_data(File.read(@identity.corpus(params[:mailbox])), :type => 'application/zip', :disposition => "attachment") end |
#create ⇒ Object
POST /stix/identities POST /stix/identities.json
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/controllers/active_stix/identities_controller.rb', line 43 def create @identity = ActiveStix::Identity.new(stix_identity_params) @identity.identity_class = "organization" respond_to do |format| if @identity.save Ldap.stix_ingest(@identity, params[:identity][:uploaded_file].path) format.html {redirect_to @identity, notice: 'Identity was successfully created.'} format.json {render :show, status: :created, location: @identity} else format.html {render :new} format.json {render json: @identity.errors, status: :unprocessable_entity} end end end |
#destroy ⇒ Object
DELETE /stix/identities/1 DELETE /stix/identities/1.json
75 76 77 78 79 80 81 |
# File 'app/controllers/active_stix/identities_controller.rb', line 75 def destroy @identity.destroy respond_to do |format| format.html {redirect_to stix_identities_url, notice: 'Identity was successfully destroyed.'} format.json {head :no_content} end end |
#edit ⇒ Object
GET /stix/identities/1/edit
38 39 |
# File 'app/controllers/active_stix/identities_controller.rb', line 38 def edit end |
#employment ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/controllers/active_stix/identities_controller.rb', line 83 def employment organization = ActiveStix::Identity.find(params[:organization_id]) @identity = ActiveStix::Identity.find(params[:identity_id]) respond_to do |format| if ActiveStix::Identity.employ(@identity, organization) format.html {redirect_to @identity, notice: 'Identity was successfully updated.'} format.json {render :show, status: :ok, location: @identity} else format.html {render @identity, notice: 'Could not create employment.'} format.json {render json: @identity.errors, status: :unprocessable_entity} end end end |
#index ⇒ Object
GET /stix/identities GET /stix/identities.json
6 7 8 |
# File 'app/controllers/active_stix/identities_controller.rb', line 6 def index @identities = ActiveStix::Identity.where("name like ?", "%#{params[:search]}%").order("name").page params[:page] end |
#new ⇒ Object
GET /stix/identities/new
33 34 35 |
# File 'app/controllers/active_stix/identities_controller.rb', line 33 def new @identity = ActiveStix::Identity.new end |
#show ⇒ Object
GET /stix/identities/1 GET /stix/identities/1.json
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/active_stix/identities_controller.rb', line 12 def show if @identity.identity_class == 'organization' @employment_records = @identity.source_relationships.where(relationship_type: "employs").page(params[:page]) @threat_groups = @identity.threat_groups @attack_patterns = @identity.attack_patterns else case params[:mailbox] when 'sent' @mailbox = "Sent" = @identity..includes(:eml).order("created_at DESC").page(params[:page]) when 'received' @mailbox = "Received" = @identity.to_refs.order("created_at DESC").page(params[:page]) else @mailbox = "Sent" = @identity..includes(:eml).order("created_at DESC").page(params[:page]) end end end |
#update ⇒ Object
PATCH/PUT /stix/identities/1 PATCH/PUT /stix/identities/1.json
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/active_stix/identities_controller.rb', line 61 def update respond_to do |format| if @identity.update(stix_identity_params) format.html {redirect_to @identity, notice: 'Identity was successfully updated.'} format.json {render :show, status: :ok, location: @identity} else format.html {render :edit} format.json {render json: @identity.errors, status: :unprocessable_entity} end end end |