This is an automated email from the ASF dual-hosted git repository.

sunilg pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new acffec7  YARN-9715. [UI2] yarn-container-log URI need to be encoded to 
avoid potential misuses. Contributed by Akhil PB.
acffec7 is described below

commit acffec7a92be540aa8531dbe06a3ea7bb813ab93
Author: Sunil G <sun...@apache.org>
AuthorDate: Fri Aug 9 12:25:10 2019 +0530

    YARN-9715. [UI2] yarn-container-log URI need to be encoded to avoid 
potential misuses. Contributed by Akhil PB.
---
 .../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 +++++
 .../src/main/webapp/app/controllers/yarn-node-container.js        | 5 +++++
 .../src/main/webapp/app/controllers/yarn-node-containers.js       | 5 +++++
 .../src/main/webapp/app/routes/yarn-container-log.js              | 8 +++++---
 .../hadoop-yarn-ui/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 +-
 .../src/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 db7470d..d23b2b3 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 e0d58ec..5ecf706 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 ddc8256..460f186 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 b8e7e36..bac26b2 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 9fb03c8..4dbd05b 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 8562bf5..fcd3cdc 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 05f0f0b..7167cd1 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 d4a4ed8..053cbe3 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 @@
         <tbody>
           {{#each model.nodeApp.containers as |container|}}
             <tr>
-              <td><a 
href="#/yarn-node-container/{{model.nodeInfo.id}}/{{model.nodeInfo.addr}}/{{container}}">{{container}}</a></td>
+              <td><a 
href="#/yarn-node-container/{{model.nodeInfo.id}}/{{encodedNodeAddr}}/{{container}}">{{container}}</a></td>
             </tr>
           {{/each}}
        </tbody>
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 919e54d..4cfd13c 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|}}
                 <tr>
-                  <td><a 
href="#/yarn-node-app/{{model.nodeInfo.id}}/{{model.nodeInfo.addr}}/{{app.appId}}">{{app.appId}}</a></td>
+                  <td><a 
href="#/yarn-node-app/{{model.nodeInfo.id}}/{{encodedNodeAddr}}/{{app.appId}}">{{app.appId}}</a></td>
                   <td><span 
class={{app.appStateStyle}}>{{app.state}}</span></td>
                   <td>{{app.user}}</td>
                 </tr>
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 f4b3250..d26fea0 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 @@
               <td>Link to Logs</td>
               <td>
                 {{log-files-comma nodeId=model.nodeInfo.id
-                    nodeAddr=model.nodeInfo.addr
+                    nodeAddr=encodedNodeAddr
                     containerId=model.nodeContainer.containerId
                     logFiles=model.nodeContainer.containerLogFiles}}
               </td>
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 1f31272..7b27684 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|}}
                 <tr>
-                  <td><a 
href="#/yarn-node-container/{{model.nodeInfo.id}}/{{model.nodeInfo.addr}}/{{container.containerId}}">{{container.containerId}}</a></td>
+                  <td><a 
href="#/yarn-node-container/{{model.nodeInfo.id}}/{{encodedNodeAddr}}/{{container.containerId}}">{{container.containerId}}</a></td>
                   <td><span 
class={{container.containerStateStyle}}>{{container.state}}</span></td>
                   <td>{{container.user}}</td>
                   <td>
                     {{log-files-comma nodeId=model.nodeInfo.id
-                        nodeAddr=model.nodeInfo.addr
+                        nodeAddr=encodedNodeAddr
                         containerId=container.containerId
                         logFiles=container.containerLogFiles}}
                   </td>


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to