Ejemplo n.º 1
0
 def __init__(self, *args, **kwargs):
     super(NodeForm, self).__init__(*args, **kwargs)
     instance = getattr(self, 'instance', None)
     # Node name is read only if we edit an existing Node instance
     if instance and type(instance.pk) is not property:
         self.fields['name'].widget.attrs['readonly'] = True
     self = bootstrap_tooltips(self)
Ejemplo n.º 2
0
    def __init__(self, *args, **kwargs):
        super(ModLogForm, self).__init__(*args, **kwargs)
        self = bootstrap_tooltips(self, exclude='repository_choices')

        repo_lst = BaseAbstractRepository.get_data_repositories()
        data_repo_lst = list()
        for rep in repo_lst:
            data_repo_lst.append((
                rep.id,
                rep.repo_name,
            ))

        self.fields['repository_choices'] = ChoiceField(choices=data_repo_lst,
                                                        required=False)

        repo_lst = BaseAbstractRepository.get_syslog_repositories()
        syslog_repo_lst = list()
        syslog_repo_lst.append(("", ""))
        for rep in repo_lst:
            syslog_repo_lst.append((
                rep.id,
                rep.repo_name,
            ))

        self.fields['repository_syslog'] = ChoiceField(choices=syslog_repo_lst,
                                                       required=False)
