From a72f3d2f2fafc7cc2c778250fe7a12e0dc4516fc Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Fri, 16 Nov 2018 16:45:30 -0500 Subject: [PATCH 1/6] 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' ]; From d8d89d253d1f4c2c5ef34b2590cb0c71c9baca66 Mon Sep 17 00:00:00 2001 From: kialam Date: Mon, 19 Nov 2018 12:59:15 -0500 Subject: [PATCH 2/6] Remove instances of "md5" from the UI. --- awx/ui/client/src/shared/form-generator.js | 8 ++++---- .../add-job-template/job-template-add.controller.js | 6 +++--- .../edit-job-template/job-template-edit.controller.js | 6 +++--- .../job_templates/factories/callback-help-init.factory.js | 8 ++++---- .../src/templates/job_templates/job-template.form.js | 2 +- awx/ui/client/src/templates/job_templates/main.js | 4 ++-- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index f9e1b9e426..d3c8516032 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -79,7 +79,7 @@ * | default | Default value to place in the field when the form is in 'add' mode. | * | defaultText | Default value to put into a select input. | * | falseValue | For radio buttons and checkboxes. Value to set the model to when the checkbox or radio button is not selected. | - * | genMD5 | true or false. If true, places the field in an input group with a button that when clicked replaces the field contents with an MD5 has key. Used with host_config_key on the job templates detail page. | + * | genHash | true or false. If true, places the field in an input group with a button that when clicked replaces the field contents with a hash as key. Used with host_config_key on the job templates detail page. | * | integer | Adds the integer directive to validate that the value entered is of type integer. Add min and max to supply lower and upper range bounds to the entered value. | * | label | Text to use as <label> element for the field | * | ngChange | Adds ng-change directive. Set to the JS expression to be evaluated by ng-change. | @@ -802,7 +802,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat html += (horizontal) ? "class=\"" + getFieldWidth() + "\"" : ""; html += ">\n"; - html += (field.clear || field.genMD5) ? "
\n" : ""; + html += (field.clear || field.genHash) ? "
\n" : ""; if (field.control === null || field.control === undefined || field.control) { html += "\n
\n"; } diff --git a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js index 1ee7f244ea..097b905699 100644 --- a/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js +++ b/awx/ui/client/src/templates/job_templates/add-job-template/job-template-add.controller.js @@ -7,14 +7,14 @@ export default [ '$filter', '$scope', '$stateParams', 'JobTemplateForm', 'GenerateForm', 'Rest', 'Alert', - 'ProcessErrors', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'Wait', + 'ProcessErrors', 'GetBasePath', 'hashSetup', 'ParseTypeChange', 'Wait', 'Empty', 'ToJSON', 'CallbackHelpInit', 'GetChoices', '$state', 'availableLabels', 'CreateSelect2', '$q', 'i18n', 'Inventory', 'Project', 'InstanceGroupsService', 'MultiCredentialService', 'ConfigData', 'resolvedModels', function( $filter, $scope, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert, - ProcessErrors, GetBasePath, md5Setup, ParseTypeChange, Wait, + ProcessErrors, GetBasePath, hashSetup, ParseTypeChange, Wait, Empty, ToJSON, CallbackHelpInit, GetChoices, $state, availableLabels, CreateSelect2, $q, i18n, Inventory, Project, InstanceGroupsService, MultiCredentialService, ConfigData, resolvedModels @@ -43,7 +43,7 @@ $scope.credentialNotPresent = false; $scope.canGetAllRelatedResources = true; - md5Setup({ + hashSetup({ scope: $scope, master: master, check_field: 'allow_callbacks', diff --git a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js index 1b6b4a1c99..b2f88af137 100644 --- a/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js +++ b/awx/ui/client/src/templates/job_templates/edit-job-template/job-template-edit.controller.js @@ -13,7 +13,7 @@ export default [ '$filter', '$scope', '$rootScope', '$location', '$stateParams', 'JobTemplateForm', 'GenerateForm', - 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'md5Setup', + 'Rest', 'Alert', 'ProcessErrors', 'GetBasePath', 'hashSetup', 'ParseTypeChange', 'Wait', 'selectedLabels', 'i18n', 'Empty', 'Prompt', 'ToJSON', 'GetChoices', 'CallbackHelpInit', 'initSurvey', '$state', 'CreateSelect2', @@ -23,7 +23,7 @@ export default function( $filter, $scope, $rootScope, $location, $stateParams, JobTemplateForm, GenerateForm, Rest, Alert, - ProcessErrors, GetBasePath, md5Setup, + ProcessErrors, GetBasePath, hashSetup, ParseTypeChange, Wait, selectedLabels, i18n, Empty, Prompt, ToJSON, GetChoices, CallbackHelpInit, SurveyControllerInit, $state, CreateSelect2, @@ -245,7 +245,7 @@ export default master = masterObject; dft = ($scope.host_config_key === "" || $scope.host_config_key === null) ? false : true; - md5Setup({ + hashSetup({ scope: $scope, master: master, check_field: 'allow_callbacks', diff --git a/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js b/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js index e1c027a4e0..2f6d184289 100644 --- a/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js +++ b/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js @@ -18,11 +18,11 @@ export default "

