Skip to content

Commit cc7e1b8

Browse files
committed
Merge remote-tracking branch 'origin/main' into migration-credentials
2 parents 5661c58 + 3aaf648 commit cc7e1b8

File tree

86 files changed

+645
-1332
lines changed

Some content is hidden

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

86 files changed

+645
-1332
lines changed

Diff for: .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:

Diff for: .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

Diff for: 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 \

Diff for: 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

Diff for: custom/conf/app.example.ini

+5
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,11 @@ ROUTER = console
444444
;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}}"
445445
;;
446446
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
447+
;;
448+
;; SSH log (Creates log from ssh git request)
449+
;;
450+
;ENABLE_SSH_LOG = false
451+
;;
447452
;; Other Settings
448453
;;
449454
;; Print Stacktraces with logs. (Rarely helpful.) Either "Trace", "Debug", "Info", "Warn", "Error", "Critical", default is "None"

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

+1
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ Default templates for project boards:
657657
- `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.)
658658
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\]`.
659659
- `ENABLE_ACCESS_LOG`: **false**: Creates an access.log in NCSA common log format, or as per the following template
660+
- `ENABLE_SSH_LOG`: **false**: save ssh log to log file
660661
- `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.)
661662
- `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.
662663
- The following variables are available:

Diff for: docs/content/doc/developers/hacking-on-gitea.en-us.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ See `make help` for all available `make` targets. Also see [`.drone.yml`](https:
127127

128128
## Building continuously
129129

130-
To run and continously rebuild when source files change:
130+
To run and continuously rebuild when source files change:
131131

132132
```bash
133133
make watch
@@ -216,7 +216,7 @@ You should validate your generated Swagger file and spell-check it with:
216216
make swagger-validate misspell-check
217217
```
218218

219-
You should commit the changed swagger JSON file. The continous integration
219+
You should commit the changed swagger JSON file. The continuous integration
220220
server will check that this has been done using:
221221

222222
```bash
@@ -315,7 +315,7 @@ branches as we will need to update it to main before merging and/or may be
315315
able to help fix issues directly.
316316

317317
Any PR requires two approvals from the Gitea maintainers and needs to pass the
318-
continous integration. Take a look at our
318+
continuous integration. Take a look at our
319319
[`CONTRIBUTING.md`](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md)
320320
document.
321321

Diff for: docs/content/doc/features/authentication.en-us.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ Adds the following fields:
8888
- Bind Password (optional)
8989

9090
- The password for the Bind DN specified above, if any. _Note: The password
91-
is stored in plaintext at the server. As such, ensure that the Bind DN
92-
has as few privileges as possible._
91+
is stored encrypted with the SECRET_KEY on the server. It is still recommended
92+
to ensure that the Bind DN has as few privileges as possible._
9393

9494
- User Search Base **(required)**
9595

Diff for: 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

Diff for: 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

Diff for: 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

Diff for: 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
```

Diff for: 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/

Diff for: models/login_source.go

+16-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"code.gitea.io/gitea/modules/auth/oauth2"
1919
"code.gitea.io/gitea/modules/auth/pam"
2020
"code.gitea.io/gitea/modules/log"
21+
"code.gitea.io/gitea/modules/secret"
2122
"code.gitea.io/gitea/modules/setting"
2223
"code.gitea.io/gitea/modules/timeutil"
2324
"code.gitea.io/gitea/modules/util"
@@ -77,11 +78,25 @@ type LDAPConfig struct {
7778
// FromDB fills up a LDAPConfig from serialized format.
7879
func (cfg *LDAPConfig) FromDB(bs []byte) error {
7980
json := jsoniter.ConfigCompatibleWithStandardLibrary
80-
return json.Unmarshal(bs, &cfg)
81+
err := json.Unmarshal(bs, &cfg)
82+
if err != nil {
83+
return err
84+
}
85+
if cfg.BindPasswordEncrypt != "" {
86+
cfg.BindPassword, err = secret.DecryptSecret(setting.SecretKey, cfg.BindPasswordEncrypt)
87+
cfg.BindPasswordEncrypt = ""
88+
}
89+
return err
8190
}
8291

8392
// ToDB exports a LDAPConfig to a serialized format.
8493
func (cfg *LDAPConfig) ToDB() ([]byte, error) {
94+
var err error
95+
cfg.BindPasswordEncrypt, err = secret.EncryptSecret(setting.SecretKey, cfg.BindPassword)
96+
if err != nil {
97+
return nil, err
98+
}
99+
cfg.BindPassword = ""
85100
json := jsoniter.ConfigCompatibleWithStandardLibrary
86101
return json.Marshal(cfg)
87102
}

Diff for: modules/auth/ldap/ldap.go

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ type Source struct {
3535
SecurityProtocol SecurityProtocol
3636
SkipVerify bool
3737
BindDN string // DN to bind with
38+
BindPasswordEncrypt string // Encrypted Bind BN password
3839
BindPassword string // Bind DN password
3940
UserBase string // Base search path for users
4041
UserDN string // Template for the DN of the user for simple auth

Diff for: 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 {

Diff for: 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>

Diff for: 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 {

Diff for: 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+
}

Diff for: 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("user2@example.com"))
117117

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

Diff for: modules/setting/indexer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ var (
5151
IssueConnStr: "",
5252
IssueIndexerName: "gitea_issues",
5353
IssueQueueType: LevelQueueType,
54-
IssueQueueDir: "indexers/issues.queue",
54+
IssueQueueDir: "queues/common",
5555
IssueQueueConnStr: "",
5656
IssueQueueBatchNumber: 20,
5757

@@ -76,7 +76,7 @@ func newIndexerService() {
7676
Indexer.IssueIndexerName = sec.Key("ISSUE_INDEXER_NAME").MustString(Indexer.IssueIndexerName)
7777

7878
Indexer.IssueQueueType = sec.Key("ISSUE_INDEXER_QUEUE_TYPE").MustString(LevelQueueType)
79-
Indexer.IssueQueueDir = sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(path.Join(AppDataPath, "indexers/issues.queue"))
79+
Indexer.IssueQueueDir = sec.Key("ISSUE_INDEXER_QUEUE_DIR").MustString(path.Join(AppDataPath, "queues/common"))
8080
Indexer.IssueQueueConnStr = sec.Key("ISSUE_INDEXER_QUEUE_CONN_STR").MustString("")
8181
Indexer.IssueQueueBatchNumber = sec.Key("ISSUE_INDEXER_QUEUE_BATCH_NUMBER").MustInt(20)
8282

Diff for: 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,

0 commit comments

Comments
 (0)