Exemplo n.º 1
0
def test_load_user_data_returns_object_from_file(mocker, fs):
    set_env_vars = {'CDB_USER_DATA': '/some/random/file.json'}
    with ScopedEnvVars({}, set_env_vars):
        os.environ['CDB_USER_DATA'] = "/some/random/file.json"
        fs.create_file("/some/random/file.json",
                       contents='{"super_cool": "user data"}')
        user_data = load_user_data()
        assert user_data == {"super_cool": "user data"}
def create_deployment_payload(env=os.environ):
    deployment = {}
    deployment["artifact_sha256"] = env.get('CDB_ARTIFACT_SHA', 'None')
    deployment["environment"] = env.get('CDB_ENVIRONMENT', 'None')
    deployment["description"] = env.get('CDB_DESCRIPTION', 'None')
    deployment["build_url"] = env.get('CDB_CI_BUILD_URL', None)

    if env.get("CDB_USER_DATA"):
        deployment["user_data"] = load_user_data()
    return deployment
Exemplo n.º 3
0
def put_evidence(project_file):
    print("Publish evidence to ComplianceDB")

    is_compliant = env_is_compliant()
    evidence_type = os.getenv('CDB_EVIDENCE_TYPE', "EVIDENCE_TYPE_UNDEFINED")
    description = os.getenv('CDB_DESCRIPTION', "UNDEFINED")
    build_url = os.getenv('CDB_CI_BUILD_URL', "URL_UNDEFINED")
    user_data = load_user_data()

    evidence = build_evidence_dict(is_compliant, evidence_type, description, build_url, user_data)
    send_evidence(project_file, evidence)
Exemplo n.º 4
0
def control_junit(project_file):
    print("Publish evidence to ComplianceDB")

    junit_results_dir = os.getenv('CDB_TEST_RESULTS_DIR', '/data/junit/')
    is_compliant, message = is_compliant_tests_directory(junit_results_dir)

    evidence_type = os.getenv('CDB_EVIDENCE_TYPE', "junit")
    description = "JUnit results xml verified by compliancedb/cdb_controls: " + message
    build_url = os.getenv('CDB_CI_BUILD_URL', "URL_UNDEFINED")
    user_data = load_user_data()

    evidence = build_evidence_dict(is_compliant, evidence_type, description, build_url, user_data)
    send_evidence(project_file, evidence)
Exemplo n.º 5
0
def test_load_user_data_None_if_not_in_env(mocker):
    with ScopedEnvVars({}):
        assert not os.getenv('CDB_USER_DATA')
        user_data = load_user_data()
        assert user_data is None