From a72f3d2f2fafc7cc2c778250fe7a12e0dc4516fc Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Fri, 16 Nov 2018 16:45:30 -0500 Subject: [PATCH] generate host_config_key using random UUIDs, not a time-based md5 hash --- awx/ui/.eslintrc.js | 3 ++- awx/ui/.jshintrc | 3 ++- .../job_templates/factories/md-5-setup.factory.js | 9 ++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/awx/ui/.eslintrc.js b/awx/ui/.eslintrc.js index 9a42d34ab2..27759bf2b9 100644 --- a/awx/ui/.eslintrc.js +++ b/awx/ui/.eslintrc.js @@ -31,7 +31,8 @@ module.exports = { $: true, _: true, codemirror: true, - jsyaml: true + jsyaml: true, + crypto: true }, rules: { 'arrow-parens': 'off', diff --git a/awx/ui/.jshintrc b/awx/ui/.jshintrc index a2bb56723e..363d2e5ba8 100644 --- a/awx/ui/.jshintrc +++ b/awx/ui/.jshintrc @@ -35,7 +35,8 @@ "moment": false, "spyOn": false, "jasmine": false, - "dagre": false + "dagre": false, + "crypto": false }, "strict": false, "quotmark": false, diff --git a/awx/ui/client/src/templates/job_templates/factories/md-5-setup.factory.js b/awx/ui/client/src/templates/job_templates/factories/md-5-setup.factory.js index bce1485d7a..eefdb0beb2 100644 --- a/awx/ui/client/src/templates/job_templates/factories/md-5-setup.factory.js +++ b/awx/ui/client/src/templates/job_templates/factories/md-5-setup.factory.js @@ -1,5 +1,5 @@ export default - function md5Setup(md5) { + function md5Setup() { return function(params) { var scope = params.scope, master = params.master, @@ -10,8 +10,9 @@ export default master[check_field] = default_val; scope.genMD5 = function (fld) { - var now = new Date(); - scope[fld] = md5.createHash('AnsibleWorks' + now.getTime()); + scope[fld] = ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c => + (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) + ); scope.$emit('NewMD5Generated'); }; @@ -26,5 +27,3 @@ export default }; }; } - -md5Setup.$inject = [ 'md5' ];