    def create_security_group(self, context, group_name, group_description):
        if not re.match('^[a-zA-Z0-9_\- ]+$', str(group_name)):
            # Some validation to ensure that values match API spec.
            # - Alphanumeric characters, spaces, dashes, and underscores.
            # TODO(Daviey): LP: #813685 extend beyond group_name checking, and
            #  probably create a param validator that can be used elsewhere.
            err = _("Value (%s) for parameter GroupName is invalid."
                    " Content limited to Alphanumeric characters, "
                    "spaces, dashes, and underscores.") % group_name
            # err not that of master ec2 implementation, as they fail to raise.
            raise exception.InvalidParameterValue(err=err)

        if len(str(group_name)) > 255:
            err = _("Value (%s) for parameter GroupName is invalid."
                    " Length exceeds maximum of 255.") % group_name
            raise exception.InvalidParameterValue(err=err)

        LOG.audit(_("Create Security Group %s"), group_name, context=context)
        self.compute_api.ensure_default_security_group(context)
        if db.security_group_exists(context, context.project_id, group_name):
            msg = _('group %s already exists')
            raise exception.EC2APIError(msg % group_name)

        if quota.allowed_security_groups(context, 1) < 1:
            msg = _("Quota exceeded, too many security groups.")
            raise exception.EC2APIError(msg)

        group = {'user_id': context.user_id,
                 'project_id': context.project_id,
                 'name': group_name,
                 'description': group_description}
        group_ref = db.security_group_create(context, group)

        self.sgh.trigger_security_group_create_refresh(context, group)

        return {'securityGroupSet': [self._format_security_group(context,
                                                                 group_ref)]}
Weaknesses in this category are related to the management of permissions, privileges, and other security features that are used to perform access control.