Fix bug with host list import not working correctly.

This commit is contained in:
Ryan Prather 2018-10-25 11:32:48 -04:00
parent e995c0e78e
commit d43775b26f
3 changed files with 43 additions and 23 deletions

View File

@ -242,6 +242,9 @@ function FileDetection($filename)
if (preg_match('/Checklist:|Unclassified|Secret|STIG[_| ]ID/i', $line)) { if (preg_match('/Checklist:|Unclassified|Secret|STIG[_| ]ID/i', $line)) {
$name['type'] = ECHECKLIST_CSV; $name['type'] = ECHECKLIST_CSV;
} }
elseif (preg_match("/host\-list/", $name['base_name'])) {
$name['type'] = HOST_LIST;
}
elseif (preg_match('/^\"NetBIOSName|^\"JobName/', $line)) { elseif (preg_match('/^\"NetBIOSName|^\"JobName/', $line)) {
$name['type'] = UNSUPPORTED_RETINA_CSV; $name['type'] = UNSUPPORTED_RETINA_CSV;
} }

View File

@ -326,6 +326,10 @@ include_once 'header.inc';
#loading { #loading {
display: none; display: none;
} }
.dz-image img {
width: 100%;
height: 100%;
}
</style> </style>
<div id='wrapper'> <div id='wrapper'>
@ -559,39 +563,49 @@ include_once 'header.inc';
<link type="text/css" href="/script/dropzone/basic.min.css" rel="stylesheet" /> <link type="text/css" href="/script/dropzone/basic.min.css" rel="stylesheet" />
<script type="text/javascript"> <script type="text/javascript">
Dropzone.options.dropzone = { Dropzone.options.dropzone = {
maxFilesize: 10, maxFilesize: 10,
success: function (file, res) { maxFiles: 1,
}, success: function (file, res) {
error: function (xhr, status, error) { res = JSON.parse(res);
console.error(xhr); if (res.imageUrl) {
console.error(error); this.emit('thumbnail', file, res.imageUrl);
}, }
acceptedFiles: ".csv" },
}; error: function (xhr, status, error) {
Dropzone.prototype.submitRequest = function (xhr, formData, files) { if(!xhr.accepted) {
$('#host-list-file').val(files[0].name); alert("That file type is not allowed, CSV only files");
var dt = new Date(files[0].lastModifiedDate); }
xhr.setRequestHeader('X-FILENAME', files[0].name); },
xhr.setRequestHeader('X-FILEMTIME', dt.toISOString()); init: function() {
return xhr.send(formData); this.hiddenFileInput.removeAttribute('multiple');
}; },
Dropzone.autoDiscover = false; acceptedFiles: ".csv"
};
Dropzone.prototype.submitRequest = function (xhr, formData, files) {
$('#host-list-file').val(files[0].name);
var dt = new Date(files[0].lastModifiedDate);
xhr.setRequestHeader('X-FILENAME', files[0].name);
xhr.setRequestHeader('X-FILEMTIME', dt.toISOString());
return xhr.send(formData);
};
Dropzone.autoDiscover = false;
$(function () { $(function () {
var mydz = new Dropzone('#dropzone'); var mydz = new Dropzone('#dropzone');
}); });
</script> </script>
<form class="dropzone" action="/upload.php" id="dropzone"> <form class="dropzone" action="/upload.php" id="dropzone">
<div class="dz-message" data-dz-message><span>Click or Drop files here to upload</span></div>
<div class="fallback"> <div class="fallback">
<input type="file" name="file" multiple /> <input type="file" name="file" multiple />
</div> </div>
</form> </form>
<form method='post' action='#' style='margin-left: 20px;' <form method='post' action='#' style='margin-left: 20px;'
onsubmit="$('#submit').attr('disabled', true); onsubmit="$('#submit').attr('disabled', true);return true;" id='host-list-form'>
return true;"> <div style='font-weight:400;color:red;'>Must keep 'host-list' as part of the filename</div>
<input type='hidden' name='file' id='host-list-file' style='display:none;' /> <input type='hidden' name='file' id='host-list-file' style='display:none;' />
<input type='hidden' name='action' value='import_host_list' /> <input type='hidden' name='action' value='import_host_list' />
<input type='hidden' name='ste' value='<?php print ($ste_id ? $ste_id : ''); ?>' /> <input type='hidden' name='ste' value='<?php print ($ste_id ? $ste_id : ''); ?>' />

View File

@ -58,6 +58,9 @@ if ($fn) {
case TECH_ECHECKLIST_EXCEL: case TECH_ECHECKLIST_EXCEL:
print header(JSON) . json_encode(['imageUrl' => '/img/scan_types/echecklist.png']); print header(JSON) . json_encode(['imageUrl' => '/img/scan_types/echecklist.png']);
break; break;
case HOST_LIST:
print header(JSON) . json_encode(['imageUrl' => '/img/file.png']);
break;
default: default:
print header(JSON) . json_encode(['imageUrl' => null]); print header(JSON) . json_encode(['imageUrl' => null]);
unlink(TMP . "/" . basename($fn)); unlink(TMP . "/" . basename($fn));