Ejemplo n.º 1
0
def scan_launch(scan_id, force, probe=None,
                mimetype_filtering=None, resubmit_files=None, verbose=False):
    """Launch an existing scan

    :param scan_id: the scan id
    :type scan_id: str
    :param force: if True force a new analysis of files
        if False use existing results
    :type force: bool
    :param probe: probe list to use
        (optional default None means all)
    :type probe: list
    :param mimetype_filtering: enable probe selection based on mimetype
        (optional default:True)
    :type mimetype_filtering: bool
    :param resubmit_files: reanalyze files produced by probes
        (optional default:True)
    :type resubmit_files: bool
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return the updated scan object
    :rtype: IrmaScan
    """
    cli = IrmaApiClient(API_ENDPOINT, max_tries=max_tries, pause=pause,
                        verify=verify, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    scan = scanapi.launch(scan_id, force, probe=probe,
                          mimetype_filtering=mimetype_filtering,
                          resubmit_files=resubmit_files)
    return scan
Ejemplo n.º 2
0
def scan_new(verbose=False):
    """Create a new scan

    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return the new generated scan object
    :rtype: IrmaScan
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    scan = scanapi.new()
    return scan
Ejemplo n.º 3
0
def scan_get(scan_id, verbose=False):
    """Fetch a scan (useful to track scan progress with scan.pstatus)

    :param scan_id: the scan id
    :type scan_id: str
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return the scan object
    :rtype: IrmaScan
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    scan = scanapi.get(scan_id)
    return scan
Ejemplo n.º 4
0
def scan_cancel(scan_id, verbose=False):
    """Cancel a scan

    :param scan_id: the scan id
    :type scan_id: str
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return the scan object
    :rtype: IrmaScan
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    scan = scanapi.cancel(scan_id)
    return scan
Ejemplo n.º 5
0
def scan_add(scan_id, filelist, verbose=False):
    """Add files to an existing scan

    :param scan_id: the scan id
    :type scan_id: str
    :param filelist: list of full path qualified files
    :type filelist: list
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return the updated scan object
    :rtype: IrmaScan
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    scan = scanapi.add(scan_id, filelist)
    return scan
Ejemplo n.º 6
0
def scan_list(limit=None, offset=None, verbose=False):
    """List all scans

    :param limit: max number of files to receive
        (optional default:25)
    :type limit: int
    :param offset: index of first result
        (optional default:0)
    :type offset: int
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return tuple of total scans and list of scans
    :rtype: tuple(int, list of IrmaScan)
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    (total, scan_list) = scanapi.list(limit=limit, offset=offset)
    return (total, scan_list)
Ejemplo n.º 7
0
def scan_add(scan_id, filelist, post_max_size_M=100, verbose=False):
    """Add files to an existing scan

    :param scan_id: the scan id
    :type scan_id: str
    :param filelist: list of full path qualified files
    :type filelist: list
    :param post_max_size_M: POST data max size in Mb
    :type post_max_size_M: int
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return the updated scan object
    :rtype: IrmaScan
    """
    cli = IrmaApiClient(API_ENDPOINT, max_tries=max_tries, pause=pause,
                        verify=verify, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    scan = scanapi.add(scan_id, filelist, post_max_size_M=post_max_size_M)
    return scan
Ejemplo n.º 8
0
def scan_proberesults(result_idx, formatted=True, verbose=False):
    """Fetch file probe results (for a given scan
        one scan <-> one result_idx

    :param result_idx: the result id
    :type result_idx: str
    :param formatted: apply frontend formatters on results
        (optional default:True)
    :type formatted: bool
    :param verbose: enable verbose requests
        (optional default:False)
    :type verbose: bool
    :return: return a IrmaResult object
    :rtype: IrmaResults
    """
    cli = IrmaApiClient(API_ENDPOINT, verbose=verbose)
    scanapi = IrmaScansApi(cli)
    proberesults = scanapi.probe_results(result_idx,
                                         formatted=formatted)
    return proberesults