Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for OpenCTI 5.3.10 (rabbitmq, grakn/typedb, connectors, redis, and platform) #30

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
8bb3ebe
Update with newer cred file specification
ckane Jun 27, 2022
67c50e7
Update to use TypeDB rather than Grakn
ckane Jun 27, 2022
bd6fd8e
Update rabbitmq version and repositories
ckane Jun 27, 2022
9602e13
Update to latest OpenCTI+connectors (5.3.7)
ckane Jun 27, 2022
003cf5c
Update redis to 7.0.2
ckane Jun 27, 2022
c4a68a7
Update rabbitmq to 3.10.5-1 (latest)
ckane Jun 28, 2022
b832bdd
Update TypeDB to 2.11.1
ckane Jun 28, 2022
0c510bd
Extend redis startup timeout to 30s to give it time to start
ckane Jun 30, 2022
45c40f2
Adjust service startup timeout limits
ckane Jul 2, 2022
12219d2
Check for connector main script named "main.py", and use it if it exists
ckane Jul 2, 2022
52f6094
Allow more time for redis to start before timeout
ckane Jul 2, 2022
bc93c88
Add valhalla module
ckane Jul 7, 2022
081b06a
Support Ubuntu 22.04 LTS
ckane Sep 7, 2022
b7df919
Fix the installation of TypeDB, which breaks with typedb-all now
ckane Sep 7, 2022
6f1000d
Update to OpenCTI 5.3.10
ckane Sep 7, 2022
dc01b8a
Install latest elasticsearch 8.x
ckane Sep 7, 2022
2e742fa
Check machine arch for correct minio download
ckane Sep 7, 2022
f348209
Pass the ${storage_bucket} variable down to the sub-scripts
ckane Sep 8, 2022
17bea66
Use S3 instead of Minio for blob storage
ckane Sep 8, 2022
df8304c
Bump to 5.3.12
ckane Sep 11, 2022
11598ce
Update to 5.3.16
ckane Oct 4, 2022
f53f30e
Update to 5.3.17 and update redis to latest as well
ckane Oct 9, 2022
3c6c2cd
Update for newer terraform s3 code
ckane Oct 9, 2022
db7b045
Use gp3 by default, it is faster and cheaper than gp2
ckane Oct 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
provider "aws" {
region = var.region
shared_credentials_file = "~/.aws/credentials"
shared_credentials_files = ["$HOME/.aws/credentials"]
profile = "default"
}

Expand Down
20 changes: 13 additions & 7 deletions aws/storage.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# S3 bucket to store install and connectors scripts.
resource "aws_s3_bucket" "opencti_bucket" {
bucket = var.storage_bucket
acl = "private"
}

# Turn on bucket versioning. We'll be storing the Terraform state in S3 and versioning will help protect against human error.
versioning {
enabled = true
}
resource "aws_s3_bucket_versioning" "opencti_bucket_versioning" {
bucket = aws_s3_bucket.opencti_bucket.id
versioning_configuration {
status = "Enabled"
}
}

resource "aws_s3_bucket_acl" "opencti_bucket_acl" {
bucket = aws_s3_bucket.opencti_bucket.id
acl = "private"
}

# S3 IAM (I don't think any of these permissions are being used)
Expand Down Expand Up @@ -34,14 +40,14 @@ resource "aws_iam_role_policy_attachment" "opencti_s3_attach" {
}

