def as_xml(self):
xml_result = Element(self.plugin_command, title=self.COMMAND_TITLE)
is_hsts_supported = True if self.hsts_header else False
xml_hsts_attr = {'isSupported': str(is_hsts_supported)}
if is_hsts_supported:
# Do some light parsing of the HSTS header
hsts_header_split = self.hsts_header.split('max-age=')[1].split(';')
hsts_max_age = hsts_header_split[0].strip()
hsts_subdomains = False
if len(hsts_header_split) > 1 and 'includeSubdomains' in hsts_header_split[1]:
hsts_subdomains = True
xml_hsts_attr['maxAge'] = hsts_max_age
xml_hsts_attr['includeSubdomains'] = str(hsts_subdomains)
xml_hsts = Element('httpStrictTransportSecurity', attrib=xml_hsts_attr)
xml_result.append(xml_hsts)
return xml_result
评论列表
文章目录