pyms sql: b "Неверный синтаксис рядом с '%' - PullRequest
0 голосов
/ 06 марта 2020

Привет! Я вижу эту ошибку в соединителе pyms sql, когда не могу выполнить хранимую процедуру. Я использую соединитель pyms sql

Я обновил код, хотя он не полностью воспроизводим но это должно дать представление о том, что может пойти не так. Я действительно подозреваю, что% r делает какой-то трюк, но это еще предстоит выяснить.

EXEC Auth.Authorize
    @Router = %s,
    @Realm = %s,
    @Action = %s,
    @URI = %s,
    @Match = %s,
    @SessionID = %s,
    @AuthProvider = %s,
    @AuthMethod = %s,
    @AuthRole = %s,
    @AuthID = %s,
    @TransportPeer = %s,
    @TransportType = %s,
    @TransportProtocol = %s,
    @TransportUserAgent = %s,
    @TransportForwardedFor = %s,
    @F5AuthenticatedDN = %s,
    @F5AuthenticatedClient = %s,
    @ManufacturingCert = %r,
    @Groups = @Groups
 ('xxx.local', 'realm1', 'register', 'com.xxx.xx.systems.xxx.tools.get_current_tools', 'exact', 19696953385938, 'dynamic', 'ticket', 'system', 'xxx', 'tcp4:127.0.0.1:49838', 'websocket', 'wamp.2.cbor.batched', 'AutobahnPython/18.5.1', None, 'CN=xxx,OU=xxx xxx,DC=xxx,DC=xxx', 'xxx', True)

========== ОШИБКА ======

(102, b"Incorrect syntax near '%'.DB-Lib error message 20018, severity 15:\nGeneral SQL Server error: Check messages from the SQL Server\n"): Traceback (most recent call last):

....

  File "dvmt_auth/session.py", line 280, in authorize
    groups=groups

==== соответствующий python код

AUTHORIZE_CALL = """
SET NOCOUNT ON
DECLARE @Groups AS GroupsType
{groups_insert}
EXEC Auth.Authorize
    @Router = %s,
    @Realm = %s,
    @Action = %s,
    @URI = %s,
    @Match = %s,
    @SessionID = %s,
    @AuthProvider = %s,
    @AuthMethod = %s,
    @AuthRole = %s,
    @AuthID = %s,
    @TransportPeer = %s,
    @TransportType = %s,
    @TransportProtocol = %s,
    @TransportUserAgent = %s,
    @TransportForwardedFor = %s,
    @F5AuthenticatedDN = %s,
    @F5AuthenticatedClient = %s,
    @ManufacturingCert = %r,
    @Groups = @Groups
"""


class F5MSSQLAuthSession(AuthSession):
    ....SNIP....

    self.append_mfg = False

    @inlineCallbacks
    def authenticate(self, realm, authid, details):
        ....SNIP....

        if auth_dn and 'MFG' in auth_dn:
                self.manufacturing_cert = True


    @inlineCallbacks
    def authorize(self, session, uri, action, options):
        transport = session.get('transport', {})
        headers = transport.get('http_headers_received', {})

        results = yield self.call_authorize(
            action=action,
            uri=uri,
            match=options.get('match', 'exact'),
            session_id=session['session'],
            authprovider=session['authprovider'],
            authmethod=session['authmethod'],
            authrole=session['authrole'],
            authid=session['authid'],
            transport_peer=transport['peer'],
            transport_type=transport['type'],
            transport_protocol=transport['protocol'],
            transport_user_agent=headers.get('user-agent'),
            transport_forwarded_for=headers.get('x-forwarded-for'),
            auth_dn=auth_dn,
            auth_client=auth_client,
            manufacturing_cert=self.manufacturing_cert,
            groups=groups  
        )

    @inlineCallbacks
    def call_authorize(self, groups=[], **kwargs):
        .....SNIP....

        params.append(kwargs['router'])
        params.append(kwargs['realm'])
        params.append(kwargs['action'])
        params.append(kwargs['uri'])
        params.append(kwargs['match'])
        params.append(kwargs['session_id'])
        params.append(kwargs['authprovider'])
        params.append(kwargs['authmethod'])
        params.append(kwargs['authrole'])
        params.append(kwargs['authid'])
        params.append(kwargs['transport_peer'])
        params.append(kwargs['transport_type'])
        params.append(kwargs['transport_protocol'])
        params.append(kwargs['transport_user_agent'])
        params.append(kwargs['transport_forwarded_for'])
        params.append(kwargs['auth_dn'])
        params.append(kwargs['auth_client'])
        params.append(kwargs['manufacturing_cert'])

        operation = AUTHORIZE_CALL.format(groups_insert=groups_insert)
...