ronin-rb / ronin-app

A local web interface for Ronin.
https://ronin-rb.dev
GNU Affero General Public License v3.0
6 stars 6 forks source link

Add a "Add Note" form to all `/db/` `show.erb` views #43

Closed postmodern closed 8 months ago

postmodern commented 11 months ago

Add a "Add Note" text area and form to all /db/``show.erb views to allow adding a new comment to the notes association of the record. This may also require adding a _add_note.erb partial template.

AI-Mozi commented 8 months ago

Is there already a route for adding notes?

AI-Mozi commented 8 months ago

Ok, its not implemented yet. Is there a reason why Note doesn't belongs_to all /db models ?

postmodern commented 8 months ago

@AI-Mozi Note is supposed to belongs_to any non-join-models that the user would interact with, such as IPAddress, HostName, Service, URL, maybe even OpenPort. I am in the process of adding more new models in the osint branch of ronin-db-activerecord, and will have to rebase the branch and update Note to have more has_many associations to the new models.

postmodern commented 8 months ago

It occurred to me you could DRY up the /db/.../notes routes by dynamically defining them:

{ip_address: Ronin::DB::IPAddress, ...}.each do |name,model|
  post "/db/#{name}/:id/notes" do
    @record = model.find(params[:id])

    if @record
      ...
    else
      ...
    end
  end

  delete "/db/#{name}/:id/notes/:note_id" do
    @record = model.find(params[:id])

    if @record
      if @record.notes.destroy(params[:note_id])
        ...
       else
        ...
      end
    end
  end
end
postmodern commented 8 months ago

Implemented by PR #59.