Beispiel #1
0
    def get(self, request, project):
        """
        Retrieve a Project
        ``````````````````

        Return details on an individual project.

        :pparam string organization_slug: the slug of the organization the
                                          project belongs to.
        :pparam string project_slug: the slug of the project to delete.
        :auth: required
        """
        active_plugins = [
            {
                'name': plugin.get_title(),
                'id': plugin.slug,
            }
            for plugin in plugins.configurable_for_project(project, version=None)
            if plugin.is_enabled(project)
            and plugin.has_project_conf()
        ]

        data = serialize(project, request.user)
        data['options'] = {
            'sentry:origins': '\n'.join(project.get_option('sentry:origins', ['*']) or []),
            'sentry:resolve_age': int(project.get_option('sentry:resolve_age', 0)),
            'sentry:scrub_data': bool(project.get_option('sentry:scrub_data', True)),
            'sentry:sensitive_fields': project.get_option('sentry:sensitive_fields', []),
        }
        data['activePlugins'] = active_plugins
        data['team'] = serialize(project.team, request.user)
        data['organization'] = serialize(project.organization, request.user)

        return Response(data)
Beispiel #2
0
 def get(self, request, project):
     context = serialize(
         [
             plugin for plugin in plugins.configurable_for_project(project, version=None)
         ], request.user, PluginSerializer(project)
     )
     return Response(context)
    def get(self, request, project):
        """
        Retrieve a Project
        ``````````````````

        Return details on an individual project.

        :pparam string organization_slug: the slug of the organization the
                                          project belongs to.
        :pparam string project_slug: the slug of the project to delete.
        :auth: required
        """
        data = serialize(project, request.user)
        data['options'] = {
            'sentry:origins': '\n'.join(project.get_option('sentry:origins', ['*']) or []),
            'sentry:resolve_age': int(project.get_option('sentry:resolve_age', 0)),
            'sentry:scrub_data': bool(project.get_option('sentry:scrub_data', True)),
            'sentry:scrub_defaults': bool(project.get_option('sentry:scrub_defaults', True)),
            'sentry:safe_fields': project.get_option('sentry:safe_fields', []),
            'sentry:sensitive_fields': project.get_option('sentry:sensitive_fields', []),
            'sentry:csp_ignored_sources_defaults': bool(project.get_option('sentry:csp_ignored_sources_defaults', True)),
            'sentry:csp_ignored_sources': '\n'.join(project.get_option('sentry:csp_ignored_sources', []) or []),
            'sentry:default_environment': project.get_option('sentry:default_environment'),
            'sentry:reprocessing_show_hint': bool(project.get_option('sentry:reprocessing_show_hint', True)),
            'sentry:reprocessing_active': bool(project.get_option('sentry:reprocessing_active', False)),
            'filters:blacklisted_ips': '\n'.join(project.get_option('sentry:blacklisted_ips', [])),
            'feedback:branding': project.get_option('feedback:branding', '1') == '1',
        }
        data['plugins'] = serialize([
            plugin
            for plugin in plugins.configurable_for_project(project, version=None)
            if plugin.has_project_conf()
        ], request.user, PluginSerializer(project))
        data['team'] = serialize(project.team, request.user)
        data['organization'] = serialize(project.organization, request.user)

        data.update({
            'digestsMinDelay': project.get_option(
                'digests:mail:minimum_delay', digests.minimum_delay,
            ),
            'digestsMaxDelay': project.get_option(
                'digests:mail:maximum_delay', digests.maximum_delay,
            ),
            'subjectPrefix': project.get_option('mail:subject_prefix'),
            'subjectTemplate': project.get_option('mail:subject_template') or DEFAULT_SUBJECT_TEMPLATE.template,
        })

        include = set(filter(bool, request.GET.get('include', '').split(',')))
        if 'stats' in include:
            data['stats'] = {
                'unresolved': self._get_unresolved_count(project),
            }

        return Response(data)
