def ipa_post():
    rst = {}
    pid = StringUtil.get_unique_str()
    ipa_path = None
    try:
        upload_file = request.files['file']
        fname = secure_filename(upload_file.filename)
        suffix_name = fname.split('.')[-1]  #以.分隔最后的字符串
        #文件后缀名不对时,不做存储处理
        if not suffix_name in allow_ext:
            rst['success'] = 0
            rst['message'] = 'file ext is not allowed'
        else:
            #为ipa文件名称添加时间戳,防止不同文件同名
            fname = pid + '.' + suffix_name
            ipa_path = os.path.join(PathUtil.upload_dir(), fname)  #路径拼接
            upload_file.save(ipa_path)  #保存上传的文件
            rst['ipaName'] = fname

            #获得ipa信息
            rsts = iOS_private.check_app_info_and_provision(ipa_path)
            for key in rsts.keys():
                rst[key] = rsts[key]
            #解压并获取IPA中二进制文件路径
            app = iOS_private.get_executable_path(ipa_path, pid)
            print 'app', app
            #检查ios私有api
            # methods_in_app, methods_not_in_app, private = iOS_private.check_private_api(app, pid)
            # rst['methods_in_app'] = methods_in_app
            # rst['private_framework'] = list(private)
            #检查ipa 64支持情况
            arcs = iOS_private.check_architectures(app)
            rst['arcs'] = arcs
            #包文件大小
            ipa_filesize = StringUtil.file_size(ipa_path)
            rst['ipaFilesize'] = str(ipa_filesize)

            print rst

            #解读数据,审核结果分析
            reviewResult = EGKReviewResultUtil.handleReviewResult(rst)
            reviewResult['success'] = 1
            reviewResult['message'] = '检查成功,数据处理完成'
            rst = reviewResult

    except Exception, e:
        print e
        rst['success'] = 0
        rst['message'] = '检查失败,也许上传的包并非真正的ipa,或者系统出现错误!'
Example #2
0
def add_redis():
    host = RequestUtil.get_parameter('host', '')
    port = RequestUtil.get_parameter('port', '6379')
    password = RequestUtil.get_parameter('password', '')

    try:
        rst = RedisMonitor().ping(host=host, port=port, password=password)
        if not rst.get('success', ''):
            # ping 失败
            return JsonUtil.object_2_json(rst)
    except:
        ResponseUtil.standard_response(0, 'Ping error!')

    # ping 通,添加
    md5 = StringUtil.md5(host + str(port))
    redis_info = RedisInfo.query.get(md5)
    if redis_info:
        redis_info.password = password
    else:
        redis_info = RedisInfo(md5=md5,
                               host=host,
                               port=port,
                               password=password)
    redis_info.save()
    return ResponseUtil.standard_response(1, redis_info.dict())
def ipa_post():
    rst = {}
    pid = StringUtil.get_unique_str()
    ipa_path = None
    try:
        upload_file = request.files['file']
        fname = secure_filename(upload_file.filename)
        suffix_name = fname.split('.')[-1]
        #文件后缀名不对时,不做存储处理
        if not suffix_name in allow_ext:
            rst['success'] = 0
            rst['success'] = 'file ext is not allowed'
        else:
            #为图片名称添加时间戳,防止不同文件同名
            fname = pid + '.' + suffix_name
            ipa_path = os.path.join(PathUtil.upload_dir(), fname)
            upload_file.save(ipa_path)
            rst['success'] = 1
            rst['data'] = {}
            #获得ipa信息
            ipa_parse = IpaParse.IpaParse(ipa_path)
            rst['data']['app_name'] = ipa_parse.app_name()
            rst['data']['version'] = ipa_parse.version()
            rst['data']['bundle_identifier'] = ipa_parse.bundle_identifier()
            rst['data']['target_os_version'] = ipa_parse.target_os_version()
            rst['data']['minimum_os_version'] = ipa_parse.minimum_os_version()
            #检查ios私有api
            app = iOS_private.get_executable_path(ipa_path, pid)
            print 'app', app
            methods_in_app, methods_not_in_app, private = iOS_private.check_private_api(
                app, pid)
            rst['data']['methods_in_app'] = methods_in_app
            rst['data']['private_framework'] = list(private)
            #检查ipa 64支持情况
            rst['data']['arcs'] = iOS_private.check_architectures(app)

    except:
        rst['success'] = 0
        rst['data'] = '检查失败,也许上传的包并非真正的ipa~'

    if ipa_path and os.path.exists(ipa_path):
        os.remove(ipa_path)  #删除上传的包

    cur_dir = os.getcwd()  #删除检查临时目录
    dest_tmp = os.path.join(cur_dir, 'tmp/' + pid)
    if os.path.exists(dest_tmp):
        shutil.rmtree(dest_tmp)
    #print rst
    return OtherUtil.object_2_dict(rst)
