1
0

feat!: rename supported kernels to targets

BREAKING CHANGE: .out-of-tree.toml: s/[[supported_kernels]]/[[targets]]/
This commit is contained in:
dump_stack() 2023-05-18 18:13:09 +00:00
parent 6939d64226
commit 6385ce92e3
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
12 changed files with 26 additions and 26 deletions

View File

@ -139,7 +139,7 @@ jobs:
echo 'name = "test"' >> .out-of-tree.toml echo 'name = "test"' >> .out-of-tree.toml
echo 'type = "${{ matrix.type }}"' >> .out-of-tree.toml echo 'type = "${{ matrix.type }}"' >> .out-of-tree.toml
echo 'script = "script.sh"' >> .out-of-tree.toml echo 'script = "script.sh"' >> .out-of-tree.toml
echo '[[supported_kernels]]' >> .out-of-tree.toml echo '[[targets]]' >> .out-of-tree.toml
echo 'distro = { id = "${{ matrix.os.distro }}", release = "${{ matrix.os.release }}" }' >> .out-of-tree.toml echo 'distro = { id = "${{ matrix.os.distro }}", release = "${{ matrix.os.release }}" }' >> .out-of-tree.toml
echo 'release_mask = ".*"' >> .out-of-tree.toml echo 'release_mask = ".*"' >> .out-of-tree.toml

View File

