Skip to content

Commit 6ab2b81

Browse files
committed
fix more
1 parent 0867bfc commit 6ab2b81

File tree

16 files changed

+31
-20
lines changed

16 files changed

+31
-20
lines changed

cmd/admin_user_create.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ func runCreateUser(ctx context.Context, c *cli.Command) error {
151151
if err != nil {
152152
return err
153153
}
154+
// codeql[disable-next-line=go/clear-text-logging]
154155
fmt.Printf("generated random password is '%s'\n", password)
155156
} else if userType == user_model.UserTypeIndividual {
156157
return errors.New("must set either password or random-password flag")

cmd/admin_user_must_change_password.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func runMustChangePassword(ctx context.Context, c *cli.Command) error {
5858
return err
5959
}
6060

61+
// codeql[disable-next-line=go/clear-text-logging]
6162
fmt.Printf("Updated %d users setting MustChangePassword to %t\n", n, mustChangePassword)
6263
return nil
6364
}

cmd/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func runGenerateSecretKey(_ context.Context, c *cli.Command) error {
9191
return err
9292
}
9393

94+
// codeql[disable-next-line=go/clear-text-logging]
9495
fmt.Printf("%s", secretKey)
9596

9697
if isatty.IsTerminal(os.Stdout.Fd()) {

cmd/hook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ Gitea or set your environment appropriately.`, "")
186186
userID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
187187
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
188188
deployKeyID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvDeployKeyID), 10, 64)
189-
actionPerm, _ := strconv.ParseInt(os.Getenv(repo_module.EnvActionPerm), 10, 64)
189+
actionPerm, _ := strconv.Atoi(os.Getenv(repo_module.EnvActionPerm))
190190

191191
hookOptions := private.HookOptions{
192192
UserID: userID,
@@ -196,7 +196,7 @@ Gitea or set your environment appropriately.`, "")
196196
GitPushOptions: pushOptions(),
197197
PullRequestID: prID,
198198
DeployKeyID: deployKeyID,
199-
ActionPerm: int(actionPerm),
199+
ActionPerm: actionPerm,
200200
}
201201

202202
scanner := bufio.NewScanner(os.Stdin)

modules/auth/password/pwn/pwn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func newRequest(ctx context.Context, method, url string, body io.ReadCloser) (*h
7272
// Adding padding will make requests more secure, however is also slower
7373
// because artificial responses will be added to the response
7474
// For more information, see https://www.troyhunt.com/enhancing-pwned-passwords-privacy-with-padding/
75-
func (c *Client) CheckPassword(pw string, padding bool) (int, error) {
75+
func (c *Client) CheckPassword(pw string, padding bool) (int64, error) {
7676
if pw == "" {
7777
return -1, ErrEmptyPassword
7878
}
@@ -111,7 +111,7 @@ func (c *Client) CheckPassword(pw string, padding bool) (int, error) {
111111
if err != nil {
112112
return -1, err
113113
}
114-
return int(count), nil
114+
return count, nil
115115
}
116116
}
117117
return 0, nil

modules/auth/password/pwn/pwn_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,25 @@ func TestPassword(t *testing.T) {
3737

3838
count, err := client.CheckPassword("", false)
3939
assert.ErrorIs(t, err, ErrEmptyPassword, "blank input should return ErrEmptyPassword")
40-
assert.Equal(t, -1, count)
40+
assert.EqualValues(t, -1, count)
4141

4242
count, err = client.CheckPassword("pwned", false)
4343
assert.NoError(t, err)
44-
assert.Equal(t, 1, count)
44+
assert.EqualValues(t, 1, count)
4545

4646
count, err = client.CheckPassword("notpwned", false)
4747
assert.NoError(t, err)
48-
assert.Equal(t, 0, count)
48+
assert.EqualValues(t, 0, count)
4949

5050
count, err = client.CheckPassword("paddedpwned", true)
5151
assert.NoError(t, err)
52-
assert.Equal(t, 1, count)
52+
assert.EqualValues(t, 1, count)
5353

5454
count, err = client.CheckPassword("paddednotpwned", true)
5555
assert.NoError(t, err)
56-
assert.Equal(t, 0, count)
56+
assert.EqualValues(t, 0, count)
5757

5858
count, err = client.CheckPassword("paddednotpwnedzero", true)
5959
assert.NoError(t, err)
60-
assert.Equal(t, 0, count)
60+
assert.EqualValues(t, 0, count)
6161
}

modules/log/logger_global.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func GetLevel() Level {
1818
}
1919

2020
func Log(skip int, level Level, format string, v ...any) {
21+
// codeql[disable-next-line=go/clear-text-logging]
2122
GetLogger(DEFAULT).Log(skip+1, &Event{Level: level}, format, v...)
2223
}
2324

modules/log/misc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func BaseLoggerToGeneralLogger(b BaseLogger) Logger {
2020
var _ Logger = (*baseToLogger)(nil)
2121

2222
func (s *baseToLogger) Log(skip int, event *Event, format string, v ...any) {
23+
// codeql[disable-next-line=go/clear-text-logging]
2324
s.base.Log(skip+1, event, format, v...)
2425
}
2526

modules/util/color.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ func HexToRBGColor(colorString string) (float64, float64, float64) {
2727
hexString = hexString[0:6]
2828
}
2929
color, err := strconv.ParseUint(hexString, 16, 32)
30+
color32 := uint32(color)
3031
if err != nil {
3132
return 0, 0, 0
3233
}
33-
r := float64(uint8(0xFF & (uint32(color) >> 16)))
34-
g := float64(uint8(0xFF & (uint32(color) >> 8)))
35-
b := float64(uint8(0xFF & uint32(color)))
34+
r := float64(uint8(0xFF & (color32 >> 16)))
35+
g := float64(uint8(0xFF & (color32 >> 8)))
36+
b := float64(uint8(0xFF & color32))
3637
return r, g, b
3738
}
3839

routers/api/v1/repo/issue_pin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func MoveIssuePin(ctx *context.APIContext) {
169169
return
170170
}
171171

172-
err = issues_model.MovePin(ctx, issue, int(ctx.PathParamInt64("position")))
172+
err = issues_model.MovePin(ctx, issue, ctx.PathParamInt("position"))
173173
if err != nil {
174174
ctx.APIErrorInternal(err)
175175
return

0 commit comments

Comments
 (0)