Beispiel #1
0
 def getTransportData(self):
     try:
         self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
         self.req.get()
     except Exception as e:
         logger.exception('Got exception: {}'.format(e))
         raise e
Beispiel #2
0
 def getTransportData(self):
     try:
         self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived, params={'hostname': tools.getHostName(), 'version': VERSION})
         self.req.get()
     except Exception as e:
         logger.exception('Got exception on getTransportData')
         raise e
Beispiel #3
0
 def getTransportData(self):
     try:
         self.req = RestRequest(
             "/{}/{}".format(self.ticket, self.scrambler),
             self,
             self.transportDataReceived,
             params={"hostname": tools.getHostName(), "version": VERSION},
         )
         self.req.get()
     except Exception as e:
         logger.exception("Got exception on getTransportData")
         raise e
Beispiel #4
0
    def transportDataReceived(self, data):
        logger.debug('Transport data received')
        try:
            self.processError(data)

            params = None

            if self.serverVersion <= OLD_METHOD_VERSION:
                script = data['result'].decode('base64').decode('bz2')
            else:
                res = data['result']
                # We have three elements on result:
                # * Script
                # * Signature
                # * Script data
                # We test that the Script has correct signature, and them execute it with the parameters
                script, signature, params = res['script'].decode(
                    'base64').decode('bz2'), res['signature'], json.loads(
                        res['params'].decode('base64').decode('bz2'))
                if tools.verifySignature(script, signature) is False:
                    raise Exception(
                        'Invalid UDS code signature. Please, report to administrator'
                    )

            self.stopAnim()

            if 'darwin' in sys.platform:
                self.showMinimized()

            QtCore.QTimer.singleShot(3000, self.endScript)
            self.hide()

            if self.serverVersion <= OLD_METHOD_VERSION:
                errorString = '<p>The server <b>{}</b> runs an old version of UDS:</p>'.format(
                    host)
                errorString += '<p>To avoid security issues, you must approve old UDS Version access.</p>'

                if QtGui.QMessageBox.warning(
                        None, 'ACCESS Warning', errorString,
                        QtGui.QMessageBox.Yes
                        | QtGui.QMessageBox.No) == QtGui.QMessageBox.No:
                    raise Exception('Server not approved. Access denied.')

            six.exec_(script, globals(), {'parent': self, 'sp': params})

        except RetryException as e:
            self.ui.info.setText(six.text_type(e) + ', retrying access...')
            # Retry operation in ten seconds
            QtCore.QTimer.singleShot(10000, self.getTransportData)

        except Exception as e:
            logger.exception('Got exception executing script:')
            self.showError(e)
Beispiel #5
0
        QtWidgets.QMessageBox.critical(None, 'Notice', 'UDS Client Version {}'.format(VERSION), QtWidgets.QMessageBox.Ok)
        sys.exit(1)

    # Setup REST api endpoint
    RestRequest.restApiUrl = '{}://{}/rest/client'.format(['http', 'https'][ssl], host)
    logger.debug('Setting request URL to %s', RestRequest.restApiUrl)
    # RestRequest.restApiUrl = 'https://172.27.0.1/rest/client'

    try:
        logger.debug('Starting execution')

        # Approbe before going on
        if approveHost(host) is False:
            raise Exception('Host {} was not approved'.format(host))

        win = UDSClient()
        win.show()

        win.start()

        exitVal = app.exec_()
        logger.debug('Execution finished correctly')

    except Exception as e:
        logger.exception('Got an exception executing client:')
        exitVal = 128
        QtWidgets.QMessageBox.critical(None, 'Error', six.text_type(e), QtWidgets.QMessageBox.Ok)

    logger.debug('Exiting')
    sys.exit(exitVal)
Beispiel #6
0
    # Setup REST api endpoint
    RestRequest.restApiUrl = "{}://{}/rest/client".format(["http", "https"][ssl], host)
    logger.debug("Setting request URL to %s", RestRequest.restApiUrl)
    # RestRequest.restApiUrl = 'https://172.27.0.1/rest/client'

    try:
        logger.debug("Starting execution")

        # Approbe before going on
        if approveHost(host) is False:
            raise Exception("Host {} was not approved".format(host))

        win = UDSClient()
        win.show()

        win.start()

        exitVal = app.exec_()
        logger.debug("Execution finished correctly")

    except Exception as e:
        logger.exception("Got an exception executing client:")
        exitVal = 128
        QtWidgets.QMessageBox.critical(
            None, "Error", six.text_type(e), QtWidgets.QMessageBox.Ok
        )

    logger.debug("Exiting")
    sys.exit(exitVal)
Beispiel #7
0
    # Setup REST api endpoint
    RestRequest.restApiUrl = '{}://{}/rest/client'.format(['http', 'https'][ssl], host)
    logger.debug('Setting request URL to {}'.format(RestRequest.restApiUrl))
    # RestRequest.restApiUrl = 'https://172.27.0.1/rest/client'

    try:
        logger.debug('Starting execution')

        # Approbe before going on
        if approveHost(host) is False:
            raise Exception('Host {} was not approved'.format(host))

        win = UDSClient()
        win.show()


        win.start()

        exitVal = app.exec_()
        logger.debug('Execution finished correctly')

    except Exception as e:
        logger.exception('Got an exception executing client:')
        exitVal = 128
        QtGui.QMessageBox.critical(None, 'Error', six.text_type(e), QtGui.QMessageBox.Ok)

    logger.debug('Exiting')
    sys.exit(exitVal)