Files
trufflehog/pkg/analyzer/analyzers/plaid/permissions.go
Nabeel AlamandKashif Khan 5b3d6155ca [Feat] Plaid API Analyzer (#4004)
* added plaid api analyzer

* updated plaid analyzer and detector

* updated plaidkey detector verify loop

* added requested changes

* added build tags into detector integration test

* updated plaid analyzer and implemented suggestions

---------

Co-authored-by: Kashif Khan <[email protected]>
2025-04-11 19:36:05 +05:00

67 lines
1.5 KiB
Go

// Code generated by go generate; DO NOT EDIT.
package plaid
import "errors"
type Permission int
const (
Invalid Permission = iota
Read Permission = iota
Write Permission = iota
)
var (
PermissionStrings = map[Permission]string{
Read: "read",
Write: "write",
}
StringToPermission = map[string]Permission{
"read": Read,
"write": Write,
}
PermissionIDs = map[Permission]int{
Read: 1,
Write: 2,
}
IdToPermission = map[int]Permission{
1: Read,
2: Write,
}
)
// ToString converts a Permission enum to its string representation
func (p Permission) ToString() (string, error) {
if str, ok := PermissionStrings[p]; ok {
return str, nil
}
return "", errors.New("invalid permission")
}
// ToID converts a Permission enum to its ID
func (p Permission) ToID() (int, error) {
if id, ok := PermissionIDs[p]; ok {
return id, nil
}
return 0, errors.New("invalid permission")
}
// PermissionFromString converts a string representation to its Permission enum
func PermissionFromString(s string) (Permission, error) {
if p, ok := StringToPermission[s]; ok {
return p, nil
}
return 0, errors.New("invalid permission string")
}
// PermissionFromID converts an ID to its Permission enum
func PermissionFromID(id int) (Permission, error) {
if p, ok := IdToPermission[id]; ok {
return p, nil
}
return 0, errors.New("invalid permission ID")
}