Ejemplo n.º 3
0
 def __init__(self, *args, **kwargs):
     super(MongoDBRepositoryForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
     self.fields['repo_type'] = ChoiceField(choices=self.REPO_TYPE)
     self.fields['db_password_salt_position'] = ChoiceField(
         choices=PASSWORD_SALT_POSITION, required=False)
     self.fields['db_password_salt_position'].empty_label = None
Ejemplo n.º 4
0
 def __init__(self, *args, **kwargs):
     super(VultureUserForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self, exclude='password')
     instance = getattr(self, 'instance', None)
     # We can't change password for an external authentication backend
     if instance and type(instance.pk) is not property \
             and instance.auth_backend:
         self.fields['password'].widget.attrs['readonly'] = True
         self.fields['pwd_confirm'].widget.attrs['readonly'] = True
Ejemplo n.º 5
0
 def __init__(self, *args, **kwargs):
     super(GLOBALSettingsForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
     repo_lst = BaseAbstractRepository.get_data_repositories()
     data_repo_lst = [(repo.id, repo.repo_name) for repo in repo_lst]
     try:
         self.fields['logs_repository'] = ChoiceField(choices=data_repo_lst, required=True,
                                         widget=Select(attrs={'class': 'form-control'}))
     except:
         pass
Ejemplo n.º 6
0
    def __init__(self, *args, **kwargs):
        super(SyslogRepositoryForm, self).__init__(*args, **kwargs)
        self = bootstrap_tooltips(self)

        PROTO = (
            ('UDP', 'UDP'),
            ('TCP', 'TCP'),
        )

        self.fields['syslog_protocol'] = ChoiceField(choices=PROTO,
                                                     required=True)
Ejemplo n.º 7
0
    def __init__(self, *args, **kwargs):
        # Get extra arg 'node' to avoid "unexpected keyword argument"
        node = kwargs.pop('node', None)
        super(ZabbixAgentForm, self).__init__(*args, **kwargs)
        bootstrap_tooltips(self)

        """ Build certificate choices - field """
        # Retrieve SSLCertificates to build choices
        certificate_list = SSLCertificate.objects.filter(is_ca=False, is_trusted_ca=False, status__ne='R').only('id',
                                                                                                                'cn')
        # Set the choices retrieven
        self.fields['tls_cert'].choices = [(cert.id, cert.cn) for cert in certificate_list]

        """ Build listener choices - field """
        # Extract ListenAddress for the listener(s) selection
        listener_filter = {'is_carp': False}
        if node:
            listener_filter['related_node'] = node
        listener_list = Listener.objects.filter(**listener_filter).only('id', 'ip')
        # Build the field
        self.fields['listeners'].choices = [(listener.id, listener.ip) for listener in listener_list]
Ejemplo n.º 8
0
    def __init__(self,
                 custom_choices=None,
                 selected_device=None,
                 *args,
                 **kwargs):
        super(InetAddressForm, self).__init__(*args, **kwargs)
        if custom_choices:
            self.fields['device'].choices = custom_choices
        if selected_device:
            self.fields['device'].initial = selected_device

        self = bootstrap_tooltips(self, exclude={'device'})
Ejemplo n.º 9
0
    def __init__(self, *args, **kwargs):
        super(ModSSLForm, self).__init__(*args, **kwargs)
        self = bootstrap_tooltips(self)

        # Extract le choices for the certificate selection
        certificate_list = SSLCertificate.objects.filter(
            is_trusted_ca__ne=True, status__ne='R').only('id', 'cn')
        certificate_choices = list()
        for cert in certificate_list:
            certificate_choices.append((cert.id, cert.cn))

        # Set the choices extracted and set the initial value
        self.fields['certificate'].choices = certificate_choices
        modssl = kwargs.pop('instance')
        if modssl:
            self.initial['certificate'] = modssl.certificate.id
Ejemplo n.º 10
0
    def __init__(self, *args, **kwargs):
        super(RewriteForm, self).__init__(*args, **kwargs)
        self = bootstrap_tooltips(self)

        # Extract le choices for the certificate selection
        app_list = Application.objects.all().only('id', 'name')
        app_choices = list()
        for app in app_list:
            app_choices.append((app.id, app.name))

        # Set the choices extracted and set the initial value
        self.fields['application'].choices = app_choices
        rewrite = kwargs.pop('instance')
        id_list = list()
        for app in rewrite.application:
            id_list.append(app.id)
        if rewrite:
            self.initial['application'] = id_list
Ejemplo n.º 11
0
    def __init__(self, *args, **kwargs):
        super(IPSECSettingsForm, self).__init__(*args, **kwargs)
        self = bootstrap_tooltips(self)

        KEYEXCHANGE = (
            ('ikev2', 'IKE version 2'),
        )
        DPD = (
            ('none', 'None'),
            ('clear', 'Clear'),
            ('hold', 'Hold'),
            ('restart', 'Restart'),
        )
        AUTHBY = (
            ('secret', 'PSK Authentication'),
        )

        self.fields['ipsec_keyexchange'] = ChoiceField(choices=KEYEXCHANGE, required=True, widget=Select(attrs={'class': 'form-control'}))
        self.fields['ipsec_dpdaction'] = ChoiceField(choices=DPD, required=True, widget=Select(attrs={'class': 'form-control'}))
        self.fields['ipsec_authby'] = ChoiceField(choices=AUTHBY, required=True, widget=Select(attrs={'class': 'form-control'}))
Ejemplo n.º 12
0
    def __init__(self, *args, **kwargs):
        super(ProxyBalancerForm, self).__init__(*args, **kwargs)
        
        HC_METHODS = (
            ('None', 'No dynamic health checking done'),
            ('TCP', 'Check that a socket to the backend can be created: e.g. "are you up"'),
            ('OPTIONS', 'Send an HTTP OPTIONS request to the backend'),
            ('HEAD', 'Send an HTTP HEAD request to the backend'),
            ('GET', 'Send an HTTP GET request to the backend')
        )

        HC_EXPR = (
            ('{%{REQUEST_STATUS} =~ /^[234]/}', 'HTTP status code is 2XX, 3XX or 4XX'),
            ('{%{REQUEST_STATUS} =~ /^[5]/}', 'HTTP status code is 5XX'),
            ('hc(\'body\') !~', 'BODY does not contains'),
            ('hc(\'body\') =~', 'BODY contains'),
        )

        self.fields['hcmethod'] = ChoiceField(choices=HC_METHODS, required=False, widget=Select(attrs={'class': 'form-control'}))
        self.fields['hcexpr'] = ChoiceField(choices=HC_EXPR, required=False, widget=Select(attrs={'class': 'form-control'}))

        self = bootstrap_tooltips(self)
Ejemplo n.º 13
0
    def __init__(self, *args, **kwargs):
        super(PFSettingsForm, self).__init__(*args, **kwargs)
        self = bootstrap_tooltips(self, exclude='repository_choices')

        repo_lst = BaseAbstractRepository.get_data_repositories()
        data_repo_lst = list()
        for rep in repo_lst:
            data_repo_lst.append((rep.id, rep.repo_name))

        self.fields['repository_choices'] = ChoiceField(choices=data_repo_lst, required=False,
                                         widget=Select(attrs={'class': 'form-control'}))

        repo_lst = BaseAbstractRepository.get_syslog_repositories()
        syslog_repo_lst = list()
        syslog_repo_lst.append(("",""))
        for rep in repo_lst:
            syslog_repo_lst.append((rep.id, rep.repo_name))

        self.fields['repository_syslog'] = ChoiceField(choices=syslog_repo_lst, required=False,
                                         widget=Select(attrs={'class': 'form-control'}))

        self.fields['repository_type'] = ChoiceField(choices=PFSettings.TYPE_REPO, required=True, 
                                        widget=Select(attrs={'class': 'form-control'}))
Ejemplo n.º 14
0
 def __init__(self, custom_choices=None, *args, **kwargs):
     super(InetAddressForm, self).__init__(*args, **kwargs)
     self.fields['ip'].help_text = _("Main IP Address of Node")
     self = bootstrap_tooltips(self)
Ejemplo n.º 15
0
    def __init__(self, *args, **kwargs):
        super(WorkerForm, self).__init__(*args, **kwargs)

        self = bootstrap_tooltips(self)
Ejemplo n.º 16
0
 def __init__(self, *args, **kwargs):
     super(DNSSettingsForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
Ejemplo n.º 17
0
 def __init__(self, *args, **kwargs):
     super(MigrationForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
Ejemplo n.º 18
0
 def __init__(self, *args, **kwargs):
     super(ElasticSearchRepositoryForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
Ejemplo n.º 19
0
 def __init__(self, *args, **kwargs):
     super(SQLRepositoryForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
Ejemplo n.º 20
0
 def __init__(self, *args, **kwargs):
     super(portalTemplateForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
Ejemplo n.º 21
0
 def __init__(self, *args, **kwargs):
     super(ModAccessForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)
Ejemplo n.º 22
0
    def __init__(self, *args, **kwargs):
        try:
            self.listeners = kwargs.pop('listeners')
        except KeyError:
            pass

        super(ApplicationForm, self).__init__(*args, **kwargs)

        self = bootstrap_tooltips(self)
        repo_lst = BaseAbstractRepository.get_auth_repositories()
        auth_repo_lst = list()
        for rep in repo_lst:
            auth_repo_lst.append((
                ObjectId(rep.id),
                rep.repo_name,
            ))

        mod_sec_choices = list()
        for rule in ModSecRulesSet.objects(type_rule__nin=('wlbl', )):
            mod_sec_choices.append((ObjectId(rule.id), rule.name))

        dataset_list = list()
        dataset_list.append(((None), "------------------------------"))
        for dataset in Dataset.objects(svm_built=True).only('name', 'id'):
            dataset_list.append((ObjectId(dataset.id), dataset.name))

        client_certificate = [('', '---------')]
        for cert in SSLCertificate.objects(is_trusted_ca__ne=True).only(
                'id', 'cn'):
            client_certificate.append(("%sSSLProxyCertificateFile-%s.txt" %
                                       (settings.CONF_DIR, cert.id), cert.cn))

        COOCKIE_CIPHER = (
            ('rc4', 'RC4 (128 bits)'),
            ('aes128', 'AES 128 (128 bits)'),
            ('aes256', 'AES 256 (256 bits)'),
        )

        IP_REPUTATION = []
        loganalyser_rules = Cluster.objects.get(
        ).system_settings.loganalyser_settings.loganalyser_rules
        for rule in loganalyser_rules:
            tags = rule.tags.split(',')

            for tag in tags:
                IP_REPUTATION.append((tag, tag.capitalize()))

        GEOIP = []
        for tag in [
                "AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG",
                "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB",
                "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW",
                "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA",
                "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM",
                "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ",
                "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE",
                "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA",
                "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU",
                "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK",
                "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT",
                "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW",
                "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU",
                "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ",
                "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS",
                "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI",
                "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS",
                "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA",
                "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM",
                "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG",
                "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK",
                "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ",
                "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC",
                "TV", "UG", "UA", "AE", "GB", "US", "UM", "UY", "UZ", "VU",
                "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW"
        ]:
            GEOIP.append((tag, tag))

        self.fields['block_reputation'] = MultipleChoiceField(
            required=False,
            choices=set(IP_REPUTATION),
            widget=SelectMultiple(attrs={'class': 'form-control select2'}))
        self.fields['block_geoip'] = MultipleChoiceField(
            required=False,
            choices=set(GEOIP),
            widget=SelectMultiple(attrs={'class': 'form-control select2'}))
        self.fields['allow_geoip'] = MultipleChoiceField(
            required=False,
            choices=set(GEOIP),
            widget=SelectMultiple(attrs={'class': 'form-control select2'}))

        self.fields['template'].queryset = portalTemplate.objects.filter()
        self.fields['auth_backend'] = ChoiceField(
            choices=auth_repo_lst,
            required=False,
            widget=Select(attrs={'class': 'form-control'}))
        self.fields['auth_backend_fallbacks'] = MultipleChoiceField(
            choices=auth_repo_lst,
            required=False,
            widget=SelectMultiple(attrs={'class': 'form-control select2'}))
        self.fields['redirect_uri'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 80,
                'rows': 1,
                'class': 'form-control'
            }))
        self.fields['sso_capture_content'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 80,
                'rows': 2,
                'class': 'form-control'
            }))
        self.fields['sso_replace_pattern'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 40,
                'rows': 2,
                'class': 'form-control'
            }))
        self.fields['sso_replace_content'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 40,
                'rows': 2,
                'class': 'form-control'
            }))
        self.fields['sso_after_post_request'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 80,
                'rows': 2,
                'class': 'form-control'
            }))
        self.fields['rules_set'] = MultipleChoiceField(
            choices=mod_sec_choices,
            required=False,
            widget=SelectMultiple(attrs={'class': 'form-control'}))
        self.fields['datasets'] = ChoiceField(
            choices=dataset_list,
            required=False,
            widget=Select(attrs={'class': 'form-control'}))
        self.fields['ssl_protocol'] = ChoiceField(
            choices=SSL_PROTOCOLS,
            required=False,
            widget=Select(attrs={'class': 'form-control'}))
        self.fields['ssl_client_certificate'] = ChoiceField(
            choices=client_certificate,
            required=False,
            widget=Select(attrs={'class': 'form-control'}))

        self.fields['custom_vhost'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 80,
                'rows': 15,
                'class': 'form-control'
            }))
        self.fields['custom_location'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 80,
                'rows': 15,
                'class': 'form-control'
            }))
        self.fields['custom_proxy'] = CharField(
            required=False,
            widget=Textarea(attrs={
                'cols': 80,
                'rows': 15,
                'class': 'form-control'
            }))

        self.fields['cookie_cipher'] = ChoiceField(
            choices=COOCKIE_CIPHER,
            required=False,
            widget=Select(attrs={'class': 'form-control'}))

        if self.initial.get("auth_backend"):
            repo = BaseAbstractRepository.search_repository(
                self.initial.get('auth_backend'))
            if isinstance(repo, LDAPRepository):
                try:
                    groups = [(x, x)
                              for x in repo.get_backend().enumerate_groups()]
                except:
                    groups = []
                finally:
                    self.fields['group_registration'] = ChoiceField(
                        choices=groups,
                        required=False,
                        widget=Select(attrs={'class': 'form-control'}))
Ejemplo n.º 23
0
 def __init__(self, *args, **kwargs):
     super(ModSecRulesSetForm, self).__init__(*args, **kwargs)
     self = bootstrap_tooltips(self)