parent
f3b0c07af2
commit
5bad772125
@ -15,6 +15,9 @@
|
|||||||
|
|
||||||
- Parameter for setting up docker registry server.
|
- Parameter for setting up docker registry server.
|
||||||
|
|
||||||
|
- Support for (distro-specific) custom docker commands that will be
|
||||||
|
executed before the base template.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Spelling in output.
|
- Spelling in output.
|
||||||
|
@ -10,6 +10,11 @@ import (
|
|||||||
"github.com/naoina/toml"
|
"github.com/naoina/toml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type DockerCommand struct {
|
||||||
|
DistroType DistroType
|
||||||
|
Command string
|
||||||
|
}
|
||||||
|
|
||||||
type OutOfTree struct {
|
type OutOfTree struct {
|
||||||
Kernels string
|
Kernels string
|
||||||
UserKernels string
|
UserKernels string
|
||||||
@ -23,6 +28,10 @@ type OutOfTree struct {
|
|||||||
Docker struct {
|
Docker struct {
|
||||||
Timeout string
|
Timeout string
|
||||||
Registry string
|
Registry string
|
||||||
|
|
||||||
|
// Commands that will be executed before
|
||||||
|
// the base layer of Dockerfile
|
||||||
|
Commands []DockerCommand
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
kernel.go
37
kernel.go
@ -109,7 +109,9 @@ func vsyscallAvailable() (available bool, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateBaseDockerImage(registry string, sk config.KernelMask) (err error) {
|
func generateBaseDockerImage(registry string, commands []config.DockerCommand,
|
||||||
|
sk config.KernelMask) (err error) {
|
||||||
|
|
||||||
imagePath, err := dockerImagePath(sk)
|
imagePath, err := dockerImagePath(sk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -143,6 +145,21 @@ func generateBaseDockerImage(registry string, sk config.KernelMask) (err error)
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, c := range commands {
|
||||||
|
switch c.DistroType {
|
||||||
|
case config.Ubuntu:
|
||||||
|
d += "RUN " + c.Command + "\n"
|
||||||
|
case config.CentOS:
|
||||||
|
d += "RUN " + c.Command + "\n"
|
||||||
|
case config.Debian:
|
||||||
|
d += "RUN " + c.Command + "\n"
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("%s not yet supported",
|
||||||
|
sk.DistroType.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch sk.DistroType {
|
switch sk.DistroType {
|
||||||
case config.Ubuntu:
|
case config.Ubuntu:
|
||||||
d += "ENV DEBIAN_FRONTEND=noninteractive\n"
|
d += "ENV DEBIAN_FRONTEND=noninteractive\n"
|
||||||
@ -578,7 +595,8 @@ func shuffle(a []string) []string {
|
|||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateKernels(km config.KernelMask, registry string, max int64,
|
func generateKernels(km config.KernelMask, registry string,
|
||||||
|
commands []config.DockerCommand, max int64,
|
||||||
download bool) (err error) {
|
download bool) (err error) {
|
||||||
|
|
||||||
log.Println("Generating for kernel mask", km)
|
log.Println("Generating for kernel mask", km)
|
||||||
@ -589,7 +607,7 @@ func generateKernels(km config.KernelMask, registry string, max int64,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = generateBaseDockerImage(registry, km)
|
err = generateBaseDockerImage(registry, commands, km)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -639,8 +657,9 @@ func generateKernels(km config.KernelMask, registry string, max int64,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func kernelAutogenHandler(workPath, registry string, max int64, host,
|
func kernelAutogenHandler(workPath, registry string,
|
||||||
download bool) (err error) {
|
commands []config.DockerCommand,
|
||||||
|
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 {
|
||||||
@ -653,7 +672,7 @@ func kernelAutogenHandler(workPath, registry string, max int64, host,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err = generateKernels(sk, registry, max, download)
|
err = generateKernels(sk, registry, commands, max, download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -704,8 +723,8 @@ func kernelDockerRegenHandler(host, download bool) (err error) {
|
|||||||
return updateKernelsCfg(host, download)
|
return updateKernelsCfg(host, download)
|
||||||
}
|
}
|
||||||
|
|
||||||
func kernelGenallHandler(distro, version, registry string, host,
|
func kernelGenallHandler(distro, version, registry string,
|
||||||
download bool) (err error) {
|
commands []config.DockerCommand, host, download bool) (err error) {
|
||||||
|
|
||||||
distroType, err := config.NewDistroType(distro)
|
distroType, err := config.NewDistroType(distro)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -717,7 +736,7 @@ func kernelGenallHandler(distro, version, registry string, host,
|
|||||||
DistroRelease: version,
|
DistroRelease: version,
|
||||||
ReleaseMask: ".*",
|
ReleaseMask: ".*",
|
||||||
}
|
}
|
||||||
err = generateKernels(km, registry, kernelsAll, download)
|
err = generateKernels(km, registry, commands, kernelsAll, download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
9
main.go
9
main.go
@ -293,11 +293,13 @@ func main() {
|
|||||||
err = kernelListHandler(kcfg)
|
err = kernelListHandler(kcfg)
|
||||||
case kernelAutogenCommand.FullCommand():
|
case kernelAutogenCommand.FullCommand():
|
||||||
err = kernelAutogenHandler(*path, *dockerRegistry,
|
err = kernelAutogenHandler(*path, *dockerRegistry,
|
||||||
*kernelAutogenMax, *kernelUseHost, !*kernelNoDownload)
|
conf.Docker.Commands, *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, *dockerRegistry,
|
err = kernelGenallHandler(*distro, *version,
|
||||||
|
*dockerRegistry, conf.Docker.Commands,
|
||||||
*kernelUseHost, !*kernelNoDownload)
|
*kernelUseHost, !*kernelNoDownload)
|
||||||
case genModuleCommand.FullCommand():
|
case genModuleCommand.FullCommand():
|
||||||
err = genConfig(config.KernelModule)
|
err = genConfig(config.KernelModule)
|
||||||
@ -321,7 +323,8 @@ 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, *dockerRegistry, kcfg, *packAutogen,
|
err = packHandler(db, *path, *dockerRegistry,
|
||||||
|
conf.Docker.Commands, kcfg, *packAutogen,
|
||||||
!*packNoDownload, *packExploitRuns, *packKernelRuns)
|
!*packNoDownload, *packExploitRuns, *packKernelRuns)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
pack.go
5
pack.go
@ -15,7 +15,8 @@ import (
|
|||||||
"code.dumpstack.io/tools/out-of-tree/config"
|
"code.dumpstack.io/tools/out-of-tree/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
func packHandler(db *sql.DB, path, registry string, kcfg config.KernelConfig,
|
func packHandler(db *sql.DB, path, registry string,
|
||||||
|
commands []config.DockerCommand, 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
|
||||||
@ -40,7 +41,7 @@ func packHandler(db *sql.DB, path, registry string, kcfg config.KernelConfig,
|
|||||||
if autogen {
|
if autogen {
|
||||||
var perRegex int64 = 1
|
var perRegex int64 = 1
|
||||||
err = kernelAutogenHandler(workPath, registry,
|
err = kernelAutogenHandler(workPath, registry,
|
||||||
perRegex, false, download)
|
commands, perRegex, false, download)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user