Qualys-IaC-Security
The qiac is a command line interface to scan Infrastructure-as-Code templates using Qualys CloudView (Cloud Security Assessment).
Description
The Qualys IaC app provides a quick yet reliable way to assess your Infrastructure-as-a-Code templates and uncover potential vulnerable situations. The qiac provides you an interface to interact with Qualys IaC module in a simple way.
This command line interface (CLI) provides following commands.
| Command Name | Feature | Description | Since Version |
|---|---|---|---|
| scan | Launch an IaC scan | You can scan one or more templates in a single command. This runs a job on Qualys cloud platform. | 1.0.0b2 |
| listscans | Get list of all IaC scans | Once you launch a scan, you can view list of all scans or a specific scan. | 1.0.0b2 |
| getresult | Get the IaC scan result | Once a scan is completed, you can download the scan result for your review. | 1.0.0b2 |
| config | Configure IaC CLI | You can configure user's credentials using this command. | 1.0.0b3 |
Installation
Prerequisite
You need to fulfill the following requirements to use this CLI tool.
- Python 3
- If your environment uses Windows OS and Python version 3.10 or greater, then you must have Microsoft Visual C++ version 14.0 or greater version installed.
- A valid Qualys subscription with access to
- CloudView (Cloud Security Assessment)
- The Qualys API
Command to install
You can install the qiac CLI from PyPI. Run the following command to install.
pip install Qualys-IaC-Security
How to use
See the supported options
You can use the --help option to get a list of supported options and their explanation.
Usage: qiac [OPTIONS] COMMAND [ARGS]...
Options:
-v, --version Show the version and exit.
-h, --help Show this message and exit.
Commands:
config Configure IaC CLI credentials.
getresult Gets the scan result.
listscans List all the scans.
scan Triggers/Launches the IaC scan.
Configure IaC CLI (optional command)
Use this command to configure user's credentials. This command is optional and should be used only when a user would like to store Qualys credentials in flat file for subsequent uses. Once this file is correctly configured, the user need not provide the Qualys platform, Qualys username/client Id, and Qualys password/client secret details for every CLI command. The authentication details are picked from the configuration file. Below command collects Qualys credentials from user and stores those to user's home directory (.qiac.yaml)
qiac config -a <Qualys Platform> -u <Qualys username/client Id> -p <Qualys password/client secret> -at <AuthType>
- The parameters: platform, username, and password are mandatory for this command.
config_file (optional): name or path of the config file.
Name: if the name is provided, then a config file with the specified name is created.
Path: if the path is provided, then the config file is created at the specified path with the default name. The default name is .qiac.yaml.
AuthType: supported values arebasicauth,oidc, andidp. If the authType is not provided, thenbasicauthwill be used by default. - This command saves the config file on the user's home directory with the name .qiac.yaml. If a user doesn't want to save the config file in the home directory, the user can use the config_file option to provide the config file path. The config_file option saves the file at the specified path.
IDP (OAuth client_credentials) authentication
When -at idp is used, the CLI authenticates against an external Identity Provider using the OAuth2 client_credentials grant type, then uses the resulting access token to call the Qualys platform. The following additional options apply:
| Option | Full name | Description | Required |
|---|---|---|---|
| -tu | --token_url | Token endpoint URL of the IDP | Yes (for idp auth type) |
| -sc | --scope | OAuth2 scope to request from the IDP token endpoint | No |
| -au | --audience | OAuth2 audience to request from the IDP token endpoint | No |
qiac config -a <Qualys Platform> -u <Client Id> -p <Client Secret> -at idp -tu <Token URL> -sc <Scope>
The access token obtained from the IDP is cached in memory for the duration of a single CLI command (e.g. across all polling calls made during scan) and is only re-fetched once it expires or the platform returns a 401 Unauthorized, avoiding unnecessary token requests on every API call.
OIDC authentication
When -at oidc is used, the CLI authenticates using the Qualys OIDC endpoint. The CLI uses the client ID and client secret to obtain an access token from the Qualys platform's OIDC endpoint, then uses this token for authentication.
qiac config -a <Qualys Platform> -u <Client Id> -p <Client Secret> -at oidc
The access token obtained from the OIDC endpoint is cached in memory for the duration of a single CLI command and is only re-fetched once it expires or the platform returns a 401 Unauthorized, avoiding unnecessary token requests on every API call.
A user can use the config file using below ways:
- Use Config file from user's home.
qiac <commands|params>
- User Config file from user's custom directory.
qiac <commands|params> -c <location of config file>
Commands could be scan, getresults, listscans.
Note: If the user does not provide credentials in command options, then CLI checks for the config file in the current directory. If the config file is not present in the current directory, then CLI checks the user's home directory.
Launch a scan
You can scan one or more file(s) using the following command.
qiac scan -a <Qualys Platform> -u <your Qualys username/client Id> -at <AuthType> -n <name of the scan> -d <path1 to a file or directory> -d <path2 to a file or directory> -d <path3 to a file or directory>...
For -at idp, also pass -tu <Token URL> (required), and optionally -sc <Scope> / -au <Audience>.
- The CLI prompts for your Qualys password/ client secret, only if password is not provided in command.
- When you provide a path to a directory for
-doption, the CLI will ZIP the contents and then upload the ZIP to the Qualys Cloud Platform. - On successful launch of the scan, the CLI output provides a Scan Id and show results in a tabular format.
Note: To scan the template(s), this CLI uploads your file(s) to the Qualys Cloud Platform.
Get the list of all scans
You can get list of scans using the following command. If you want to get the scan details for a specific scan, provide the IaC scan Id obtained from the launch scan output.
qiac listscans -a <Qualys Platform> -u <your Qualys username/client Id> -i <Scan Id> -at <AuthType>
- This will fetch list of all IaC scan and its details and print it in tabular format on the terminal.
Get the scan result
Once you see that the scan status is FINISHED or ERROR, you can use the following command to get the IaC scan result.
qiac getresult -a <Qualys Platform> -u <your Qualys username/client Id> -i <Scan Id> -at <AuthType>
- This will download the scan result and print it in tabular format on the terminal.
Documentation
For more information you can refer Secure Infrastructure as Code section in this user guide: https://www.qualys.com/docs/qualys-cloud-view-user-guide.pdf
Support
If you have any questions, please contact Qualys Support team at support@qualys.com
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qualys_iac_security-1.0.9.0-py3-none-any.whl.
File metadata
- Download URL: qualys_iac_security-1.0.9.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1949e665d77a5814f0a94b81132598b174173722948493b9644195b05765640
|
|
| MD5 |
b933e0d02687f56aaa9b335c64bc170f
|
|
| BLAKE2b-256 |
a119ee8e8a8cd72d1955237961ed97b6278102b002fd0389994cead92e4a6414
|