Implements parameter for setting up docker registry server
This commit is contained in:
parent
f3d67cc3c2
commit
f3b0c07af2
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
- rootfs generator for Ubuntu 14.04.
|
- rootfs generator for Ubuntu 14.04.
|
||||||
|
|
||||||
|
- Parameter for setting up docker registry server.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Spelling in output.
|
- Spelling in output.
|
||||||
|
27
kernel.go
27
kernel.go
@ -109,7 +109,7 @@ func vsyscallAvailable() (available bool, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateBaseDockerImage(sk config.KernelMask) (err error) {
|
func generateBaseDockerImage(registry string, sk config.KernelMask) (err error) {
|
||||||
imagePath, err := dockerImagePath(sk)
|
imagePath, err := dockerImagePath(sk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -128,7 +128,12 @@ func generateBaseDockerImage(sk config.KernelMask) (err error) {
|
|||||||
sk.DistroType.String(), sk.DistroRelease)
|
sk.DistroType.String(), sk.DistroRelease)
|
||||||
os.MkdirAll(imagePath, os.ModePerm)
|
os.MkdirAll(imagePath, os.ModePerm)
|
||||||
|
|
||||||
d += fmt.Sprintf("FROM %s:%s\n",
|
d += "FROM "
|
||||||
|
if registry != "" {
|
||||||
|
d += registry + "/"
|
||||||
|
}
|
||||||
|
|
||||||
|
d += fmt.Sprintf("%s:%s\n",
|
||||||
strings.ToLower(sk.DistroType.String()),
|
strings.ToLower(sk.DistroType.String()),
|
||||||
sk.DistroRelease,
|
sk.DistroRelease,
|
||||||
)
|
)
|
||||||
@ -573,7 +578,9 @@ func shuffle(a []string) []string {
|
|||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateKernels(km config.KernelMask, max int64, download bool) (err error) {
|
func generateKernels(km config.KernelMask, registry string, max int64,
|
||||||
|
download bool) (err error) {
|
||||||
|
|
||||||
log.Println("Generating for kernel mask", km)
|
log.Println("Generating for kernel mask", km)
|
||||||
|
|
||||||
_, err = genRootfsImage(dockerImageInfo{ContainerName: km.DockerName()},
|
_, err = genRootfsImage(dockerImageInfo{ContainerName: km.DockerName()},
|
||||||
@ -582,7 +589,7 @@ func generateKernels(km config.KernelMask, max int64, download bool) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = generateBaseDockerImage(km)
|
err = generateBaseDockerImage(registry, km)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -632,7 +639,9 @@ func generateKernels(km config.KernelMask, max int64, download bool) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func kernelAutogenHandler(workPath string, max int64, host, download bool) (err error) {
|
func kernelAutogenHandler(workPath, registry string, max int64, host,
|
||||||
|
download bool) (err error) {
|
||||||
|
|
||||||
ka, err := config.ReadArtifactConfig(workPath + "/.out-of-tree.toml")
|
ka, err := config.ReadArtifactConfig(workPath + "/.out-of-tree.toml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -644,7 +653,7 @@ func kernelAutogenHandler(workPath string, max int64, host, download bool) (err
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = generateKernels(sk, max, download)
|
err = generateKernels(sk, registry, max, download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -695,7 +704,9 @@ func kernelDockerRegenHandler(host, download bool) (err error) {
|
|||||||
return updateKernelsCfg(host, download)
|
return updateKernelsCfg(host, download)
|
||||||
}
|
}
|
||||||
|
|
||||||
func kernelGenallHandler(distro, version string, host, download bool) (err error) {
|
func kernelGenallHandler(distro, version, registry string, host,
|
||||||
|
download bool) (err error) {
|
||||||
|
|
||||||
distroType, err := config.NewDistroType(distro)
|
distroType, err := config.NewDistroType(distro)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -706,7 +717,7 @@ func kernelGenallHandler(distro, version string, host, download bool) (err error
|
|||||||
DistroRelease: version,
|
DistroRelease: version,
|
||||||
ReleaseMask: ".*",
|
ReleaseMask: ".*",
|
||||||
}
|
}
|
||||||
err = generateKernels(km, kernelsAll, download)
|
err = generateKernels(km, registry, kernelsAll, download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
11
main.go
11
main.go
@ -117,6 +117,9 @@ func main() {
|
|||||||
dockerTimeoutFlag := app.Flag("docker-timeout", "Timeout for docker")
|
dockerTimeoutFlag := app.Flag("docker-timeout", "Timeout for docker")
|
||||||
dockerTimeout := dockerTimeoutFlag.Default(conf.Docker.Timeout).Duration()
|
dockerTimeout := dockerTimeoutFlag.Default(conf.Docker.Timeout).Duration()
|
||||||
|
|
||||||
|
dockerRegistryFlag := app.Flag("docker-registry", "Registry for docker")
|
||||||
|
dockerRegistry := dockerRegistryFlag.Default(conf.Docker.Registry).String()
|
||||||
|
|
||||||
pewCommand := app.Command("pew", "Build, run and test module/exploit")
|
pewCommand := app.Command("pew", "Build, run and test module/exploit")
|
||||||
|
|
||||||
pewMax := pewCommand.Flag("max", "Test no more than X kernels").
|
pewMax := pewCommand.Flag("max", "Test no more than X kernels").
|
||||||
@ -289,12 +292,12 @@ func main() {
|
|||||||
case kernelListCommand.FullCommand():
|
case kernelListCommand.FullCommand():
|
||||||
err = kernelListHandler(kcfg)
|
err = kernelListHandler(kcfg)
|
||||||
case kernelAutogenCommand.FullCommand():
|
case kernelAutogenCommand.FullCommand():
|
||||||
err = kernelAutogenHandler(*path, *kernelAutogenMax,
|
err = kernelAutogenHandler(*path, *dockerRegistry,
|
||||||
*kernelUseHost, !*kernelNoDownload)
|
*kernelAutogenMax, *kernelUseHost, !*kernelNoDownload)
|
||||||
case kernelDockerRegenCommand.FullCommand():
|
case kernelDockerRegenCommand.FullCommand():
|
||||||
err = kernelDockerRegenHandler(*kernelUseHost, !*kernelNoDownload)
|
err = kernelDockerRegenHandler(*kernelUseHost, !*kernelNoDownload)
|
||||||
case kernelGenallCommand.FullCommand():
|
case kernelGenallCommand.FullCommand():
|
||||||
err = kernelGenallHandler(*distro, *version,
|
err = kernelGenallHandler(*distro, *version, *dockerRegistry,
|
||||||
*kernelUseHost, !*kernelNoDownload)
|
*kernelUseHost, !*kernelNoDownload)
|
||||||
case genModuleCommand.FullCommand():
|
case genModuleCommand.FullCommand():
|
||||||
err = genConfig(config.KernelModule)
|
err = genConfig(config.KernelModule)
|
||||||
@ -318,7 +321,7 @@ func main() {
|
|||||||
case logMarkdownCommand.FullCommand():
|
case logMarkdownCommand.FullCommand():
|
||||||
err = logMarkdownHandler(db, *path, *logMarkdownTag)
|
err = logMarkdownHandler(db, *path, *logMarkdownTag)
|
||||||
case packCommand.FullCommand():
|
case packCommand.FullCommand():
|
||||||
err = packHandler(db, *path, kcfg, *packAutogen,
|
err = packHandler(db, *path, *dockerRegistry, kcfg, *packAutogen,
|
||||||
!*packNoDownload, *packExploitRuns, *packKernelRuns)
|
!*packNoDownload, *packExploitRuns, *packKernelRuns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
pack.go
5
pack.go
@ -15,7 +15,7 @@ import (
|
|||||||
"code.dumpstack.io/tools/out-of-tree/config"
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func packHandler(db *sql.DB, path string, kcfg config.KernelConfig,
|
func packHandler(db *sql.DB, path, registry string, kcfg config.KernelConfig,
|
||||||
autogen, download bool, exploitRuns, kernelRuns int64) (err error) {
|
autogen, download bool, exploitRuns, kernelRuns int64) (err error) {
|
||||||
|
|
||||||
dockerTimeout := time.Minute
|
dockerTimeout := time.Minute
|
||||||
@ -39,7 +39,8 @@ func packHandler(db *sql.DB, path string, kcfg config.KernelConfig,
|
|||||||
|
|
||||||
if autogen {
|
if autogen {
|
||||||
var perRegex int64 = 1
|
var perRegex int64 = 1
|
||||||
err = kernelAutogenHandler(workPath, perRegex, false, download)
|
err = kernelAutogenHandler(workPath, registry,
|
||||||
|
perRegex, false, download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user