def __init__(self, config):
     with open(os.path.join(config.templatedir, 'validate_srv_req.html'), 'r', encoding="utf-8") as f:
         self.req_template = jinja2.Template(f.read())
     with open(os.path.join(config.templatedir, 'validate_srv_res.html'), 'r', encoding="utf-8") as f:
         self.res_template = jinja2.Template(f.read())
     self.config = config
     self.p_dict = Validator.get_profiles()
     self.p_keys = Validator.get_profiles().keys()
     self.p_reverse = {}
     for (k, v) in Validator.get_profiles().items():
         self.p_reverse[v] = k
Beispiel #2
0
 def __init__(self, config):
     with open(os.path.join(config.templatedir, 'validate_srv_req.html'),
               'r',
               encoding="utf-8") as f:
         self.req_template = jinja2.Template(f.read())
     with open(os.path.join(config.templatedir, 'validate_srv_res.html'),
               'r',
               encoding="utf-8") as f:
         self.res_template = jinja2.Template(f.read())
     self.config = config
     self.p_dict = Validator.get_profiles()
     self.p_keys = Validator.get_profiles().keys()
     self.p_reverse = {}
     for (k, v) in Validator.get_profiles().items():
         self.p_reverse[v] = k
 def test_list_profiles(self):
     """ -- List profiles """
     logging.info(TestValidator.test_list_profiles.__doc__)
     print(TestValidator.test_list_profiles.__doc__)
     # print('Profile Key | Profile Display Name')
     for (profile, display_name) in Validator.get_profiles().items():
         # print(profile + ' | ' + display_name)
         pass
 def test_list_profiles(self):
     """ -- List profiles """
     logging.info(TestValidator.test_list_profiles.__doc__)
     print(TestValidator.test_list_profiles.__doc__)
     # print('Profile Key | Profile Display Name')
     for (profile, display_name) in Validator.get_profiles().items():
         # print(profile + ' | ' + display_name)
         pass
def main():
    invocation = CliInvocation()
    validator = Validator(invocation)
    if invocation.args.proflist:
        print('File | Profile')
        for profile in validator.get_profiles():
            print(profile['file'] + ' | ' + profile['name'])
        exit(0)
    else:
        return validator.validate()
Beispiel #6
0
def main():
    invocation = CliInvocation()
    validator = Validator(invocation)
    if invocation.args.proflist:
        print('File | Profile')
        for profile in validator.get_profiles():
            print(profile['file'] + ' | ' + profile['name'])
        exit(0)
    else:
        return validator.validate()
Beispiel #7
0
 def __init__(self):
     self.HttpServer = {'port': 8080, 'listen': '0.0.0.0'}
     self.templatedir = os.path.join(
         os.path.dirname(os.path.realpath(__file__)), 'template')
     self.tempdir = '/tmp'
     # setup list of available profiles
     self.profiles = {}
     validator = Validator(ApiArgs(listprofiles=True).cliInvocation)
     self.profileoptions = '<option disabled selected value> -- select an option -- </option>'
     for display_name in Validator.get_profiles().values():
         self.profileoptions += '<option>' + display_name + '</option>'
Beispiel #8
0
 def __init__(self):
     self.HttpServer = {
         'port': 8080,
         'listen': '0.0.0.0'
     }
     self.templatedir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'template')
     self.tempdir = '/tmp'
     # setup list of available profiles
     self.profiles = {}
     validator = Validator(ApiArgs(listprofiles=True).cliInvocation)
     self.profileoptions = '<option disabled selected value> -- select an option -- </option>'
     for display_name in Validator.get_profiles().values():
         self.profileoptions += '<option>' + display_name +  '</option>'
Beispiel #9
0
        profile_dict = json.loads(''.join(fd.readlines()))
    html = '<html><head><meta charset="UTF-8"><link rel="stylesheet" type="text/css" ' \
           'href="../css/tables.css"></head><body><h1>SAML Schematron Rules for profile "%s"</h1>%s</body></html>'
    os.system('scripts/listrules.sh > work/listrules.json')
    rules = json.loads(''.join(open('work/listrules.json').readlines()))
    tabhtml = '<table class="pure-table">'
    for rule in sorted(rules):
        if not rule.startswith('rule'):
            continue
        if rule not in profile_dict['rules']:
            continue
        try:
            tabhtml += '<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n' % \
                    (rule, rules[rule]["Severity"], rules[rule]["Message"])
        except KeyError as e:
            print("rule:" + rule)
            raise
    tabhtml += '</table>'
    fname = 'saml_schtron/webapp/static/html/' + profile['file'][:-5] + '.html'
    with open(fname, 'w') as fd:
        fd.write(html % (profile['name'], tabhtml))
    print('File %s written.' % fname)


validator = Validator(ApiArgs(listprofiles=True).cliInvocation)
gen_profile_rules({
    'file': 'allrules.json',
    'name': 'All available schematron rules'
})
for profile in validator.get_profiles():
    gen_profile_rules(profile)
def gen_profile_rules(profile):
    with open('rules/profiles/' + profile['file']) as fd:
        profile_dict = json.loads(''.join(fd.readlines()))
    html = '<html><head><meta charset="UTF-8"><link rel="stylesheet" type="text/css" ' \
           'href="../css/tables.css"></head><body><h1>SAML Schematron Rules for profile "%s"</h1>%s</body></html>'
    os.system('scripts/listrules.sh > work/listrules.json')
    rules = json.loads(''.join(open('work/listrules.json').readlines()))
    tabhtml = '<table class="pure-table">'
    for rule in sorted(rules):
        if not rule.startswith('rule'):
            continue
        if rule not in profile_dict['rules']:
            continue
        try:
            tabhtml += '<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n' % \
                    (rule, rules[rule]["Severity"], rules[rule]["Message"])
        except KeyError as e:
            print("rule:" + rule)
            raise
    tabhtml += '</table>'
    fname = 'saml_schtron/webapp/static/html/' + profile['file'][:-5] + '.html'
    with open(fname, 'w') as fd:
        fd.write(html % (profile['name'], tabhtml))
    print('File %s written.' % fname)


validator = Validator(ApiArgs(listprofiles=True).cliInvocation)
gen_profile_rules({'file': 'allrules.json', 'name': 'All available schematron rules'})
for profile in validator.get_profiles():
    gen_profile_rules(profile)