API - Asset Group Update from CSV file (Fully Automated - Commented)

Document created by Brandon Reeves on Jun 22, 2011Last modified by Brandon Reeves on Jun 22, 2011
Version 3Show Document
  • View in full screen mode

#!/usr/local/bin/bash

##Ensure Proper Paths

. /scripts/qualys/shared/qualys_vars

script_dir="$(pwd)"

file2="$script_dir/sn.txt"

appliances="scanner1,scanner2,scanner3,etc"

default_appl="scanner1"

#Collateral Damage Potential

cdp="medium-high"

#Target Distribution

td="medium"

#Confidentiality Requirement

cr="high"

#Integrity Requirement

ir="high"

#Availability Requirement

ar="medium"

##This Script Updates Qualys Asset Groups with all appropriate values and

##Updates any IP addresses if they are available from a CSV file.

##The Format of the CSV file is:

##ASSET GROUP,APP NAME,FACILITY,OWNER,IP ADDRESSES

#Other Variables listed below for used in the Qualys Asset Groups

#Dont uncomment the below lines, they are for reference purposes only

#agtitle=Asset Group

#fac=Facility

#bo=Person who is responsible for Asset Group

#ips=IP Addresses to Address to Asset Group

 

IFS=";"

while read agtitle appname fac bo ips

do

     if [ -z $ips ]; then

      echo "No IP in Address Field for $agtitle"

      comments="$agtitle - $appname - $fac - $bo"

      result="$(curl -u $qualys_user:$qualys_pass -s -k -H "X-Requested-With: Browser" -D $script_dir/headers.15 -d "action=edit&title=$agtitle&scanner_appliances=$appliances&default_scanner_appliance=$default_appl&cvss_enviro_cdp=$cdp&cvss_enviro_td=$td&cvss_enviro_cr=$cr&cvss_enviro_ir=$ir&cvss_enviro_ar=$ar&comments=$comments&location=$fac" "https://qualysapi.qualys.com/msp/asset_group.php" | grep -i status)"

      echo "$result"

      echo "Updating $agtitle"

     else

      comments="$agtitle - $appname - $fac - $bo"

      result="$(curl -u $qualys_user:$qualys_pass -s -k -H "X-Requested-With: Browser" -D $script_dir/headers.15 -d "action=edit&title=$agtitle&scanner_appliances=$appliances&default_scanner_appliance=$default_appl&cvss_enviro_cdp=$cdp&cvss_enviro_td=$td&cvss_enviro_cr=$cr&cvss_enviro_ir=$ir&cvss_enviro_ar=$ar&comments=$comments&location=$fac&add_host_ips=$ips" "https://qualysapi.qualys.com/msp/asset_group.php" | grep -i status)"

      echo "$result"

      echo "Updating $agtitle"

      echo "$ips"

     fi

done < <(strings $file2)

exit 0

Attachments

    Outcomes