Terry McCorkle

QualysGuard® 7.13 API Notification - 15 Day

Blog Post created by Terry McCorkle on Jan 29, 2014

This update to QualysGuard 7.13 includes improvements to the QualysGuard API, allowing you to integrate your programs and API calls with QualysGuard Vulnerability Management (VM) and QualysGuard Policy Compliance (PC).

 

Highlights Include:

 

  • VM and PC - “Report Share” API v2 download CSV reports without headers
  • VM - New "HTTP Authentication”
  • API v2 PC - New "Policy Merge”
  • API v2 PC - Policy Report XML now includes custom control references
  • PC - “Apache Authentication” API v2 - Support for multiple instances per host
  • PC - “MS SQL Authentication” API v2 - Auto discover database instances

 

VM and PC - “Report Share” API v2 download CSV reports without headers

 

The “Report Share” API v2 (/api/2.0/fo/report/) allows you to launch and download reports. With this release you can choose to download reports in CSV format without the header information for all VM reports and PC reports that can be downloaded in CSV format. Basically we’ll include just the central CSV tables containing your security and compliance data, not the header metadata.

 

Want to omit the header from your CSV report? Using the“Report Share” API v2 first launch this report with the input parameter “hide_header=1” and then download the report in the usual way.

 

Step 1 - Launch your report in CSV format

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl"-X "POST" -d "action=launch&template_id=123&output_format=csv&hide_header=1" "https://qualysapi.qualys.com/api/2.0/fo/report/

 

XML output:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE GENERIC SYSTEM "https://qualysapi.qualys.com/api/2.0/simple_return.dtd">
<SIMPLE_RETURN>
  <RESPONSE>
    <DATETIME>2012-12-11T21:45:23Z</DATETIME>
    <TEXT>New report launched</TEXT>
    <ITEM_LIST>
      <ITEM>
      <KEY>ID</KEY>
      <VALUE>6622</VALUE>
      </ITEM>
    </ITEM_LIST>
  </RESPONSE>
</SIMPLE_RETURN>

 

Step 2 - Download your CSV report

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -X "POST" -d "action=fetch&id=6622" "https://qualysapi.qualys.com/api/2.0/fo/report/"

 

CSV output:

You’ll notice there’s no header information (report title, date,user who launched the report, etc).

 

         CSV - Headers.png

 

VM – New "HTTP Authentication” API v2

 

You now have the option to choose HTTP authentication for vulnerability scans using QualysGuard Vulnerability Management (VM). Use the“HTTP Authentication” API v2 (/api/2.0/fo/auth/http/) for scanning protected portions of web sites and devices like printers and routers that require HTTP protocol level authentication. (Note this is not Form-based authentication). By authenticating we can perform additional vulnerability tests that we couldn’t do otherwise.

 

How it works – During a vulnerability scan, if we come across a web page that requires HTTP authentication then we’ll check to see if an HTTP record exists in your account with applicable credentials. If yes,we’ll use the credentials in the record to perform HTTP authentication.

 

List HTTP records

 


API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" -d "action=list&ids=55111" "https://qualysapi.qualys.com/api/2.0/fo/auth/http/"

 

XML output:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE AUTH_HTTP_LIST_OUTPUT SYSTEM "https://qualysapi.qualys.com/api/2.0/fo/auth/http/auth_http_list_output.dtd">
<AUTH_HTTP_LIST_OUTPUT>
 <RESPONSE>
   <DATETIME>2014-01-03T08:08:19Z</DATETIME>
   <AUTH_HTTP_LIST>
     <AUTH_HTTP>
       <ID>55111</ID>
       <TITLE><![CDATA[My HTTPRecord]]></TITLE>
       <USERNAME><![CDATA[jsmith]]></USERNAME>
       <SSL>0</SSL>
       <REALM><![CDATA[MyHomepage]]></REALM>
       <CREATED>
         <DATETIME>2014-01-03T07:51:48Z</DATETIME>
         <BY>acme_ab1</BY>
       </CREATED>
       <LAST_MODIFIED>
       <DATETIME>2014-01-03T07:51:48Z</DATETIME>
       </LAST_MODIFIED>
     </AUTH_HTTP>
   </AUTH_HTTP_LIST>
 </RESPONSE>