# OpenCTI installer script
resource "aws_s3_bucket_object" "opencti-install-script" {
resource "aws_s3_object" "opencti-install-script" {
bucket = aws_s3_bucket.opencti_bucket.id
key = "opencti-installer.sh"
source = "../opencti_scripts/installer.sh"
}

# OpenCTI connectors script
resource "aws_s3_bucket_object" "opencti-connectors-script" {
resource "aws_s3_object" "opencti-connectors-script" {
bucket = aws_s3_bucket.opencti_bucket.id
key = "opencti-connectors.sh"
source = "../opencti_scripts/connectors.sh"
Expand Down
3 changes: 3 additions & 0 deletions aws/vm.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ resource "aws_instance" "opencti_instance" {
iam_instance_profile = aws_iam_instance_profile.opencti_profile.name
root_block_device {
volume_size = var.root_volume_size
volume_type = "gp3"
iops = 3000
throughput = 125
}
subnet_id = var.subnet_id

Expand Down
75 changes: 47 additions & 28 deletions opencti_scripts/connectors.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ if [[ ${ubuntu_version} == 18 ]]
then
python_ver="3.7"
elif [[ ${ubuntu_version} == 20 ]]
then
# Using bionic since focal not avaialble yet for RabbitMQ
python_ver="3"
elif [[ ${ubuntu_version} == 22 ]]
then
# Using bionic since focal not avaialble yet for RabbitMQ
python_ver="3"
Expand All @@ -140,26 +144,26 @@ warn_user
# This will only set up your instance for the connectors enabled. You must supply an API token (e.g., alienvault token) and enable the service.
# It should be safe to run this after changing configs or enabling services.
declare -A CONNECTORS;
CONNECTORS['alienvault']=0
CONNECTORS['amitt']=0
CONNECTORS['crowdstrike']=0
CONNECTORS['cryptolaemus']=0
CONNECTORS['cve']=1
CONNECTORS['cyber-threat-coalition']=0
CONNECTORS['cybercrime-tracker']=0
CONNECTORS['export-file-csv']=1
CONNECTORS['export-file-stix']=1
CONNECTORS['hygiene']=0
CONNECTORS['import-file-pdf-observables']=1
CONNECTORS['import-file-stix']=1
CONNECTORS['ipinfo']=0
CONNECTORS['lastinfosec']=0
CONNECTORS['malpedia']=0
CONNECTORS['misp']=1
CONNECTORS['mitre']=1
CONNECTORS['opencti']=1
CONNECTORS['valhalla']=0
CONNECTORS['virustotal']=1
CONNECTORS['external-import/alienvault']=0
CONNECTORS['external-import/amitt']=0
CONNECTORS['external-import/crowdstrike']=0
CONNECTORS['external-import/cryptolaemus']=0
CONNECTORS['external-import/cve']=1
CONNECTORS['external-import/cyber-threat-coalition']=0
CONNECTORS['external-import/cybercrime-tracker']=0
CONNECTORS['internal-export-file/export-file-csv']=1
CONNECTORS['internal-export-file/export-file-stix']=1
CONNECTORS['internal-enrichment/hygiene']=0
CONNECTORS['internal-import-file/import-document']=1
CONNECTORS['internal-import-file/import-file-stix']=1
CONNECTORS['internal-enrichment/ipinfo']=0
CONNECTORS['external-import/lastinfosec']=0
CONNECTORS['external-import/malpedia']=0
CONNECTORS['external-import/misp']=1
CONNECTORS['external-import/mitre']=1
CONNECTORS['external-import/opencti']=1
CONNECTORS['external-import/valhalla']=1
CONNECTORS['internal-enrichment/virustotal']=1

echo "The following connectors will be installed:"
for i in "${!CONNECTORS[@]}"
Expand Down Expand Up @@ -200,16 +204,31 @@ do
sed -i"" -e "s/id: 'ChangeMe'/id: '$(uuidgen -r | tr -d '\n' | tr '[:upper:]' '[:lower:]')'/g" "${opencti_connector_dir}/$i/src/config.yml"
fi

if [[ ! -f "/etc/systemd/system/opencti-connector-$i.service" ]]
sbasename=$(basename "$i")
scriptname="$sbasename"

# Some of the services use the service name as the main Python script name, while
# others have started using "main.py". This check attempts to discover which the
# service in question is using, and adapts to it, falling back on the old behavior
if [[ -f "${opencti_connector_dir}/$i/src/main.py" ]]; then
scriptname="main"
fi

if [[ ! -f "/etc/systemd/system/opencti-connector-$sbasename.service" ]]
then
cat > /etc/systemd/system/opencti-connector-$i.service <<- EOT
cat > /etc/systemd/system/opencti-connector-$sbasename.service <<- EOT
[Unit]
Description=OpenCTI Connector - $i
After=network.target
StartLimitBurst=30
StartLimitInterval=0

[Service]
RestartSec=20
TimeoutStartSec=600
Type=simple
WorkingDirectory=${opencti_connector_dir}/$i/src
ExecStart=/usr/bin/python${python_ver} "${opencti_connector_dir}/$i/src/$i.py"
ExecStart=/usr/bin/python${python_ver} "${opencti_connector_dir}/$i/src/$scriptname.py"
ExecReload=/bin/kill -s HUP \$MAINPID
ExecStop=/bin/kill -s TERM \$MAINPID
PrivateTmp=true
Expand All @@ -219,16 +238,16 @@ WantedBy=multi-user.target
EOT

systemctl daemon-reload
systemctl start opencti-connector-$i.service
systemctl start opencti-connector-$sbasename.service
fi

if [[ $(systemctl status --no-pager opencti-connector-$i.service | grep 'Active: active') ]]
if [[ $(systemctl status --no-pager opencti-connector-$sbasename.service | grep 'Active: active') ]]
then
echo "opencti-connector-$i.service is already running, restarting due to config changes"
systemctl restart opencti-connector-$i.service
echo "opencti-connector-$sbasename.service is already running, restarting due to config changes"
systemctl restart opencti-connector-$sbasename.service
fi

quit_on_error "Installing service for connector: $i"
quit_on_error "Installing service for connector: $sbasename"
fi
done

Expand Down
Loading