Beispiel #4
0
    def handle(self, request, organization, project):
        if request.POST:
            enabled = set(request.POST.getlist('plugin'))
            for plugin in plugins.configurable_for_project(project, version=None):
                if plugin.slug in enabled:
                    plugin.enable(project)
                else:
                    plugin.disable(project)

            messages.add_message(
                request, messages.SUCCESS, _('Your settings were saved successfully.')
            )

            return self.redirect(request.path)
    def get(self, request, project):
        """
        Retrieve a Project
        ``````````````````

        Return details on an individual project.

        :pparam string organization_slug: the slug of the organization the
                                          project belongs to.
        :pparam string project_slug: the slug of the project to delete.
        :auth: required
        """
        active_plugins = [
            {
                'name': plugin.get_title(),
                'id': plugin.slug,
            }
            for plugin in plugins.configurable_for_project(project, version=None)
            if plugin.is_enabled(project)
            and plugin.has_project_conf()
        ]

        data = serialize(project, request.user)
        data['options'] = {
            'sentry:origins': '\n'.join(project.get_option('sentry:origins', ['*']) or []),
            'sentry:resolve_age': int(project.get_option('sentry:resolve_age', 0)),
            'sentry:scrub_data': bool(project.get_option('sentry:scrub_data', True)),
            'sentry:scrub_defaults': bool(project.get_option('sentry:scrub_defaults', True)),
            'sentry:sensitive_fields': project.get_option('sentry:sensitive_fields', []),
            'sentry:csp_ignored_sources_defaults': bool(project.get_option('sentry:csp_ignored_sources_defaults', True)),
            'sentry:csp_ignored_sources': '\n'.join(project.get_option('sentry:csp_ignored_sources', []) or []),
            'sentry:default_environment': project.get_option('sentry:default_environment'),
            'feedback:branding': project.get_option('feedback:branding', '1') == '1',
        }
        data['activePlugins'] = active_plugins
        data['team'] = serialize(project.team, request.user)
        data['organization'] = serialize(project.organization, request.user)

        include = set(filter(bool, request.GET.get('include', '').split(',')))
        if 'stats' in include:
            data['stats'] = {
                'unresolved': self._get_unresolved_count(project),
            }

        return Response(data)
Beispiel #6
0
    def serialize(self, obj, attrs, user):
        from sentry.plugins import plugins

        data = super(DetailedProjectSerializer, self).serialize(
            obj, attrs, user
        )
        data.update({
            'latestRelease': attrs['latest_release'],
            'options': {
                'sentry:origins': '\n'.join(attrs['options'].get('sentry:origins', ['*']) or []),
                'sentry:resolve_age': int(attrs['options'].get('sentry:resolve_age', 0)),
                'sentry:scrub_data': bool(attrs['options'].get('sentry:scrub_data', True)),
                'sentry:scrub_defaults': bool(attrs['options'].get('sentry:scrub_defaults', True)),
                'sentry:safe_fields': attrs['options'].get('sentry:safe_fields', []),
                'sentry:sensitive_fields': attrs['options'].get('sentry:sensitive_fields', []),
                'sentry:csp_ignored_sources_defaults': bool(attrs['options'].get('sentry:csp_ignored_sources_defaults', True)),
                'sentry:csp_ignored_sources': '\n'.join(attrs['options'].get('sentry:csp_ignored_sources', []) or []),
                'sentry:reprocessing_active': bool(attrs['options'].get('sentry:reprocessing_active', False)),
                'filters:blacklisted_ips': '\n'.join(attrs['options'].get('sentry:blacklisted_ips', [])),
                'feedback:branding': attrs['options'].get('feedback:branding', '1') == '1',
            },
            'digestsMinDelay': attrs['options'].get(
                'digests:mail:minimum_delay', digests.minimum_delay,
            ),
            'digestsMaxDelay': attrs['options'].get(
                'digests:mail:maximum_delay', digests.maximum_delay,
            ),
            'subjectPrefix': attrs['options'].get('mail:subject_prefix'),
            'subjectTemplate': attrs['options'].get('mail:subject_template') or DEFAULT_SUBJECT_TEMPLATE.template,
            'organization': attrs['org'],
            'plugins': serialize([
                plugin
                for plugin in plugins.configurable_for_project(obj, version=None)
                if plugin.has_project_conf()
            ], user, PluginSerializer(obj)),
            'platforms': attrs['platforms'],
            'processingIssues': attrs['processing_issues'],
            'defaultEnvironment': attrs['options'].get('default_environment'),
        })
        return data
