Merge pull request #2443 from jakemcdermott/fix-2397

sanitize host detail modal stderr/stdout
This commit is contained in:
Jake McDermott 2018-07-10 11:44:11 -04:00 committed by GitHub
commit 630cdce244
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 6 deletions

View File

@ -170,10 +170,13 @@
}
.HostEvent-stdoutColumn{
white-space: pre;
overflow-y: scroll;
overflow-y: hidden;
overflow-x: auto;
margin-left: 46px;
padding-top: 4px;
white-space: pre-wrap;
word-break: break-all;
word-wrap: break-word;
}
.HostEvent-noJson{

View File

@ -1,6 +1,7 @@
function HostEventsController (
$scope,
$state,
$filter,
HostEventService,
hostEvent,
OutputStrings
@ -11,6 +12,9 @@ function HostEventsController (
$scope.getActiveHostIndex = getActiveHostIndex;
$scope.closeHostEvent = closeHostEvent;
$scope.strings = OutputStrings;
const sanitize = $filter('sanitize');
function init () {
hostEvent.event_name = hostEvent.event;
$scope.event = _.cloneDeep(hostEvent);
@ -31,7 +35,7 @@ function HostEventsController (
if (hostEvent.event_data.res.stdout === '') {
$scope.stdout = ' ';
} else {
$scope.stdout = hostEvent.event_data.res.stdout;
$scope.stdout = sanitize(hostEvent.event_data.res.stdout);
}
}
@ -39,7 +43,7 @@ function HostEventsController (
if (hostEvent.event_data.res.stderr === '') {
$scope.stderr = ' ';
} else {
$scope.stderr = hostEvent.event_data.res.stderr;
$scope.stderr = sanitize(hostEvent.event_data.res.stderr);
}
}
@ -49,13 +53,13 @@ function HostEventsController (
if ($scope.module_name === 'debug' &&
_.has(hostEvent.event_data, 'res.result.stdout')) {
$scope.stdout = hostEvent.event_data.res.result.stdout;
$scope.stdout = sanitize(hostEvent.event_data.res.result.stdout);
}
if ($scope.module_name === 'yum' &&
_.has(hostEvent.event_data, 'res.results') &&
_.isArray(hostEvent.event_data.res.results)) {
const event = hostEvent.event_data.res.results;
$scope.stdout = event[0];// eslint-disable-line prefer-destructuring
$scope.stdout = sanitize(event[0]);// eslint-disable-line prefer-destructuring
}
// instantiate Codemirror
if ($state.current.name === 'output.host-event.json') {
@ -164,6 +168,7 @@ function HostEventsController (
HostEventsController.$inject = [
'$scope',
'$state',
'$filter',
'HostEventService',
'hostEvent',
'OutputStrings'