github.com/google/osv-scalibr@v0.4.1/extractor/filesystem/secrets/mariadb/credential.go (about) 1 // Copyright 2025 Google LLC 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package mariadb 16 17 import "strings" 18 19 // Credentials contains mariadb credentials 20 type Credentials struct { 21 Section string 22 Host string 23 Port string 24 User string 25 Password string 26 } 27 28 func (c *Credentials) setField(key, value string) bool { 29 // "Dashes (-) and underscores (_) in option names are interchangeable" 30 // ref: https://mariadb.com/docs/server/server-management/install-and-upgrade-mariadb/configuring-mariadb/configuring-mariadb-with-option-files#options 31 k := strings.TrimSpace(strings.ToLower(key)) 32 switch k { 33 case "host": 34 c.Host = value 35 case "user": 36 c.User = value 37 case "password": 38 c.Password = value 39 case "port": 40 c.Port = value 41 default: 42 return false 43 } 44 return true 45 } 46 47 // isSecret returns true if a set of credentials contains a secret 48 func isSecret(c *Credentials) bool { 49 return c.Password != "" 50 }