Skip to content

Commit 4e5d929

Browse files
authored
Merge pull request #169 from oracle-devrel/fn-datasafe-auditdb-to-oci-logging
First Release
2 parents 738e633 + 10f1130 commit 4e5d929

28 files changed

+1594
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2021 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
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 [![Deploy to Oracle Cloud](https://oci-resourcemanager-plugin.plugins.oci.oraclecloud.com/latest/deploy-to-oracle-cloud.svg)](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+
![](./images/DatasafetoOCILoggingArchitecture.jpg)
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.
52.3 KB
Loading
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
###############################################################################
2+
# Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
3+
# This software is dual-licensed to you under the Universal Permissive License
4+
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
###############################################################################
6+
#
7+
# Author: Fabrizio Zarri
8+
#
9+
################################################################################
10+
11+
data "oci_objectstorage_namespace" "bucket_namespace" {
12+
compartment_id = var.compartment_ocid
13+
}
14+
15+
resource "oci_objectstorage_bucket" "tracker-bucket" {
16+
compartment_id = var.compartment_ocid
17+
name = local.tracker_bucket_name
18+
namespace = data.oci_objectstorage_namespace.bucket_namespace.namespace
19+
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
###############################################################################
2+
# Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
3+
# This software is dual-licensed to you under the Universal Permissive License
4+
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
###############################################################################
6+
#
7+
# Author: Fabrizio Zarri
8+
#
9+
################################################################################
10+
11+
# Container Registry Policies
12+
13+
14+
resource "oci_artifacts_container_repository" "fn_container_repository" {
15+
16+
compartment_id = var.compartment_ocid
17+
display_name = local.oci_repo_displayname
18+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
###############################################################################
2+
# Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
3+
# This software is dual-licensed to you under the Universal Permissive License
4+
# (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl.
5+
###############################################################################
6+
#
7+
# Author: Fabrizio Zarri
8+
#
9+
################################################################################
10+
11+
data "oci_identity_region_subscriptions" "home_region_subscriptions" {
12+
tenancy_id = var.tenancy_ocid
13+
14+
filter {
15+
name = "is_home_region"
16+
values = [true]
17+
}
18+
}
19+
20+
data "oci_identity_regions" "oci_regions" {
21+
22+
filter {
23+
name = "name"
24+
values = [var.region]
25+
}
26+
27+
}
28+
29+
data "oci_identity_tenancy" "oci_tenancy" {
30+
tenancy_id = var.tenancy_ocid
31+
}
32+
33+
data "oci_objectstorage_namespace" "namespace" {
34+
compartment_id = var.tenancy_ocid
35+
}
36+
37+
data "oci_identity_compartment" "compartment" {
38+
id = var.compartment_ocid
39+
}
40+

0 commit comments

Comments
 (0)