1
0
This commit is contained in:
dump_stack() 2019-08-17 09:35:36 +00:00
parent b654fb29b9
commit 73b39b5c0d
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
4 changed files with 14 additions and 6 deletions

View File

@ -32,7 +32,9 @@ func (km KernelMask) DockerName() string {
type ArtifactType int
const (
// KernelModule is any kind of kernel module
KernelModule ArtifactType = iota
// KernelExploit is the privelege escalation exploit
KernelExploit
)
@ -111,11 +113,15 @@ func (ka Artifact) Supported(ki KernelInfo) (supported bool, err error) {
type DistroType int
const (
// Ubuntu https://ubuntu.com/
Ubuntu DistroType = iota
// CentOS https://www.centos.org/
CentOS
// Debian https://www.debian.org/
Debian
)
// DistroTypeStrings is the string version of enum DistroType
var DistroTypeStrings = [...]string{"Ubuntu", "CentOS", "Debian"}
// NewDistroType is create new Distro object
@ -160,12 +166,14 @@ func (dt DistroType) MarshalTOML() (data []byte, err error) {
return
}
// ByRootFS is sorting by .RootFS lexicographically
type ByRootFS []KernelInfo
func (a ByRootFS) Len() int { return len(a) }
func (a ByRootFS) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByRootFS) Less(i, j int) bool { return a[i].RootFS < a[j].RootFS }
// KernelInfo defines kernels.toml entries
type KernelInfo struct {
DistroType DistroType
DistroRelease string // 18.04/7.4.1708/9.1

View File

@ -24,7 +24,7 @@ import (
"code.dumpstack.io/tools/out-of-tree/config"
)
const KERNELS_ALL int64 = math.MaxInt64
const kernelsAll int64 = math.MaxInt64
func kernelListHandler(kcfg config.KernelConfig) (err error) {
if len(kcfg.Kernels) == 0 {
@ -496,7 +496,7 @@ func generateKernels(km config.KernelMask, max int64) (err error) {
err = dockerImageAppend(km, pkg)
if err == nil {
max -= 1
max--
} else {
log.Println("dockerImageAppend", err)
}
@ -590,7 +590,7 @@ func kernelGenallHandler(distro, version string, host bool) (err error) {
DistroRelease: version,
ReleaseMask: ".*",
}
err = generateKernels(km, KERNELS_ALL)
err = generateKernels(km, kernelsAll)
if err != nil {
return
}

View File

@ -118,7 +118,7 @@ func main() {
pewCommand := app.Command("pew", "Build, run and test module/exploit")
pewMax := pewCommand.Flag("max", "Test no more than X kernels").
PlaceHolder("X").Default(fmt.Sprint(KERNELS_ALL)).Int64()
PlaceHolder("X").Default(fmt.Sprint(kernelsAll)).Int64()
pewRuns := pewCommand.Flag("runs", "Runs per each kernel").
Default("1").Int64()
@ -153,7 +153,7 @@ func main() {
"Download random kernels from set defined by regex in "+
"release_mask, but no more than X for each of "+
"release_mask").PlaceHolder("X").Default(
fmt.Sprint(KERNELS_ALL)).Int64()
fmt.Sprint(kernelsAll)).Int64()
kernelDockerRegenCommand := kernelCommand.Command("docker-regen",
"Regenerate kernels config from out_of_tree_* docker images")
kernelGenallCommand := kernelCommand.Command("genall",

2
pew.go
View File

@ -392,7 +392,7 @@ func performCI(ka config.Artifact, kcfg config.KernelConfig, binaryPath,
if supported {
found = true
max -= 1
max--
for i := int64(0); i < runs; i++ {
swg.Add()
go whatever(&swg, ka, kernel, binaryPath,