屏蔽storm ui的kill功能

 今天有个storm的topology被人kill掉了,但是找不到是谁做的,storm的ui有kill topology的功能,但是没有权限验证,这样就导致知道ui地址的任何人都可以kill掉topology,比较危险,考虑把这个action disable掉。

有两种方法:

1.前端增加nginx,做location

分析ui页面,对应kill的button,html中的action为:

1
< input  enabled = ""  onclick = "confirmAction('xxxxxxxxxx', 'xxxxxxxx', 'kill', true, 30)"  type = "button"  value = "Kill" >

调用了js的confirmAction方法,这个方法存在于storm-core/src/ui/public/js/script.js 中,

方法的定义如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function  confirmAction(id, name, action, wait, defaultWait) {
     var  opts = {
         type: 'POST' ,
         url: '/topology/'  + id +  '/'  + action
     };
     if  (wait) {
         var  waitSecs = prompt( 'Do you really want to '  + action +  ' topology "'  + name +  '"? '  +
                               'If yes, please, specify wait time in seconds:' ,
                               defaultWait);
         if  (waitSecs !=  null  && waitSecs !=  ""  && ensureInt(waitSecs)) {
             opts.url +=  '/'  + waitSecs;
         else  {
             return  false ;
         }
     else  if  (!confirm( 'Do you really want to '  + action +  ' topology "'  + name +  '"?' )) {
         return  false ;
     }
     $( "input[type=button]" ).attr( "disabled" "disabled" );
     $.ajax(opts).always( function  () {
         window.location.reload();
     }).fail( function  () {
         alert( "Error while communicating with Nimbus." )
     });
     return  false ;
}

可以看到方法主要分为两步,生成post请求的url,格式为'/topology/' + id + '/' + action + '/' + waitSecs,这里action为kill,waitSecs为触发kill时手动填入的时间,比如这里的30s,最终的url格式如下:

1
/topology/xxxxx/kill/xxxx

第二步就是根据这个设置触发一个ajax请求,这里我们只需要关心第一步即可,设置nginx如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
upstream storm {
             server  127.0.0.1:8888 weight=3 max_fails=3 fail_timeout=5s;
}
     server {
                     server_name storm.xxx.com;
                             listen 80;
                                 proxy_set_header Host $host;
                                 proxy_read_timeout 3600;
                                 proxy_set_header X-Forwarded-For  $remote_addr;
                                 access_log  /var/log/nginx/storm .access.log main;
                                 error_log   /var/log/nginx/storm .error.log debug;
                                 location ~*  /topology/ (.*) /kill/ (.*) {
                                         return  403;
                                         }
                                 location / {
                                                 proxy_pass http: //storm ;
                                         }
         }
这样,就可以屏蔽掉前端的kill功能了。

注意一个细节,storm ui的默认端口时8080,这个端口和nm冲突(见bug https://github.com/yahoo/storm-yarn/issues/25),设置storm.yaml ui.port: 8888,并重启ui即可.

2.更改代码,去掉action相关的button

storm-core/src/ui/public/topology.html
去除掉下面的部分:

1
2
3
4
5
< div  id = "topology-actions" >
< h2  class = "js-only" >Topology actions</ h2 >
< p  id = "topology-actions"  class = "js-only" >    
</ p >
</ div >

需要重新编译,还没有做测试。。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值