kics
kics copied to clipboard
fix(query): added case handling for "destination_port_ranges" field for rdp/ssh_is_exposed_to_the_internet -- terraform/azure
Reason for Proposed Changes
- Currently the "rdp_is_exposed_to_the_internet" and "ssh_is_exposed_to_the_internet" queries lack support for the "destination_port_ranges" field of the relevant resources :
azurerm_network_security_ruleandazurerm_network_security_group; they only support the "destination_port_range" field which serves the same purpose. - The difference between the two fields is the fact that "destination_port_ranges" comes in the form of an array of string values that each represent a "destination_port_range", so new case handling must be added to the queries to support both fields.
Proposed Changes
- Updated the queries results and auxiliary functions to properly detect and handle the two relevant fields.
- Added positive2/negative2 test files to both queries that contain samples relying on the "destination_port_ranges" field. The original test files now named positive1/negative1 will keep all samples that use the simple "destination_port_range" field.
- This changes should prevent valid False Negative results when the samples provided rely on the newly supported field.
- Added support for "Udp" protocol to the "rdp_is_exposed_to_the_internet" query since RDP8.0+ allows so; tests were adjusted/added accordingly.
I submit this contribution under the Apache-2.0 license.

KICS version: v2.1.13
|
|
⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.
Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.
🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 21271469 | Triggered | Generic Password | a0baa6e33065485175b27568edb9dc4dd3ce1431 | assets/queries/terraform/azure/unrestricted_sql_server_access/test/negative5.tf | View secret |
| 20838717 | Triggered | Generic Password | ee027eb243c15b979241b083c7fae99c38da3c57 | assets/queries/azureResourceManager/sql_server_database_with_alerts_disabled/test/negative8.bicep | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.






