2020-04-03 23:11:33 +00:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"regexp"
|
2021-07-22 03:52:37 +00:00
|
|
|
"strings"
|
2020-04-03 23:11:33 +00:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
const (
|
|
|
|
windows = "windows"
|
|
|
|
testStringInput = "abcdefghijkl"
|
|
|
|
|
|
|
|
// RFC3339Zero is the default value for time.Time.Unix().
|
|
|
|
RFC3339Zero = int64(-62135596800)
|
2020-04-03 23:11:33 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// TLS13 is the textual representation of TLS 1.3.
|
|
|
|
TLS13 = "1.3"
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// TLS12 is the textual representation of TLS 1.2.
|
|
|
|
TLS12 = "1.2"
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// TLS11 is the textual representation of TLS 1.1.
|
|
|
|
TLS11 = "1.1"
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// TLS10 is the textual representation of TLS 1.0.
|
|
|
|
TLS10 = "1.0"
|
2020-04-20 21:03:38 +00:00
|
|
|
|
2021-08-05 04:17:07 +00:00
|
|
|
clean = "clean"
|
|
|
|
tagged = "tagged"
|
|
|
|
unknown = "unknown"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2021-05-04 22:06:05 +00:00
|
|
|
// Hour is an int based representation of the time unit.
|
2022-02-09 22:07:53 +00:00
|
|
|
Hour = time.Minute * 60 //nolint:revive
|
2020-05-02 16:20:40 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// Day is an int based representation of the time unit.
|
|
|
|
Day = Hour * 24
|
2021-03-22 09:04:09 +00:00
|
|
|
|
2021-05-04 22:06:05 +00:00
|
|
|
// Week is an int based representation of the time unit.
|
|
|
|
Week = Day * 7
|
|
|
|
|
|
|
|
// Year is an int based representation of the time unit.
|
|
|
|
Year = Day * 365
|
|
|
|
|
|
|
|
// Month is an int based representation of the time unit.
|
|
|
|
Month = Year / 12
|
2021-08-05 04:17:07 +00:00
|
|
|
)
|
2021-06-18 04:35:43 +00:00
|
|
|
|
2021-08-05 04:17:07 +00:00
|
|
|
const (
|
2021-08-03 09:55:21 +00:00
|
|
|
errFmtLinuxNotFound = "open %s: no such file or directory"
|
2021-05-04 22:06:05 +00:00
|
|
|
)
|
2020-05-04 19:39:25 +00:00
|
|
|
|
2021-08-02 11:55:30 +00:00
|
|
|
var (
|
|
|
|
reDuration = regexp.MustCompile(`^(?P<Duration>[1-9]\d*?)(?P<Unit>[smhdwMy])?$`)
|
|
|
|
)
|
2020-08-21 02:16:23 +00:00
|
|
|
|
2021-11-11 09:13:32 +00:00
|
|
|
var (
|
|
|
|
// AlphaNumericCharacters are literally just valid alphanumeric chars.
|
|
|
|
AlphaNumericCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
|
|
)
|
2020-12-03 05:23:52 +00:00
|
|
|
|
2021-07-22 03:52:37 +00:00
|
|
|
var htmlEscaper = strings.NewReplacer(
|
|
|
|
"&", "&",
|
|
|
|
"<", "<",
|
|
|
|
">", ">",
|
|
|
|
`"`, """,
|
|
|
|
"'", "'",
|
|
|
|
)
|
2021-08-02 11:55:30 +00:00
|
|
|
|
|
|
|
// ErrTimeoutReached error thrown when a timeout is reached.
|
|
|
|
var ErrTimeoutReached = errors.New("timeout reached")
|
|
|
|
|
|
|
|
// ErrTLSVersionNotSupported returned when an unknown TLS version supplied.
|
|
|
|
var ErrTLSVersionNotSupported = errors.New("supplied TLS version isn't supported")
|