Documentation ¶
Index ¶
- Constants
- Variables
- func AddStringSliceItem(item string, slice *[]string)
- func BuildRegex(pattern string, specialChar string, length int) string
- func BuildRegexJWT(firstRange, secondRange, thirdRange string) string
- func CancellableWrite[T any](ctx context.Context, ch chan<- T, item T) error
- func ConstantResponseHttpClient(statusCode int, body string) *http.Client
- func ExportErrors(errs ...error) []error
- func GetAccountNumFromAWSID(AWSID string) (string, error)
- func IsBinary(filename string) bool
- func IsDone(ctx context.Context) bool
- func PinnedCertPool() *x509.CertPool
- func PinnedRetryableHttpClient() *http.Client
- func RandomID(length int) string
- func RangeValidation(rangeInput string) bool
- func Recover(ctx context.Context)
- func RecoverWithExit(ctx context.Context)
- func RemoveStringSliceItem(item string, slice *[]string)
- func ResponseContainsSubstring(reader io.ReadCloser, target string) (bool, error)
- func RetryableHttpClient() *http.Client
- func RetryableHttpClientTimeout(timeOutSeconds int64) *http.Client
- func SaneHttpClient() *http.Client
- func SaneHttpClientTimeOut(timeout time.Duration) *http.Client
- func SkipFile(filename string) bool
- func ToUpperCase(input string) string
- type CustomTransport
- type ExportError
- type FakeTransport
- type Filter
- type FilterRuleSet
- type RegexState
- type Secret
Constants ¶
const ( // MetricsNamespace is the namespace for all metrics. MetricsNamespace = "trufflehog" // MetricsSubsystem is the subsystem for all metrics. MetricsSubsystem = "scanner" )
const AlphaNumPattern = "0-9a-zA-Z"
const DefaultResponseTimeout = 5 * time.Second
const EmailPattern = `` /* 456-byte string literal not displayed */
const HexPattern = "0-9a-f"
const RegexPattern = "0-9a-z"
const SubDomainPattern = `\b([A-Za-z0-9](?:[A-Za-z0-9\-]{0,61}[A-Za-z0-9])?)\b`
const UUIDPattern = `\b([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\b`
const UUIDPatternUpperCase = `\b([0-9A-Z]{8}-[0-9A-Z]{4}-[0-9A-Z]{4}-[0-9A-Z]{4}-[0-9A-Z]{12})\b`
Variables ¶
var (
KB, MB, GB, TB, PB = 1e3, 1e6, 1e9, 1e12, 1e15
)
Functions ¶
func AddStringSliceItem ¶
func BuildRegex ¶ added in v3.6.9
Custom Regex functions
func BuildRegexJWT ¶ added in v3.6.9
func CancellableWrite ¶ added in v3.44.0
CancellableWrite blocks on writing the item to the channel but can be cancelled by the context. If both the context is cancelled and the channel write would succeed, either operation will be performed randomly.
func ConstantResponseHttpClient ¶ added in v3.46.0
func ExportErrors ¶ added in v3.67.6
ExportErrors converts a list of errors into []ExportError.
func GetAccountNumFromAWSID ¶ added in v3.63.0
func IsBinary ¶ added in v3.63.5
IsBinary returns true if the file extension is in the binaryExtensions list.
func PinnedCertPool ¶
func RangeValidation ¶ added in v3.6.9
func RecoverWithExit ¶ added in v3.12.1
RecoverWithExit handles panics and reports to Sentry before exiting.
func RemoveStringSliceItem ¶
func ResponseContainsSubstring ¶ added in v3.42.0
func ResponseContainsSubstring(reader io.ReadCloser, target string) (bool, error)
func RetryableHttpClient ¶
func RetryableHttpClientTimeout ¶ added in v3.10.4
func SaneHttpClient ¶
func SaneHttpClientTimeOut ¶
SaneHttpClientTimeOut adds a custom timeout for some scanners
func ToUpperCase ¶ added in v3.6.9
Types ¶
type CustomTransport ¶
type CustomTransport struct {
T http.RoundTripper
}
func NewCustomTransport ¶
func NewCustomTransport(T http.RoundTripper) *CustomTransport
type ExportError ¶ added in v3.67.6
type ExportError string
ExportError is an implementation of error that can be JSON marshalled. It must be a public exported type for this reason.
func (ExportError) Error ¶ added in v3.67.6
func (e ExportError) Error() string
type FakeTransport ¶ added in v3.45.0
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func FilterFromFiles ¶
FilterFromFiles creates a Filter using the rules in the provided include and exclude files.
type FilterRuleSet ¶
func FilterRulesFromFile ¶
func FilterRulesFromFile(source string) (*FilterRuleSet, error)
FilterRulesFromFile loads the list of regular expression filter rules in `source` and creates a FilterRuleSet.
func (*FilterRuleSet) Matches ¶
func (rules *FilterRuleSet) Matches(object string) bool
Matches will return true if any of the regular expressions in the FilterRuleSet match the pattern.
type RegexState ¶ added in v3.42.0
type RegexState struct {
// contains filtered or unexported fields
}
func PasswordRegexCheck ¶ added in v3.42.0
func PasswordRegexCheck(pattern string) RegexState
PasswordRegexCheck constructs an username usernameRegex pattern from a given pattern of excluded characters.
func UsernameRegexCheck ¶ added in v3.42.0
func UsernameRegexCheck(pattern string) RegexState
UsernameRegexCheck constructs an username usernameRegex pattern from a given pattern of excluded characters.
func (RegexState) Matches ¶ added in v3.42.0
func (r RegexState) Matches(data []byte) []string
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}