Documentation
¶
Index ¶
- Constants
- Variables
- func ByteToString(orig []byte) string
- func CheckUnpriUserNS() error
- func FileExist(path string) bool
- func FindTargetDeviceID(mi *MountInfo) bool
- func GetAllCGroupSubSystem() ([]string, error)
- func GetCgroupVersion() (int, error)
- func GetKernelVersion() ([]int, error)
- func HttpSendJson(method string, url string, data string) (string, error)
- func IntContains(s []int, e int) bool
- func IsDir(FilePath string) bool
- func IsDirectory(path string) bool
- func IsSoftLink(FilePath string) bool
- func MakeDev(major, minor string) int
- func RandString(n int) string
- func ReadLines(path string) ([]string, error)
- func RemoveDuplicateElement(addrs []string) []string
- func RewriteFile(path string, content string, perm os.FileMode)
- func SetBlockAccessible(path string) error
- func ShellExec(shellPath string) error
- func StringContains(s []string, e string) bool
- func UnixHttpSend(method string, unixPath string, uri string, data string) (string, error)
- func WriteFile(path string, content string) error
- func WriteFileAdd(path string, content string) error
- func WriteShellcodeToCrontab(header string, filePath string, shellcode string) error
- type CgroupInfo
- type Level
- type LevelLogger
- type MountInfo
- type Wrapper
Constants ¶
View Source
const ( DebugPrefix = "[DEBUG] " InfoPrefix = "[INFO_] " WarnPrefix = "[WARN_] " ErrorPrefix = "[ERROR] " )
Variables ¶
View Source
var ( RedBold = color.New(color.FgRed).Add(color.Bold) GreenBold = color.New(color.FgGreen).Add(color.Bold) YellowBold = color.New(color.FgYellow).Add(color.Bold) BlueBold = color.New(color.FgBlue).Add(color.Bold) )
Colorful Bold use like `GreenBold.Sprint(str)`
View Source
var ( ColorDebugPrefix = GreenBold.Sprint(DebugPrefix) ColorInfoPrefix = BlueBold.Sprint(InfoPrefix) ColorWarnPrefix = YellowBold.Sprint(WarnPrefix) ColorErrorPrefix = RedBold.Sprint(ErrorPrefix) )
View Source
var DefaultLevel = INFO
Functions ¶
func ByteToString ¶
func CheckUnpriUserNS ¶ added in v1.0.6
func CheckUnpriUserNS() error
CheckUnpriUserNS checks if the current host enable unprivileged user namespace. reference:
https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/ https://unit42.paloaltonetworks.com/cve-2022-0492-cgroups/
exceptional case:
the sysctl files(/proc/sys/kernel/unprivileged_userns_clone) only exist in Debian, Ubuntu. We can not check the sysctl file in other distros, test in CentOS Linux release 8.4.2105 (Core).
func GetAllCGroupSubSystem ¶ added in v1.0.6
func GetCgroupVersion ¶ added in v1.0.6
get cgroup version V1/V2 hybrid mode will not work in container
func HttpSendJson ¶ added in v0.1.10
func IntContains ¶ added in v1.0.4
IntContains check string array contains a int number
func IsDirectory ¶ added in v1.0.2
func IsSoftLink ¶
func RandString ¶
func ReadLines ¶ added in v1.0.3
ReadLines reads a whole file into memory and returns a slice of its lines. from https://stackoverflow.com/questions/5884154/read-text-file-into-string-array-and-write
func RemoveDuplicateElement ¶
func SetBlockAccessible ¶
set all block device accessible
func StringContains ¶ added in v1.0.4
StringContains check string array contains a string
func UnixHttpSend ¶
func WriteFileAdd ¶ added in v1.0.1
Types ¶
type CgroupInfo ¶ added in v1.0.6
type CgroupInfo struct { HierarchyID int ControllerLst string // split by "," but should not be split CgroupPath string OriginalInfo string }
func GetAllCGroup ¶ added in v1.0.6
func GetAllCGroup() ([]CgroupInfo, error)
func GetCgroup ¶ added in v1.1.0
func GetCgroup(pid int) ([]CgroupInfo, error)
GetCgroup returns the cgroup info of the process param pid: 0 = self, 1 = container main process
type LevelLogger ¶ added in v1.1.0
func (*LevelLogger) Close ¶ added in v1.1.0
func (l *LevelLogger) Close()
func (*LevelLogger) Debug ¶ added in v1.1.0
func (l *LevelLogger) Debug(format string, v ...interface{})
func (*LevelLogger) Error ¶ added in v1.1.0
func (l *LevelLogger) Error(format string, v ...interface{})
func (*LevelLogger) Info ¶ added in v1.1.0
func (l *LevelLogger) Info(format string, v ...interface{})
func (*LevelLogger) Warn ¶ added in v1.1.0
func (l *LevelLogger) Warn(format string, v ...interface{})
type MountInfo ¶
type MountInfo struct { Device string Fstype string Root string MountPoint string Opts []string Major string Minor string SuperBlockOptions []string }
func GetMountInfo ¶
type Wrapper ¶ added in v1.1.0
type Wrapper struct { LevelLogger // contains filtered or unexported fields }
func NewStdoutWrapper ¶ added in v1.1.0
func NewStdoutWrapper() *Wrapper
Source Files
¶
Click to show internal directories.
Click to hide internal directories.