@rtype: Boolean
@returns: True if the GLSA was applied, False if not
"""
- aList = grabfile(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep)))
+ aList = grabfile(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa"))
return (self.nr in aList)
def inject(self):
@returns: None
"""
if not self.isApplied():
- checkfile = open(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep)), "a+")
+ checkfile = open(os.path.join(os.sep, self.config["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa"), "a+")
checkfile.write(self.nr+"\n")
checkfile.close()
return None
vdbapi=None, portdbapi=None):
from portage.sets.files import StaticFileSet, ConfigFileSet
from portage.sets.profiles import PackagesSystemSet
- from portage.sets.security import AffectedSet
+ from portage.sets.security import NewAffectedSet
from portage.sets.dbapi import EverythingSet
rValue = set()
rValue.add(myset)
rValue.add(PackagesSystemSet("system", profile_paths))
if settings != None and portdbapi != None:
- rValue.add(AffectedSet("security", settings, vdbapi, portdbapi))
+ rValue.add(NewAffectedSet("security", settings, vdbapi, portdbapi))
else:
rValue.add(InternalPackageSet("security"))
if vdbapi != None:
# $Id$
import portage.glsa as glsa
+from portage.util import grabfile
+from portage.const import CACHE_PATH
+import os
from portage.sets import PackageSet
class SecuritySet(PackageSet):
_operations = ["merge"]
-
+ _skip_applied = False
+
def __init__(self, name, settings, vardbapi, portdbapi):
super(SecuritySet, self).__init__(name)
self._settings = settings
self._vardbapi = vardbapi
self._portdbapi = portdbapi
+ self._checkfile = os.path.join(os.sep, self._settings["ROOT"], CACHE_PATH.lstrip(os.sep), "glsa")
+
+ def getGlsaList(self, skip_applied):
+ glsaindexlist = glsa.get_glsa_list(self._settings)
+ if skip_applied:
+ applied_list = grabfile(self._checkfile)
+ glsaindexlist = set(glsaindexlist).difference(applied_list)
+ glsaindexlist = list(glsaindexlist)
+ glsaindexlist.sort()
+ return glsaindexlist
def load(self):
- glsaindexlist = glsa.get_glsa_list(self._settings)
+ glsaindexlist = self.getGlsaList(self._skip_applied)
atomlist = []
for glsaid in glsaindexlist:
myglsa = glsa.Glsa(glsaid, self._settings, self._vardbapi, self._portdbapi)
def useGlsa(self, myglsa):
return True
+
+ def updateAppliedList(self):
+ glsaindexlist = self.getGlsaList(True)
+ applied_list = grabfile(self._checkfile)
+ for glsaid in glsaindexlist:
+ myglsa = glsa.Glsa(glsaid, self._settings, self._vardbapi, self._portdbapi)
+ if not myglsa.isVulnerable():
+ applied_list.append(glsaid)
+ write_atomic(self._checkfile, "\n".join(applied_list))
class NewGlsaSet(SecuritySet):
- def useGlsa(self, myglsa):
- return not myglsa.isApplied()
+ _skip_applied = True
class AffectedSet(SecuritySet):
def useGlsa(self, myglsa):
return myglsa.isVulnerable()
+
+class NewAffectedSet(AffectedSet):
+ _skip_applied = True