(
        filenames: Sequence[str],
        keys: Set[bytes],
)
return bad_files
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.
Check if files contain AWS secrets.
Check if files contain AWS secrets .
def check_file_for_aws_keys(
        filenames: Sequence[str],
        keys: Set[bytes],
) -> List[BadFile]:
    """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, 'rb') as content:
            text_body = content.read()
            for key in keys:
                # naively match the entire file, low chance of incorrect
                # collision
                if key in text_body:
                    key_hidden = key.decode()[:4].ljust(28, '*')
                    bad_files.append(BadFile(filename, key_hidden))
    return bad_files
def check_file_for_aws_keys ( filenames : Sequence [ str ] , keys : Set [ bytes ] , ) -> List [ BadFile ] : bad_files = [ ] for filename in filenames : with open ( filename , 'rb' ) as content : text_body = content . read ( ) for key in keys : # naively match the entire file, low chance of incorrect # collision if key in text_body : key_hidden = key . decode ( ) [ : 4 ] . ljust ( 28 , '*' ) bad_files . append ( BadFile ( filename , key_hidden ) ) return bad_files