-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
first and only commit for new nmap xml feature
- Loading branch information
Showing
49 changed files
with
647 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
class NmapfilesController < ApplicationController | ||
before_action :set_nmapfile, only: [:show, :update, :destroy] | ||
|
||
# GET /nmapfiles | ||
# GET /nmapfiles.json | ||
def index | ||
@jumpsquares = Jumpsquare.all | ||
@jumpsizes = Jumpsize.all | ||
#@nmapfiles = Nmapfile.all | ||
@nmapfiles = Nmapfile.search(params[:search]).paginate(:page => params[:page], :per_page => @jumpsizes.first.itemsperpage).find(:all, :order => sort_order('lower(nmapfilename)')) | ||
end | ||
|
||
# GET /nmapfiles/1 | ||
# GET /nmapfiles/1.json | ||
def show | ||
end | ||
|
||
# GET /nmapfiles/new | ||
def new | ||
@nmapfile = Nmapfile.new | ||
end | ||
|
||
# GET /nmapfiles/1/edit | ||
def edit | ||
end | ||
|
||
# POST /nmapfiles | ||
# POST /nmapfiles.json | ||
def create | ||
@nmapfile = Nmapfile.new(nmapfile_params) | ||
|
||
respond_to do |format| | ||
if @nmapfile.save | ||
format.html { redirect_to @nmapfile, notice: 'nmap file was successfully created.' } | ||
format.json { render action: 'show', status: :created, location: @nmapfile } | ||
else | ||
format.html { render action: 'new' } | ||
format.json { render json: @nmapfile.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /nmapfiles/1 | ||
# PATCH/PUT /nmapfiles/1.json | ||
def update | ||
respond_to do |format| | ||
if @nmapfile.update(nmapfile_params) | ||
format.html { redirect_to @nmapfile, notice: 'Nmapfile was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render action: 'edit' } | ||
format.json { render json: @nmapfile.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /nmapfiles/1 | ||
# DELETE /nmapfiles/1.json | ||
def destroy | ||
@nmapfile.remove_nmapxml! | ||
FileUtils.remove_dir("#{Rails.root}/public/uploads/nmapfile/nmapxml/#{@nmapfile.id}", :force => true) | ||
@nmapfile.destroy | ||
respond_to do |format| | ||
format.html { redirect_to nmapfiles_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
def xmlviewer | ||
@jumpsquares = Jumpsquare.all | ||
@nmapfile = Nmapfile.find(params[:nmapfile_id]) | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_nmapfile | ||
@nmapfile = Nmapfile.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def nmapfile_params | ||
params.require(:nmapfile).permit(:nmapfilename, :nmapfilerecords, :nmapfilematches, :nmapxml) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module NmapfilesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class Nmapfile < ActiveRecord::Base | ||
mount_uploader :nmapxml, NmapxmlUploader | ||
validates_presence_of :nmapfilename, :nmapxml | ||
|
||
def self.search(search) | ||
if search | ||
where('nmapfilename ILIKE ?', "%#{search}%") | ||
else | ||
scoped | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# encoding: utf-8 | ||
require 'carrierwave/processing/mime_types' | ||
class NmapxmlUploader < CarrierWave::Uploader::Base | ||
|
||
# Include RMagick or MiniMagick support: | ||
# include CarrierWave::RMagick | ||
# include CarrierWave::MiniMagick | ||
include CarrierWave::MimeTypes | ||
|
||
# Choose what kind of storage to use for this uploader: | ||
storage :file | ||
# storage :fog | ||
|
||
# Override the directory where uploaded files will be stored. | ||
# This is a sensible default for uploaders that are meant to be mounted: | ||
def store_dir | ||
# must use ID for delete to work correctly | ||
# "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.nmapfilename + "." + rand(1...10000).to_s}" | ||
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" | ||
end | ||
|
||
# Provide a default URL as a default if there hasn't been a file uploaded: | ||
# def default_url | ||
# # For Rails 3.1+ asset pipeline compatibility: | ||
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_')) | ||
# | ||
# "/images/fallback/" + [version_name, "default.png"].compact.join('_') | ||
# end | ||
|
||
# Process files as they are uploaded: | ||
# process :scale => [200, 300] | ||
# | ||
# def scale(width, height) | ||
# # do something | ||
# end | ||
|
||
# Create different versions of your uploaded files: | ||
# version :thumb do | ||
# process :scale => [50, 50] | ||
# end | ||
|
||
# Add a white list of extensions which are allowed to be uploaded. | ||
# For images you might use something like this: | ||
def extension_white_list | ||
%w(xml) | ||
end | ||
|
||
|
||
version :preprocessed do | ||
#process :preprocess | ||
process :set_content_type | ||
def full_filename(for_file) | ||
super.chomp(File.extname(super)) + '.xml' | ||
end | ||
|
||
def set_content_type(*args) | ||
self.file.instance_variable_set(:@content_type, "application/xml") | ||
end | ||
end | ||
# Override the filename of the uploaded files: | ||
# Avoid using model.id or version_name here, see uploader/store.rb for details. | ||
# def filename | ||
# "scan.xml" if original_filename | ||
# end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!DOCTYPE html> | ||
<div class="row"> | ||
<div class="col-lg-6 col-lg-offset-3"> | ||
<div class="well"> | ||
<%= form_for @nmapfile, html: { multipart: true, :class => "form-horizontal" } do |f| %> | ||
<% if @nmapfile.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@nmapfile.errors.count, "error") %> prohibited this Application Type from being saved:</h2> | ||
|
||
<ul> | ||
<% @nmapfile.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<fieldset> | ||
<legend>Nmap XML</legend> | ||
<div class="form-group"> | ||
<%= f.label "Descriptive Name:", :class => "col-lg-3 control-label" %> | ||
<div class="col-lg-7"> | ||
<%= f.text_field :nmapfilename, :class => "form-control" %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-group"> | ||
<%= f.label "Upload Nmap XML File:", :class => "col-lg-3 control-label" %> | ||
<div class="col-lg-7"> | ||
<%= f.file_field :nmapxml %> | ||
</div> | ||
</div> | ||
|
||
<br> | ||
<center> | ||
<div class="form-group"> | ||
<%= f.submit class: 'btn btn-primary' %> | ||
</div> | ||
<%= link_to 'Back', nmapfiles_path %> | | ||
<%= link_to 'View Nmap Scans', nmapfiles_path %> | | ||
<%= link_to 'Home', :userroot %> | ||
</center> | ||
</fieldset> | ||
|
||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<% provide(:title, 'Editing Nmap XML') %> | ||
|
||
|
||
<%= render 'form' %> |
Oops, something went wrong.