from django.conf import settings from django.core.exceptions import ImproperlyConfigured from commonware.log import getLogger from cef import log_cef as orig_log_cef from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.views import APIView as RestAPIView log = getLogger(__name__) sys_cef_log = getLogger('signing_service.cef') def log_cef(msg, request, **kw): severity = kw.pop('severity', settings.CEF_DEFAULT_SEVERITY) cef_kw = { 'msg': msg, 'signature': request.get_full_path(), 'config': { 'cef.product': settings.CEF_PRODUCT, 'cef.vendor': settings.CEF_VENDOR, 'cef.version': settings.CEF_VERSION, 'cef.device_version': settings.CEF_DEVICE_VERSION, 'cef.file': getattr(settings, 'CEF_FILE', 'syslog') } } if severity > 2: # Log a copy of the CEF message but only for severe messages. # Messages lower than this could be every http request, etc. sys_cef_log.error('CEF Severity: {sev} Message: {msg}'.format(
from django_statsd.clients import statsd from commonware.log import getLogger from rest_framework.response import Response from apk_signer.base import APIView, log_cef, UnprotectedAPIView from apk_signer.exceptions import ConflictError from apk_signer.sign import signer log = getLogger(__name__) class AuthView(APIView): def get(self, request): return Response({'message': 'GET authentication successful'}) def post(self, request): return Response({'message': 'POST authentication successful'}) class CEFView(UnprotectedAPIView): def get(self, request): log_cef('this is a test message', request, severity=5) return Response({'message': 'CEF messages sent'}) class LogView(UnprotectedAPIView): def get(self, request):
from base64 import b64encode from django import forms from django.conf import settings from django_paranoia.forms import ParanoidForm from commonware.log import getLogger from rest_framework.response import Response from websigning import new_app_signer from websigning.sign.xpi import ParsingError, Signature from signing_service.base import APIView from signing_service.exceptions import BadRequestError log = getLogger(__name__) # Initialize the signer _SIGNER = new_app_signer(settings.SIGNING_SERVICE_APPS_KEY_FILE, settings.SIGNING_SERVICE_APPS_CERT_FILE, settings.SIGNING_SERVICE_APPS_CA_CHAIN_FILE, backend=settings.SIGNING_SERVICE_ENGINE) class SignAppForm(ParanoidForm): # max_length refers to the filename length, not the size of the file # itself file = forms.FileField(max_length=128) def clean_file(self): jar_signature = self.cleaned_data['file']
from django.conf import settings from commonware.log import getLogger from cef import log_cef as orig_log_cef from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.views import APIView as RestAPIView log = getLogger(__name__) sys_cef_log = getLogger('apk_signer.cef') def log_cef(msg, request, **kw): severity = kw.pop('severity', settings.CEF_DEFAULT_SEVERITY) cef_kw = {'msg': msg, 'signature': request.get_full_path(), 'config': { 'cef.product': settings.CEF_PRODUCT, 'cef.vendor': settings.CEF_VENDOR, 'cef.version': settings.CEF_VERSION, 'cef.device_version': settings.CEF_DEVICE_VERSION, 'cef.file': getattr(settings, 'CEF_FILE', 'syslog')}} if severity > 2: # Log a copy of the CEF message but only for severe messages. # Messages lower than this could be every http request, etc. sys_cef_log.error('CEF Severity: {sev} Message: {msg}' .format(sev=severity, msg=msg)) # Allow the passing of additional cs* values. for k, v in kw.items(): if k.startswith('cs'):
from django.conf import settings from django.core.exceptions import ImproperlyConfigured from commonware.log import getLogger from cef import log_cef as orig_log_cef from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.views import APIView as RestAPIView log = getLogger(__name__) sys_cef_log = getLogger('apk_signer.cef') def log_cef(msg, request, **kw): severity = kw.pop('severity', settings.CEF_DEFAULT_SEVERITY) cef_kw = { 'msg': msg, 'signature': request.get_full_path(), 'config': { 'cef.product': settings.CEF_PRODUCT, 'cef.vendor': settings.CEF_VENDOR, 'cef.version': settings.CEF_VERSION, 'cef.device_version': settings.CEF_DEVICE_VERSION, 'cef.file': getattr(settings, 'CEF_FILE', 'syslog') } } if severity > 2: # Log a copy of the CEF message but only for severe messages. # Messages lower than this could be every http request, etc. sys_cef_log.error('CEF Severity: {sev} Message: {msg}'.format(
from django.conf import settings from commonware.log import getLogger from cef import log_cef as orig_log_cef from rest_framework.permissions import AllowAny from rest_framework.response import Response from rest_framework.views import APIView as RestAPIView log = getLogger(__name__) sys_cef_log = getLogger('signing_service.cef') def log_cef(msg, request, **kw): severity = kw.pop('severity', settings.CEF_DEFAULT_SEVERITY) cef_kw = {'msg': msg, 'signature': request.get_full_path(), 'config': { 'cef.product': settings.CEF_PRODUCT, 'cef.vendor': settings.CEF_VENDOR, 'cef.version': settings.CEF_VERSION, 'cef.device_version': settings.CEF_DEVICE_VERSION, 'cef.file': getattr(settings, 'CEF_FILE', 'syslog')}} if severity > 2: # Log a copy of the CEF message but only for severe messages. # Messages lower than this could be every http request, etc. sys_cef_log.error('CEF Severity: {sev} Message: {msg}' .format(sev=severity, msg=msg)) # Allow the passing of additional cs* values. for k, v in kw.items(): if k.startswith('cs'):