Affected by GO-2022-0369
and 22 other vulnerabilities
GO-2022-0369: Gogs vulnerable to improper PAM authorization handling in gogs.io/gogs
GO-2022-0473: Cross site scripting via cookies in gogs in gogs.io/gogs
GO-2022-0483: Cross-site Scripting vulnerability in repository issue list in Gogs in gogs.io/gogs
GO-2022-0554: Unrestricted Upload of File with Dangerous Type in Gogs in gogs.io/gogs
GO-2022-0556: OS Command Injection in file editor in Gogs in gogs.io/gogs
GO-2022-0562: Path Traversal in Git HTTP endpoints in Gogs in gogs.io/gogs
GO-2022-0570: Path Traversal in file editor on Windows in Gogs in gogs.io/gogs
GO-2022-0583: Server-Side Request Forgery in gogs webhook in gogs.io/gogs
GO-2022-1060: Gogs vulnerable to Cross-site Scripting in gogs.io/gogs
GO-2023-1596: Gogs OS Command Injection vulnerability in gogs.io/gogs
GO-2023-1971: Gogs and Gitea SSRF Vulnerability in code.gitea.io/gitea
GO-2024-3275: Unpatched Remote Code Execution in Gogs in gogs.io/gogs
GO-2024-3355: Remote Command Execution in file editing in gogs in gogs.io/gogs
GO-2024-3356: Path Traversal in file update API in gogs in gogs.io/gogs
package
Version:
v0.6.15
Opens a new window with list of versions in this module.
Published: Sep 26, 2015
License: MIT
Opens a new window with license information.
Imports: 4
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
一个基于hash值生成随机图像的包。
关于identicon并没有统一的标准,一般用于在用户注册时,
取用户的邮箱或是访问IP等数据(也可以是其它任何数据),
进行hash运算,之后根据hash数据,产生一张图像,
这样即可以为用户产生一张独特的头像,又不会泄漏用户的隐藏。
在identicon中,把图像分成以下九个部分:
-------------
| 1 | 2 | 3 |
-------------
| 4 | 5 | 6 |
-------------
| 7 | 8 | 9 |
-------------
其中1、3、9、7为不同角度(依次增加90度)的同一张图片,
2、6、8、4也是如此,这样可以保持图像是对称的,比较美观。
5则单独使用一张图片。
// 根据用户访问的IP,为其生成一张头像
img, _ := identicon.Make(128, color.NRGBA{},color.NRGBA{}, []byte("192.168.1.1"))
fi, _ := os.Create("/tmp/u1.png")
png.Encode(fi, img)
fi.Close()
// 或者
ii, _ := identicon.New(128, color.NRGBA{}, color.NRGBA{}, color.NRGBA{})
img := ii.Make([]byte("192.168.1.1"))
img = ii.Make([]byte("192.168.1.2"))
NOTE: go test 会在当前目录的testdata文件夹下产生大量的随机图片。
要运行测试,必须保证该文件夹是存在的,且有相应的写入权限。
根据data数据产生一张唯一性的头像图片。
size 头像的大小。
back, fore头像的背景和前景色。
type Identicon struct {
}
Identicon 用于产生统一尺寸的头像。
可以根据用户提供的数据,经过一定的算法,自动产生相应的图案和颜色。
声明一个Identicon实例。
size表示整个头像的大小。
back表示前景色。
fore表示所有可能的前景色,会为每个图像随机挑选一个作为其前景色。
NOTE:前景色不要与背景色太相近。
Source Files
¶
Click to show internal directories.
Click to hide internal directories.