Triage and Remediation
Remediation
Using Console
Using Console
To remediate the Oracle Port Should Not Be Open misconfiguration for GCP using GCP console, follow these steps:
- Log in to the GCP console (https://console.cloud.google.com/).
- Select the project that contains the affected resource.
- In the navigation menu on the left-hand side, click on “Compute Engine” and then select “VM instances”.
- Locate the instance that has the open Oracle port and click on its name to open its details page.
- Click on the “Edit” button at the top of the page to edit the instance settings.
- Scroll down to the “Firewall” section and click on “Management, security, disks, networking, sole tenancy”.
- Under the “Firewall” section, click on “Network interfaces”.
- Click on “default” to expand the network interface settings.
- In the “Firewall rules” section, locate the rule that allows traffic on the Oracle port (default is 1521).
- Click on the trashcan icon next to the rule to delete it.
- Click on the “Save” button at the bottom of the page to save the changes.
- Verify that the Oracle port is no longer open by running a port scan or checking the instance’s firewall rules.
Using CLI
Using CLI
To remediate the misconfiguration “Oracle Port Should Not Be Open” for GCP using GCP CLI, follow the below steps:Replace [FIREWALL_RULE_NAME] with the name of the firewall rule identified in step 4.The output should not contain the firewall rule that was deleted in step 5.By following these steps, you have successfully remediated the misconfiguration “Oracle Port Should Not Be Open” for GCP using GCP CLI.
- Open the GCP console and navigate to the GCP project where the misconfiguration exists.
- Open the Cloud Shell by clicking on the icon on the top right corner of the console.
- Run the following command to list all the firewall rules in the project:
- Identify the firewall rule that allows access to the Oracle port. Note down the name of the firewall rule.
- Run the following command to delete the firewall rule:
- Confirm the deletion by typing “Y” when prompted.
- Verify that the firewall rule has been deleted by running the following command:
Using Python
Using Python
To remediate the misconfiguration “Oracle Port Should Not Be Open” in GCP using Python, you can follow the below steps:Note: Replace ‘your-project-id’ with the actual ID of your GCP project, and ‘oracle-port’ with the name of the firewall rule that allows traffic to the Oracle port.
- Identify the instances in your GCP project that have the Oracle port open. You can use the GCP Python SDK to get the list of instances and their network configuration.
- For each instance with the Oracle port open, use the GCP Python SDK to update the firewall rule that allows traffic to the Oracle port. You can either delete the rule or modify it to allow traffic only from a specific IP address or range.
- To delete the firewall rule, you can use the following Python code:
- To modify the firewall rule to allow traffic only from a specific IP address or range, you can use the following Python code: