in src/python/detectors/missing_pagination/missing_pagination.py [0:0]
def s3_loop_noncompliant(s3bucket_name, s3prefix_name):
import boto3
s3_client = boto3.resource('s3').meta.client
# Noncompliant: loops through the contents without checking whether
# more requests are needed.
list_object_response = s3_client.list_objects_v2(Bucket=s3bucket_name,
Prefix=s3prefix_name)
try:
if 'Contents' in list_object_response:
s3_deployment_folders = list_object_response['Contents']
return s3_deployment_folders
except ListException:
print("List objects in bucket {} with prefix {} "
"failed with response {}".format(s3bucket_name,
s3prefix_name,
list_object_response))