Successful requests create an entry on the Jobs page, where results and history can be viewed.

"; }; - // The md5 helper emits NewMD5Generated whenever a new key is available - if (scope.removeNewMD5Generated) { - scope.removeNewMD5Generated(); + // The md5 helper emits NewHashGenerated whenever a new key is available + if (scope.removeNewHashGenerated) { + scope.removeNewHashGenerated(); } - scope.removeNewMD5Generated = scope.$on('NewMD5Generated', function() { + scope.removeNewHashGenerated = scope.$on('NewHashGenerated', function() { scope.configKeyChange(); }); diff --git a/awx/ui/client/src/templates/job_templates/job-template.form.js b/awx/ui/client/src/templates/job_templates/job-template.form.js index f716cb4abb..673a5880d5 100644 --- a/awx/ui/client/src/templates/job_templates/job-template.form.js +++ b/awx/ui/client/src/templates/job_templates/job-template.form.js @@ -353,7 +353,7 @@ function(NotificationsList, i18n) { type: 'text', ngShow: "allow_callbacks && allow_callbacks !== 'false'", ngChange: "configKeyChange()", - genMD5: true, + genHash: true, column: 2, awPopOver: "callback_help", awPopOverWatch: "callback_help", diff --git a/awx/ui/client/src/templates/job_templates/main.js b/awx/ui/client/src/templates/job_templates/main.js index 82d254cfb4..0c096c0134 100644 --- a/awx/ui/client/src/templates/job_templates/main.js +++ b/awx/ui/client/src/templates/job_templates/main.js @@ -1,13 +1,13 @@ import jobTemplateAdd from './add-job-template/main'; import jobTemplateEdit from './edit-job-template/main'; import multiCredential from './multi-credential/main'; -import md5Setup from './factories/md-5-setup.factory'; +import hashSetup from './factories/hash-setup.factory'; import CallbackHelpInit from './factories/callback-help-init.factory'; import JobTemplateForm from './job-template.form'; export default angular.module('jobTemplates', [jobTemplateAdd.name, jobTemplateEdit.name, multiCredential.name]) - .factory('md5Setup', md5Setup) + .factory('hashSetup', hashSetup) .factory('CallbackHelpInit', CallbackHelpInit) .factory('JobTemplateForm', JobTemplateForm); From 71ee9d28b9fa9f9dcf0ceb70c5d804255681a547 Mon Sep 17 00:00:00 2001 From: kialam Date: Mon, 19 Nov 2018 14:32:46 -0500 Subject: [PATCH 3/6] Add link to original gist and rename file. --- .../{md-5-setup.factory.js => hash-setup.factory.js} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename awx/ui/client/src/templates/job_templates/factories/{md-5-setup.factory.js => hash-setup.factory.js} (81%) 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/hash-setup.factory.js similarity index 81% rename from awx/ui/client/src/templates/job_templates/factories/md-5-setup.factory.js rename to awx/ui/client/src/templates/job_templates/factories/hash-setup.factory.js index eefdb0beb2..b565e06820 100644 --- a/awx/ui/client/src/templates/job_templates/factories/md-5-setup.factory.js +++ b/awx/ui/client/src/templates/job_templates/factories/hash-setup.factory.js @@ -1,5 +1,5 @@ export default - function md5Setup() { + function hashSetup() { return function(params) { var scope = params.scope, master = params.master, @@ -9,11 +9,12 @@ export default scope[check_field] = default_val; master[check_field] = default_val; - scope.genMD5 = function (fld) { + // Original gist here: https://gist.github.com/jed/982883 + scope.genHash = function (fld) { 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'); + scope.$emit('NewHashGenerated'); }; scope.toggleCallback = function (fld) { From 362a3753d07746cc3c051f3d934cbcdc97372532 Mon Sep 17 00:00:00 2001 From: kialam Date: Wed, 21 Nov 2018 13:02:16 -0500 Subject: [PATCH 4/6] Remove 'angular-md5' from our dependencies. --- awx/ui/client/src/app.js | 1 - .../job_templates/factories/callback-help-init.factory.js | 2 +- awx/ui/client/src/vendor.js | 1 - awx/ui/package-lock.json | 5 ----- awx/ui/package.json | 1 - 5 files changed, 1 insertion(+), 9 deletions(-) diff --git a/awx/ui/client/src/app.js b/awx/ui/client/src/app.js index e5ebe9c776..0064b358d0 100644 --- a/awx/ui/client/src/app.js +++ b/awx/ui/client/src/app.js @@ -53,7 +53,6 @@ angular 'angular-duration-format', 'angularMoment', 'AngularScheduler', - 'angular-md5', 'dndLists', 'ncy-angular-breadcrumb', 'ngSanitize', diff --git a/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js b/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js index 2f6d184289..2a3b0382e5 100644 --- a/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js +++ b/awx/ui/client/src/templates/job_templates/factories/callback-help-init.factory.js @@ -18,7 +18,7 @@ export default "