def ipa_post():
    rst = {}
    pid = StringUtil.get_unique_str()
    ipa_path = None
    try:
        upload_file = request.files['file']
        fname = secure_filename(upload_file.filename)
        suffix_name = fname.split('.')[-1]
        #文件后缀名不对时,不做存储处理
        if not suffix_name in allow_ext:
            rst['success'] = 0
            rst['success'] = 'file ext is not allowed'
        else:
            #为图片名称添加时间戳,防止不同文件同名
            fname = pid + '.' + suffix_name
            ipa_path = os.path.join(PathUtil.upload_dir(), fname)
            upload_file.save(ipa_path)
            rst['success'] = 1
            rst['data'] = {}
            #获得ipa信息
            ipa_parse = IpaParse.IpaParse(ipa_path)
            rst['data']['app_name'] = ipa_parse.app_name()
            rst['data']['version'] = ipa_parse.version()
            rst['data']['bundle_identifier'] = ipa_parse.bundle_identifier()
            rst['data']['target_os_version'] = ipa_parse.target_os_version()
            rst['data']['minimum_os_version'] = ipa_parse.minimum_os_version()
            #检查ios私有api
            app = iOS_private.get_executable_path(ipa_path, pid)
            print 'app', app
            methods_in_app, methods_not_in_app, private = iOS_private.check_private_api(app, pid)
            rst['data']['methods_in_app'] = methods_in_app
            rst['data']['private_framework'] = list(private)
            #检查ipa 64支持情况
            rst['data']['arcs'] = iOS_private.check_architectures(app)
            
    except:
        rst['success'] = 0
        rst['data'] = '检查失败,也许上传的包并非真正的ipa~'
    
    if ipa_path and os.path.exists(ipa_path):
        os.remove(ipa_path) #删除上传的包

    cur_dir = os.getcwd() #删除检查临时目录
    dest_tmp = os.path.join(cur_dir, 'tmp/' + pid)
    if os.path.exists(dest_tmp):
        shutil.rmtree(dest_tmp)
    #print rst
    return OtherUtil.object_2_dict(rst)
Example #5
0
def add_redis(host, port, psw, email):
    '''
    info: 添加一个redis信息到数据库
    '''
    add_time = DateUtil.now_datetime()
    md5 = StringUtil.md5(host + str(port))
    r = get_redis(md5)
    if r:
        #存在,update
        sql = "update redis_info set redis_host = ?, redis_port = ?, redis_pass = ?, email = ?, add_time = ? where md5 = ?"
        params = (host, port, psw, email, add_time, md5)
        return SqliteHandler().exec_update(sql, params)
    else:
        sql = "insert into redis_info (redis_host, redis_port, redis_pass, email, add_time, md5) values (?, ?, ?, ?, ?, ?)"
        params = (host, port, psw, email, add_time, md5)
        return SqliteHandler().exec_insert(sql, params)
Example #6
0
def add_redis():
    host = request.form.get("host")
    port = request.form.get("port")
    password = request.form.get("password")

    md5 = StringUtil.md5(host + str(port))
    redis_info = RedisInfo.query.get(md5)
    if redis_info:
        redis_info.password = password
    else:
        redis_info = RedisInfo(md5=md5,
                               host=host,
                               port=port,
                               password=password)
    redis_info.save()
    return ResponseUtil.standard_response(redis_info.dict())
Example #7
0
def add_redis(host, port, psw, email):
    '''
    info: 添加一个redis信息到数据库
    '''
    add_time = DateUtil.now_datetime()
    md5 = StringUtil.md5(host + str(port))
    r = get_redis(md5)
    if r:
        #存在,update
        sql = "update redis_info set redis_host = ?, redis_port = ?, redis_pass = ?, email = ?, add_time = ? where md5 = ?"
        params = (host, port, psw, email, add_time, md5)
        return SqliteHandler().exec_update(sql, params)
    else:
        sql = "insert into redis_info (redis_host, redis_port, redis_pass, email, add_time, md5) values (?, ?, ?, ?, ?, ?)"
        params = (host, port, psw, email, add_time, md5)
        return SqliteHandler().exec_insert(sql, params)
