-
Notifications
You must be signed in to change notification settings - Fork 7
/
credentials.go
35 lines (29 loc) · 926 Bytes
/
credentials.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package vcodeHMAC
import (
"bufio"
"os"
"strings"
)
func getCredentials(fileString string) ([2]string, error) {
var credentials [2]string
file, err := os.Open(fileString)
if err != nil {
return credentials, err
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
//We remove spaces to account for discrepancies in user configuration of creds file
if strings.Contains(scanner.Text(), "veracode_api_key_id") {
removeSpaces := strings.Replace(scanner.Text(), " ", "", -1)
credentials[0] = strings.Replace(removeSpaces, "veracode_api_key_id=", "", -1)
} else if strings.Contains(scanner.Text(), "veracode_api_key_secret") {
removeSpaces := strings.Replace(scanner.Text(), " ", "", -1)
credentials[1] = strings.Replace(removeSpaces, "veracode_api_key_secret=", "", -1)
}
}
if err := scanner.Err(); err != nil {
return credentials, err
}
return credentials, nil
}