linux系统中 屏蔽storm ui的kill功能的两种方法

网络知识 2023-02-09 13:14www.1681989.comseo网站推广

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

  有两种方法

  1.前端增加ngx,做location

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


复制代码

代码如下:
  <put enabled="" onclick="confirmAction('xxxxxxxxxx', 'xxxxxxxx', 'kill', true, 30)" type="button" value="Kill">

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


复制代码

代码如下:
  function confirmAction(id, name, action, wait, defaultWait) {var opts = {type:'POST',url:'/ology/' + id + '/' + action};
  if (wait) {
  var waitSecs = prompt('Do you really want to ' + action + ' ology "' + name + '"? ' +'If yes, please, specify wait time seconds:',defaultWait);if (waitSecs != null && waitSecs != "" && ensureInt(waitSecs)) {opts.url += '/' + waitSecs;} else {return false;}
  } else if (!confirm('Do you really want to ' + action + ' ology "' + name + '"?')) {return false;}
  $("put[type=button]").attr("disabled", "disabled");$.ajax(opts).always(function () {wdow.location.reload();}).fail(function () {alert("Error while municatg with Nimbus.")});return false;}

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


复制代码代码如下:  /ology/xxxxx/kill/xxxx

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


复制代码代码如下:  upstream storm {
  server 127.0.0.1:8888 weight=3 max_fails=3 fail_timeout=5s;}
  server {
  server_name storm.xxx.;
  listen 80;
  proxy_set_header Host $host;
  proxy_read_timeout 3600;
  proxy_set_header X-Forwarded-For $remote_addr;aess_log /var/log/ngx/storm.aess.log ma;error_log /var/log/ngx/storm.error.log debug;location ~ /ology/(.)/kill/(.) {return 403;}
  location / {
  proxy_pass http://storm;
  }
  }

  这样,就可以屏蔽掉前端的kill功能了。

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

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


复制代码代码如下:  storm-core/src/ui/public/ology.html

  去除掉下面的部分


复制代码代码如下:  <div id="ology-actions">
  <h2 class="js-only">Topology actions</h2>
  <p id="ology-actions" class="js-only">
  </p>
  </div>

  第二种方法需要重新编译,还没有做测试。。

  以上就是lux系统中屏蔽storm ui的kill功能的2种方法,在此感谢本文的原创作者 “菜光光的博客” ,请务必保留此出处http://caiguangguang.blog.51cto./1652935/1557514,谢谢阅读,希望能帮到大家,请继续关注脚本之家,我们会努力分享更多优秀的文章。

上一篇:Adobe Reader因不再吸引Linux用户决定退出Linux系统 下一篇:linux系统中InputStream输入流的方法之reset()和mark(

Copyright © 2016-2025 www.1681989.com 推火网 版权所有 Power by