</AUTH_HTTP_LIST_OUTPUT>

 

HTTP record list output DTD:

 

<!-- QUALYS AUTH_HTTP_LIST_OUTPUT DTD -->
<!ELEMENTAUTH_HTTP_LIST_OUTPUT (REQUEST?, RESPONSE)>
<!ELEMENT REQUEST (DATETIME,USER_LOGIN, RESOURCE, PARAM_LIST?, POST_DATA?)>
<!ELEMENT DATETIME(#PCDATA)>
<!ELEMENT USER_LOGIN (#PCDATA)>
<!ELEMENT RESOURCE(#PCDATA)>
<!ELEMENT PARAM_LIST (PARAM+)>
<!ELEMENT PARAM (KEY,VALUE)>
<!ELEMENT KEY (#PCDATA)>
<!ELEMENT VALUE (#PCDATA)>
<!-- if returned, POST_DATA will be urlencoded -->
<!ELEMENT POST_DATA(#PCDATA)>
<!ELEMENT RESPONSE (DATETIME, (AUTH_HTTP_LISTID_SET)?,WARNING_LIST?, GLOSSARY?)>
<!ELEMENT AUTH_HTTP_LIST (AUTH_HTTP+)>
<!ELEMENT AUTH_HTTP (ID, TITLE, USERNAME, SSL, (REALMVHOST), IP_SET?,CREATED, LAST_MODIFIED, COMMENTS?)>
<!ELEMENT ID (#PCDATA)>
<!ELEMENT TITLE (#PCDATA)>
<!ELEMENT USERNAME (#PCDATA)>
<!ELEMENT SSL (#PCDATA)>
<!ELEMENT REALM (#PCDATA)>
<!ELEMENTVHOST (#PCDATA)>
<!ELEMENT IP_SET (IPIP_RANGE)+>
<!ELEMENT IP(#PCDATA)>
<!ELEMENT IP_RANGE (#PCDATA)>
<!ELEMENT CREATED(DATETIME, BY)>
<!ELEMENT BY (#PCDATA)>
<!ELEMENT LAST_MODIFIED(DATETIME)>
<!ELEMENT COMMENTS (#PCDATA)>
<!ELEMENT WARNING_LIST(WARNING+)>
<!ELEMENT WARNING (CODE?, TEXT, URL?, ID_SET?)>
<!ELEMENT CODE (#PCDATA)>
<!ELEMENT TEXT (#PCDATA)>
<!ELEMENTURL (#PCDATA)>
<!ELEMENT ID_SET (IDID_RANGE)+>
<!ELEMENT ID_RANGE(#PCDATA)>
<!ELEMENT GLOSSARY (USER_LIST?)>
<!ELEMENT USER_LIST(USER+)>
<!ELEMENT USER (USER_LOGIN, FIRST_NAME, LAST_NAME)>
<!ELEMENT FIRST_NAME (#PCDATA)>
<!ELEMENT LAST_NAME (#PCDATA)>
<!-- EOF -->

 

Create a new HTTP record - realm

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" -d "action=create&amp;username=jsmith&amp;password=abc123&amp;title=MyHTTPRecord1&amp;realm=MyHomepage" "https://qualysapi.qualys.com/api/2.0/fo/auth/http/"

 

XML output:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE BATCH_RETURN SYSTEM "https://qualysapi.qualys.com/api/2.0/batch_return.dtd">
<BATCH_RETURN>
  <RESPONSE>
    <DATETIME>2014-01-03T07:51:48Z</DATETIME>
    <BATCH_LIST>
      <BATCH>
        <TEXT>Successfully Created</TEXT>
        <ID_SET>
          <ID>55111</ID>
        </ID_SET>
      </BATCH>
    </BATCH_LIST>
  </RESPONSE>
</BATCH_RETURN>

 

 

Create a new HTTP record - virtual host

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" -d "action=create&amp;username=jsmith&amp;password=abc123&amp;title=MyHTTPRecord+2&amp;vhost=bank.us.corp1.com" "https://qualysapi.qualys.com/api/2.0/fo/auth/http/"

 

 

 

Update an HTTP record

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" -d "action=update&ids=55114&realm=11" "https://qualysapi.qualys.com/api/2.0/fo/auth/http/"

 

 

 

Delete an HTTP record

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" -d "action=delete&ids=55114" "https://qualysapi.qualys.com/api/2.0/fo/auth/http/"

 

 

 

List authentication records - now includes HTTP records

 

API request:
curl -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -d "action=list&id_min=54190&id_max=54436" "https://qualysapi.qualys.com/api/2.0/fo/auth/"

 

 

PC - New "Policy Merge” API v2

 

We’re pleased to introduce the new “Policy Merge” API v2 (resource /api/2.0/fo/compliance/policy/ with the parameter action=merge). This new API allows you to merge (combine) 2 or more compliance policies using QualysGuard Policy Compliance (PC). You can choose to merge some or all parts of a new policy into an existing one. Also you can preview merge changes before saving them. This API is available to Managers and Auditors.

 

For example, say you imported a policy from our library (Policy A) and configured it to add asset groups, controls and sections. Later we might release an updated version of this policy (Policy B) with new controls and technologies. In this scenario you can use the Policy Merge API to add the new controls and technologies from Policy B into Policy A (your existing policy) without losing the asset groups, controls and sections you added.

 

Policy Merge Request 1 - preview merged policy

 

Policy ID 15993 (Policy A) will be updated with content merged from policy ID 15994 (Policy B) and the XML output will show the merged policy in preview mode. Policy changes will not be saved in Policy 15993 since the request includes “preview_merge=1”.

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: curl" "https://qualysapi.qualys.com/api/2.0/fo/compliance/policy/?action=merge&id=15993&merge_policy_id=15994&replace_cover_page=1&add_new_asset_groups=1&add_new_technologies=1&update_section_heading=1&add_new_controls=1&update_existing_controls=1&preview_merge=1"

 

 

PC - Policy Report XML now includes custom control references

 

With this release you can choose to create policy reports with your custom control references in XML and CSV format - just follow the steps below.

 

The policy report XML output now lists the control references defined for each control. We’ve updated the policy report DTD (compliance_policy_report.dtd) to add the new element <CONTROL_REFERENCES>.

 

Step 1 - Configure the template settings

 

Configure your policy report template using the user interface (under PC > Reports > Templates). Be sure to choose the Group by Controls option and under Sections choose Control References.

 

 

Step 2 - Launch a PC policy report

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -X "POST" -d"action=launch&template_id=55469&output_format=xml" "https://qualysapi.qualys.com/api/2.0/fo/report/"

 

 

XML output:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPEGENERIC SYSTEM "https://qualysapi.qualys.com/api/2.0/simple_return.dtd">
<SIMPLE_RETURN>
  <RESPONSE>
    <DATETIME>2013-12-11T21:45:23Z</DATETIME>
    <TEXT>New reportlaunched</TEXT>
    <ITEM_LIST>
      <ITEM>
        <KEY>ID</KEY>
        <VALUE>1665</VALUE>
      </ITEM>
    </ITEM_LIST>
  </RESPONSE>
</SIMPLE_RETURN>

 

Step 3 - Download report XML

 

API request:
curl -k -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -X "POST" -d"action=fetch&id=1665" "https://qualysapi.qualys.com/api/2.0/fo/report/"

 

 

XML output:

...          
         <CONTROL_LIST>           
           <CONTROL>             
             <CID>1376</CID>             
             <STATEMENT><![CDATA[Status of the'Interactive Logon: Do not require CTRLALTDEL'
                         setting]]></STATEMENT>             
             <CONTROL_REFERENCES>ABC123,4.6.88</CONTROL_REFERENCES>             
             <RATIONALE><![CDATA[The Windows OS behaves differently when the'CTRLALTDelete' is invoked 
                         before login--this guarantees that the authentication process for the system 
                         is engaged. Otherwise, when only the two-line login screen is presented, it
                         is possible that a Trojan program is displaying a phony userid/password login 
                         screen, which will collect the credentials and exit, leaving the user believing
                         that he/she simply mistype done or both of the required values. NOTE: As this 
                         is one of the reverse-logic controls, it is important to remember that this 
                         should be DISABLED to actually be enabled.]]>
             </RATIONALE>
             <STATUS><![CDATA[Passed]]></STATUS>
             <EVIDENCE><![CDATA[CHECK1]]></EVIDENCE>
           </CONTROL>  
... 

 

 

PC - “Apache Authentication” API v2 – Support for multiple instances per host

Apache Server authentication is available for compliance scans using QualysGuard Policy Compliance (PC). With this release the “Apache Authentication” API v2 (/api/2.0/fo/auth/apache/) now supports authentication to multiple Apache server instances on the same host.

 

Want to set it up? Just create multiple Apache server authentication records - 1 record for each host instance. In each record, a host instance is defined by a unique IP address and configuration file pair.You can create 2 records for the same IP address, but the config file can’t be the same in the 2 records.

 

Create multiple Apache records

 

To scan 2 Apache instances on the same IP, you’ll create 2 Apache authentication records. This is how you create 2 records for IP10.10.25.25 - note the 2 different configuration files.

 

 

API request (record 1):

curl -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -X "POST" -d "action=create&amp;title=ApacheRecord1&amp;unix_apache_config_file=/opt/IBM/HTTPServer/conf/httpd.conf1&amp;unix_apache_control_command=/opt/IBM/HTTPServer/bin1&amp;ips=10.10.25.25" "https://qualysapi.qualys.com/api/2.0/fo/auth/apache/"

 

 

API request (record 2):

curl -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -X "POST" -d "action=create&amp;title=ApacheRecord2&amp;unix_apache_config_file=/opt/IBM/HTTPServer/conf/httpd.conf2&amp;unix_apache_control_command=/opt/IBM/HTTPServer/bin1&amp;ips=10.10.25.25" "https://qualysapi.qualys.com/api/2.0/fo/auth/apache/"

 

 

List Apache records

 

This is a way you can review the authentication record settings before you scan. The Apache records list XML (auth_apache_list_output.dtd)did not change.

 

 

Reporting of Apache Server instances

 

Your PC reports identify compliance evaluation findings forApache instances. With this release each instance identifies the configuration file path.

 

PC - “MS SQL Authentication” API v2 - Autodiscover database instances

 

MS SQL Server authentication is available for compliance scans using QualysGuard Policy Compliance (PC). With this release the “MS SQL authentication” API v2 (/api/2.0/fo/auth/ms_sql/) supports the automatic discovery of MS SQL Server instances. Just specify the auto discovery option(s) in your records and we’ll find all matching instances on target hosts and attempt authentication.

 

Create MS SQL records

 

API request (record 1):

For IP 10.10.25.25 auto discover instance names, database names and ports.

curl -u "USERNAME:PASSWORD" -H "X-Requested-With:Curl" -X "POST" -d "action=create&amp;title=MSSQLRecord+1&amp;username=myname&amp;password=mypassword&amp;ips=10.10.25.25&amp;auto_discover_instances=1&amp;auto_discover_databases=1&amp;auto_discover_ports=1" "https://qualysapi.qualys.com/api/2.0/fo/auth/ms_sql/"

 

 

API request (record 2):

For IP 10.10.25.100 we’ll auto discover ports and instances but the database name will be set to “mydbname”.

curl -u "USERNAME:PASSWORD" -H "X-Requested-With:Curl" -X "POST" -d "action=create&amp;title=MSSQLRecord+2&amp;username=myname&amp;password=mypassword&amp;ips=10.10.25.100&amp;auto_discover_ports=1&amp;auto_discover_instances=1&amp;database=mydbname" "https://qualysapi.qualys.com/api/2.0/fo/auth/ms_sql/"

 

 

List MS SQL records

 

This is a way you can review the authentication record settings before you scan. The MS SQL records list XML (auth_ms_sql_list_output.dtd)has been updated.

 

API request:

curl -u "USERNAME:PASSWORD" -H "X-Requested-With: Curl" -X "POST" -d "action=list" "https://qualysapi.qualys.com/api/2.0/fo/auth/ms_sql/"

Outcomes