当前位置: 首页>>代码示例>>Python>>正文


Python config.CRITsConfig类代码示例

本文整理汇总了Python中crits.config.config.CRITsConfig的典型用法代码示例。如果您正苦于以下问题:Python CRITsConfig类的具体用法?Python CRITsConfig怎么用?Python CRITsConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CRITsConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: force_reset_config

def force_reset_config():
    """
    Resets the values for the CRITsConfig class by dropping the
    database collection and then saving a new default CRITsConfig.
    """

    print "Resetting CRITs configuration settings."
    CRITsConfig.drop_collection();

    crits_config = CRITsConfig();
    crits_config.save();
开发者ID:dicato,项目名称:crits,代码行数:11,代码来源:setconfig.py

示例2: get_config

def get_config():
    """
    Get the CRITs configuration.

    :returns: :class:`crits.config.config.CRITsConfig`
    """

    crits_config = CRITsConfig.objects().first()
    if not crits_config:
        crits_config = CRITsConfig()
        crits_config.save()
    return crits_config
开发者ID:AInquel,项目名称:crits,代码行数:12,代码来源:tests.py

示例3: clean_db

def clean_db():
    """
    Clean up the DB after testing.
    """

    src = SourceAccess.objects(name=TSRC).first()
    if src:
        src.delete()
    user = CRITsUser.objects(username=TUSER_NAME).first()
    if user:
        user.delete()
    TestObject.drop_collection()
    TestSourceObject.drop_collection()
    CRITsConfig.drop_collection()
开发者ID:AInquel,项目名称:crits,代码行数:14,代码来源:tests.py

示例4: __init__

    def __init__(self, username=None, email=None):
        """
        Set the default subject, body, from address, and other bits.
        """

        # set the user and email address to send to
        self.username = username
        self.email = email

        # grab the CRITs url to use for links
        crits_config = CRITsConfig.objects().first()
        self.instance_url = crits_config.instance_url
        if self.instance_url.endswith("/"):
            self.instance_url = self.instance_url[:-1]

        # set the email address to send this email from
        self.from_address = crits_config.crits_email

        # setup the email subject
        if crits_config.crits_email_end_tag:
            self.subject = "CRITs: Subscriptions and Notifications" + crits_config.crits_email_subject_tag
        else:
            self.subject = crits_config.crits_email_subject_tag + "CRITs: Subscriptions and Notifications"

        # start the body of the email
        comments_url = self.instance_url + reverse('crits-comments-views-activity')
        self.body = "Here's info on the latest comments and updates to CRITs that you are subscribed to!\n\n"
        self.body += "For more info, check out the Activity page: %s\n\n" % comments_url
开发者ID:armtash,项目名称:crits,代码行数:28,代码来源:generate_notifications.py

示例5: change_user_password

def change_user_password(username, current_p, new_p, new_p_c):
    """
    Change the password for a user.

    :param username: The user to query for.
    :type username: str
    :param current_p: The user's current password.
    :type current_p: str
    :param new_p: The new password.
    :type new_p: str
    :param new_p_c: New password confirmation.
    :type new_p_c: str
    :returns: dict with keys "success" (boolean) and "message" (str) if failed.
    """

    if new_p != new_p_c:
        return {'success': False, 'message': 'New password confirmation does not match.'}
    from crits.core.user import CRITsUser
    username = str(username)
    user = CRITsUser.objects(username=username).first()
    if not user:
        return {'success': False, 'message': 'Unknown user.'}
    if not user.check_password(current_p):
        return {'success': False, 'message': 'Current password invalid.'}
    if user.set_password(new_p, username):
        return {'success': True, 'message': 'Password Change Successful.'}
    else:
        from crits.config.config import CRITsConfig
        crits_config = CRITsConfig.objects().first()
        if crits_config:
            regex_desc = crits_config.password_complexity_desc
        else:
            regex_desc = settings.PASSWORD_COMPLEXITY_DESC
        return {'success': False,
                'message': 'Password not complex enough: %s' % regex_desc}
开发者ID:thelok,项目名称:crits-1,代码行数:35,代码来源:user_tools.py

