forked from cheyunhua/Libra
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
5,616 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<p align="center"> | ||
<img src="img/logo.jpg"> | ||
</p> | ||
|
||
# Yearning SQL审核平台 | ||
 | ||
 | ||
 | ||
|
||
##### MYSQL web端 SQL审核平台。 | ||
|
||
## Version 版本 | ||
|
||
Yearning for Golang v2.0.0 | ||
|
||
Yearning for Python v1.4.7 | ||
|
||
## Yearning2.0 前端项目 | ||
|
||
[Gemini](https://github.com/cookieY/Gemini) | ||
|
||
## Website 官网 | ||
|
||
[www.yearning.io](http://yearning.io) | ||
|
||
|
||
## Community 社区 | ||
Yearning 使用与交流 Q群: 103674679 | ||
|
||
Yearning2.0(Go) 使用交流 Q群: 747364310 | ||
## Feature 功能 | ||
|
||
- SQL查询 | ||
- 查询工单 | ||
- 导出 | ||
- 自动补全,智能提示 | ||
- 查询语句审计 | ||
- SQL审核 | ||
- 流程化工单 | ||
- SQL语句检测与执行 | ||
- SQL回滚 | ||
- 历史审核记录 | ||
- 推送 | ||
- E-mail工单推送 | ||
- 钉钉webhook机器人工单推送 | ||
- 用户权限及管理 | ||
- 角色划分 | ||
- 基于用户的细粒度权限 | ||
- 注册 | ||
- 其他 | ||
- todoList | ||
- LDAP登录 | ||
- 动态审核规则配置 | ||
|
||
## Install 安装及使用日志 | ||
|
||
[使用及安装文档](http://guide.yearning.io) | ||
|
||
## Develop 二次开发 | ||
|
||
[二次开发注意事项](https://guide.yearning.io/developer.html) | ||
|
||
## About 联系方式 | ||
|
||
E-mail: [email protected] | ||
|
||
## Snapshot 效果展示 | ||
|
||
- Login | ||
|
||
|
||
|
||
 | ||
|
||
|
||
- Dashboard | ||
|
||
 | ||
|
||
- 审核 | ||
|
||
 | ||
|
||
- SQL语法高亮及自动补全 | ||
|
||
 | ||
|
||
- 查询 | ||
|
||
 | ||
|
||
- 细粒度的权限分配 | ||
 | ||
|
||
- 我的工单 | ||
 | ||
|
||
|
||
## License | ||
|
||
- AGPL v3 | ||
|
||
任何二次开发及二次开源项目请严格遵守相应开源许可 | ||
|
||
2019 © Henry Yee | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Mysql] | ||
Db = "Yearning_go" | ||
Host = "127.0.0.1" | ||
Port = "3306" | ||
Password = "19931003" | ||
User = "root" | ||
|
||
[General] | ||
|
||
Host = "127.0.0.1:8080" | ||
SecretKey = "u)zall!ag&mci+ja5u&-6*1e^ufyu)l4i8+^=mw$845@k!ie+3.txt" |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"time" | ||
|
||
pb "Juno/libraGrpc/proto" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
const ( | ||
address = "localhost:50001" | ||
) | ||
|
||
func ExDDLClient(order *pb.LibraAuditOrder) { | ||
|
||
// Set up a connection to the server. | ||
conn, err := grpc.Dial(address, grpc.WithInsecure()) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewJunoClient(conn) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
r, err := c.OrderDDLExec(ctx, order) | ||
if err != nil { | ||
log.Fatalf("could not connect: %v", err) | ||
} | ||
fmt.Println(r.Message) | ||
} | ||
|
||
func ExDMLClient(order *pb.LibraAuditOrder) { | ||
|
||
// Set up a connection to the server. | ||
conn, err := grpc.Dial(address, grpc.WithInsecure()) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewJunoClient(conn) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
r, err := c.OrderDMLExec(ctx, order) | ||
if err != nil { | ||
log.Fatalf("could not connect: %v", err) | ||
} | ||
fmt.Println(r.Message) | ||
} | ||
|
||
|
||
func TsClient(order *pb.LibraAuditOrder) { | ||
|
||
// Set up a connection to the server. | ||
conn, err := grpc.Dial(address, grpc.WithInsecure()) | ||
if err != nil { | ||
log.Fatalf("did not connect: %v", err) | ||
} | ||
defer conn.Close() | ||
c := pb.NewJunoClient(conn) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second) | ||
defer cancel() | ||
r, err := c.OrderDeal(ctx, order) | ||
if err != nil { | ||
log.Fatalf("could not connect: %v", err) | ||
} | ||
for _, i := range r.Record { | ||
fmt.Println(i.SQL) // SQL语句 | ||
fmt.Println(i.Status) //审核状态 | ||
fmt.Println(i.Level) // 错误等级 | ||
fmt.Println(i.Error) // 错误信息 | ||
fmt.Println(i.AffectRows) //影响行数 | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package client | ||
|
||
import ( | ||
pb "Juno/libraGrpc/proto" | ||
"testing" | ||
) | ||
|
||
func TestExDDLClient(t *testing.T) { | ||
|
||
s := pb.LibraAuditOrder{ | ||
SQL: "CREATE TABLE `core_grai32ned` (`id` int unsigned AUTO_INCREMENT PRIMARY KEY COMMENT 'id',`username` varchar(50) NOT NULL COMMENT 'xxx')", | ||
DataBase: "test01", | ||
Source: &pb.Source{ | ||
Addr: "127.0.0.1", | ||
User: "root", | ||
Password: "xxxxx", | ||
Port: 3306, | ||
}, | ||
IsDML: false, | ||
Backup: true, | ||
Execute: true, | ||
WorkId: "xxxxx123", | ||
} | ||
ExDDLClient(&s) | ||
} | ||
|
||
func TestExDMLClient(t *testing.T) { | ||
|
||
s := pb.LibraAuditOrder{ | ||
SQL: "INSERT INTO `Yearning`.`b_test`(`id`,`idx`,`dateux`) VALUES(66732326,'321',NULL);", | ||
DataBase: "test01", | ||
Table: "b_test", | ||
Source: &pb.Source{ | ||
Addr: "127.0.0.1", | ||
User: "root", | ||
Password: "xxxxx", | ||
Port: 3306, | ||
}, | ||
IsDML: true, | ||
Backup: true, | ||
Execute: true, | ||
WorkId: "xxxxx1234", | ||
} | ||
ExDMLClient(&s) | ||
} | ||
|
||
func TestTsClient(t *testing.T) { | ||
|
||
s := pb.LibraAuditOrder{ | ||
SQL: "CREATE TABLE `core_grai32ned` (`id` int unsigned AUTO_INCREMENT PRIMARY KEY COMMENT 'id',`username` varchar(50) NOT NULL COMMENT 'xxx')", | ||
DataBase: "test01", | ||
Source: &pb.Source{ | ||
Addr: "127.0.0.1", | ||
User: "root", | ||
Password: "xxxxx", | ||
Port: 3306, | ||
}, | ||
Check: true, | ||
WorkId: "xxxxx123", | ||
} | ||
TsClient(&s) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
syntax = "proto3"; | ||
package proto; | ||
|
||
|
||
message LibraAuditOrder { | ||
string SQL = 1; | ||
string DataBase = 2; | ||
string Table = 3; | ||
bool Execute = 4; | ||
bool Check = 5; | ||
bool IsDML = 6; | ||
bool Backup = 7; | ||
Source source = 8; | ||
string WorkId = 9; | ||
|
||
} | ||
|
||
message Source { | ||
string Addr = 1; | ||
string User = 2; | ||
string Password = 3; | ||
int32 Port = 4; | ||
} | ||
|
||
message Record { | ||
string SQL = 1; | ||
int32 AffectRows = 2; | ||
string Status = 3; | ||
string Error = 4; | ||
int32 Level = 6; | ||
} | ||
|
||
message RecordSet { | ||
repeated Record record = 1; | ||
} | ||
|
||
message ExecOrder { | ||
string Message = 1; | ||
} | ||
|
||
service Juno { | ||
rpc OrderDeal (LibraAuditOrder) returns (RecordSet) {} | ||
rpc OrderDMLExec (LibraAuditOrder) returns (ExecOrder) {} | ||
rpc OrderDDLExec (LibraAuditOrder) returns (ExecOrder) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module Yearning-go | ||
|
||
go 1.12 | ||
|
||
require ( | ||
github.com/BurntSushi/toml v0.3.1 | ||
github.com/dgrijalva/jwt-go v3.2.0+incompatible | ||
github.com/go-sql-driver/mysql v1.4.1 | ||
github.com/jinzhu/gorm v1.9.8 | ||
github.com/jmoiron/sqlx v1.2.0 | ||
github.com/labstack/echo/v4 v4.1.5 | ||
github.com/pingcap/errors v0.11.4 | ||
github.com/pingcap/parser v0.0.0-20190531122720-f244897cfc07 | ||
github.com/pingcap/tidb v0.0.0-20190603053416-d71ce873bb23 | ||
github.com/prometheus/common v0.2.0 | ||
github.com/remyoudompheng/bigfft v0.0.0-20190512091148-babf20351dd7 // indirect | ||
github.com/siddontang/go-mysql v0.0.0-20190618002340-dbe0224ac097 | ||
golang.org/x/crypto v0.0.0-20190513172903-22d7a77e9e5f | ||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect | ||
gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect | ||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df | ||
gopkg.in/ldap.v3 v3.0.3 | ||
vitess.io/vitess v0.0.0-20190119075008-dbef792951a40d6ac55f4d58fe50c7ce8e4fc665 | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.