mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-30 12:20:33 +00:00
Converting all inputs which are coming as secret to lowercase (#1276)
Closes #926 Co-authored-by: qwerty287 <80460567+qwerty287@users.noreply.github.com>
This commit is contained in:
parent
711f12ed27
commit
11f37f4649
5 changed files with 34 additions and 3 deletions
|
@ -50,8 +50,9 @@ func secretCreate(c *cli.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
secret := &woodpecker.Secret{
|
||||
Name: c.String("name"),
|
||||
Name: strings.ToLower(c.String("name")),
|
||||
Value: c.String("value"),
|
||||
Images: c.StringSlice("image"),
|
||||
Events: c.StringSlice("event"),
|
||||
|
|
|
@ -50,8 +50,9 @@ func secretUpdate(c *cli.Context) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
secret := &woodpecker.Secret{
|
||||
Name: c.String("name"),
|
||||
Name: strings.ToLower(c.String("name")),
|
||||
Value: c.String("value"),
|
||||
Images: c.StringSlice("image"),
|
||||
Events: c.StringSlice("event"),
|
||||
|
|
|
@ -16,6 +16,7 @@ package api
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
|
@ -50,7 +51,7 @@ func PostSecret(c *gin.Context) {
|
|||
}
|
||||
secret := &model.Secret{
|
||||
RepoID: repo.ID,
|
||||
Name: in.Name,
|
||||
Name: strings.ToLower(in.Name),
|
||||
Value: in.Value,
|
||||
Events: in.Events,
|
||||
Images: in.Images,
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright 2022 Woodpecker Authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package migration
|
||||
|
||||
import (
|
||||
"xorm.io/xorm"
|
||||
)
|
||||
|
||||
var lowercaseSecretNames = task{
|
||||
name: "lowercase-secret-names",
|
||||
fn: func(sess *xorm.Session) (err error) {
|
||||
_, err = sess.Exec("UPDATE secrets SET secret_name = LOWER(secret_name);")
|
||||
return err
|
||||
},
|
||||
}
|
|
@ -35,6 +35,7 @@ var migrationTasks = []*task{
|
|||
&dropSenders,
|
||||
&alterTableLogUpdateColumnLogDataType,
|
||||
&alterTableSecretsAddUserCol,
|
||||
&lowercaseSecretNames,
|
||||
}
|
||||
|
||||
var allBeans = []interface{}{
|
||||
|
|
Loading…
Reference in a new issue