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'>
@ -561,11 +565,20 @@ include_once 'header.inc';
<script type="text/javascript"> <script type="text/javascript">
Dropzone.options.dropzone = { Dropzone.options.dropzone = {
maxFilesize: 10, maxFilesize: 10,
maxFiles: 1,
success: function (file, res) { success: function (file, res) {
res = JSON.parse(res);
if (res.imageUrl) {
this.emit('thumbnail', file, res.imageUrl);
}
}, },
error: function (xhr, status, error) { error: function (xhr, status, error) {
console.error(xhr); if(!xhr.accepted) {
console.error(error); alert("That file type is not allowed, CSV only files");
}
},
init: function() {
this.hiddenFileInput.removeAttribute('multiple');
}, },
acceptedFiles: ".csv" acceptedFiles: ".csv"
}; };
@ -584,14 +597,15 @@ include_once 'header.inc';
</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));