qualysclient.QualysClient

class QualysClient(username=None, password=None)

Bases: object

a simple client for interacting with the Qualys API

Methods

add_ips

Add IP addresses to the user's subscription.

cancel_running_report

Cancel a running report in the user’s account.

compliance_control_list

View a list of compliance controls which are visible to the user.

compliance_exception_delete

Delete Exception(s)

compliance_exception_list

List, request, update and delete exceptions in your account.

compliance_exception_request

An exception is created with the expiry date matching the creation date.

compliance_exception_update

Update Exception(s)

compliance_policy_add_asset_group_ids

Add asset group IDs to policy

compliance_policy_export

Export compliance policies from your account to an XML file.

compliance_policy_import

Import a compliance policy, defined in an XML file, into your account.

compliance_policy_list

View a list of compliance policies visible to the user.

compliance_policy_merge

Merge (combine) 2 or more compliance policies using Qualys Policy Compliance (PC).

compliance_policy_remove_asset_group_ids

Remove asset group IDs from policy

compliance_policy_set_asset_group_ids

Set asset group IDs for policy

compliance_posture_list

View current compliance posture data (info records) for hosts within the user’s account.

download_saved_report

Download a saved report in the user’s account

excluded_host_change_history

View change history for excluded hosts in the user’s subscription.

excluded_host_list

Show the excluded host list for the user's account.

host_list

Download a list of scanned hosts in the user’s account

host_list_detection

Download a list of hosts with the hosts latest vulnerability data, based on the host based scan data available in the user’s account.

launch_report

Launch a report in the user's account.

launch_scorecard

Launch a vulnerability scorecard report in the user’s Report Share.

list_ip

List IP addresses in the user account.

list_reports

View a list of reports in the user’s account when Report Share feature is enabled.

login

Authenticate to Qualys API

logout

Log out of authenticated sessionn

update_ips

Update IP addresses in the user's subscription.

add_ips(**kwargs) Response

Add IP addresses to the user’s subscription.

Once added they are available for scanning and reporting.

Parameters:

**kwargs – supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

cancel_running_report(id: int, **kwargs) Response

Cancel a running report in the user’s account.

Parameters:
  • id (int) – Specifies the report ID of a running report that you want to cancel. The status of the report must be “running”.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Raises:

ParameterValidationError – When Parameter Validation fails

Returns:

Response – Qualys API response contained within request.Response object

compliance_control_list(**kwargs) Response

View a list of compliance controls which are visible to the user.

Controls in the XML output are sorted by control ID in ascending order. Optional input parameters support filtering the list.

Parameters:

**kwargs

supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_exception_delete(exception_numbers: str, **kwargs)

Delete Exception(s)

Parameters:
  • exception_numbers (str) – Show a specific exception by specifying a valid exception number. Multiple entries are comma separated. An exception number range is specified with a hyphen (for example, 50-55).

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_exception_list(**kwargs)

List, request, update and delete exceptions in your account.

By default, all exceptions in the user’s account are listed. Use the optional parameters to filter the list output

Parameters:

**kwargs

supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_exception_request(control_id: int, host_id: int, policy_id: int, technology_id: int, assignee_id: str, comments: str, **kwargs)

An exception is created with the expiry date matching the creation date.

Parameters:
  • control_id (int) – Specify the control ID of the control for which you want to request an exception.

  • host_id (int) – Specify the host ID of the host for which you want to request an exception.

  • policy_id (int) – Specify the policy ID of the policy that contains the control for which you want to request an exception.

  • technology_id (int) – Specify the technology ID of the technology associated with the host for which you want to request an exception.

  • assignee_id (str) – You can assign exception to another user. Specify user ID of the user, who has access to the hosts that the exceptions apply to.

  • comments (str) – User defined comments.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_exception_update(exception_numbers: str, comments: str, **kwargs)

Update Exception(s)

Parameters:
  • exception_numbers (str) – Show a specific exception by specifying a valid exception number. Multiple entries are comma separated. An exception number range is specified with a hyphen (for example, 50-55).

  • comments (str) – User defined comments.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_policy_add_asset_group_ids(id: int, asset_group_ids: str, **kwargs)

Add asset group IDs to policy

Parameters:
  • id (int) – Policy ID for the policy you want to update

  • asset_group_ids (str) – Asset groups IDs for the asset groups you want to add to the policy specified in “id”. Multiple IDs are comma separated. Each asset group must have at least 1 assigned IP address.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_policy_export(id: int, **kwargs) Response

Export compliance policies from your account to an XML file.

Service provided controls are exported and you can choose to also export user defined controls. The output also includes an appendix with human readable look-ups for control descriptions, giving you explanation on the various aspects of control description and evaluation.

Parameters:
Returns:

Response

compliance_policy_import(xml_file: FileIO, title: str, **kwargs) Response

Import a compliance policy, defined in an XML file, into your account.

We’ll include all the service-provided controls from your XML file. You have the option to also include userdefined controls.

Parameters:
  • xml_file (FileIO) – The file containing the policy details.

  • title (str) – The title of the new policy.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_policy_list(**kwargs)

View a list of compliance policies visible to the user.

Policies in the XML output are sorted by compliance policy ID in ascending order. Optional input parameters support filtering the policy list output.

Parameters:

**kwargs

supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_policy_merge(id: int, merge_policy_id: int, **kwargs) Response

