Exemple #1
0
def writeCerts(dirn):
    '''
    Copy test SSL certs from synapse.data to a directory.

    Args:
        dirn (str): Path to write files too.

    Notes:
        Writes the following files to disk:
        . ca.crt
        . ca.key
        . ca.pem
        . server.crt
        . server.key
        . server.pem
        . root.crt
        . root.key
        . user.crt
        . user.key

        The ca has signed all three certs.  The ``server.crt`` is for
        a server running on localhost. The ``root.crt`` and ``user.crt``
        certs are both are user certs which can connect. They have the
        common names "root@localhost" and "user@localhost", respectively.

    Returns:
        None
    '''
    fns = ('ca.crt', 'ca.key', 'ca.pem', 'server.crt', 'server.key',
           'server.pem', 'root.crt', 'root.key', 'user.crt', 'user.key')
    for fn in fns:
        byts = s_data.get(fn)
        dst = os.path.join(dirn, fn)
        if not os.path.exists(dst):
            with s_common.genfile(dst) as fd:
                fd.write(byts)
Exemple #2
0
import regex

import synapse.data as s_data

tldlist = list(s_data.get('iana.tlds'))

tldlist.sort(key=lambda x: len(x))
tldlist.reverse()

tldcat = '|'.join(tldlist)
fqdn_re = regex.compile(r'((?:[a-z0-9_-]{1,63}\.){1,10}(?:%s))' % tldcat)

scrape_types = [  # type: ignore
    ('hash:md5', r'(?=(?:[^A-Za-z0-9]|^)([A-Fa-f0-9]{32})(?:[^A-Za-z0-9]|$))',
     {}),
    ('hash:sha1', r'(?=(?:[^A-Za-z0-9]|^)([A-Fa-f0-9]{40})(?:[^A-Za-z0-9]|$))',
     {}),
    ('hash:sha256',
     r'(?=(?:[^A-Za-z0-9]|^)([A-Fa-f0-9]{64})(?:[^A-Za-z0-9]|$))', {}),
    ('inet:url', r'[a-zA-Z][a-zA-Z0-9]*://[^ \'\"\t\n\r\f\v]+', {}),
    ('inet:ipv4',
     r'(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)',
     {}),
    ('inet:server',
     r'((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):[0-9]{1,5})',
     {}),
    ('inet:fqdn',
     r'(?=(?:[^a-z0-9_.-]|^)((?:[a-z0-9_-]{1,63}\.){1,10}(?:%s))(?:[^a-z0-9_.-]|[.\s]|$))'
     % tldcat, {}),
    ('inet:email',
     r'(?=(?:[^a-z0-9_.+-]|^)([a-z0-9_\.\-+]{1,256}@(?:[a-z0-9_-]{1,63}\.){1,10}(?:%s))(?:[^a-z0-9_.-]|[.\s]|$))'
Exemple #3
0
 def test_data_iana_tlds(self):
     self.true('link' in s_data.get('iana.tlds'))
Exemple #4
0
 def test_data_iana_tlds(self):
     self.true('link' in s_data.get('iana.tlds'))