mirror of
https://github.com/ansible/awx.git
synced 2026-03-07 19:51:08 -03:30
adding sanitizer filter for app
I'm adding a sanitize filter to be used whenever we want to escape tags that are generated from user input. In addition, I created a filters folder and a filter file that imports filters into the app
This commit is contained in:
@@ -22,6 +22,7 @@ import 'tower/forms';
|
|||||||
import 'tower/lists';
|
import 'tower/lists';
|
||||||
import 'tower/widgets';
|
import 'tower/widgets';
|
||||||
import 'tower/help';
|
import 'tower/help';
|
||||||
|
import 'tower/filters';
|
||||||
import {Home, HomeGroups, HomeHosts} from 'tower/controllers/Home';
|
import {Home, HomeGroups, HomeHosts} from 'tower/controllers/Home';
|
||||||
import {SocketsController} from 'tower/controllers/Sockets';
|
import {SocketsController} from 'tower/controllers/Sockets';
|
||||||
import {Authenticate} from 'tower/controllers/Authentication';
|
import {Authenticate} from 'tower/controllers/Authentication';
|
||||||
|
|||||||
5
awx/ui/static/js/filters.js
Normal file
5
awx/ui/static/js/filters.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import sanitizeFilters from 'tower/filters/sanitize/xss-sanitizer.filter';
|
||||||
|
|
||||||
|
export {
|
||||||
|
sanitizeFilters
|
||||||
|
};
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
angular.module('sanitizeFilter', []).filter('sanitize', function() {
|
||||||
|
return function(input) {
|
||||||
|
input = input.replace(/</g, "<").replace(/>/g, ">");
|
||||||
|
return input;
|
||||||
|
};
|
||||||
|
});
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('CompletedJobsDefinition', [])
|
angular.module('CompletedJobsDefinition', ['sanitizeFilter'])
|
||||||
.value( 'CompletedJobsList', {
|
.value( 'CompletedJobsList', {
|
||||||
|
|
||||||
name: 'completed_jobs',
|
name: 'completed_jobs',
|
||||||
@@ -70,7 +70,9 @@ export default
|
|||||||
label: 'Name',
|
label: 'Name',
|
||||||
columnClass: 'col-md-3 col-sm-4 col-xs-4',
|
columnClass: 'col-md-3 col-sm-4 col-xs-4',
|
||||||
ngClick: "viewJobLog(completed_job.id, completed_job.nameHref)",
|
ngClick: "viewJobLog(completed_job.id, completed_job.nameHref)",
|
||||||
defaultSearchField: true
|
defaultSearchField: true,
|
||||||
|
awToolTip: "{{ completed_job.name | sanitize }}",
|
||||||
|
dataPlacement: 'top'
|
||||||
},
|
},
|
||||||
failed: {
|
failed: {
|
||||||
label: 'Job failed?',
|
label: 'Job failed?',
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('QueuedJobsDefinition', [])
|
angular.module('QueuedJobsDefinition', ['sanitizeFilter'])
|
||||||
.value( 'QueuedJobsList', {
|
.value( 'QueuedJobsList', {
|
||||||
|
|
||||||
name: 'queued_jobs',
|
name: 'queued_jobs',
|
||||||
@@ -62,7 +62,9 @@ export default
|
|||||||
label: 'Name',
|
label: 'Name',
|
||||||
columnClass: 'col-md-3 col-sm-4 col-xs-4',
|
columnClass: 'col-md-3 col-sm-4 col-xs-4',
|
||||||
ngClick: "viewJobLog(queued_job.id, queued_job.nameHref)",
|
ngClick: "viewJobLog(queued_job.id, queued_job.nameHref)",
|
||||||
defaultSearchField: true
|
defaultSearchField: true,
|
||||||
|
awToolTip: "{{ queued_job.name | sanitize }}",
|
||||||
|
awTipPlacement: "top"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('RunningJobsDefinition', [])
|
angular.module('RunningJobsDefinition', ['sanitizeFilter'])
|
||||||
.value( 'RunningJobsList', {
|
.value( 'RunningJobsList', {
|
||||||
|
|
||||||
name: 'running_jobs',
|
name: 'running_jobs',
|
||||||
@@ -63,7 +63,9 @@ export default
|
|||||||
label: 'Name',
|
label: 'Name',
|
||||||
columnClass: 'col-md-3 col-sm-4 col-xs-4',
|
columnClass: 'col-md-3 col-sm-4 col-xs-4',
|
||||||
ngClick: "viewJobLog(running_job.id, running_job.nameHref)",
|
ngClick: "viewJobLog(running_job.id, running_job.nameHref)",
|
||||||
defaultSearchField: true
|
defaultSearchField: true,
|
||||||
|
awToolTip: "{{ running_job.name | sanitize }}",
|
||||||
|
awTipPlacement: "top"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('ScheduledJobsDefinition', [])
|
angular.module('ScheduledJobsDefinition', ['sanitizeFilter'])
|
||||||
.value( 'ScheduledJobsList', {
|
.value( 'ScheduledJobsList', {
|
||||||
|
|
||||||
name: 'schedules',
|
name: 'schedules',
|
||||||
@@ -62,7 +62,7 @@ export default
|
|||||||
sourceModel: 'unified_job_template',
|
sourceModel: 'unified_job_template',
|
||||||
sourceField: 'name',
|
sourceField: 'name',
|
||||||
ngClick: "editSchedule(schedule.id)",
|
ngClick: "editSchedule(schedule.id)",
|
||||||
awToolTip: "{{ schedule.nameTip }}",
|
awToolTip: "{{ schedule.nameTip | sanitize}}",
|
||||||
dataPlacement: "top",
|
dataPlacement: "top",
|
||||||
defaultSearchField: true
|
defaultSearchField: true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -402,7 +402,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
* Include the standard TB data-XXX attributes to controll a tooltip's appearance. We will
|
* Include the standard TB data-XXX attributes to controll a tooltip's appearance. We will
|
||||||
* default placement to the left and delay to the config setting.
|
* default placement to the left and delay to the config setting.
|
||||||
*/
|
*/
|
||||||
.directive('awToolTip', ['$sce', function($sce) {
|
.directive('awToolTip', [ function() {
|
||||||
return {
|
return {
|
||||||
link: function(scope, element, attrs) {
|
link: function(scope, element, attrs) {
|
||||||
var delay = (attrs.delay !== undefined && attrs.delay !== null) ? attrs.delay : ($AnsibleConfig) ? $AnsibleConfig.tooltip_delay : {show: 500, hide: 100},
|
var delay = (attrs.delay !== undefined && attrs.delay !== null) ? attrs.delay : ($AnsibleConfig) ? $AnsibleConfig.tooltip_delay : {show: 500, hide: 100},
|
||||||
@@ -423,9 +423,6 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
attrs.awToolTip = attrs.awToolTip.replace(/</g, "<");
|
|
||||||
attrs.awToolTip = attrs.awToolTip.replace(/>/g, ">");
|
|
||||||
attrs.awToolTip = $sce.getTrustedHtml(attrs.awToolTip);
|
|
||||||
$(element).tooltip({
|
$(element).tooltip({
|
||||||
placement: placement,
|
placement: placement,
|
||||||
delay: delay,
|
delay: delay,
|
||||||
|
|||||||
Reference in New Issue
Block a user