From 9fb6c6e2a1f563feb337716800836460f4576da3 Mon Sep 17 00:00:00 2001 From: Sunil G Date: Fri, 9 Aug 2019 12:25:10 +0530 Subject: [PATCH] YARN-9715. [UI2] yarn-container-log URI need to be encoded to avoid potential misuses. Contributed by Akhil PB. (cherry picked from commit acffec7a92be540aa8531dbe06a3ea7bb813ab93) --- .../src/main/webapp/app/controllers/yarn-container-log.js | 5 +++-- .../src/main/webapp/app/controllers/yarn-node-app.js | 5 +++++ .../src/main/webapp/app/controllers/yarn-node-apps.js | 5 +++++ .../main/webapp/app/controllers/yarn-node-container.js | 5 +++++ .../main/webapp/app/controllers/yarn-node-containers.js | 5 +++++ .../src/main/webapp/app/routes/yarn-container-log.js | 8 +++++--- .../src/main/webapp/app/routes/yarn-node-app.js | 8 +++++--- .../src/main/webapp/app/templates/yarn-node-app.hbs | 2 +- .../src/main/webapp/app/templates/yarn-node-apps.hbs | 2 +- .../src/main/webapp/app/templates/yarn-node-container.hbs | 2 +- .../main/webapp/app/templates/yarn-node-containers.hbs | 4 ++-- 11 files changed, 38 insertions(+), 13 deletions(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-container-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-container-log.js index db7470d548f..d23b2b379f5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-container-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-container-log.js @@ -23,6 +23,7 @@ export default Ember.Controller.extend({ breadcrumbs: Ember.computed('model.nodeInfo', 'model.containerInfo', function () { var nodeInfo = this.get('model.nodeInfo'), containerInfo = this.get('model.containerInfo'); + var nodeAddr = encodeURIComponent(nodeInfo.addr); return [{ text: "Home", routeName: 'application' @@ -31,10 +32,10 @@ export default Ember.Controller.extend({ routeName: 'yarn-nodes.table' }, { text: `Node [ ${nodeInfo.id} ]`, - href: `#/yarn-node/${nodeInfo.id}/${nodeInfo.addr}`, + href: `#/yarn-node/${nodeInfo.id}/${nodeAddr}/info`, }, { text: `Container [ ${containerInfo.id} ]`, - href: `#/yarn-node-container/${nodeInfo.id}/${nodeInfo.addr}/${containerInfo.id}`, + href: `#/yarn-node-container/${nodeInfo.id}/${nodeAddr}/${containerInfo.id}`, }, { text: "Log", }]; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-app.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-app.js index e0d58ecc410..5ecf706f8f5 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-app.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-app.js @@ -35,6 +35,11 @@ export default Ember.Controller.extend({ }, { text: `Application [ ${nodeInfo.appId} ]`, }]; + }), + + encodedNodeAddr: Ember.computed("model.nodeInfo", function() { + var nodeInfo = this.get("model.nodeInfo"); + return encodeURIComponent(nodeInfo.addr); }) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-apps.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-apps.js index ddc8256a73c..460f186af34 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-apps.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-apps.js @@ -35,6 +35,11 @@ export default Ember.Controller.extend({ }, { text: "Applications", }]; + }), + + encodedNodeAddr: Ember.computed("model.nodeInfo", function() { + var nodeInfo = this.get("model.nodeInfo"); + return encodeURIComponent(nodeInfo.addr); }) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-container.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-container.js index b8e7e36b048..bac26b2c91f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-container.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-container.js @@ -35,6 +35,11 @@ export default Ember.Controller.extend({ }, { text: `Container [ ${nodeInfo.containerId} ]` }]; + }), + + encodedNodeAddr: Ember.computed("model.nodeInfo", function() { + var nodeInfo = this.get("model.nodeInfo"); + return encodeURIComponent(nodeInfo.addr); }) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-containers.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-containers.js index 9fb03c814be..4dbd05b2ff8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-containers.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/controllers/yarn-node-containers.js @@ -35,6 +35,11 @@ export default Ember.Controller.extend({ }, { text: "Containers", }]; + }), + + encodedNodeAddr: Ember.computed("model.nodeInfo", function() { + var nodeInfo = this.get("model.nodeInfo"); + return encodeURIComponent(nodeInfo.addr); }) }); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-container-log.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-container-log.js index 8562bf567df..fcd3cdc4ee1 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-container-log.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-container-log.js @@ -23,12 +23,14 @@ import AbstractRoute from './abstract'; export default AbstractRoute.extend({ model(param) { - var id = param.node_addr + Constants.PARAM_SEPARATOR + param.container_id + + var nodeAddress = decodeURIComponent(param.node_addr); + nodeAddress = nodeAddress.replace(/(^\w+:|^)\/\//, ''); + var id = nodeAddress + Constants.PARAM_SEPARATOR + param.container_id + Constants.PARAM_SEPARATOR + param.filename; return Ember.RSVP.hash({ containerLog: this.store.findRecord('yarn-container-log', id), containerInfo: { id: param.container_id }, - nodeInfo: { id: param.node_id, addr: param.node_addr } + nodeInfo: { id: param.node_id, addr: nodeAddress } }).then(function(hash) { // Just return as its success. return hash; @@ -38,7 +40,7 @@ export default AbstractRoute.extend({ return reason; } else { // Assume empty response received from server. - return { nodeInfo: { id: param.node_id, addr: param.node_addr }, + return { nodeInfo: { id: param.node_id, addr: nodeAddress }, containerInfo: { id: param.container_id }, containerLog: { logs: "", containerID: param.container_id, logFileName: param.filename}}; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-node-app.js b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-node-app.js index 05f0f0b6936..7167cd12705 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-node-app.js +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/routes/yarn-node-app.js @@ -22,11 +22,13 @@ import AbstractRoute from './abstract'; export default AbstractRoute.extend({ model(param) { + var address = decodeURIComponent(param.node_addr); + address = address.replace(/(^\w+:|^)\/\//, ''); return Ember.RSVP.hash({ nodeApp: this.store.queryRecord('yarn-node-app', - { nodeAddr : param.node_addr, appId: param.app_id }), - nmGpuInfo: this.store.findRecord('yarn-nm-gpu', param.node_addr, {reload:true}), - nodeInfo: { id: param.node_id, addr: param.node_addr, appId: param.app_id } + { nodeAddr : address, appId: param.app_id }), + nmGpuInfo: this.store.findRecord('yarn-nm-gpu', address, {reload:true}), + nodeInfo: { id: param.node_id, addr: address, appId: param.app_id } }); }, diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-app.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-app.hbs index d4a4ed8638e..053cbe39e22 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-app.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-app.hbs @@ -50,7 +50,7 @@ {{#each model.nodeApp.containers as |container|}} - {{container}} + {{container}} {{/each}} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs index 919e54df545..4cfd13cbe9a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-apps.hbs @@ -35,7 +35,7 @@ {{#if model.apps}} {{#each model.apps as |app|}} - {{app.appId}} + {{app.appId}} {{app.state}} {{app.user}} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-container.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-container.hbs index f4b3250bc1c..d26fea0a3a0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-container.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-container.hbs @@ -58,7 +58,7 @@ Link to Logs {{log-files-comma nodeId=model.nodeInfo.id - nodeAddr=model.nodeInfo.addr + nodeAddr=encodedNodeAddr containerId=model.nodeContainer.containerId logFiles=model.nodeContainer.containerLogFiles}} diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs index 1f312722072..7b276849dc8 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-ui/src/main/webapp/app/templates/yarn-node-containers.hbs @@ -36,12 +36,12 @@ {{#if model.containers}} {{#each model.containers as |container|}} - {{container.containerId}} + {{container.containerId}} {{container.state}} {{container.user}} {{log-files-comma nodeId=model.nodeInfo.id - nodeAddr=model.nodeInfo.addr + nodeAddr=encodedNodeAddr containerId=container.containerId logFiles=container.containerLogFiles}}