Packs/Code42/Integrations/Code42/Code42.py
def build_query_payload(args):
    """
    Build a query payload combining passed args
    """
    search_args = []
    if args.get('hash'):
        if len(args['hash']) == 32:
            search_args.append(MD5.eq(args['hash']))
        elif len(args['hash']) == 64:
            search_args.append(SHA256.eq(args['hash']))
    if args.get('hostname'):
        search_args.append(OSHostname.eq(args['hostname']))
    if args.get('username'):
        search_args.append(DeviceUsername.eq(args['username']))
    if args.get('exposure'):
        # Because the CLI can't accept lists, convert the args to a list if the type is string.
        if isinstance(args['exposure'], str):
            args['exposure'] = args['exposure'].split(',')
        search_args.append(ExposureType.is_in(args['exposure']))
    # Convert list of search criteria to *args
    query = FileEventQuery.all(*search_args)
    query.page_size = args.get('results')
    LOG('File Event Query: {}'.format(query))
    return str(query)

    Build a query payload combining passed args
    
Build a query payload combining passed args
Build a query payload combining passed args
def build_query_payload(args):
    search_args = []
    if args.get('hash'):
        if len(args['hash']) == 32:
            search_args.append(MD5.eq(args['hash']))
        elif len(args['hash']) == 64:
            search_args.append(SHA256.eq(args['hash']))
    if args.get('hostname'):
        search_args.append(OSHostname.eq(args['hostname']))
    if args.get('username'):
        search_args.append(DeviceUsername.eq(args['username']))
    if args.get('exposure'):
        if isinstance(args['exposure'], str):
            args['exposure'] = args['exposure'].split(',')
        search_args.append(ExposureType.is_in(args['exposure']))
    query = FileEventQuery.all(*search_args)
    query.page_size = args.get('results')
    LOG('File Event Query: {}'.format(query))
    return str(query)
def build_query_payload ( args ) : search_args = [ ] if args . get ( 'hash' ) : if len ( args [ 'hash' ] ) == 32 : search_args . append ( MD5 . eq ( args [ 'hash' ] ) ) elif len ( args [ 'hash' ] ) == 64 : search_args . append ( SHA256 . eq ( args [ 'hash' ] ) ) if args . get ( 'hostname' ) : search_args . append ( OSHostname . eq ( args [ 'hostname' ] ) ) if args . get ( 'username' ) : search_args . append ( DeviceUsername . eq ( args [ 'username' ] ) ) if args . get ( 'exposure' ) : if isinstance ( args [ 'exposure' ] , str ) : args [ 'exposure' ] = args [ 'exposure' ] . split ( ',' ) search_args . append ( ExposureType . is_in ( args [ 'exposure' ] ) ) query = FileEventQuery . all ( * search_args ) query . page_size = args . get ( 'results' ) LOG ( 'File Event Query: {}' . format ( query ) ) return str ( query )
Build a query payload combining passed args
Build a query payload combining passed args
"""
    Build a query payload combining passed args
    """ # Because the CLI can't accept lists, convert the args to a list if the type is string. # Convert list of search criteria to *args
args