Пример #1
0
 def check_cfg(self):
     """ Check for Cfg files that end in .crypt but aren't encrypted """
     for root, _, files in os.walk(
             os.path.join(Bcfg2.Options.setup.repository, "Cfg")):
         for fname in files:
             fpath = os.path.join(root, fname)
             if self.HandlesFile(fpath) and fname.endswith(".crypt"):
                 if not is_encrypted(open(fpath).read()):
                     self.LintError(
                         "unencrypted-cfg",
                         "%s is a .crypt file, but it is not encrypted" %
                         fpath)
Пример #2
0
 def check_properties(self):
     """ Check for Properties data that has an ``encrypted`` attribute but
     aren't encrypted """
     for root, _, files in os.walk(
             os.path.join(Bcfg2.Options.setup.repository, "Properties")):
         for fname in files:
             fpath = os.path.join(root, fname)
             if self.HandlesFile(fpath) and fname.endswith(".xml"):
                 xdata = lxml.etree.parse(fpath)
                 for elt in xdata.xpath('//*[@encrypted]'):
                     if not elt.text:
                         self.LintError(
                             "empty-encrypted-properties",
                             "Element in %s has an 'encrypted' attribute, "
                             "but no text content: %s" %
                             (fpath, self.RenderXML(elt)))
                     elif not is_encrypted(elt.text):
                         self.LintError(
                             "unencrypted-properties",
                             "Element in %s has an 'encrypted' attribute, "
                             "but is not encrypted: %s" %
                             (fpath, self.RenderXML(elt)))