]> xenbits.xensource.com Git - people/gdunlap/xsatool.git/commitdiff
VersionMeta: Make XSA list per-tree
authorGeorge Dunlap <george.dunlap@citrix.com>
Wed, 17 May 2017 16:32:07 +0000 (17:32 +0100)
committerGeorge Dunlap <george.dunlap@citrix.com>
Wed, 17 May 2017 16:32:07 +0000 (17:32 +0100)
Not all XSAs apply to each tree; therefore to which XSAs need to be
applied as prerequisites for a given XSA, we need to store them
per-tree.

Change this to a map[Tree][]int.  Create SecurityMeta.InitVersion() to
initialize an empty version properly.

Also:
- explicitly list in an XSA which trees are supported (unused)
- Add SecurityMeta.AddXSA(), which will update VersionMeta based on xsa.Trees

Signed-off-by: George Dunlap <george.dunlap@citrix.com>
global.go
meta.go

index 6d8c12aaedc66109ca4c2c62756a7c96cb869c3d..fb8d4836de4e41a2f7574a8d52de3259f78f0b90 100644 (file)
--- a/global.go
+++ b/global.go
@@ -55,10 +55,13 @@ func MainGlobalUpdate(unused *XSAMeta, args []string) int {
                                fmt.Printf("New version %v supercedes %v, discarding XSAs\n",
                                        fv, vm.Latest)
                                vm.Latest = fv
-                               vm.XSAs = []int{}
+                               ForEachCodeTree(func(t Tree) error {
+                                       vm.XSAs[t] = []int{}
+                                       return nil
+                               })
                        }
                } else if init && fv.XenVersion().IsGreaterEqualThan(limit) {
-                       sm.Versions[fv.XenVersion()] = &VersionMeta{Latest: fv, XSAs: []int{}}
+                       sm.InitVersion(fv)
                } else {
                        fmt.Printf("Skipping version %v\n", fv)
                }
diff --git a/meta.go b/meta.go
index b17935a24e4eb1cc574cc80d8636311560ae360c..25cb8f7378b89a63444814335e1fa306132446af 100644 (file)
--- a/meta.go
+++ b/meta.go
@@ -142,7 +142,7 @@ func (tc ToolConfig) GetPath(t Tree) (s string) {
 
 type VersionMeta struct {
        Latest XenVersionFull
-       XSAs   []int
+       XSAs   map[Tree][]int
 }
 
 type SecurityMeta struct {
@@ -190,9 +190,32 @@ func (sm *SecurityMeta) Save() (err error) {
        return
 }
 
+func (sm *SecurityMeta) InitVersion(fv XenVersionFull) *VersionMeta {
+       var vm VersionMeta
+
+       vm.XSAs = make(map[Tree][]int)
+       vm.Latest = fv
+       ForEachCodeTree(func(t Tree) error {
+               vm.XSAs[t] = []int{}
+               return nil
+       })
+       sm.Versions[fv.XenVersion()] = &vm
+
+       return &vm
+}
+
+func (sm *SecurityMeta) AddXSA(xsa *XSAMeta) {
+       for _, vm := range sm.Versions {
+               for _, t := range xsa.Trees {
+                       vm.XSAs[t] = append(vm.XSAs[t], xsa.XSA)
+               }
+       }
+}
+
 type XSAMeta struct {
        XSA               int
        SupportedVersions []XenVersion
+       Trees             []Tree
        Recipes           map[XenVersion]*Recipe
        // Not exported
        dirty bool