Successful requests create an entry on the Jobs page, where results and history can be viewed.

"; }; - // The md5 helper emits NewHashGenerated whenever a new key is available + // The hash helper emits NewHashGenerated whenever a new key is available if (scope.removeNewHashGenerated) { scope.removeNewHashGenerated(); } diff --git a/awx/ui/client/src/vendor.js b/awx/ui/client/src/vendor.js index b1cc68174a..f683511b02 100644 --- a/awx/ui/client/src/vendor.js +++ b/awx/ui/client/src/vendor.js @@ -53,7 +53,6 @@ require('angular-codemirror'); require('angular-drag-and-drop-lists'); require('angular-duration-format'); require('angular-gettext'); -require('angular-md5'); require('angular-moment'); require('angular-scheduler'); require('angular-tz-extensions'); diff --git a/awx/ui/package-lock.json b/awx/ui/package-lock.json index b6bf415a64..2418cbac80 100644 --- a/awx/ui/package-lock.json +++ b/awx/ui/package-lock.json @@ -220,11 +220,6 @@ } } }, - "angular-md5": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/angular-md5/-/angular-md5-0.1.10.tgz", - "integrity": "sha1-fLbH1cHQQB/+mHGhF4SfA8LMSGM=" - }, "angular-mocks": { "version": "1.6.10", "resolved": "https://registry.npmjs.org/angular-mocks/-/angular-mocks-1.6.10.tgz", diff --git a/awx/ui/package.json b/awx/ui/package.json index e5eb180b52..14dabffb8d 100644 --- a/awx/ui/package.json +++ b/awx/ui/package.json @@ -103,7 +103,6 @@ "angular-drag-and-drop-lists": "git+https://git@github.com/ansible/angular-drag-and-drop-lists#v1.4.1", "angular-duration-format": "^1.0.1", "angular-gettext": "^2.3.5", - "angular-md5": "^0.1.8", "angular-moment": "^0.10.1", "angular-mousewheel": "^1.0.5", "angular-sanitize": "~1.6.6", From 1ac5bc5e2bdec45a6721aea28cb12cc4ee64ebb8 Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Tue, 20 Nov 2018 11:31:42 -0500 Subject: [PATCH 5/6] remove angular-md5 license --- docs/licenses/ui/angular-md5.txt | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 docs/licenses/ui/angular-md5.txt diff --git a/docs/licenses/ui/angular-md5.txt b/docs/licenses/ui/angular-md5.txt deleted file mode 100644 index af9bf42f58..0000000000 --- a/docs/licenses/ui/angular-md5.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2014 PatrickJS - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. From 22802e7a64ddb5270300e6a882d4c34f989b322b Mon Sep 17 00:00:00 2001 From: kialam Date: Wed, 21 Nov 2018 13:04:18 -0500 Subject: [PATCH 6/6] Update README to include needed npm version. --- awx/ui/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/README.md b/awx/ui/README.md index ba5b595392..b30640d867 100644 --- a/awx/ui/README.md +++ b/awx/ui/README.md @@ -2,7 +2,7 @@ ## Requirements - node.js 8.x LTS -- npm 5.x LTS +- npm >=5.10 - bzip2, gcc-c++, git, make ## Development