Beispiel #7
0
def manage_plugins(request, organization, project):
    if request.POST:
        enabled = set(request.POST.getlist('plugin'))
        for plugin in plugins.configurable_for_project(project, version=None):
            if plugin.slug in enabled:
                plugin.enable(project)
            else:
                plugin.disable(project)

        messages.add_message(
            request, messages.SUCCESS,
            _('Your settings were saved successfully.'))

        return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update({
        'organization': organization,
        'team': project.team,
        'page': 'plugins',
        'project': project,
    })

    return render_to_response('sentry/projects/plugins/list.html', context, request)
Beispiel #8
0
def get_plugins_with_status(project):
    return [
        (plugin, safe_execute(plugin.is_enabled, project))
        for plugin in plugins.configurable_for_project(project, version=None)
    ]
Beispiel #9
0
    def serialize(self, obj, attrs, user):
        from sentry.plugins import plugins

        data = super(DetailedProjectSerializer,
                     self).serialize(obj, attrs, user)
        data.update(
            {
                'latestRelease':
                attrs['latest_release'],
                'options': {
                    'sentry:csp_ignored_sources_defaults':
                    bool(attrs['options'].get(
                        'sentry:csp_ignored_sources_defaults', True)),
                    'sentry:csp_ignored_sources':
                    '\n'.join(attrs['options'].get(
                        'sentry:csp_ignored_sources', []) or []),
                    'sentry:reprocessing_active':
                    bool(attrs['options'].get(
                        'sentry:reprocessing_active', False)),
                    'filters:blacklisted_ips':
                    '\n'.join(attrs['options'].get(
                        'sentry:blacklisted_ips', [])),
                    u'filters:{}'.format(FilterTypes.RELEASES):
                    '\n'.join(attrs['options'].get(
                        u'sentry:{}'.format(FilterTypes.RELEASES), [])),
                    u'filters:{}'.format(FilterTypes.ERROR_MESSAGES):
                    '\n'.
                    join(attrs['options'].get(u'sentry:{}'.format(
                        FilterTypes.ERROR_MESSAGES), [])),
                    'feedback:branding':
                    attrs['options'].get('feedback:branding', '1') == '1',
                },
                'digestsMinDelay':
                attrs['options'].get(
                    'digests:mail:minimum_delay',
                    digests.minimum_delay,
                ),
                'digestsMaxDelay':
                attrs['options'].get(
                    'digests:mail:maximum_delay',
                    digests.maximum_delay,
                ),
                'subjectPrefix':
                attrs['options'].get('mail:subject_prefix', options.get('mail.subject-prefix')),
                'allowedDomains':
                attrs['options'].get(
                    'sentry:origins', ['*']),
                'resolveAge':
                int(attrs['options'].get('sentry:resolve_age', 0)),
                'dataScrubber':
                bool(attrs['options'].get('sentry:scrub_data', True)),
                'dataScrubberDefaults':
                bool(attrs['options'].get('sentry:scrub_defaults', True)),
                'safeFields':
                attrs['options'].get('sentry:safe_fields', []),
                'storeCrashReports': bool(attrs['options'].get('sentry:store_crash_reports', False)),
                'sensitiveFields':
                attrs['options'].get('sentry:sensitive_fields', []),
                'subjectTemplate':
                attrs['options'].get(
                    'mail:subject_template') or DEFAULT_SUBJECT_TEMPLATE.template,
                'securityToken': attrs['options'].get('sentry:token') or obj.get_security_token(),
                'securityTokenHeader': attrs['options'].get('sentry:token_header'),
                'verifySSL': bool(attrs['options'].get('sentry:verify_ssl', False)),
                'scrubIPAddresses': bool(attrs['options'].get('sentry:scrub_ip_address', False)),
                'scrapeJavaScript': bool(attrs['options'].get('sentry:scrape_javascript', True)),
                'organization':
                attrs['org'],
                'plugins':
                serialize(
                    [
                        plugin for plugin in plugins.configurable_for_project(obj, version=None)
                        if plugin.has_project_conf()
                    ], user, PluginSerializer(obj)
                ),
                'platforms': attrs['platforms'],
                'processingIssues': attrs['processing_issues'],
                'defaultEnvironment': attrs['options'].get('sentry:default_environment'),
                'relayPiiConfig': attrs['options'].get('sentry:relay_pii_config'),
            }
        )
        return data
