Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复API6没有根据admin值插入到数据库的问题 #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions OWASPApiTop10/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ gin的session在知道secret之后就可以任意伪造

`/v2/register`

前端请求有隐藏的admin标签,可以手动加上,admin为true可以注册为管理员权限用户
前端请求有admin字段,可以手动修改,admin为true可以注册为管理员权限用户

username=123&password=123&admin=false
`{"username": "123","password": "123","email": "[email protected]","admin": "true"}`

### API7: Security misconfiguration [✔︎]

Expand Down
4 changes: 2 additions & 2 deletions OWASPApiTop10/docker/src/api/API6_MassAssignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func Register(c *gin.Context) {
return
}
//向数据库插入用户
sql1 := "INSERT INTO user (token,username,password,email) VALUES (?,?,?,?);"
res1, err1 := db.Exec(sql1, Token(), request.Username, MD5(request.Password), request.Email)
sql1 := "INSERT INTO user (token,username,password,email,admin) VALUES (?,?,?,?,?);"
res1, err1 := db.Exec(sql1, Token(), request.Username, MD5(request.Password), request.Email, func() int{if request.Admin=="true"{return 1}else{return 0}}())
if err1 != nil {
fmt.Println("register insert error: ", err1)
c.JSON(400, gin.H{"code": 400, "msg": "Register error!"})
Expand Down
4 changes: 2 additions & 2 deletions OWASPApiTop10/source/api/API6_MassAssignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func Register(c *gin.Context) {
return
}
//向数据库插入用户
sql1 := "INSERT INTO user (token,username,password,email) VALUES (?,?,?,?);"
res1, err1 := db.Exec(sql1, Token(), request.Username, MD5(request.Password), request.Email)
sql1 := "INSERT INTO user (token,username,password,email,admin) VALUES (?,?,?,?,?);"
res1, err1 := db.Exec(sql1, Token(), request.Username, MD5(request.Password), request.Email, func() int{if request.Admin=="true"{return 1}else{return 0}}())
if err1 != nil {
fmt.Println("register insert error: ", err1)
c.JSON(400, gin.H{"code": 400, "msg": "Register error!"})
Expand Down