示例#1
0
    if len(policy_list_original_file) != len(policy_list_original):
        pc_lib_general.pc_exit_error(
            500,
            'Mapped policy list appears to be missing a mapped policy.  This should not be possibile?'
        )
    print('Done.')
    print()

    # Work though the list of policies to build the update package
    print(
        'API - Individual policy retrieval and update (might take a while)...')
    policy_update_error = False
    policy_update_error_list = []
    for policy_original_temp in policy_list_original:
        # Get the individual policy JSON object
        pc_settings, response_package = pc_lib_api.api_policy_get(
            pc_settings, policy_original_temp['policyId'])
        policy_specific_temp = response_package['data']
        print()
        # Need to also get the origional policy object to map in the compliance correctly with the new policy list
        policy_specific_temp_file = export_file_data['policy_object_original'][
            policy_original_temp['policyId']]

        # Add new compliance section(s)
        complianceMetadata_section_list_new_temp_2 = []
        for complianceMetadata_section_temp in policy_specific_temp_file[
                'complianceMetadata']:
            complianceMetadata_section_new_temp = {}
            for map_section_temp in map_section_list:
                if map_section_temp[
                        'sectionGUIDOriginal'] == complianceMetadata_section_temp[
                            'complianceId']:
示例#2
0
    if policy['name'].lower() == args.policy_name.lower():
        policy_id = policy['policyId']
        break
if policy_id is None:
    pc_lib_general.pc_exit_error(500, 'Entered Policy Name was not found!')
print('Done.')

# Print the JSON object from the policy list API call (different from the specific policy object call below)
print()
print('Policy from list:')
print(json.dumps(policy))
print()

# Get the individual complete policy object from the API
print('API - Getting the specific policy...', end='')
pc_settings, response_package = pc_lib_api.api_policy_get(pc_settings, policy_id)
policy_specific = response_package['data']
print('Done.')

# Print the JSON object from the specific policy API call (use this one for any updates to the policy object)
print()
print('Original Policy Object:')
print(json.dumps(policy_specific))
print()

# Print the JSON object of the related Saved Search (if desired with the -rql switch)
if args.rql:
    # Get the related Saved Search object for the policy
    pc_settings, response_package = pc_lib_api.api_search_get(pc_settings, policy['rule']['criteria'])
    policy_search = response_package['data']