Beispiel #10
0
 def plugins(self):
     return [
         plugins.configurable_for_project(project)
         for project in self.projects
     ]
Beispiel #11
0
    def serialize(self, obj, attrs, user):
        from sentry.plugins import plugins

        def get_value_with_default(key):
            value = attrs['options'].get(key)
            if value is not None:
                return value
            return projectoptions.get_well_known_default(
                key, epoch=attrs['options'].get('sentry:option-epoch'))

        data = super(DetailedProjectSerializer,
                     self).serialize(obj, attrs, user)
        data.update({
            'latestRelease':
            attrs['latest_release'],
            'options': {
                'sentry:csp_ignored_sources_defaults':
                bool(attrs['options'].get(
                    'sentry:csp_ignored_sources_defaults', True)),
                'sentry:csp_ignored_sources':
                '\n'.join(
                    attrs['options'].get('sentry:csp_ignored_sources', [])
                    or []),
                'sentry:reprocessing_active':
                bool(attrs['options'].get('sentry:reprocessing_active',
                                          False)),
                'filters:blacklisted_ips':
                '\n'.join(attrs['options'].get('sentry:blacklisted_ips', [])),
                u'filters:{}'.format(FilterTypes.RELEASES):
                '\n'.join(attrs['options'].get(
                    u'sentry:{}'.format(FilterTypes.RELEASES), [])),
                u'filters:{}'.format(FilterTypes.ERROR_MESSAGES):
                '\n'.join(attrs['options'].get(
                    u'sentry:{}'.format(FilterTypes.ERROR_MESSAGES), [])),
                'feedback:branding':
                attrs['options'].get('feedback:branding', '1') == '1',
            },
            'digestsMinDelay':
            attrs['options'].get(
                'digests:mail:minimum_delay',
                digests.minimum_delay,
            ),
            'digestsMaxDelay':
            attrs['options'].get(
                'digests:mail:maximum_delay',
                digests.maximum_delay,
            ),
            'subjectPrefix':
            attrs['options'].get('mail:subject_prefix',
                                 options.get('mail.subject-prefix')),
            'allowedDomains':
            attrs['options'].get('sentry:origins', ['*']),
            'resolveAge':
            int(attrs['options'].get('sentry:resolve_age', 0)),
            'dataScrubber':
            bool(attrs['options'].get('sentry:scrub_data', True)),
            'dataScrubberDefaults':
            bool(attrs['options'].get('sentry:scrub_defaults', True)),
            'safeFields':
            attrs['options'].get('sentry:safe_fields', []),
            'storeCrashReports':
            bool(attrs['options'].get('sentry:store_crash_reports', False)),
            'sensitiveFields':
            attrs['options'].get('sentry:sensitive_fields', []),
            'subjectTemplate':
            attrs['options'].get('mail:subject_template')
            or DEFAULT_SUBJECT_TEMPLATE.template,
            'securityToken':
            attrs['options'].get('sentry:token') or obj.get_security_token(),
            'securityTokenHeader':
            attrs['options'].get('sentry:token_header'),
            'verifySSL':
            bool(attrs['options'].get('sentry:verify_ssl', False)),
            'scrubIPAddresses':
            bool(attrs['options'].get('sentry:scrub_ip_address', False)),
            'scrapeJavaScript':
            bool(attrs['options'].get('sentry:scrape_javascript', True)),
            'groupingConfig':
            get_value_with_default('sentry:grouping_config'),
            'groupingEnhancements':
            get_value_with_default('sentry:grouping_enhancements'),
            'groupingEnhancementsBase':
            get_value_with_default('sentry:grouping_enhancements_base'),
            'fingerprintingRules':
            get_value_with_default('sentry:fingerprinting_rules'),
            'organization':
            attrs['org'],
            'plugins':
            serialize([
                plugin for plugin in plugins.configurable_for_project(
                    obj, version=None) if plugin.has_project_conf()
            ], user, PluginSerializer(obj)),
            'platforms':
            attrs['platforms'],
            'processingIssues':
            attrs['processing_issues'],
            'defaultEnvironment':
            attrs['options'].get('sentry:default_environment'),
            'relayPiiConfig':
            attrs['options'].get('sentry:relay_pii_config'),
            'builtinSymbolSources':
            get_value_with_default('sentry:builtin_symbol_sources'),
            'symbolSources':
            attrs['options'].get('sentry:symbol_sources'),
        })
        return data
