github监控平台hawkeye搭建

Hawkeye

监控github代码库,及时发现员工托管公司代码到GitHub行为并预警,降低代码泄露风险。感谢0xbug的分享,而且恢复极快。

https://github.com/0xbug/Hawkeye.git

搭建这个主要是因为公司的代码被泄露了,而且还带了测试账号在其中。解决方法:制度宣导  技术管控

我是centos7需要安装python3

搭建过程:

安装python3

yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

 

wget https://www.python.org/ftp/python/3.5.3/Python-3.5.3.tgz

 
mkdir /usr/local/python3 
tar -zxvf Python-3.5.3.tgz
cd Python-3.5.3


./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv3


pip3 -V
python3 -V

安装配置Hawkeye

cd Hawkeye
pip3 install virtualenv
virtualenv3 --python=/usr/bin/python3 venv
source venv/bin/activate
pip3 install -r deploy/requirements.txt


cp config.ini.example config.ini
vim config.ini
[GitHub]
USERNAME = github的账号
PASSWORD = githu的密码
ERROR = We could not perform this search

[MongoDB]
HOST = localhost
PORT = 27017
ACCOUNT = mongo的账号
PASSWORD = mongo的密码
未配置告警邮箱可以自己配置

 先创建mongo用户

mongo
>db.createUser({user:'root',pwd:'password',roles:[{role:'dbOwner',db:'Hawkeye'}]})

运行

python3 Hawkeye.py

然后访问 http://0.0.0.0:5000/ 进行关键词、告警、黑名单、定时任务配置(初次运行需要点击确认按钮新建cron任务)。

后台运行:
nohup python3 -u /root/Hawkeye/Hawkeye.py > outgithub.log 2>&1 &



遇到的问题记录一下:

1.出现如下错误:
[2017-07-17 17:25:19,610] ERROR in app: Exception on /api/setting/cron [GET]
Traceback (most recent call last):
File "/opt/Hawkeye/venv/lib/python3.4/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/Hawkeye/venv/lib/python3.4/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functionsrule.endpoint
File "/opt/Hawkeye/venv/lib/python3.4/site-packages/flask_restful/init.py", line 480, in wrapper
resp = resource(*args, **kwargs)
File "/opt/Hawkeye/venv/lib/python3.4/site-packages/flask/views.py", line 84, in view
return self.dispatch_request(*args, **kwargs)
File "/opt/Hawkeye/venv/lib/python3.4/site-packages/flask_restful/init.py", line 595, in dispatch_request
resp = meth(*args, **kwargs)
File "Hawkeye.py", line 235, in get
return jsonify({'status': 200, 'msg': '获取信息成功', 'result': read_cron()})
File "Hawkeye.py", line 285, in read_cron
user_cron = CronTab(user=True)
TypeError: init() got an unexpected keyword argument 'user'

解决方法:
卸载 crontab库,  pip3 uninstall crontab
安装 python-crontab 解决问题   手动安装一下这个包
https://github.com/doctormo/python-crontab


2.

数据量很大时,前端点击页数会报500错误

解决方法:

MongoDB Shell中执行

use admin
db.adminCommand({setParameter: 1, internalQueryExecMaxBlockingSortBytes: 52428800})

阅读更多
文章标签: hawkeye github
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭
关闭