Skip to content

Commit 76d117f

Browse files
authored
Merge branch 'main' into add-max-concurrent-hashes
2 parents 60f1152 + 6021fbf commit 76d117f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+504
-1192
lines changed

.drone.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ services:
153153
MYSQL_DATABASE: test
154154

155155
- name: mysql8
156-
image: mysql:8.0
156+
image: mysql:8
157157
environment:
158158
MYSQL_ALLOW_EMPTY_PASSWORD: yes
159159
MYSQL_DATABASE: testgitea
@@ -319,7 +319,7 @@ trigger:
319319
services:
320320
- name: pgsql
321321
pull: default
322-
image: postgres:9.5
322+
image: postgres:10
323323
environment:
324324
POSTGRES_DB: test
325325
POSTGRES_PASSWORD: postgres
@@ -503,7 +503,7 @@ steps:
503503
pull: always
504504
image: techknowlogick/xgo:go-1.16.x
505505
commands:
506-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
506+
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
507507
- export PATH=$PATH:$GOPATH/bin
508508
- make release
509509
environment:
@@ -599,7 +599,7 @@ steps:
599599
pull: always
600600
image: techknowlogick/xgo:go-1.16.x
601601
commands:
602-
- curl -sL https://deb.nodesource.com/setup_14.x | bash - && apt-get install -y nodejs
602+
- curl -sL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
603603
- export PATH=$PATH:$GOPATH/bin
604604
- make release
605605
environment:

.github/pull_request_template.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Please check the following:
22

3-
1. Make sure you are targeting the `master` branch, pull requests on release branches are only allowed for bug fixes.
3+
1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for bug fixes.
44
2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/master/CONTRIBUTING.md
55
3. Describe what your pull request does and which issue you're targeting (if any)
66

Dockerfile.rootless

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RUN apk --no-cache add \
3535
ca-certificates \
3636
gettext \
3737
git \
38+
curl \
3839
gnupg
3940

4041
RUN addgroup \

cmd/serv.go

+4
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ func fail(userMessage, logMessage string, args ...interface{}) {
8181
}
8282
}
8383

84+
if len(logMessage) > 0 {
85+
_ = private.SSHLog(true, fmt.Sprintf(logMessage+": ", args...))
86+
}
87+
8488
os.Exit(1)
8589
}
8690

custom/conf/app.example.ini

