Beispiel #1
0
    def log_details(self):
        with section(self.config, self.get_pretty_type()):
            self.config.logger.info('File path: {}'.format(self.binary))
            self.config.logger.info('Name: {}'.format(self.name))
            self.config.logger.info('Version: {}'.format(self.version))

            self.config.logger.debug(
                LazyLog(lambda: 'File size: {}'.format(
                    os.path.getsize(self.binary))))
            self.config.logger.debug(
                LazyLog(lambda: 'File SHA256: {}'.format(
                    hash_file(self.binary, 'sha256'))))
            self.config.logger.debug(
                LazyLog(lambda: 'File SHA1: {}'.format(
                    hash_file(self.binary, 'sha1'))))
            self.config.logger.debug(
                LazyLog(lambda: 'File MD5: {}'.format(
                    hash_file(self.binary, 'md5'))))

            if self.details:
                self.config.logger.debug('Details: ')
                lines = list(line for line in (l.strip() for l in self.details)
                             if line)
                for line in lines:
                    self.config.logger.debug(line)
Beispiel #2
0
    def log_details(self):
        with section(self.config, self.get_pretty_type()):
            self.config.logger.info('File path: {}'.format(self.user_binary))
            self.config.logger.info('Name: {}'.format(self.name))
            self.config.logger.info('Version: {}'.format(self.version))
            self._log_apps()
            self._log_media()

            self.config.logger.debug(LazyLog(
                lambda: 'File size: {}'.format(os.path.getsize(self.binary))))
            self.config.logger.debug(LazyLog(
                lambda: 'File SHA256: {}'.format(hash_file(self.binary, 'sha256'))))
            self.config.logger.debug(LazyLog(
                lambda: 'File SHA1: {}'.format(hash_file(self.binary, 'sha1'))))
            self.config.logger.debug(LazyLog(
                lambda: 'File MD5: {}'.format(hash_file(self.binary, 'md5'))))

            self.config.logger.debug('Parsed config:')
            self.config.logger.debug(yaml.safe_dump(self.ecosystem))
Beispiel #3
0
    def log_details(self):
        with section(self.config, self.get_pretty_type()):
            self.config.logger.info('File path: {}'.format(self.binary))
            self.config.logger.info('Package name: {}'.format(self.get_name()))
            self.config.logger.info('Version name: {}'.format(
                self.apk.get_androidversion_name()))
            self.config.logger.info('Version code: {}'.format(
                self.apk.get_androidversion_code()))

            self.config.logger.debug(
                LazyLog(lambda: 'File size: {}'.format(
                    os.path.getsize(self.binary))))
            self.config.logger.debug(
                LazyLog(lambda: 'File SHA256: {}'.format(
                    hash_file(self.binary, 'sha256'))))
            self.config.logger.debug(
                LazyLog(lambda: 'File SHA1: {}'.format(
                    hash_file(self.binary, 'sha1'))))
            self.config.logger.debug(
                LazyLog(lambda: 'File MD5: {}'.format(
                    hash_file(self.binary, 'md5'))))
Beispiel #4
0
    def _get_signed_url(self, customer, binary, artifact):
        md5 = hash_file(binary, 'md5', False)
        headers = {
            'Content-Type': 'application/json',
            'Content-MD5': base64.b64encode(md5).decode('utf-8'),
            'Authorization': 'Bearer {}'.format(self.auth_store['id_token'])
        }

        url_path = '/{0}/{1}/{2}?type={3}&noContentType=true'.format(
            customer, artifact.get_name(), artifact.get_version(),
            artifact.get_type())
        url = self._get_base_url('registry_signed_url') + url_path
        return self.handler.get(url, headers=headers)
Beispiel #5
0
    def _maybe_inject_version(self):
        if self.version != 'latest':
            return

        latest_media = self.config.api.get_highest_artifact('media', self.name)
        if latest_media:
            is_in_project_mode = getattr(self.config, 'project_mode', None)
            checksum = latest_media.get('checksum') or {}
            if is_in_project_mode and checksum.get('sha1') == hash_file(
                    self.media_file, 'sha1'):
                self.version = int(latest_media.get('version'))
                self.already_registered = True
            else:
                self.version = int(latest_media.get('version')) + 1
        else:
            self.version = 1
Beispiel #6
0
    def prepare_apk(self, binary):
        apk = Apk.parse(self.config, binary)

        is_in_project_mode = getattr(self.config, 'project_mode', None)
        if is_in_project_mode:
            try:
                apk_artifact = self.config.api.get_artifact(
                    apk.get_type(), apk.get_name(), apk.get_version())
            except ApiError as e:
                self.config.logger.debug(e, exc_info=True)
                apk_artifact = {}

            checksum = apk_artifact.get('checksum') or {}
            if checksum.get('sha1') == hash_file(binary, 'sha1'):
                apk.already_registered = True

        return apk
Beispiel #7
0
    def _register_signed_url(self, customer, signed_url, binary, artifact):
        sha1 = hash_file(binary, 'sha1')
        headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer {}'.format(self.auth_store['id_token'])
        }
        payload = {
            'name': str(artifact.get_name()),
            'version': str(artifact.get_version()),
            'customer': customer,
            'url': signed_url,
            'type': str(artifact.get_type()),
            'checksum': {
                'sha1': sha1
            }
        }

        if artifact.get_registry_meta_data():
            payload.update(artifact.get_registry_meta_data())

        url = self._get_base_url('registry_artifact_url') + '/{0}'.format(
            customer)
        self.handler.post(url, headers=headers, json=payload)
Beispiel #8
0
    def _upload_to_signed_url(self, signed_url, binary):
        md5 = hash_file(binary, 'md5', False)
        headers = {'Content-MD5': base64.b64encode(md5).decode('utf-8')}

        self.handler.put(signed_url, binary, headers=headers)