示例6: reset_password

    def reset_password(self, rcode, new_p, new_p_c, analyst):
        """
        Reset the user's password. Validate the reset code, ensure the two
        passwords are identical, and then set.

        :param rcode: Reset Code to validate.
        :type rcode: str
        :param new_p: New password.
        :type new_p: str
        :param new_p_c: New password confirmation.
        :type new_p_c: str
        :param analyst: The user.
        :type analyst: str
        :returns: dict with keys "success" (boolean) and "message" (str).
        """

        if self.validate_reset_code(rcode, analyst)['success']:
            if new_p == new_p_c:
                self.password_reset.reset_code = ""
                if self.set_password(new_p):
                    return {'success': True, 'message': 'Password reset.'}
                else:
                    crits_config = CRITsConfig.objects().first()
                    if crits_config:
                        pw_desc = crits_config.password_complexity_desc
                    else:
                        pw_desc = settings.PASSWORD_COMPLEXITY_DESC
                    message = 'Password not complex enough: %s' % pw_desc
                    return {'success': False, 'message': message}
            else:
                return {'success': False, 'message': 'Passwords do not match.'}
        else:
            self.password_reset.reset_code = ""
            self.save(username=analyst)
            return {'success': False, 'message': 'Reset Code Expired.'}
开发者ID:Abdullah-Mughal,项目名称:crits,代码行数:35,代码来源:user.py

示例7: _generate_request_instance

    def _generate_request_instance(self, request_type):
        """Automatically generate a request instance to use.

        In the end, this saves us from having to load each request class in a
        explicit way. Loading via a string is helpful to reduce the code per
        call.
        """
        crits_config = CRITsConfig.objects().first()

        http_proxy_value = None

        if crits_config.http_proxy:
            http_proxy_value = crits_config.http_proxy

        class_lookup = {'dns': 'DnsRequest', 'whois': 'WhoisRequest',
                        'ssl': 'SslRequest', 'enrichment': 'EnrichmentRequest',
                        'attributes': 'AttributeRequest'}
        class_name = class_lookup[request_type]
        mod = __import__('passivetotal.libs.%s' % request_type,
                         fromlist=[class_name])
        loaded = getattr(mod, class_name)
        headers = {'PT-INTEGRATION': 'CRITs'}
        authenticated = loaded(self.username, self.api_key, headers=headers,
            http_proxy=http_proxy_value, https_proxy=http_proxy_value)

        return authenticated
开发者ID:TheDr1ver,项目名称:crits_services,代码行数:26,代码来源:__init__.py

示例8: upgrade

def upgrade(lv, options):
    """
    Perform the upgrade.

    :param lv: The CRITs version we are running.
    :type lv: str
    :param options: The options passed in for what to upgrade.
    :type options: dict
    """

    # eventually we will do something to check to see what the current version
    # of the CRITs DB is so we can upgrade through several versions at once.
    # this is important if prep scripts need to be run for certain upgrades
    # to work properly.
    mall = options.get('mall')
    campaigns = options.get('campaigns')
    domains = options.get('domains')
    emails = options.get('emails')
    events = options.get('events')
    indicators = options.get('indicators')
    ips = options.get('ips')
    pcaps = options.get('pcaps')
    samples = options.get('samples')
    targets = options.get('targets')
    skip = options.get('skip')
    sort_ids = options.get('sort_ids')

    # run prep migrations
    if not skip:
        prep_database()

    # run full migrations
    if mall or campaigns:
        migrate_collection(Campaign, sort_ids)
    if mall or domains:
        migrate_collection(Domain, sort_ids)
    if mall or emails:
        migrate_collection(Email, sort_ids)
    if mall or events:
        migrate_collection(Event, sort_ids)
    if mall or indicators:
        migrate_collection(Indicator, sort_ids)
    if mall or ips:
        migrate_collection(IP, sort_ids)
    if mall or pcaps:
        migrate_collection(PCAP, sort_ids)
    if mall or samples:
        migrate_collection(Sample, sort_ids)
    if mall or targets:
        migrate_collection(Target, sort_ids)

    # Always bump the version to the latest in settings.py
    config = CRITsConfig.objects()
    if len(config) > 1:
        print "You have more than one config object. This is really bad."
    else:
        config = config[0]
        config.crits_version = settings.CRITS_VERSION
        config.save()
开发者ID:brentonchang,项目名称:crits-1,代码行数:59,代码来源:upgrade.py

示例9: create_config_if_not_exist

