Skip to content

Commit 69102cd

Browse files
committed
oval: add textfilecontent54 objects
Claircore has need to interrogate the corresponding textfilecontent54 tests, so implement the referenced objects to make the lookup heuristics easier. Signed-off-by: Hank Donnay <[email protected]>
1 parent 066a9f8 commit 69102cd

File tree

3 files changed

+42
-13
lines changed

3 files changed

+42
-13
lines changed

oval/objects.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
func (o *Objects) init() {
99
var wg sync.WaitGroup
10-
wg.Add(5)
10+
wg.Add(6)
1111

1212
go func() {
1313
defer wg.Done()
@@ -25,6 +25,14 @@ func (o *Objects) init() {
2525
}
2626
}()
2727

28+
go func() {
29+
defer wg.Done()
30+
o.textfilecontent54Memo = make(map[string]int, len(o.TextfileContent54Objects))
31+
for i, v := range o.TextfileContent54Objects {
32+
o.textfilecontent54Memo[v.ID] = i
33+
}
34+
}()
35+
2836
go func() {
2937
defer wg.Done()
3038
o.rpminfoMemo = make(map[string]int, len(o.RPMInfoObjects))
@@ -62,6 +70,9 @@ func (o *Objects) Lookup(ref string) (kind string, index int, err error) {
6270
if i, ok := o.version55Memo[ref]; ok {
6371
return o.Version55Objects[i].XMLName.Local, i, nil
6472
}
73+
if i, ok := o.textfilecontent54Memo[ref]; ok {
74+
return o.TextfileContent54Objects[i].XMLName.Local, i, nil
75+
}
6576
if i, ok := o.rpminfoMemo[ref]; ok {
6677
return o.RPMInfoObjects[i].XMLName.Local, i, nil
6778
}

oval/textfilecontent54.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,19 @@ type TextfileContent54Test struct {
1212
}
1313

1414
var _ Test = (*TextfileContent54Test)(nil)
15+
16+
// TextfileContent54Object : >tests>textfilecontent54_object
17+
type TextfileContent54Object struct {
18+
XMLName xml.Name `xml:"textfilecontent54_object"`
19+
ID string `xml:"id,attr"`
20+
Version int `xml:"version,attr"`
21+
Filepath string `xml:"filepath"`
22+
Pattern string `xml:"pattern"`
23+
Instance TCInstance `xml:"instance"`
24+
}
25+
26+
type TCInstance struct {
27+
XMLName xml.Name `xml:"instance"`
28+
Instance string `xml:",chardata"`
29+
Kind string `xml:"datatype,attr"`
30+
}

oval/types.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,20 @@ type StateRef struct {
260260

261261
// Objects : >objects
262262
type Objects struct {
263-
once sync.Once
264-
XMLName xml.Name `xml:"objects"`
265-
LineObjects []LineObject `xml:"line_object"`
266-
Version55Objects []Version55Object `xml:"version55_object"`
267-
RPMInfoObjects []RPMInfoObject `xml:"rpminfo_object"`
268-
RPMVerifyFileObjects []RPMVerifyFileObject `xml:"rpmverifyfile_object"`
269-
DpkgInfoObjects []DpkgInfoObject `xml:"dpkginfo_object"`
270-
lineMemo map[string]int
271-
version55Memo map[string]int
272-
rpminfoMemo map[string]int
273-
rpmverifyfileMemo map[string]int
274-
dpkginfoMemo map[string]int
263+
once sync.Once
264+
XMLName xml.Name `xml:"objects"`
265+
LineObjects []LineObject `xml:"line_object"`
266+
Version55Objects []Version55Object `xml:"version55_object"`
267+
TextfileContent54Objects []TextfileContent54Object `xml:"textfilecontent54_object"`
268+
RPMInfoObjects []RPMInfoObject `xml:"rpminfo_object"`
269+
RPMVerifyFileObjects []RPMVerifyFileObject `xml:"rpmverifyfile_object"`
270+
DpkgInfoObjects []DpkgInfoObject `xml:"dpkginfo_object"`
271+
lineMemo map[string]int
272+
version55Memo map[string]int
273+
textfilecontent54Memo map[string]int
274+
rpminfoMemo map[string]int
275+
rpmverifyfileMemo map[string]int
276+
dpkginfoMemo map[string]int
275277
}
276278

277279
// States : >states

0 commit comments

Comments
 (0)