Github代码监控

/ GitLinux_Safe / 3 条评论 / 5445浏览

写在B站代码泄漏之后

环境

ubuntu 16.04

redis

mysql数据库

node环境

# 建库
CREATE DATABASE IF NOT EXISTS github DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_bin;

单机ip: 111.111.111.167

python3 pip3 python3-venv

源码

$ git clone https://github.com/VKSRC/Github-Monitor.git

源码部署方式

项目运行依赖 redis, 请在运行服务前启动redis-server

首先将.env.sample复制一份重命名为.env,并按照自己的要求修改配置

(py3) root@hadoop:/opt/projects/Github-Monitor# cp .env.sample .env
(py3) root@hadoop:/opt/projects/Github-Monitor# cat .env
# Django Settings
DEBUG="True"  # Django后台是否以debug模式运行, 可选True/False
ALLOWED_HOSTS="111.111.111.167,192.168.0.112,127.0.0.1,localhost"  # 配置Django Allowed_Hosts, 如果DEBUG为False, 需要将访问的host地址添加进来,如'localhost,github.vipkid.com.cn'

# Database Settings
# DATABASE choice is mysql or sqlite
DATABASE="mysql"  # 数据库类型, 可选sqlite或mysql
DB_NAME="github"  # 数据库名称
DB_HOST="127.0.0.1"  # mysql host
DB_PORT="3306"  # mysql port
DB_USER="root"  # mysql用户名
DB_PASSWORD="密码"  # mysql密码

# Redis Settings
REDIS_HOST="127.0.0.1"  # redis host
REDIS_PORT="6379"  # redis port
REDIS_PASSWORD=""  # redis password

# Email Settings
# If you do not fill it in, it is None/False
EMAIL_HOST="smtp.example.com"  # smtp host
EMAIL_PORT="25"  # smtp port
FROM_EMAIL="secuirty@example.com"  # 发件人
EMAIL_HOST_USER="security@example.com"  # email user, 如为匿名发送,将值设为空字符即可
EMAIL_HOST_PASSWORD="password123!@#"  # email password, 如为匿名发送,将值设为空字符即可
EMAIL_USE_TLS="False"  # 与SMTP服务器通信时是否使用TLS(安全)连接, 可选True/False
EMAIL_USE_SSL="False"  # 与SMTP服务器通信时是否使用SSL(安全)连接, 可选True/False

# initial Administrator
INIT_ADMIN_USERNAME="admin"  # 初始化系统用户使用的用户名
INIT_ADMIN_PASSWORD="password123!@#"  # 初始化系统用户使用的用户密码

进入后端代码

为了不污染系统级的python环境,建议建立虚拟环境

$ cd server
$ python3 -m venv py3 && source py3/bin/activate
$ pip3 install -r requirements.pip -i https://pypi.douban.com/simple 

Run

#初始化数据库
$ python3 manage.py migrate

(py3) root@hadoop:/opt/projects/Github-Monitor/server# python3 manage.py migrate
Operations to perform:
  Apply all migrations: admin, auth, authtoken, contenttypes, monitor, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying admin.0002_logentry_remove_auto_add... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK
  Applying authtoken.0001_initial... OK
  Applying authtoken.0002_auto_20160226_1747... OK
  Applying monitor.0001_initial... OK
  Applying monitor.0002_auto_20180920_1908... OK
  Applying monitor.0003_leakage_task... OK
  Applying monitor.0004_leakage_fragment... OK
  Applying monitor.0005_task_name... OK
  Applying monitor.0006_task_mail... OK
  Applying monitor.0007_remove_leakage_content... OK
  Applying monitor.0008_leakage_keyword... OK
  Applying monitor.0009_auto_20181213_1825... OK
  Applying sessions.0001_initial... OK


#初始化用户账号
$ python3 manage.py init_admin

#启动web后端服务:
$ python3 manage.py runserver 0.0.0.0:8001

#启动监控任务服务:
$ python3 manage.py monitor_task_service

前端run

$ npm install
$ npm run-script build
$ npm run start
 DONE  Compiled successfully in 29721ms                                                                       14:43:46


  App running at:
  - Local:   http://localhost:8000/ (copy to clipboard failed)
  - Network: http://111.111.111.167:8000/

获取github token

点击下面链接创建token

https://github.com/settings/tokens

使用

创建任务

关键词 建议填写项目独有的代码

demo

http://111.111.111.167:8000/

彩蛋

拿bilibili的练练手?

还有一个漏网之鱼

  1. 码小六比 Github Monitor 好用一点

    回复
  2. 并非基佬。

    回复
  3. 1

    嘤嘤嘤。。。

    回复