def create_config_if_not_exist():
    """
    If the CRITsConfig already exists then the CRITsConfig is returned,
    otherwise a new CRITsConfig will be created, saved, and returned.

    Returns:
        Returns the CRITsConfig if it already exists, otherwise a
        default CRITsConfig is returned.
    """

    crits_config = CRITsConfig.objects().first()
    if not crits_config:
        print "Creating a new CRITs configuration."
        crits_config = CRITsConfig()
        crits_config.save()
    else:
        print "A CRITs configuration already exists. Skipping default creation."

    return crits_config
开发者ID:dicato,项目名称:crits,代码行数:19,代码来源:setconfig.py

示例10: email_user

    def email_user(self, subject, message, from_email=None):
        """
        Sends an e-mail to this User.
        """

        from django.core.mail import send_mail
        if not from_email:
            crits_config = CRITsConfig.objects().first()
            if crits_config:
                from_email = crits_config.crits_email
        send_mail(subject, message, from_email, [self.email])
开发者ID:Abdullah-Mughal,项目名称:crits,代码行数:11,代码来源:user.py

示例11: modify_configuration

def modify_configuration(config_form, analyst):
    """
    Modify the configuration with the submitted changes.

    :param config_form: The form data.
    :type config_form: dict
    :param analyst: The user making the modifications.
    :type analyst: str
    :returns: dict with key "message"
    """

    config = CRITsConfig.objects().first()
    if not config:
        config = CRITsConfig()
    data = config_form.cleaned_data
    allowed_hosts_list = data['allowed_hosts'].split(',')
    allowed_hosts = ()
    for allowed_host in allowed_hosts_list:
        allowed_hosts = allowed_hosts + (allowed_host.strip(),)
    data['allowed_hosts'] = allowed_hosts
    service_dirs_list = data['service_dirs'].split(',')
    service_dirs = ()
    for service_dir in service_dirs_list:
        service_dirs = service_dirs + (service_dir.strip(),)
    data['service_dirs'] = service_dirs
    config.merge(data, overwrite=True)
    try:
        config.save(username=analyst)
        return {'message': "Success!"}
    except Exception, e:
        return {'message': "Failure: %s" % e}
开发者ID:dmbuchta,项目名称:crits,代码行数:31,代码来源:handlers.py

示例12: authenticate

    def authenticate(self, username, password=None, user_agent=None,
                     remote_addr=None, accept_language=None,
                     totp_enabled='Disabled'):
        """
        Perform the authentication of the user.

        :param username: The user to authenticate.
        :type username: str
        :param password: The password provided to authenticate with.
        :type password: str
        :param user_agent: The user-agent in the request.
        :type user_agent: str
        :param remote_addr: The hostname/ip in the request.
        :type remote_addr: str
        :param accept_language: The Accept Language in the request.
        :type accept_language: str
        :param totp_enabled: If TOTP is enabled and should be checked as well.
        :type totp_enabled: str
        :returns: :class:`crits.core.user.CRITsUser`, None
        """

        e = EmbeddedLoginAttempt()
        e.user_agent = user_agent
        e.remote_addr = remote_addr
        e.accept_language = accept_language
        if not username:
            logger.warn("No username passed to CRITsRemoteUserBackend (auth)")
            return None
        config = CRITsConfig.objects().first()
        user = None
        username = self.clean_username(username)
        user = CRITsUser.objects(username=username).first()
        if user and user.is_active:
            if self._exceeded_login_threshold(user):
                return None

            # Log in user
            self._successful_settings(user, e, totp_enabled)
            if config.ldap_update_on_login:
                user.update_from_ldap("Auto LDAP update", config)
            return user
        elif not user and config.create_unknown_user:
            # Create the user
            user = CRITsUser.create_user(username=username, password=None)
            user.sources.append(config.company_name)
            # Attempt to update info from LDAP
            user.update_from_ldap("Auto LDAP update", config)
            user = self._successful_settings(user, e, totp_enabled)
            return user
        else:
            logger.warn("Unknown user and not creating accounts.")
            return None
开发者ID:Abdullah-Mughal,项目名称:crits,代码行数:52,代码来源:user.py

