def check_file_for_aws_keys(filenames, keys):
    """Check if files contain AWS secrets.

    Return a list of all files containing AWS secrets and keys found, with all
    but the first four characters obfuscated to ease debugging.
    """
    bad_files = []
    for filename in filenames:
        with open(filename, 'r') as content:
            text_body = content.read()
            for key in keys:
                if key in text_body:
                    bad_files.append({'filename': filename, 'key': key[:4] +
                        '*' * 28})
    return bad_files