Beispiel #12
0
    def serialize(self, obj, attrs, user):
        from sentry.plugins import plugins

        data = super(DetailedProjectSerializer,
                     self).serialize(obj, attrs, user)
        data.update({
            'latestRelease':
            attrs['latest_release'],
            'options': {
                'sentry:origins':
                '\n'.join(attrs['options'].get('sentry:origins', ['*']) or []),
                'sentry:resolve_age':
                int(attrs['options'].get('sentry:resolve_age', 0)),
                'sentry:scrub_data':
                bool(attrs['options'].get('sentry:scrub_data', True)),
                'sentry:scrub_defaults':
                bool(attrs['options'].get('sentry:scrub_defaults', True)),
                'sentry:safe_fields':
                attrs['options'].get('sentry:safe_fields', []),
                'sentry:sensitive_fields':
                attrs['options'].get('sentry:sensitive_fields', []),
                'sentry:csp_ignored_sources_defaults':
                bool(attrs['options'].get(
                    'sentry:csp_ignored_sources_defaults', True)),
                'sentry:csp_ignored_sources':
                '\n'.join(
                    attrs['options'].get('sentry:csp_ignored_sources', [])
                    or []),
                'sentry:reprocessing_active':
                bool(attrs['options'].get('sentry:reprocessing_active',
                                          False)),
                'filters:blacklisted_ips':
                '\n'.join(attrs['options'].get('sentry:blacklisted_ips', [])),
                'filters:{}'.format(FilterTypes.RELEASES):
                '\n'.join(attrs['options'].get(
                    'sentry:{}'.format(FilterTypes.RELEASES), [])),
                'filters:{}'.format(FilterTypes.ERROR_MESSAGES):
                '\n'.join(attrs['options'].get(
                    'sentry:{}'.format(FilterTypes.ERROR_MESSAGES), [])),
                'feedback:branding':
                attrs['options'].get('feedback:branding', '1') == '1',
            },
            'digestsMinDelay':
            attrs['options'].get(
                'digests:mail:minimum_delay',
                digests.minimum_delay,
            ),
            'digestsMaxDelay':
            attrs['options'].get(
                'digests:mail:maximum_delay',
                digests.maximum_delay,
            ),
            'subjectPrefix':
            attrs['options'].get('mail:subject_prefix'),
            'subjectTemplate':
            attrs['options'].get('mail:subject_template')
            or DEFAULT_SUBJECT_TEMPLATE.template,
            'organization':
            attrs['org'],
            'plugins':
            serialize([
                plugin for plugin in plugins.configurable_for_project(
                    obj, version=None) if plugin.has_project_conf()
            ], user, PluginSerializer(obj)),
            'platforms':
            attrs['platforms'],
            'processingIssues':
            attrs['processing_issues'],
            'defaultEnvironment':
            attrs['options'].get('default_environment'),
        })
        return data
Beispiel #13
0
 def plugins(self):
     return [
         plugins.configurable_for_project(project)
         for project in self.projects
     ]