Esempio n. 1
0
def test_get_dotted_function():
    """test dotted access to the nested dictionary helper"""

    data = {'a': {'b': 1}}
    assert get_dotted(data, 'a') == {'b': 1}
    assert get_dotted(data, 'a.b') == 1
    assert get_dotted(data, 'a.b.c') is None
Esempio n. 2
0
def config_from_yaml(filename):
    """pull config variables from config file"""

    config_dict = load_yaml(filename)
    config = {
        'SERVER': get_dotted(config_dict, 'agent.server'),
        'APIKEY': get_dotted(config_dict, 'agent.apikey'),
        'QUEUE': get_dotted(config_dict, 'agent.queue')}
    return {k: v for k, v in config.items() if v is not None}
Esempio n. 3
0
def config_from_yaml(filename):
    """pull config variables from config file"""

    config_dict = load_yaml(filename)
    config = {
        # flask
        'APPLICATION_ROOT': get_dotted(config_dict, 'server.application_root'),
        'SECRET_KEY': get_dotted(config_dict, 'server.secret'),
        # sqlalchemy
        'SQLALCHEMY_DATABASE_URI': get_dotted(config_dict, 'server.db'),
        # sner
        'SNER_VAR': get_dotted(config_dict, 'server.var'),
        'SNER_SESSION_IDLETIME': get_dotted(config_dict, 'server.session_idletime'),
        'SNER_TAGS_HOST': get_dotted(config_dict, 'server.tags_host'),
        'SNER_TAGS_VULN': get_dotted(config_dict, 'server.tags_vuln'),
        'SNER_TAGS_ANNOTATE': get_dotted(config_dict, 'server.tags_annotate'),
        'SNER_TRIM_REPORT_CELLS': get_dotted(config_dict, 'server.trim_report_cells'),
        'SNER_PLANNER': get_dotted(config_dict, 'planner')
    }
    return {k: v for k, v in config.items() if v is not None}
Esempio n. 4
0
def config_from_yaml(filename):
    """pull config variables from config file"""

    config_dict = load_yaml(filename)
    config = {
        'SECRET_KEY': get_dotted(config_dict, 'server.secret'),
        'APPLICATION_ROOT': get_dotted(config_dict, 'server.application_root'),
        'SQLALCHEMY_DATABASE_URI': get_dotted(config_dict, 'server.db'),
        'SNER_VAR': get_dotted(config_dict, 'server.var'),
        'SNER_SESSION_IDLETIME': get_dotted(config_dict, 'server.session_idletime'),
        'SNER_TAGS': get_dotted(config_dict, 'server.tags')}
    return {k: v for k, v in config.items() if v is not None}