Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
CookieYe committed Aug 13, 2019
1 parent 173d537 commit 2b6baa3
Show file tree
Hide file tree
Showing 51 changed files with 5,616 additions and 3 deletions.
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Expand Down Expand Up @@ -643,7 +643,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
along with this program. If not, see <http://www.gnu.org/licenses/>.

Also add information on how to contact you by electronic and paper mail.

Expand All @@ -658,4 +658,4 @@ specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.
<http://www.gnu.org/licenses/>.
107 changes: 107 additions & 0 deletions README.md
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审核平台
![LICENSE](https://img.shields.io/badge/license-AGPL%20-blue.svg)
![](https://img.shields.io/badge/build-release-brightgreen.svg)  
![](https://img.shields.io/badge/version-v2.0.0-brightgreen.svg)  

##### 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



![login](img/login.png)


- Dashboard

![](img/dash.png)

- 审核

![](img/audit.png)

- SQL语法高亮及自动补全

![](img/highlight.png)

- 查询

![](img/query.png)

- 细粒度的权限分配
![](img/per.png)

- 我的工单
![](img/myorder.png)


## License

- AGPL v3

任何二次开发及二次开源项目请严格遵守相应开源许可

2019 © Henry Yee


11 changes: 11 additions & 0 deletions conf.toml.template
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 added develop/Juno-1.0.0.linux-amd64.tar.gz
Binary file not shown.
82 changes: 82 additions & 0 deletions develop/example/client/client.go
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) //影响行数
}
}



62 changes: 62 additions & 0 deletions develop/example/client/client_test.go
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)
}
45 changes: 45 additions & 0 deletions develop/example/proto/detection.proto
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) {}
}
24 changes: 24 additions & 0 deletions go.mod
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
)
Binary file added img/PER.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/audit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/dash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/highlight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/login.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/myorder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/query.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 2b6baa3

Please sign in to comment.