<commit_before>import os
from django import VERSION
from django.conf import settings
from django.core.checks import register, Tags, Error, Warning

from djangae.environment import get_application_root

from google.appengine.tools.sdk_update_checker import GetVersionObject, _VersionList


# django 1.8 didn't declare a "caches" tag
if not hasattr(Tags, "caches"):
    Tags.caches = "caches"
    Tags.urls = "urls"


MAX_APP_ENGINE_SDK_VERSION = (1, 9, 57)

CSP_SOURCE_NAMES = [
    'CSP_DEFAULT_SRC',
    'CSP_SCRIPT_SRC',
    'CSP_IMG_SRC',
    'CSP_OBJECT_SRC',
    'CSP_MEDIA_SRC',
    'CSP_FRAME_SRC',
    'CSP_FONT_SRC',
    'CSP_STYLE_SRC',
    'CSP_CONNECT_SRC',
]


@register
def check_app_engine_sdk_version(app_configs=None, **kwargs):
    errors = []
    sdk_version = tuple(_VersionList(GetVersionObject()['release']))
    if sdk_version > MAX_APP_ENGINE_SDK_VERSION:
            errors.append(Warning(
                "MAX_APP_ENGINE_SDK_VERSION",
                hint="You are using a version of the App Engine SDK that is not yet supported",
                id='djangae.W002',
            ))
    return errors


@register(Tags.security)<commit_msg>fix sdk_update_checker not existing in production environment<commit_after>import os
from django import VERSION
from django.conf import settings
from django.core.checks import register, Tags, Error, Warning

from djangae.environment import get_application_root

try:
    from google.appengine.tools.sdk_update_checker import GetVersionObject, _VersionList
except ImportError:
    GetVersionObject = None


# django 1.8 didn't declare a "caches" tag
if not hasattr(Tags, "caches"):
    Tags.caches = "caches"
    Tags.urls = "urls"


MAX_APP_ENGINE_SDK_VERSION = (1, 9, 57)

CSP_SOURCE_NAMES = [
    'CSP_DEFAULT_SRC',
    'CSP_SCRIPT_SRC',
    'CSP_IMG_SRC',
    'CSP_OBJECT_SRC',
    'CSP_MEDIA_SRC',
    'CSP_FRAME_SRC',
    'CSP_FONT_SRC',
    'CSP_STYLE_SRC',
    'CSP_CONNECT_SRC',
]


@register
def check_app_engine_sdk_version(app_configs=None, **kwargs):
    errors = []
    if GetVersionObject:
        sdk_version = tuple(_VersionList(GetVersionObject()['release']))
        if sdk_version > MAX_APP_ENGINE_SDK_VERSION:
            errors.append(Warning(
                "MAX_APP_ENGINE_SDK_VERSION",
                hint="You are using a version of the App Engine SDK that is not yet supported",
                id='djangae.W002',
            ))
    return errors


@register(Tags.security)
{'fraction_non_alphanumeric': 0.09334415584415584, 'fraction_numerical': 0.007305194805194805, 'mean_word_length': 3.55637707948244, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2048741', 'n_tokens_mistral': 876, 'n_tokens_neox': 824, 'n_words': 184}