示例13: handle

    def handle(self, *args, **options):
        """
        Script execution.
        """

        username = options.get('username')
        firstname = options.get('firstname')
        lastname = options.get('lastname')
        email = options.get('email')
        sendemail = options.get('sendemail')
        admin = options.get('admin')
        organization = options.get('organization')
        password = self.temp_password()

        if not username:
            raise CommandError("Must provide a username.")
        if not email:
            raise CommandError("Must provide an email address.")
        user = CRITsUser.objects(username=username).first()
        if user:
            raise CommandError("User '%s' exists in CRITs!" % username)
        else:
            user = CRITsUser.create_user(username, password, email)
            user.first_name = firstname
            user.last_name = lastname
            user.is_staff = True
            user.save()
            user.organization = organization
            if admin:
                user.role = "Administrator"
            user.save()

            if sendemail:
                crits_config = CRITsConfig.objects().first()
                if crits_config.crits_email_end_tag:
                    subject = "New CRITs User Account" + crits_config.crits_email_subject_tag
                else:
                    subject = crits_config.crits_email_subject_tag + "New CRITs User Account"
                body = """You are receiving this email because someone has created a
CRITs account for you. If you feel like you have received this in
error, please ignore this email. Your account information is below:\n\n
"""
                body += "Username:\t%s\n" % username
                body += "Password:\t%s\n\n\n" % password
                body += """You should log in immediately and reset your password.\n
Thank you!
"""
                user.email_user(subject, body)

            self.stdout.write("User '%s' created successfully!" % username)
            self.stdout.write("\nTemp password: \t%s" % password)
            self.stdout.write("\n")
开发者ID:maurakilleen,项目名称:crits,代码行数:52,代码来源:adduser.py

示例14: prep_db

def prep_db():
    """
    Prep the DB for testing.
    """

    clean_db()
    # Create a new default config
    crits_config = CRITsConfig()
    crits_config.save()
    # Add Source
    handlers.add_new_source(TSRC, TRANDUSER)

    # Add User
    user = CRITsUser.create_user(username=TUSER_NAME,
                                 password=TUSER_PASS,
                                 email=TUSER_EMAIL
                                 )
    user.first_name = TUSER_FNAME
    user.last_name = TUSER_LNAME
    user.save()

    # Add test source object
    '''
开发者ID:armtash,项目名称:crits,代码行数:23,代码来源:tests.py

示例15: crits_config

def crits_config(request):
    """
    Generate the CRITs Configuration template.

    :param request: Django request object (Required)
    :type request: :class:`django.http.HttpRequest`
    :returns: :class:`django.http.HttpResponse`
    """

    crits_config = CRITsConfig.objects().first()
    user = request.user

    if user.has_access_to(GeneralACL.CONTROL_PANEL_READ):
        if crits_config:
            crits_config = crits_config.to_dict()
            crits_config['allowed_hosts'] = ", ".join(crits_config['allowed_hosts'])
            crits_config['service_dirs'] = ", ".join(crits_config['service_dirs'])
            config_general_form = ConfigGeneralForm(initial=crits_config)
            config_LDAP_form = ConfigLDAPForm(initial=crits_config)
            config_security_form = ConfigSecurityForm(initial=crits_config)
            config_logging_form = ConfigLoggingForm(initial=crits_config)
            config_services_form = ConfigServicesForm(initial=crits_config)
            config_download_form = ConfigDownloadForm(initial=crits_config)
            config_CRITs_form = ConfigCritsForm(initial=crits_config)
        else:
            config_general_form = ConfigGeneralForm()
            config_LDAP_form = ConfigLDAPForm()
            config_security_form = ConfigSecurityForm()
            config_logging_form = ConfigLoggingForm()
            config_services_form = ConfigServicesForm()
            config_download_form = ConfigDownloadForm()
            config_CRITs_form = ConfigCritsForm()
        user_list = get_user_list()
        try:
            return render(request, 'config.html',
                                  {'config_general_form': config_general_form,
                                   'config_LDAP_form': config_LDAP_form,
                                   'config_security_form': config_security_form,
                                   'config_logging_form': config_logging_form,
                                   'config_services_form': config_services_form,
                                   'config_download_form': config_download_form,
                                   'config_CRITs_form': config_CRITs_form,
                                   'user_list': user_list})
        except Exception as e:
            # this should help troubleshooting config forms
            logger.error(e)
    else:
        return render(request, 'error.html',
                                  {'error': 'User does not have permission to view Control Panel.'})
开发者ID:armtash,项目名称:crits,代码行数:49,代码来源:views.py


注:本文中的crits.config.config.CRITsConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。