コード例 #1
0
ファイル: script.py プロジェクト: escapewindow/signingscript
async def async_main(context):
    work_dir = context.config['work_dir']
    context.task = scriptworker.client.get_task(context.config)
    log.info("validating task")
    validate_task_schema(context)
    context.signing_servers = load_signing_server_config(context)
    cert_type = task_cert_type(context.task)
    signing_formats = task_signing_formats(context.task)
    # TODO scriptworker needs to validate CoT artifact
    # Use standard SSL for downloading files.
    with aiohttp.ClientSession() as base_ssl_session:
        orig_session = context.session
        context.session = base_ssl_session
        file_urls = context.task["payload"]["unsignedArtifacts"]
        filelist = await download_artifacts(context, file_urls)
        context.session = orig_session
    log.info("getting token")
    await get_token(context, os.path.join(work_dir, 'token'), cert_type, signing_formats)
    for filepath in filelist:
        log.info("signing %s", filepath)
        source = os.path.join(work_dir, filepath)
        await sign_file(context, source, cert_type, signing_formats,
                        context.config["ssl_cert"])
        sigfiles = detached_sigfiles(filepath, signing_formats)
        copy_to_artifact_dir(context, source, target=filepath)
        for sigpath in sigfiles:
            copy_to_artifact_dir(context, os.path.join(work_dir, sigpath), target=sigpath)
    log.info("Done!")
コード例 #2
0
ファイル: script.py プロジェクト: lundjordan/signingscript
async def async_main(context):
    work_dir = context.config['work_dir']
    context.task = scriptworker.client.get_task(context.config)
    log.info("validating task")
    validate_task_schema(context)
    context.signing_servers = load_signing_server_config(context)
    cert_type = task_cert_type(context.task)
    all_signing_formats = task_signing_formats(context.task)
    log.info("getting token")
    await get_token(context, os.path.join(work_dir, 'token'), cert_type, all_signing_formats)
    filelist_dict = build_filelist_dict(context, all_signing_formats)
    for path, path_dict in filelist_dict.items():
        copy_to_dir(path_dict['full_path'], context.config['work_dir'], target=path)
        log.info("signing %s", path)
        source = os.path.join(work_dir, path)
        await sign_file(context, source, cert_type, path_dict['formats'], context.config["ssl_cert"])
        sigfiles = detached_sigfiles(path, path_dict['formats'])
        copy_to_dir(source, context.config['artifact_dir'], target=path)
        for sigpath in sigfiles:
            copy_to_dir(os.path.join(work_dir, sigpath), context.config['artifact_dir'], target=sigpath)
    log.info("Done!")
コード例 #3
0
ファイル: test_task.py プロジェクト: lundjordan/signingscript
def test_no_error_is_reported_when_no_missing_url(context):
    context.task = task_generator.generate_object()
    validate_task_schema(context)
コード例 #4
0
ファイル: test_task.py プロジェクト: lundjordan/signingscript
def test_missing_mandatory_urls_are_reported(context):
    context.task = task_generator.generate_object()
    del(context.task['scopes'])

    with pytest.raises(ScriptWorkerTaskException):
        validate_task_schema(context)
コード例 #5
0
def test_missing_mandatory_urls_are_reported(context):
    context.task = task_generator.generate_object(urls=[])  # no URLs provided

    with pytest.raises(ScriptWorkerTaskException):
        validate_task_schema(context)