Merge (combine) 2 or more compliance policies using Qualys Policy Compliance (PC).

Parameters:
  • id (int) – The ID of the policy that will be updated with merged content (let’s call this Policy A).

  • merge_policy_id (int) – Tell us the policy with the content that will be merged into Policy A (let’s call this Policy B).

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_policy_remove_asset_group_ids(id: int, asset_group_ids: str, **kwargs)

Remove asset group IDs from policy

Parameters:
  • id (int) – Policy ID for the policy you want to update

  • asset_group_ids (str) – Asset groups IDs for the asset groups you want to delete to the policy specified in “id”. Multiple IDs are comma separated. Each asset group must have at least 1 assigned IP address.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_policy_set_asset_group_ids(id: int, asset_group_ids: str, **kwargs)

Set asset group IDs for policy

Use this action to reset the asset groups for a specified policy. Any assigned asset groups not specified in this request will be removed.

Parameters:
  • id (int) – Policy ID for the policy you want to update

  • asset_group_ids (str) – Asset groups IDs for the asset groups you want to assign to the policy specified in “id”. Multiple IDs are comma separated. Each asset group must have at least 1 assigned IP address.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

compliance_posture_list(policy_id: int, **kwargs)

View current compliance posture data (info records) for hosts within the user’s account.

Each compliance posture info record includes a compliance posture ID and other attributes. Optional input parameters support filtering the posture info record output. .

Parameters:
  • policy_id (int) – Show compliance posture info records for a specified policy. A valid policy ID is required.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

download_saved_report(id: int, **kwargs) Response

Download a saved report in the user’s account

You can download all report types (map, scan, patch, authentication, scorecard, remediation, compliance). This option is available when the Report Share feature is enabled in the user’s subscription.

Parameters:
  • id (int) – (Required) Specifies the report ID of a saved report that you want to download. The status of the report must be “finished”

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

excluded_host_change_history(**kwargs)

View change history for excluded hosts in the user’s subscription.

History record IDs in the XML output are listed in decreasing order.

Parameters:

**kwargs

supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

excluded_host_list(**kwargs)

Show the excluded host list for the user’s account.

Hosts in your excluded host list will not be scanned.

Parameters:

**kwargs

supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

host_list(truncation_limit=10, **kwargs)

Download a list of scanned hosts in the user’s account

By default, all scanned hosts in the user account are included and basic information about each host is provided. Hosts in the XML output are sorted by host ID in ascending order.

The output of the Host List API is paginated. By default, a maximum of 1,000 host records are returned per request. You can customize the page size (i.e. the number of host records) by using the parameter “truncation_limit=10000” for instance. In this case the results will be return with pages of 10,000 host records.

Parameters:
  • truncation_limit (int, optional) – Specifies the maximum number of host records processed per request. Defaults to 10.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

host_list_detection(truncation_limit=10, **kwargs)

Download a list of hosts with the hosts latest vulnerability data, based on the host based scan data available in the user’s account.

This data brings a lot of value to customers because they provide the latest complete vulnerability status for the hosts (NEW, ACTIVE, FIXED, REOPENED) and history information.

Parameters:
  • truncation_limit (int, optional) – Specifies the maximum number of host records processed per request. Defaults to 10.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

launch_report(template_id: int, **kwargs) Response

Launch a report in the user’s account. Launch a report in the user’s account. The Report Share feature must be enabled in the user’s subscription. When a report is launched with Report Share, the report is run in the background, and the report generation processing does not timeout until the report has completed.

Parameters:
  • template_id (int) – (Required) The template ID of the report you want to launch.

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

launch_scorecard(name: str, **kwargs) Response

Launch a vulnerability scorecard report in the user’s Report Share.

Launch a vulnerability scorecard report in the user’s Report Share. It is not possible to launch any compliance scorecard reports or WAS scorecard reports using this API at this time. When a scorecard report is launched, the report is run in the background, and the report generation processing does not timeout until the report has completed.

Parameters:
  • name (str) –

    (Required) Specifies the scorecard name for the vulnerability scorecard report that you want to launch. This name corresponds to a service-provided scorecard or a user-created scorecard. For a service-provided scorecard, specify one of these names:

    • Asset Group Vulnerability Report

    • Ignored Vulnerabilities Report

    • Most Prevalent Vulnerabilities Report

    • Most Vulnerable Hosts Report

    • Patch Report

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

list_ip(**kwargs) Response

List IP addresses in the user account. By default, all hosts in the user account are included.

Optional input parameters support filtering the list by IP addresses and host tracking method.

Returns:

Response – Qualys API response contained within request.Response object

list_reports(**kwargs) Response

View a list of reports in the user’s account when Report Share feature is enabled.

The report list output includes all report types, including scorecard reports.

Parameters:

**kwargs

supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

login(username, password)

Authenticate to Qualys API

Parameters:
  • username (str) – Qualys Username

  • password (str) – Qualys Password

logout()

Log out of authenticated sessionn

update_ips(ips: str, **kwargs) Response

Update IP addresses in the user’s subscription.

Parameters:
  • ips (str) – (Required) The hosts within the subscription you want to update. IPs must be specified by using the “ips” parameter (using the POST method)

  • **kwargs

    supported keywords documented within the Qualys VM/PC API user guide

Returns:

Response – Qualys API response contained within request.Response object

Example

ips=10.10.10.200,10.10.23.40