@ -135,7 +135,7 @@ type Artifact struct {
Type ArtifactType Type ArtifactType
TestFiles []FileTransfer TestFiles []FileTransfer
SourcePath string SourcePath string
SupportedKernels []KernelMask Targets []KernelMask
Script string Script string
@ -187,7 +187,7 @@ func (ka Artifact) checkSupport(ki KernelInfo, km KernelMask) (
// Supported returns true if given kernel is supported by artifact // Supported returns true if given kernel is supported by artifact
func (ka Artifact) Supported(ki KernelInfo) (supported bool, err error) { func (ka Artifact) Supported(ki KernelInfo) (supported bool, err error) {
for _, km := range ka.SupportedKernels { for _, km := range ka.Targets {
supported, err = ka.checkSupport(ki, km) supported, err = ka.checkSupport(ki, km)
if supported { if supported {
break break
@ -331,8 +331,8 @@ func ReadArtifactConfig(path string) (ka Artifact, err error) {
return return
} }
for i, _ := range ka.SupportedKernels { for i, _ := range ka.Targets {
km := &ka.SupportedKernels[i] km := &ka.Targets[i]
if len(km.Kernel.Version) != 0 && km.ReleaseMask != "" { if len(km.Kernel.Version) != 0 && km.ReleaseMask != "" {
s := "Only one way to define kernel version is allowed" s := "Only one way to define kernel version is allowed"
err = errors.New(s) err = errors.New(s)

View File

@ -17,7 +17,7 @@ func TestMarshalUnmarshal(t *testing.T) {
Name: "Put name here", Name: "Put name here",
Type: KernelModule, Type: KernelModule,
} }
artifactCfg.SupportedKernels = append(artifactCfg.SupportedKernels, artifactCfg.Targets = append(artifactCfg.Targets,
KernelMask{distro.Distro{ KernelMask{distro.Distro{
ID: distro.Ubuntu, ID: distro.Ubuntu,
Release: "18.04", Release: "18.04",

View File

@ -229,7 +229,7 @@ func firstSupported(kcfg config.KernelConfig, ka config.Artifact,
return return
} }
ka.SupportedKernels = []config.KernelMask{km} ka.Targets = []config.KernelMask{km}
for _, ki = range kcfg.Kernels { for _, ki = range kcfg.Kernels {
var supported bool var supported bool

View File

@ -3,15 +3,15 @@
name = "out-of-tree exploit example" name = "out-of-tree exploit example"
type = "exploit" type = "exploit"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "16.04" } distro = { id = "Ubuntu", release = "16.04" }
release_mask = "4[.]4[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116)-.*" release_mask = "4[.]4[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116)-.*"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "16.04" } distro = { id = "Ubuntu", release = "16.04" }
release_mask = "4[.]8[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58)-.*" release_mask = "4[.]8[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58)-.*"
[[supported_kernels]] [[targets]]
# Can be Ubuntu/CentOS/Debian/etc. # Can be Ubuntu/CentOS/Debian/etc.
distro = { id = "Ubuntu", release = "16.04" } distro = { id = "Ubuntu", release = "16.04" }
# regex for `uname -r` # regex for `uname -r`
@ -19,14 +19,14 @@ distro = { id = "Ubuntu", release = "16.04" }
# stupid way to generate: $ echo '4.4.0-('$(seq 44 | xargs echo | sed 's/ /|/g')')-.*' # stupid way to generate: $ echo '4.4.0-('$(seq 44 | xargs echo | sed 's/ /|/g')')-.*'
release_mask = "4[.]10[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42)-.*" release_mask = "4[.]10[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42)-.*"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "16.04" } distro = { id = "Ubuntu", release = "16.04" }
release_mask = "4[.]11[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14)-.*" release_mask = "4[.]11[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14)-.*"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "16.04" } distro = { id = "Ubuntu", release = "16.04" }
# equivalent for "4[.]13[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21)-.*" # equivalent for "4[.]13[.]0-(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21)-.*"
[supported_kernels.kernel] [targets.kernel]
version = [ 4 ] version = [ 4 ]
major = [ 13 ] major = [ 13 ]
minor = [ 0 ] minor = [ 0 ]

View File

@ -3,24 +3,24 @@
name = "out-of-tree module example" name = "out-of-tree module example"
type = "module" type = "module"
[[supported_kernels]] [[targets]]
# Can be Ubuntu/CentOS/Debian/etc. # Can be Ubuntu/CentOS/Debian/etc.
distro = { id = "Ubuntu", release = "16.04" } distro = { id = "Ubuntu", release = "16.04" }
# regex for `uname -r` # regex for `uname -r`
# See also: regex-golang.appspot.com # See also: regex-golang.appspot.com
release_mask = "4[.]4[.]0-70-.*" release_mask = "4[.]4[.]0-70-.*"
# [[supported_kernels]] may be defined unlimited number of times # [[targets]] may be defined unlimited number of times
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "18.04" } distro = { id = "Ubuntu", release = "18.04" }
# Also you can use only one kernel # Also you can use only one kernel
release_mask = "4[.]15[.]0-(24|29)-generic" release_mask = "4[.]15[.]0-(24|29)-generic"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "18.04" } distro = { id = "Ubuntu", release = "18.04" }
# Also you can use only one kernel # Also you can use only one kernel
release_mask = "4[.]15[.]0-23-generic" release_mask = "4[.]15[.]0-23-generic"
[[supported_kernels]] [[targets]]
distro = { id = "CentOS", release = "7" } distro = { id = "CentOS", release = "7" }
release_mask = "3[.]10[.]0-862.el7.x86_64" release_mask = "3[.]10[.]0-862.el7.x86_64"

View File

@ -1,7 +1,7 @@
name = "out-of-tree preload" name = "out-of-tree preload"
type = "module" type = "module"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "18.04" } distro = { id = "Ubuntu", release = "18.04" }
release_mask = ".*" release_mask = ".*"

View File

@ -5,6 +5,6 @@ type = "script"
script = "script.sh" script = "script.sh"
[[supported_kernels]] [[targets]]
distro = { id = "Ubuntu", release = "22.04" } distro = { id = "Ubuntu", release = "22.04" }
release_mask = ".*" release_mask = ".*"

4
gen.go
View File

@ -32,11 +32,11 @@ func genConfig(at config.ArtifactType) (err error) {
Name: "Put name here", Name: "Put name here",
Type: at, Type: at,
} }
a.SupportedKernels = append(a.SupportedKernels, config.KernelMask{ a.Targets = append(a.Targets, config.KernelMask{
Distro: distro.Distro{ID: distro.Ubuntu, Release: "18.04"}, Distro: distro.Distro{ID: distro.Ubuntu, Release: "18.04"},
ReleaseMask: ".*", ReleaseMask: ".*",
}) })
a.SupportedKernels = append(a.SupportedKernels, config.KernelMask{ a.Targets = append(a.Targets, config.KernelMask{
Distro: distro.Distro{ID: distro.Debian, Release: "8"}, Distro: distro.Distro{ID: distro.Debian, Release: "8"},
ReleaseMask: ".*", ReleaseMask: ".*",
}) })

View File

@ -107,7 +107,7 @@ func (cmd KernelAutogenCmd) Run(kernelCmd *KernelCmd, g *Globals) (err error) {
shutdown := false shutdown := false
kernel.SetSigintHandler(&shutdown) kernel.SetSigintHandler(&shutdown)
for _, sk := range ka.SupportedKernels { for _, sk := range ka.Targets {
if sk.Distro.Release == "" { if sk.Distro.Release == "" {
err = errors.New("Please set distro_release") err = errors.New("Please set distro_release")
return return

4
pew.go
View File

@ -101,11 +101,11 @@ func (cmd *PewCmd) Run(g *Globals) (err error) {
return return
} }
ka.SupportedKernels = []config.KernelMask{km} ka.Targets = []config.KernelMask{km}
} }
if cmd.Guess { if cmd.Guess {
ka.SupportedKernels, err = genAllKernels() ka.Targets, err = genAllKernels()
if err != nil { if err != nil {
return return
} }

View File

@ -105,7 +105,7 @@ func buildPreload(workPath, tmp string, ki config.KernelInfo,
Distro: ki.Distro, Distro: ki.Distro,
ReleaseMask: ki.KernelRelease, ReleaseMask: ki.KernelRelease,
} }
ka.SupportedKernels = []config.KernelMask{km} ka.Targets = []config.KernelMask{km}
if ka.Docker.Timeout.Duration != 0 { if ka.Docker.Timeout.Duration != 0 {
dockerTimeout = ka.Docker.Timeout.Duration dockerTimeout = ka.Docker.Timeout.Duration