+5
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,11 @@ ROUTER = console
446446
;ACCESS_LOG_TEMPLATE = {{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"
447447
;;
448448
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
449+
;;
450+
;; SSH log (Creates log from ssh git request)
451+
;;
452+
;ENABLE_SSH_LOG = false
453+
;;
449454
;; Other Settings
450455
;;
451456
;; Print Stacktraces with logs. (Rarely helpful.) Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "None"

docs/content/doc/advanced/config-cheat-sheet.en-us.md

+1
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,7 @@ Default templates for project boards:
658658
- `ROUTER`: **console**: The mode or name of the log the router should log to. (If you set this to `,` it will log to default gitea logger.)
659659
NB: You must have `DISABLE_ROUTER_LOG` set to `false` for this option to take effect. Configure each mode in per mode log subsections `\[log.modename.router\]`.
660660
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
661+
- `ENABLE_SSH_LOG`: **false**: save ssh log to log file
661662
- `ACCESS`: **file**: Logging mode for the access logger, use a comma to separate values. Configure each mode in per mode log subsections `\[log.modename.access\]`. By default the file mode will log to `$ROOT_PATH/access.log`. (If you set this to `,` it will log to the default gitea logger.)
662663
- `ACCESS_LOG_TEMPLATE`: **`{{.Ctx.RemoteAddr}} - {{.Identity}} {{.Start.Format "[02/Jan/2006:15:04:05 -0700]" }} "{{.Ctx.Req.Method}} {{.Ctx.Req.URL.RequestURI}} {{.Ctx.Req.Proto}}" {{.ResponseWriter.Status}} {{.ResponseWriter.Size}} "{{.Ctx.Req.Referer}}\" \"{{.Ctx.Req.UserAgent}}"`**: Sets the template used to create the access log.
663664
- The following variables are available:

docs/content/doc/installation/with-docker-rootless.en-us.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ services:
107107
+ - db
108108
+
109109
+ db:
110-
+ image: mysql:5.7
110+
+ image: mysql:8
111111
+ restart: always
112112
+ environment:
113113
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -148,7 +148,7 @@ services:
148148
+ - db
149149
+
150150
+ db:
151-
+ image: postgres:9.6
151+
+ image: postgres:13
152152
+ restart: always
153153
+ environment:
154154
+ - POSTGRES_USER=gitea

docs/content/doc/installation/with-docker.en-us.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ services:
137137
+ - db
138138
+
139139
+ db:
140-
+ image: mysql:5.7
140+
+ image: mysql:8
141141
+ restart: always
142142
+ environment:
143143
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -188,7 +188,7 @@ services:
188188
+ - db
189189
+
190190
+ db:
191-
+ image: postgres:9.6
191+
+ image: postgres:13
192192
+ restart: always
193193
+ environment:
194194
+ - POSTGRES_USER=gitea

docs/content/doc/installation/with-docker.zh-cn.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ services:
122122
+ - db
123123
+
124124
+ db:
125-
+ image: mysql:5.7
125+
+ image: mysql:8
126126
+ restart: always
127127
+ environment:
128128
+ - MYSQL_ROOT_PASSWORD=gitea
@@ -172,7 +172,7 @@ services:
172172
+ - db
173173
+
174174
+ db:
175-
+ image: postgres:9.6
175+
+ image: postgres:13
176176
+ restart: always
177177
+ environment:
178178
+ - POSTGRES_USER=gitea

integrations/README_ZH.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ make test-sqlite
2626
## 如何使用 mysql 数据库进行集成测试
2727
首先在docker容器里部署一个 mysql 数据库
2828
```
29-
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:5.7 #(just ctrl-c to stop db and clean the container)
29+
docker run -e "MYSQL_DATABASE=test" -e "MYSQL_ALLOW_EMPTY_PASSWORD=yes" -p 3306:3306 --rm --name mysql mysql:8 #(just ctrl-c to stop db and clean the container)
3030
```
3131
之后便可以基于这个数据库进行集成测试
3232
```
@@ -36,7 +36,7 @@ TEST_MYSQL_HOST=localhost:3306 TEST_MYSQL_DBNAME=test TEST_MYSQL_USERNAME=root T
3636
## 如何使用 pgsql 数据库进行集成测试
3737
同上,首先在 docker 容器里部署一个 pgsql 数据库
3838
```
39-
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:9.5 #(just ctrl-c to stop db and clean the container)
39+
docker run -e "POSTGRES_DB=test" -p 5432:5432 --rm --name pgsql postgres:13 #(just ctrl-c to stop db and clean the container)
4040
```
4141
之后便可以基于这个数据库进行集成测试
4242
```

models/avatar.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const DefaultAvatarSize = -1
4444
const DefaultAvatarPixelSize = 28
4545

4646
// AvatarRenderedSizeFactor is the factor by which the default size is increased for finer rendering
47-
const AvatarRenderedSizeFactor = 2
47+
const AvatarRenderedSizeFactor = 4
4848

4949
// HashEmail hashes email address to MD5 string.
5050
// https://en.gravatar.com/site/implement/hash/

modules/markup/markdown/goldmark.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,19 @@ func (r *HTMLRenderer) renderTaskCheckBoxListItem(w util.BufWriter, source []byt
384384
} else {
385385
_, _ = w.WriteString("<li>")
386386
}
387-
end := ">"
388-
if r.XHTML {
389-
end = " />"
387+
_, _ = w.WriteString(`<input type="checkbox" disabled=""`)
388+
segments := node.FirstChild().Lines()
389+
if segments.Len() > 0 {
390+
segment := segments.At(0)
391+
_, _ = w.WriteString(fmt.Sprintf(` data-source-position="%d"`, segment.Start))
390392
}
391-
var err error
392393
if n.IsChecked {
393-
_, err = w.WriteString(`<input type="checkbox" disabled="" checked=""` + end)
394-
} else {
395-
_, err = w.WriteString(`<input type="checkbox" disabled=""` + end)
394+
_, _ = w.WriteString(` checked=""`)
396395
}
397-
if err != nil {
398-
return ast.WalkStop, err
396+
if r.XHTML {
397+
_, _ = w.WriteString(` />`)
398+
} else {
399+
_ = w.WriteByte('>')
399400
}
400401
fc := n.FirstChild()
401402
if fc != nil {

modules/markup/markdown/markdown_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ func testAnswers(baseURLContent, baseURLImages string) []string {
166166
<p>(from <a href="https://www.markdownguide.org/extended-syntax/" rel="nofollow">https://www.markdownguide.org/extended-syntax/</a>)</p>
167167
<h3 id="user-content-checkboxes">Checkboxes</h3>
168168
<ul>
169-
<li class="task-list-item"><input type="checkbox" disabled=""/>unchecked</li>
170-
<li class="task-list-item"><input type="checkbox" disabled="" checked=""/>checked</li>
171-
<li class="task-list-item"><input type="checkbox" disabled=""/>still unchecked</li>
169+
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="434"/>unchecked</li>
170+
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="450" checked=""/>checked</li>
171+
<li class="task-list-item"><input type="checkbox" disabled="" data-source-position="464"/>still unchecked</li>
172172
</ul>
173173
<h3 id="user-content-definition-list">Definition list</h3>
174174
<dl>

modules/markup/sanitizer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ReplaceSanitizer() {
4343

4444
// Checkboxes
4545
sanitizer.policy.AllowAttrs("type").Matching(regexp.MustCompile(`^checkbox$`)).OnElements("input")
46-
sanitizer.policy.AllowAttrs("checked", "disabled").OnElements("input")
46+
sanitizer.policy.AllowAttrs("checked", "disabled", "data-source-position").OnElements("input")
4747

4848
// Custom URL-Schemes
4949
if len(setting.Markdown.CustomURLSchemes) > 0 {

modules/private/hook.go

+31
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package private
66

77
import (
8+
"encoding/json"
89
"fmt"
910
"net/http"
1011
"net/url"
@@ -57,6 +58,12 @@ type HookOptions struct {
5758
IsDeployKey bool
5859
}
5960

61+
// SSHLogOption ssh log options
62+
type SSHLogOption struct {
63+
IsError bool
64+
Message string
65+
}
66+
6067
// HookPostReceiveResult represents an individual result from PostReceive
6168
type HookPostReceiveResult struct {
6269
Results []HookPostReceiveBranchResult
@@ -146,3 +153,27 @@ func SetDefaultBranch(ownerName, repoName, branch string) error {
146153
}
147154
return nil
148155
}
156+
157+
// SSHLog sends ssh error log response
158+
func SSHLog(isErr bool, msg string) error {
159+
reqURL := setting.LocalURL + "api/internal/ssh/log"
160+
req := newInternalRequest(reqURL, "POST")
161+
req = req.Header("Content-Type", "application/json")
162+
163+
jsonBytes, _ := json.Marshal(&SSHLogOption{
164+
IsError: isErr,
165+
Message: msg,
166+
})
167+
req.Body(jsonBytes)
168+
169+
req.SetTimeout(60*time.Second, 60*time.Second)
170+
resp, err := req.Response()
171+
if err != nil {
172+
return fmt.Errorf("unable to contact gitea: %v", err)
173+
}
174+
defer resp.Body.Close()
175+
if resp.StatusCode != http.StatusOK {
176+
return fmt.Errorf("Error returned from gitea: %v", decodeJSONError(resp).Err)
177+
}
178+
return nil
179+
}

modules/repository/commits_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ func TestPushCommits_AvatarLink(t *testing.T) {
112112
pushCommits.Len = len(pushCommits.Commits)
113113

114114
assert.Equal(t,
115-
"https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=56",
115+
"https://secure.gravatar.com/avatar/ab53a2911ddf9b4817ac01ddcd3d975f?d=identicon&s=112",
116116
pushCommits.AvatarLink("[email protected]"))
117117

118118
assert.Equal(t,
119119
"https://secure.gravatar.com/avatar/"+
120120
fmt.Sprintf("%x", md5.Sum([]byte("[email protected]")))+
121-
"?d=identicon&s=56",
121+
"?d=identicon&s=112",
122122
pushCommits.AvatarLink("[email protected]"))
123123
}
124124

modules/setting/log.go

+1
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ func newLogService() {
287287

288288
options := newDefaultLogOptions()
289289
options.bufferLength = Cfg.Section("log").Key("BUFFER_LEN").MustInt64(10000)
290+
EnableSSHLog = Cfg.Section("log").Key("ENABLE_SSH_LOG").MustBool(false)
290291

291292
description := LogDescription{
292293
Name: log.DEFAULT,

modules/setting/setting.go

+1
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ var (
320320
DisableRouterLog bool
321321
RouterLogLevel log.Level
322322
EnableAccessLog bool
323+
EnableSSHLog bool
323324
AccessLogTemplate string
324325
EnableXORMLog bool
325326

options/locale/locale_cs-CZ.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2225,7 +2225,6 @@ auths.host=Server
22252225
auths.port=Port
22262226
auths.bind_dn=Připojení DN
22272227
auths.bind_password=Heslo připojení
2228-
auths.bind_password_helper=Upozornění: Toto heslo je ukládáno v nešifrované podobě. Použijte účet pouze pro čtení, pokud je to možné.
22292228
auths.user_base=Výchozí bod hledání uživatelů
22302229
auths.user_dn=DN uživatele
22312230
auths.attribute_username=Atribut uživatelského jména

options/locale/locale_de-DE.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2278,7 +2278,6 @@ auths.host=Host
22782278
auths.port=Port
22792279
auths.bind_dn=DN binden
22802280
auths.bind_password=Passwort binden
2281-
auths.bind_password_helper=Achtung: Das Passwort wird im Klartext gespeichert. Benutze, wenn möglich, einen Account, der nur über Lesezugriff verfügt.
22822281
auths.user_base=Basis für Benutzersuche
22832282
auths.user_dn=Benutzer-DN
22842283
auths.attribute_username=Benutzernamens-Attribut

options/locale/locale_es-ES.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,6 @@ auths.host=Servidor
22822282
auths.port=Puerto
22832283
auths.bind_dn=Bind DN
22842284
auths.bind_password=Contraseña Bind
2285-
auths.bind_password_helper=Advertencia: Esta contraseña se almacena en texto plano. Utilice una cuenta de sólo lectura si es posible.
22862285
auths.user_base=Base de búsqueda de usuarios
22872286
auths.user_dn=DN de Usuario
22882287
auths.attribute_username=Atributo nombre de usuario

options/locale/locale_fa-IR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,6 @@ auths.host=میزبان
18961896
auths.port=درگاه (پورت)
18971897
auths.bind_dn=DN متصل شده
18981898
auths.bind_password=اتصال گذرواژه
1899-
auths.bind_password_helper=هشدار: این گذرواژه به صورت متن خام ذخیره می شود. استفاده حساب های کاربری فقط-خواندنی امکان پذیر هست.
19001899
auths.user_base=پایگاه جستجوی کاربر
19011900
auths.user_dn=کاربر DN
19021901
auths.attribute_username=ویژگی نام کاربری

options/locale/locale_fr-FR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2222,7 +2222,6 @@ auths.host=Hôte
22222222
auths.port=Port
22232223
auths.bind_dn=Bind DN
22242224
auths.bind_password=Bind mot de passe
2225-
auths.bind_password_helper=Attention: ce mot de passe est stocké en clair. Veuillez utiliser, si possible, un compte avec des droits limités en lecture seule.
22262225
auths.user_base=Utilisateur Search Base
22272226
auths.user_dn=Utilisateur DN
22282227
auths.attribute_username=Attribut nom d'utilisateur

options/locale/locale_hu-HU.ini

-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,6 @@ auths.host=Kiszolgáló
14951495
auths.port=Port
14961496
auths.bind_dn=Bind DN
14971497
auths.bind_password=Bind Jelszó
1498-
auths.bind_password_helper=Figyelem: Ez a jelszó egyszerű szövegben van tárolva. Ha lehetséges használjon csak olvasható fiókot.
14991498
auths.user_base=Felhasználókeresés alapja (BaseDN)
15001499
auths.user_dn=Felhasználói DN
15011500
auths.attribute_username=Felhasználónév attribútum

options/locale/locale_it-IT.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,6 @@ auths.host=Host
20972097
auths.port=Porta
20982098
auths.bind_dn=Binda DN
20992099
auths.bind_password=Binda Password
2100-
auths.bind_password_helper=Attenzione: La password è memorizzata in testo normale. Se possibile, utilizzare un account di sola lettura.
21012100
auths.user_base=Base ricerca utente
21022101
auths.user_dn=DN dell'utente
21032102
auths.attribute_username=Attributo nome utente

options/locale/locale_ja-JP.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2282,7 +2282,6 @@ auths.host=ホスト
22822282
auths.port=ポート
22832283
auths.bind_dn=バインドDN
22842284
auths.bind_password=バインドパスワード
2285-
auths.bind_password_helper=警告: このパスワードはプレーンテキストで保存されます。 可能であれば読み取り専用アカウントを使用してください。
22862285
auths.user_base=ユーザー検索ベース
22872286
auths.user_dn=ユーザーDN
22882287
auths.attribute_username=ユーザー名

options/locale/locale_lv-LV.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,6 @@ auths.host=Resursdators
22482248
auths.port=Ports
22492249
auths.bind_dn=Saistīšanas DN
22502250
auths.bind_password=Saistīšanas parole
2251-
auths.bind_password_helper=Brīdinājums: Šī parole tiks glabāta nešifrētā veidā. Ieteicams izmantot kontu ar tikai lasīšanas tiesībām.
22522251
auths.user_base=Lietotāja pamatnosacījumi
22532252
auths.user_dn=Lietotāja DN
22542253
auths.attribute_username=Lietotājvārda atribūts

options/locale/locale_nl-NL.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,6 @@ auths.host=Host
21182118
auths.port=Poort
21192119
auths.bind_dn=Binden DN
21202120
auths.bind_password=Bind wachtwoord
2121-
auths.bind_password_helper=Waarschuwing: Dit wachtwoord wordt opgeslagen in platte tekst. Indien mogelijk gebruik dan een alleen-lezen account.
21222121
auths.user_base=User Search Base
21232122
auths.user_dn=User DN
21242123
auths.attribute_username=Gebruikersnaam attribuut

options/locale/locale_pl-PL.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2027,7 +2027,6 @@ auths.host=Serwer
20272027
auths.port=Port
20282028
auths.bind_dn=DN powiązania
20292029
auths.bind_password=Hasło Bind
2030-
auths.bind_password_helper=Uwaga: To hasło będzie przechowywane w czystym tekście. Użyj konta "tylko do odczytu", jeśli to możliwe.
20312030
auths.user_base=Baza wyszukiwania
20322031
auths.user_dn=DN użytkownika
20332032
auths.attribute_username=Atrybut nazwy użytkownika

options/locale/locale_pt-BR.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,6 @@ auths.host=Servidor
20162016
auths.port=Porta
20172017
auths.bind_dn=Vincular DN
20182018
auths.bind_password=Vincular senha
2019-
auths.bind_password_helper=Atenção: Esta senha é armazenada em texto sem formatação. Se possível, use uma conta de somente leitura.
20202019
auths.user_base=Base de pesquisa do usuário
20212020
auths.user_dn=Usuário do DN
20222021
auths.attribute_username=Atributo nome de usuário

options/locale/locale_pt-PT.ini

-1
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,6 @@ auths.host=Servidor
22692269
auths.port=Porto
22702270
auths.bind_dn=Vincular DN
22712271
auths.bind_password=Vincular senha
2272-
auths.bind_password_helper=Atenção: Esta senha é armazenada em texto simples. Use uma conta só de leitura, se possível.
22732272
auths.user_base=Base de pesquisa de utilizador
22742273
auths.user_dn=DN do utilizador
22752274
auths.attribute_username=Atributo do nome de utilizador

0 commit comments

Comments
 (0)