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)) {
$name['type'] = ECHECKLIST_CSV;
}
elseif (preg_match("/host\-list/", $name['base_name'])) {
$name['type'] = HOST_LIST;
}
elseif (preg_match('/^\"NetBIOSName|^\"JobName/', $line)) {
$name['type'] = UNSUPPORTED_RETINA_CSV;
}

View File

@ -326,6 +326,10 @@ include_once 'header.inc';
#loading {
display: none;
}
.dz-image img {
width: 100%;
height: 100%;
}
</style>
<div id='wrapper'>
@ -559,39 +563,49 @@ include_once 'header.inc';
<link type="text/css" href="/script/dropzone/basic.min.css" rel="stylesheet" />
<script type="text/javascript">
Dropzone.options.dropzone = {
maxFilesize: 10,
success: function (file, res) {
},
error: function (xhr, status, error) {
console.error(xhr);
console.error(error);
},
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;
Dropzone.options.dropzone = {
maxFilesize: 10,
maxFiles: 1,
success: function (file, res) {
res = JSON.parse(res);
if (res.imageUrl) {
this.emit('thumbnail', file, res.imageUrl);
}
},
error: function (xhr, status, error) {
if(!xhr.accepted) {
alert("That file type is not allowed, CSV only files");
}
},
init: function() {
this.hiddenFileInput.removeAttribute('multiple');
},
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 () {
var mydz = new Dropzone('#dropzone');
});
$(function () {
var mydz = new Dropzone('#dropzone');
});
</script>
<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">
<input type="file" name="file" multiple />
</div>
</form>
<form method='post' action='#' style='margin-left: 20px;'
onsubmit="$('#submit').attr('disabled', true);
return true;">
onsubmit="$('#submit').attr('disabled', true);return true;" id='host-list-form'>
<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='action' value='import_host_list' />
<input type='hidden' name='ste' value='<?php print ($ste_id ? $ste_id : ''); ?>' />

View File

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