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 CancellableRead[T any](ctx context.Context, ch <-chan T) (T, error)
- 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 GenerateRandomPassword(lower, upper, numeric, special bool, length int) string
- 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 RecoverWithHandler(ctx context.Context, callback func(error))
- func RemoveStringSliceItem(item string, slice *[]string)
- func ResponseContainsSubstring(reader io.ReadCloser, target string) (bool, error)
- func RetryableHTTPClient(opts ...ClientOption) *http.Client
- func RetryableHTTPClientTimeout(timeOutSeconds int64, opts ...ClientOption) *http.Client
- func SaneHttpClient() *http.Client
- func SaneHttpClientTimeOut(timeout time.Duration) *http.Client
- func SkipFile(filename string) bool
- func SliceContainsString(origTargetString string, stringSlice []string, ignoreCase bool) (bool, string, int)
- func ToUpperCase(input string) string
- func UserAgent() string
- type ChannelClosedErr
- type ClientOption
- func WithBackoff(b retryablehttp.Backoff) ClientOption
- func WithCheckRetry(cr retryablehttp.CheckRetry) ClientOption
- func WithMaxRetries(retries int) ClientOption
- func WithRetryWaitMax(wait time.Duration) ClientOption
- func WithRetryWaitMin(wait time.Duration) ClientOption
- func WithTimeout(timeout time.Duration) ClientOption
- type CustomTransport
- type ExportError
- type FakeTransport
- type Filter
- type FilterRuleSet
- type InstrumentedTransport
- type RegexState
- type Secret
Constants ¶
const ( // MetricsNamespace is the namespace for all metrics. MetricsNamespace = "offensiveboar" // MetricsSubsystem is the subsystem for all metrics. MetricsSubsystem = "scanner" )
const AlphaNumPattern = "0-9a-zA-Z"
const DefaultResponseTimeout = 5 * time.Second
const EmailPattern = `` /* 462-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 ¶
Custom Regex functions
func BuildRegexJWT ¶
func CancellableRead ¶
CancellableRead blocks on receiving an item from the channel but can be cancelled by the context. If the channel is closed, a ChannelClosedErr is returned. If both the context is cancelled and the channel read would succeed, either operation will be performed randomly, however priority is given to context cancellation.
func CancellableWrite ¶
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, however priority is given to context cancellation.
func ExportErrors ¶
ExportErrors converts a list of errors into []ExportError.
func GenerateRandomPassword ¶
GoFakeIt Password generator does not guarantee inclusion of characters. Using a custom random password generator with guaranteed inclusions (atleast) of lower, upper, numeric and special characters
func PinnedCertPool ¶
func RangeValidation ¶
func RecoverWithExit ¶
RecoverWithExit handles panics and reports to Sentry before exiting.
func RecoverWithHandler ¶
RecoverWithHandler handles panics and reports to Sentry, then turns control over to a provided function. This permits extra reporting in the same scope without re-panicking, as recover() clears the state after it's called. Does NOT block to flush sentry report.
func RemoveStringSliceItem ¶
func ResponseContainsSubstring ¶
func ResponseContainsSubstring(reader io.ReadCloser, target string) (bool, error)
func RetryableHTTPClient ¶
func RetryableHTTPClient(opts ...ClientOption) *http.Client
func RetryableHTTPClientTimeout ¶
func RetryableHTTPClientTimeout(timeOutSeconds int64, opts ...ClientOption) *http.Client
RetryableHTTPClientTimeout returns a new http client with a specified timeout and RoundTripper transport
func SaneHttpClient ¶
func SaneHttpClientTimeOut ¶
SaneHttpClientTimeOut adds a custom timeout for some scanners
func SliceContainsString ¶
func SliceContainsString(origTargetString string, stringSlice []string, ignoreCase bool) (bool, string, int)
SliceContainsString searches a slice to determine if it contains a specified string. Returns the index of the first match in the slice.
func ToUpperCase ¶
Types ¶
type ChannelClosedErr ¶
type ChannelClosedErr struct{}
ChannelClosedErr indicates that a read was performed from a closed channel.
func (ChannelClosedErr) Error ¶
func (ChannelClosedErr) Error() string
type ClientOption ¶
type ClientOption func(*retryablehttp.Client)
ClientOption configures how we set up the client.
func WithBackoff ¶
func WithBackoff(b retryablehttp.Backoff) ClientOption
WithBackoff allows setting a custom backoff policy.
func WithCheckRetry ¶
func WithCheckRetry(cr retryablehttp.CheckRetry) ClientOption
WithCheckRetry allows setting a custom CheckRetry policy.
func WithMaxRetries ¶
func WithMaxRetries(retries int) ClientOption
WithMaxRetries allows setting a custom maximum number of retries.
func WithRetryWaitMax ¶
func WithRetryWaitMax(wait time.Duration) ClientOption
WithRetryWaitMax allows setting a custom maximum retry wait.
func WithRetryWaitMin ¶
func WithRetryWaitMin(wait time.Duration) ClientOption
WithRetryWaitMin allows setting a custom minimum retry wait.
func WithTimeout ¶
func WithTimeout(timeout time.Duration) ClientOption
WithTimeout allows setting a custom timeout.
type CustomTransport ¶
type CustomTransport struct {
T http.RoundTripper
}
func NewCustomTransport ¶
func NewCustomTransport(T http.RoundTripper) *CustomTransport
type ExportError ¶
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 ¶
func (e ExportError) Error() string
type FakeTransport ¶
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.
func (*Filter) Pass ¶
Pass returns true if the include FilterRuleSet matches the pattern and the exclude FilterRuleSet does not match.
func (*Filter) ShouldExclude ¶
ShouldExclude return true if any regular expressions in the exclude FilterRuleSet matches the path.
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 InstrumentedTransport ¶
type InstrumentedTransport struct {
T http.RoundTripper
}
func NewInstrumentedTransport ¶
func NewInstrumentedTransport(T http.RoundTripper) *InstrumentedTransport
type RegexState ¶
type RegexState struct {
// contains filtered or unexported fields
}
func PasswordRegexCheck ¶
func PasswordRegexCheck(pattern string) RegexState
PasswordRegexCheck constructs an username usernameRegex pattern from a given pattern of excluded characters.
func UsernameRegexCheck ¶
func UsernameRegexCheck(pattern string) RegexState
UsernameRegexCheck constructs an username usernameRegex pattern from a given pattern of excluded characters.
func (RegexState) Matches ¶
func (r RegexState) Matches(data []byte) []string
type Secret ¶
type Secret struct {
// contains filtered or unexported fields
}