YARN-9715. [UI2] yarn-container-log URI need to be encoded to avoid potential misuses. Contributed by Akhil PB.

(cherry picked from commit acffec7a92)
This commit is contained in:
Sunil G 2019-08-09 12:25:10 +05:30
parent 3e9071207a
commit 9fb6c6e2a1
11 changed files with 38 additions and 13 deletions

View File

@ -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",
}];

View File

@ -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);
})
});

View File

@ -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);
})
});

View File

@ -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);
})
});

View File

@ -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);
})
});

View File

@ -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}};

View File

@ -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 }
});
},

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>