summaryrefslogtreecommitdiffstats
path: root/pym/portage/sets/security.py
diff options
context:
space:
mode:
Diffstat (limited to 'pym/portage/sets/security.py')
-rw-r--r--pym/portage/sets/security.py33
1 files changed, 29 insertions, 4 deletions
diff --git a/pym/portage/sets/security.py b/pym/portage/sets/security.py
index 4827886a8..cf4af0940 100644
--- a/pym/portage/sets/security.py
+++ b/pym/portage/sets/security.py
@@ -3,20 +3,34 @@
# $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)
@@ -27,11 +41,22 @@ class SecuritySet(PackageSet):
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