|
| 1 | +# Data Safe Audit Database to OCI Logging |
| 2 | + |
| 3 | +Owner: Fabrizio Zarri |
| 4 | + |
| 5 | +Oracle Data Safe is a fully-integrated, regional Cloud service focused on data security. It provides a complete and integrated set of features of the Oracle Cloud Infrastructure (OCI) for protecting sensitive and regulated data in Oracle databases. |
| 6 | + |
| 7 | +Oracle Data Safe delivers essential security services for Oracle Autonomous Database, Exadata Database on Dedicated Infrastructure, Oracle Base Database and Oracle Databases running in OCI. Data Safe also supports on-premises Oracle Databases, Exadata Database on Cloud@Customer, and multicloud deployments. All Oracle Database customers can reduce the risk of a data breach and simplify compliance by using Data Safe to assess configuration and user risk, monitor and audit user activity, and discover, classify, and mask sensitive data. |
| 8 | + |
| 9 | +Oracle Functions is a serverless, highly scalable, fully managed Functions-as-a-Service platform built on Oracle Cloud Infrastructure and powered by the open-source Fn Project engine. Developers can use Oracle Functions to write and deploy code that delivers business value without worrying about provisioning or managing the underlying infrastructure. Oracle Functions is container-native, with functions packaged as Docker container images. |
| 10 | + |
| 11 | +This Reference Architecture describes OCI Logging based solution for collecting Oracle Datasafe Oracle DB Audit Logs for continuous monitoring and troubleshooting. An OCI Function pulls audit logs from Data Safe REST API Endpoints regularly and ingest them in OCI Logging. |
| 12 | +From OCI Logging Data Safe DB Audit Logs, can be send to OCI Logging Analytics, external SIEM and OCI Object Storage. See [Design Guidance for SIEM Integration](https://docs.oracle.com/en-us/iaas/Content/cloud-adoption-framework/siem-integration.htm) |
| 13 | + |
| 14 | +## Prerequisites |
| 15 | + |
| 16 | +- Configure Data Safe to get Database Audit Events from Oracle DataBase. |
| 17 | + |
| 18 | +- Configure OCI Registry username (your OCI username) and OCI Registry user password (your OCI user authtoken), See [Generating an Auth Token to Enable Login to Oracle Cloud Infrastructure Registry](https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsgenerateauthtokens.htm) |
| 19 | + |
| 20 | +- Create and/or Check IAM Policies to permit Oracle Cloud Infrastructure Registry username to push function image in OCI Registry. See [Policies to Control Repository Access](https://docs.oracle.com/en-us/iaas/Content/Registry/Concepts/registrypolicyrepoaccess.htm) |
| 21 | + |
| 22 | +- Permission to `manage` the following types of resources in your Oracle Cloud Infrastructure tenancy: `IAM policies`, `Dynamic Group`, `vcns`, `services-gateways`, `route-tables`, `security-lists`, `subnets`, `functions`, `Monitor Alarms`, and `Notifications`. |
| 23 | + |
| 24 | +- Quota to create the following resources: 1 VCN, 1 subnets, 1 Service Gateway, 1 route rule, 1 function, 1 dynamic group, 1 policy in root compartment, 1 Monitor Alarm, and 1 Notification Subscription. |
| 25 | + |
| 26 | +If you don't have the required permissions and quota, contact your tenancy administrator. See [Policy Reference](https://docs.cloud.oracle.com/en-us/iaas/Content/Identity/Reference/policyreference.htm), [Service Limits](https://docs.cloud.oracle.com/en-us/iaas/Content/General/Concepts/servicelimits.htm), [Compartment Quotas](https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcequotas.htm). |
| 27 | + |
| 28 | +## Deploy Using Oracle Resource Manager |
| 29 | + |
| 30 | +1. Click [](https://cloud.oracle.com/resourcemanager/stacks/create?region=home&zipUrl=https://github.com/oracle-devrel/technology-engineering/releases/download/fn-datasafe-to-oci-logging/fn-datasafe-dbaudit-to-oci-logging.zip) |
| 31 | + |
| 32 | +2. If you aren't already signed in, when prompted, enter the tenancy and user credentials. |
| 33 | + |
| 34 | +3. Review and accept the terms and conditions. |
| 35 | + |
| 36 | +4. Select the region where you want to deploy the stack. |
| 37 | + |
| 38 | +5. Follow the on-screen prompts and instructions to create the stack. |
| 39 | + |
| 40 | +6. After creating the stack, click **Terraform Actions**, and select **Plan**. |
| 41 | + |
| 42 | +7. Wait for the job to be completed, and review the plan. |
| 43 | + |
| 44 | +8. To make any changes, return to the Stack Details page, click **Edit Stack**, and make the required changes. Then, run the **Plan** action again. |
| 45 | + |
| 46 | +9. If no further changes are necessary, return to the Stack Details page, click **Terraform Actions**, and select **Apply**. |
| 47 | + |
| 48 | +## Deploy Using the Terraform CLI |
| 49 | + |
| 50 | +### Clone the Module |
| 51 | +Now, you'll want a local copy of this repo. You can make that with the commands: |
| 52 | + |
| 53 | + git clone https://github.com/oracle-devrel/technology-engineering.git |
| 54 | + cd security/security-design/fn-datasafe-dbaudit-to-oci-logging |
| 55 | + ls |
| 56 | + |
| 57 | +### Prerequisites |
| 58 | +First off, you'll need to do some pre-deploy setup for Docker and Fn Project inside your machine: |
| 59 | + |
| 60 | +``` |
| 61 | +sudo su - |
| 62 | +yum update |
| 63 | +yum install yum-utils |
| 64 | +yum-config-manager --enable *addons |
| 65 | +yum install docker-engine |
| 66 | +groupadd docker |
| 67 | +service docker restart |
| 68 | +usermod -a -G docker opc |
| 69 | +chmod 666 /var/run/docker.sock |
| 70 | +exit |
| 71 | +curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh |
| 72 | +exit |
| 73 | +``` |
| 74 | + |
| 75 | +OR |
| 76 | + |
| 77 | +you'll use [Oracle Linux Cloud Developer Image](https://docs.oracle.com/en-us/iaas/oracle-linux/developer/index.htm). The Oracle Linux Cloud Developer image provides the latest development tools, languages, and Oracle Cloud Infrastructure Software Development Kits (SDKs) to rapidly deploy, that include Podman instead of Docker. |
| 78 | +The Oracle Linux Cloud Developer image don't include Fn Project but it easy to setup: |
| 79 | + |
| 80 | +``` |
| 81 | +curl -LSs https://raw.githubusercontent.com/fnproject/cli/master/install | sh |
| 82 | +``` |
| 83 | + |
| 84 | +Also, please follow this [note](https://docs.oracle.com/en-us/iaas/Content/Functions/Tasks/functionsinstalldocker.htm#Install_Docker_for_Use_with_Oracle_Functions__section_podman_instead_of_docker). By default, Fn Project (and by extension, OCI Functions) assumes the use of Docker to build and deploy function images. However, Fn Project also supports Podman as an alternative to Docker. When using Fn Project CLI version 0.6.12 and above, you can set a configuration setting to specify that you want to use Podman instead of Docker. |
| 85 | + |
| 86 | + |
| 87 | +### Set Up and Configure Terraform |
| 88 | + |
| 89 | +1. Complete the prerequisites described [here](https://github.com/cloud-partners/oci-prerequisites). |
| 90 | + |
| 91 | +2. Create a `terraform.tfvars` file, and specify the following variables: |
| 92 | + |
| 93 | +``` |
| 94 | +# Authentication |
| 95 | +tenancy_ocid = "<tenancy_ocid>" |
| 96 | +user_ocid = "<user_ocid>" |
| 97 | +fingerprint = "<finger_print>" |
| 98 | +private_key_path = "<pem_private_key_path>" |
| 99 | +
|
| 100 | +# #OCI Region Identifier (see: https://docs.oracle.com/en-us/iaas/Content/General/Concepts/regions.htm) |
| 101 | +region = "<oci_region>" |
| 102 | +
|
| 103 | +# Compartment |
| 104 | +compartment_ocid = "<compartment_ocid>" |
| 105 | +
|
| 106 | +# OCIR |
| 107 | +ocir_user_name = "<ocir_user_name>" <- OCI Registry username (your OCI username) |
| 108 | +ocir_user_password = "<ocir_user_password>" <- OCI Registry user password (your OCI user authtoken) |
| 109 | +
|
| 110 | +# Deployment name is used in resource names |
| 111 | +deployment_name="<deployment name>" |
| 112 | +
|
| 113 | +``` |
| 114 | + |
| 115 | +Please note that the `terraform.tfvars` file will include sensitive information and needs to be protected from unauthorized usage. |
| 116 | + |
| 117 | +### Create the Resources |
| 118 | +Run the following commands: |
| 119 | + |
| 120 | + terraform init |
| 121 | + terraform plan |
| 122 | + terraform apply |
| 123 | + |
| 124 | +### Test the stack |
| 125 | + |
| 126 | +You can test the stack by login/logout in the DB already integrated with Data Safe that generates DB audit log. The function will load the logs in 1 minutes and you can see it in Logging Console. |
| 127 | +In Logging Console will be present a new Log Group (ex. loggr-test-eu-milan-1-fn_ds_to_ol-d54e) and relative 2 logs: |
| 128 | +- Log with data from Data Safe: Log Type Custom (example log name: log-test-eu-milan-1-fn_ds_to_ol-d54e) |
| 129 | +- Log execution function: Log Type Service (example log name: fn-datasafe-dbaudit-test-eu-milan-1-fn_ds_to_ol-d54e) |
| 130 | + |
| 131 | +### Destroy the Deployment |
| 132 | +When you no longer need the deployment, you can run this command to destroy the resources: |
| 133 | + |
| 134 | + terraform destroy |
| 135 | + |
| 136 | +If there is error in destroying the object storage bucket, manually delete the bucket and run "terraform destroy" again. |
| 137 | + |
| 138 | +### Test Environment |
| 139 | +We tested the terraform script in [Oracle Linux Cloud Developer Image](https://docs.oracle.com/en-us/iaas/oracle-linux/developer/index.htm) and Oracle Resource Manager. |
| 140 | + |
| 141 | +### Architecture Diagram |
| 142 | + |
| 143 | + |
| 144 | +## License |
| 145 | +Copyright (c) 2023 Oracle and/or its affiliates. |
| 146 | + |
| 147 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 148 | + |
| 149 | +See [LICENSE](LICENSE) for more details. |
| 150 | + |
| 151 | +ORACLE AND ITS AFFILIATES DO NOT PROVIDE ANY WARRANTY WHATSOEVER, EXPRESS OR IMPLIED, FOR ANY SOFTWARE, MATERIAL OR CONTENT OF ANY KIND CONTAINED OR PRODUCED WITHIN THIS REPOSITORY, AND IN PARTICULAR SPECIFICALLY DISCLAIM ANY AND ALL IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. FURTHERMORE, ORACLE AND ITS AFFILIATES DO NOT REPRESENT THAT ANY CUSTOMARY SECURITY REVIEW HAS BEEN PERFORMED WITH RESPECT TO ANY SOFTWARE, MATERIAL OR CONTENT CONTAINED OR PRODUCED WITHIN THIS REPOSITORY. IN ADDITION, AND WITHOUT LIMITING THE FOREGOING, THIRD PARTIES MAY HAVE POSTED SOFTWARE, MATERIAL OR CONTENT TO THIS REPOSITORY WITHOUT ANY REVIEW. USE AT YOUR OWN RISK. |
0 commit comments