Example #8
0
def ipa_post():
    rst = {}
    pid = StringUtil.get_unique_str()
    ipa_path = None
    try:
        upload_file = request.files['file']
        fname = secure_filename(upload_file.filename)
        suffix_name = fname.split('.')[-1]
        #文件后缀名不对时,不做存储处理
        if not suffix_name in allow_ext:
            rst['success'] = 0
            rst['success'] = 'file ext is not allowed'
        else:
            #为图片名称添加时间戳,防止不同文件同名
            fname = pid + '.' + suffix_name
            ipa_path = os.path.join(PathUtil.upload_dir(), fname)
            upload_file.save(ipa_path)
            rst['success'] = 1
            rst['data'] = {}
            #获得ipa信息
            rsts = iOS_private.check_app_info_and_provision(ipa_path)
            for key in rsts.keys():
                rst['data'][key] = rsts[key]
            # ipa_parse = IpaParse.IpaParse(ipa_path)
            # rst['data']['version'] = ipa_parse.version()
            # rst['data']['bundle_identifier'] = ipa_parse.bundle_identifier()
            # rst['data']['target_os_version'] = ipa_parse.target_os_version()
            # rst['data']['minimum_os_version'] = ipa_parse.minimum_os_version()
            #检查ios私有api
            app = iOS_private.get_executable_path(ipa_path, pid)
            print 'app', app
            methods_in_app, methods_not_in_app, private = iOS_private.check_private_api(
                app, pid)
            rst['data']['methods_in_app'] = methods_in_app
            rst['data']['private_framework'] = list(private)
            #检查ipa 64支持情况
            arcs = iOS_private.check_architectures(app)
            rst['data']['arcs'] = arcs

    except Exception, e:
        print e
        rst['success'] = 0
        rst['data'] = '检查失败,也许上传的包并非真正的ipa,或者系统出现错误!'
def ipa_post():
    rst = {}
    pid = StringUtil.get_unique_str()
    ipa_path = None
    try:
        upload_file = request.files['file']
        fname = secure_filename(upload_file.filename)
        suffix_name = fname.split('.')[-1]
        #文件后缀名不对时,不做存储处理
        if not suffix_name in allow_ext:
            rst['success'] = 0
            rst['success'] = 'file ext is not allowed'
        else:
            #为图片名称添加时间戳,防止不同文件同名
            fname = pid + '.' + suffix_name
            ipa_path = os.path.join(PathUtil.upload_dir(), fname)
            upload_file.save(ipa_path)
            rst['success'] = 1
            rst['data'] = {}
            #获得ipa信息
            rsts = iOS_private.check_app_info_and_provision(ipa_path)
            for key in rsts.keys():
                rst['data'][key] = rsts[key]
            # ipa_parse = IpaParse.IpaParse(ipa_path)
            # rst['data']['version'] = ipa_parse.version()
            # rst['data']['bundle_identifier'] = ipa_parse.bundle_identifier()
            # rst['data']['target_os_version'] = ipa_parse.target_os_version()
            # rst['data']['minimum_os_version'] = ipa_parse.minimum_os_version()
            #检查ios私有api
            app = iOS_private.get_executable_path(ipa_path, pid)
            print 'app', app
            methods_in_app, methods_not_in_app, private = iOS_private.check_private_api(app, pid)
            rst['data']['methods_in_app'] = methods_in_app
            rst['data']['private_framework'] = list(private)
            #检查ipa 64支持情况
            arcs = iOS_private.check_architectures(app)
            rst['data']['arcs'] = arcs
            
    except Exception, e:
        print e
        rst['success'] = 0
        rst['data'] = '检查失败,也许上传的包并非真正的ipa,或者系统出现错误!'
Example #10
0
def api_webhook_new():
    # login user
    user_id = RequestUtil.get_login_user().get('id', '')
    server_id = RequestUtil.get_parameter('server_id', '')
    # server must be added by yourself
    if not Server.query.filter_by(id=server_id, user_id=user_id).first():
        return ResponseUtil.standard_response(0, 'Permition deny!')

    repo = RequestUtil.get_parameter('repo', '')
    branch = RequestUtil.get_parameter('branch', '')
    shell = RequestUtil.get_parameter('shell', '')

    if not all((repo, branch, shell, server_id)):
        return ResponseUtil.standard_response(0, 'Form data can not be blank!')

    webhook_id = RequestUtil.get_parameter('id', '')
    if webhook_id:
        # update webhook
        # you can only update the webhook which you create.
        webhook = WebHook.query.filter_by(
            id=webhook_id, user_id=user_id).first()
        if not webhook:
            return ResponseUtil.standard_response(0, 'WebHook is not exist!')
        webhook.repo = repo
        webhook.branch = branch
        webhook.shell = shell
        webhook.server_id = server_id
    else:
        # new webhook
        webhook = WebHook(
            repo=repo,
            branch=branch,
            shell=shell,
            server_id=server_id,
            user_id=user_id,
            key=StringUtil.md5_token()
        )

    webhook.save()

    return ResponseUtil.standard_response(1, webhook.dict(with_key=True))