Skip to content

Commit 2dbef35

Browse files
committed
Merge remote-tracking branch 'giteaoffical/main'
* giteaoffical/main: Move eslintrc/stylelintrc to non-deprecated extensions (go-gitea#20110) Allow manager logging to set SQL (go-gitea#20064) Replace pubkey with privkey in keys_ssh.tmpl (go-gitea#20112) Update security information to add a public gpg key to make sending encrypted message possible (go-gitea#20117)
2 parents 990344e + 48ef12b commit 2dbef35

File tree

11 files changed

+149
-13
lines changed

11 files changed

+149
-13
lines changed
File renamed without changes.

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
* text=auto eol=lf
22
*.tmpl linguist-language=Handlebars
3-
/.eslintrc linguist-language=YAML
4-
/.stylelintrc linguist-language=YAML
53
/public/vendor/** -text -eol linguist-vendored
64
/vendor/** -text -eol linguist-vendored
75
/web_src/fomantic/build/** linguist-generated
File renamed without changes.

SECURITY.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,76 @@
33
The Gitea maintainers take security seriously.
44
If you discover a security issue, please bring it to their attention right away!
55

6-
### Reporting a Vulnerability
6+
## Reporting a Vulnerability
77

88
Please **DO NOT** file a public issue, instead send your report privately to `[email protected]`.
99

10+
## Protecting Security Information
11+
12+
Due to the sensitive nature of security information, you can use below GPG public key encrypt your mail body.
13+
14+
The PGP key is valid until June 24, 2024.
15+
Key ID: 6FCD2D5B
16+
Key Type: RSA
17+
Expires: 6/24/2024
18+
Key Size: 4096/4096
19+
Fingerprint: 3DE0 3D1E 144A 7F06 9359 99DC AAFD 2381 6FCD 2D5B
20+
UserID: Gitea Security <[email protected]>
21+
22+
```
23+
-----BEGIN PGP PUBLIC KEY BLOCK-----
24+
25+
mQINBGK1Z/4BEADFMqXA9DeeChmSxUjF0Be5sq99ZUhgrZjcN/wOzz0wuCJZC0l8
26+
4uC+d6mfv7JpJYlzYzOK97/x5UguKHkYNZ6mm1G9KHaXmoIBDLKDzfPdJopVNv2r
27+
OajijaE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od4a64JyNIEo4CTTSPVeWd7njsGqli2U3A4xL2CcyYvt
59+
D/MWcMBGEoLSNTswwKdom4FaJpn5KThnK/T0bQcmJblJhoCtppXisbexZnCpuS0x
60+
Zdlm2T14KJ3LABEBAAGJAjwEGAEIACYWIQQ94D0eFEp/BpNZmdyq/SOBb80tWwUC
61+
YrVn/gIbDAUJA8JnAAAKCRCq/SOBb80tWyTBD/9AGpW6QoDF7zYjHAozH9S5RGCA
62+
Y7E82dG/0xmFUwPprAG0BKmmgU6TiipyVGmKIXGYYYU92pMnbvXkYQMoa+WJNncN
63+
D3fY52UeXeffTf4cFpStlzi9xgYtOLhFamzYu/4xhkjOX+xhOSXscCiFRyT8cF3B
64+
O6c5BHU+Zj0/rGPgOyPUbx7l7B9MubB/41nNX35k08e+8T3wtWDb4XF+15HnRfva
65+
6fblO8wgU25Orv2Rm1jnKGa9DxJ8nE40IMrqDapENtDuL+zKJsvR0+ptWvEyL56U
66+
GtJJG5un6mXiLKuRQT0DEv4MdZRHDgDstDnqcbEiazVEbUuvhZZob6lRY2A19m1+
67+
7zfnDxkhqCA1RCnv4fdvcPdCMMFHwLpdhjgW0aI/uwgwrvsEz5+JRlnLvdQHlPAg
68+
q7l2fGcBSpz9U0ayyfRPjPntsNCtZl1UDxGLeciPkZhyG84zEWQbk/j52ZpRN+Ik
69+
ALpRLa8RBFmFSmXDUmwQrmm1EmARyQXwweKU31hf8ZGbCp2lPuRYm1LuGiirXSVP
70+
GysjRAJgW+VRpBKOzFQoUAUbReVWSaCwT8s17THzf71DdDb6CTj31jMLLYWwBpA/
71+
i73DgobDZMIGEZZC1EKqza8eh11xfyHFzGec03tbh+lIen+5IiRtWiEWkDS9ll0G
72+
zgS/ZdziCvdAutqnGA==
73+
=gZWO
74+
-----END PGP PUBLIC KEY BLOCK-----
75+
76+
```
77+
1078
Security reports are greatly appreciated and we will publicly thank you for it, although we keep your name confidential if you request it.

cmd/manager_logging.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,18 @@ var (
174174
Action: runAddSMTPLogger,
175175
},
176176
},
177+
}, {
178+
Name: "log-sql",
179+
Usage: "Set LogSQL",
180+
Flags: []cli.Flag{
181+
cli.BoolFlag{
182+
Name: "debug",
183+
}, cli.BoolFlag{
184+
Name: "off",
185+
Usage: "Switch off SQL logging",
186+
},
187+
},
188+
Action: runSetLogSQL,
177189
},
178190
},
179191
}
@@ -381,3 +393,18 @@ func runReleaseReopenLogging(c *cli.Context) error {
381393
fmt.Fprintln(os.Stdout, msg)
382394
return nil
383395
}
396+
397+
func runSetLogSQL(c *cli.Context) error {
398+
ctx, cancel := installSignals()
399+
defer cancel()
400+
setup("manager", c.Bool("debug"))
401+
402+
statusCode, msg := private.SetLogSQL(ctx, !c.Bool("off"))
403+
switch statusCode {
404+
case http.StatusInternalServerError:
405+
return fail("InternalServerError", msg)
406+
}
407+
408+
fmt.Fprintln(os.Stdout, msg)
409+
return nil
410+
}

models/db/engine.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,12 @@ func GetMaxID(beanOrTableName interface{}) (maxID int64, err error) {
287287
_, err = x.Select("MAX(id)").Table(beanOrTableName).Get(&maxID)
288288
return maxID, err
289289
}
290+
291+
func SetLogSQL(ctx context.Context, on bool) {
292+
e := GetEngine(ctx)
293+
if x, ok := e.(*xorm.Engine); ok {
294+
x.ShowSQL(on)
295+
} else if sess, ok := e.(*xorm.Session); ok {
296+
sess.Engine().ShowSQL(on)
297+
}
298+
}

models/db/log.go

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package db
66

77
import (
88
"fmt"
9+
"sync/atomic"
910

1011
"code.gitea.io/gitea/modules/log"
1112

@@ -14,15 +15,19 @@ import (
1415

1516
// XORMLogBridge a logger bridge from Logger to xorm
1617
type XORMLogBridge struct {
17-
showSQL bool
18-
logger log.Logger
18+
showSQLint *int32
19+
logger log.Logger
1920
}
2021

2122
// NewXORMLogger inits a log bridge for xorm
2223
func NewXORMLogger(showSQL bool) xormlog.Logger {
24+
showSQLint := int32(0)
25+
if showSQL {
26+
showSQLint = 1
27+
}
2328
return &XORMLogBridge{
24-
showSQL: showSQL,
25-
logger: log.GetLogger("xorm"),
29+
showSQLint: &showSQLint,
30+
logger: log.GetLogger("xorm"),
2631
}
2732
}
2833

@@ -94,14 +99,16 @@ func (l *XORMLogBridge) SetLevel(lvl xormlog.LogLevel) {
9499

95100
// ShowSQL set if record SQL
96101
func (l *XORMLogBridge) ShowSQL(show ...bool) {
97-
if len(show) > 0 {
98-
l.showSQL = show[0]
99-
} else {
100-
l.showSQL = true
102+
showSQL := int32(1)
103+
if len(show) > 0 && !show[0] {
104+
showSQL = 0
101105
}
106+
atomic.StoreInt32(l.showSQLint, showSQL)
102107
}
103108

104109
// IsShowSQL if record SQL
105110
func (l *XORMLogBridge) IsShowSQL() bool {
106-
return l.showSQL
111+
showSQL := atomic.LoadInt32(l.showSQLint)
112+
113+
return showSQL == 1
107114
}

modules/private/manager.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"io"
1111
"net/http"
1212
"net/url"
13+
"strconv"
1314
"time"
1415

1516
"code.gitea.io/gitea/modules/json"
@@ -139,6 +140,24 @@ func ReleaseReopenLogging(ctx context.Context) (int, string) {
139140
return http.StatusOK, "Logging Restarted"
140141
}
141142

143+
// SetLogSQL sets database logging
144+
func SetLogSQL(ctx context.Context, on bool) (int, string) {
145+
reqURL := setting.LocalURL + "api/internal/manager/set-log-sql?on=" + strconv.FormatBool(on)
146+
147+
req := newInternalRequest(ctx, reqURL, "POST")
148+
resp, err := req.Response()
149+
if err != nil {
150+
return http.StatusInternalServerError, fmt.Sprintf("Unable to contact gitea: %v", err.Error())
151+
}
152+
defer resp.Body.Close()
153+
154+
if resp.StatusCode != http.StatusOK {
155+
return resp.StatusCode, decodeJSONError(resp).Err
156+
}
157+
158+
return http.StatusOK, "Log SQL setting set"
159+
}
160+
142161
// LoggerOptions represents the options for the add logger call
143162
type LoggerOptions struct {
144163
Group string

routers/private/internal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func Routes() *web.Route {
6868
r.Post("/manager/pause-logging", PauseLogging)
6969
r.Post("/manager/resume-logging", ResumeLogging)
7070
r.Post("/manager/release-and-reopen-logging", ReleaseReopenLogging)
71+
r.Post("/manager/set-log-sql", SetLogSQL)
7172
r.Post("/manager/add-logger", bind(private.LoggerOptions{}), AddLogger)
7273
r.Post("/manager/remove-logger/{group}/{name}", RemoveLogger)
7374
r.Get("/manager/processes", Processes)

routers/private/manager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"net/http"
1010

11+
"code.gitea.io/gitea/models/db"
1112
"code.gitea.io/gitea/modules/context"
1213
"code.gitea.io/gitea/modules/graceful"
1314
"code.gitea.io/gitea/modules/json"
@@ -67,6 +68,12 @@ func ReleaseReopenLogging(ctx *context.PrivateContext) {
6768
ctx.PlainText(http.StatusOK, "success")
6869
}
6970

71+
// SetLogSQL re-sets database SQL logging
72+
func SetLogSQL(ctx *context.PrivateContext) {
73+
db.SetLogSQL(ctx, ctx.FormBool("on"))
74+
ctx.PlainText(http.StatusOK, "success")
75+
}
76+
7077
// RemoveLogger removes a logger
7178
func RemoveLogger(ctx *context.PrivateContext) {
7279
group := ctx.Params("group")

templates/user/settings/keys_ssh.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
<input readonly="" value="{{$.TokenToSign}}">
7676
<div class="help">
7777
<p>{{$.i18n.Tr "settings.ssh_token_help"}}</p>
78-
<p><code>{{printf "echo -n '%s' | ssh-keygen -Y sign -n gitea -f /path_to_your_pubkey" $.TokenToSign}}</code></p>
78+
<p><code>{{printf "echo -n '%s' | ssh-keygen -Y sign -n gitea -f /path_to_your_privkey" $.TokenToSign}}</code></p>
7979
</div>
8080
<br>
8181
</div>

0 commit comments

Comments
 (0)