Implements marshalling for config
This commit is contained in:
@@ -45,6 +45,20 @@ func (at *ArtifactType) UnmarshalTOML(data []byte) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (at ArtifactType) MarshalTOML() (data []byte, err error) {
|
||||
s := ""
|
||||
switch at {
|
||||
case KernelModule:
|
||||
s = "module"
|
||||
case KernelExploit:
|
||||
s = "exploit"
|
||||
default:
|
||||
err = errors.New(fmt.Sprintf("Cannot marshal %d", at))
|
||||
}
|
||||
data = []byte(`"` + s + `"`)
|
||||
return
|
||||
}
|
||||
|
||||
type Artifact struct {
|
||||
Name string
|
||||
Type ArtifactType
|
||||
@@ -114,6 +128,22 @@ func (dt *DistroType) UnmarshalTOML(data []byte) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (dt DistroType) MarshalTOML() (data []byte, err error) {
|
||||
s := ""
|
||||
switch dt {
|
||||
case Ubuntu:
|
||||
s = "Ubuntu"
|
||||
case CentOS:
|
||||
s = "CentOS"
|
||||
case Debian:
|
||||
s = "Debian"
|
||||
default:
|
||||
err = errors.New(fmt.Sprintf("Cannot marshal %d", dt))
|
||||
}
|
||||
data = []byte(`"` + s + `"`)
|
||||
return
|
||||
}
|
||||
|
||||
type KernelInfo struct {
|
||||
DistroType DistroType
|
||||
DistroRelease string // 18.04/7.4.1708/9.1
|
||||
|
||||
Reference in New Issue
Block a user