Skip to content
Permalink
Browse files

Update references to python2 in docs and yml files

  • Loading branch information...
pwnbus committed Jul 1, 2019
1 parent 0e0e92e commit 75e5e7c9abb13ae833fd2dff139489ad281adf10
@@ -23,7 +23,7 @@ Resources:
S3Bucket: public.us-west-2.security.allizom.org
S3Key: mozdef-lambda-layer/layer-latest.zip
CompatibleRuntimes:
- python2.7
- python3.6
LicenseInfo: 'MPL 2.0'
LambdalertIAMRole:
Type: AWS::IAM::Role
@@ -36,16 +36,16 @@ Resources:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
AlertWritersEnv:
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
AlertWritersEnv:
Type: "AWS::Lambda::Function"
Properties:
Properties:
Handler: "lambdalert.handle"
Role:
Fn::GetAtt:
Role:
Fn::GetAtt:
- "LambdalertIAMRole"
- "Arn"
Code:
Code:
S3Bucket: public.us-west-2.security.allizom.org
S3Key: mozdef-lambda-layer/function-latest.zip
Layers:
@@ -55,9 +55,9 @@ Resources:
OPTIONS_ESSERVERS: !Ref ESUrl
OPTIONS_MQPROTOCOL: sqs
VpcConfig:
SecurityGroupIds:
SecurityGroupIds:
- !Ref MozDefSecurityGroup
SubnetIds: !Ref PublicSubnetIds
ReservedConcurrentExecutions: 1
Runtime: "python2.7"
Runtime: "python3.6"
Timeout: 120
@@ -23,7 +23,7 @@ Resources:
S3Bucket: public.us-west-2.security.allizom.org
S3Key: mozdef-lambda-layer/layer-latest.zip
CompatibleRuntimes:
- python2.7
- python3.6
LicenseInfo: 'MPL 2.0'
LambdalertIAMRole:
Type: AWS::IAM::Role
@@ -36,16 +36,16 @@ Resources:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
AlertWritersEnv:
- arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole
AlertWritersEnv:
Type: "AWS::Lambda::Function"
Properties:
Properties:
Handler: "lambdalert.handle"
Role:
Fn::GetAtt:
Role:
Fn::GetAtt:
- "LambdalertIAMRole"
- "Arn"
Code:
Code:
S3Bucket: public.us-west-2.security.allizom.org
S3Key: mozdef-lambda-layer/function-latest.zip
Layers:
@@ -55,9 +55,9 @@ Resources:
OPTIONS_ESSERVERS: !Ref ESUrl
OPTIONS_MQPROTOCOL: sqs
VpcConfig:
SecurityGroupIds:
SecurityGroupIds:
- !Ref MozDefSecurityGroup
SubnetIds: !Ref PublicSubnetIds
ReservedConcurrentExecutions: 1
Runtime: "python2.7"
Runtime: "python3.6"
Timeout: 120
@@ -13,7 +13,7 @@ clean:
rm -rf $(ROOT_DIR)/build/*

.PHONY: deploy-shell
deploy-shell:
deploy-shell:
docker run -ti -v ~/.aws:/root/.aws -v ${PWD}:/var/task mozdef/mozdef_base:latest

.PHONY: package-layer
@@ -34,13 +34,13 @@ package-function: clean
zip -r /var/task/cloudy_mozdef/lambda_layer/function-latest.zip ."

.PHONY: upload-s3
upload-s3:
upload-s3:
aws s3 cp ${PWD}/cloudy_mozdef/lambda_layer/layer-latest.zip s3://public.us-west-2.security.allizom.org/mozdef-lambda-layer/layer-latest.zip
aws s3 cp ${PWD}/cloudy_mozdef/lambda_layer/function-latest.zip s3://public.us-west-2.security.allizom.org/mozdef-lambda-layer/function-latest.zip

.PHONY: publish-layer
publish-layer: upload-s3
aws lambda publish-layer-version \
--layer-name mozdef --compatible-runtimes python2.7 \
--layer-name mozdef --compatible-runtimes python3.6 \
--content S3Bucket=public.us-west-2.security.allizom.org,S3Key=mozdef-lambda-layer/layer-latest.zip

@@ -66,7 +66,7 @@ Create a mozdef user::
chown mozdef: .bash*
chown -R mozdef: *

We need to install a python2.7 virtualenv.
We need to install a python3.6 virtualenv.

On Yum-based systems::

@@ -79,23 +79,23 @@ On APT-based systems::
Then::

sudo -i -u mozdef -g mozdef
mkdir /opt/mozdef/python2.7
wget https://www.python.org/ftp/python/2.7.11/Python-2.7.11.tgz
tar xvzf Python-2.7.11.tgz
cd Python-2.7.11
./configure --prefix=/opt/mozdef/python2.7 --enable-shared LDFLAGS="-Wl,--rpath=/opt/mozdef/python2.7/lib"
mkdir /opt/mozdef/python3.6
wget https://www.python.org/ftp/python/3.6.9/Python-3.6.9.tgz
tar xvzf Python-3.6.9.tgz
cd Python-3.6.9
./configure --prefix=/opt/mozdef/python3.6 --enable-shared LDFLAGS="-Wl,--rpath=/opt/mozdef/python3.6/lib"
make
make install

cd /opt/mozdef

wget https://bootstrap.pypa.io/get-pip.py
export LD_LIBRARY_PATH=/opt/mozdef/python2.7/lib/
./python2.7/bin/python get-pip.py
./python2.7/bin/pip install virtualenv
export LD_LIBRARY_PATH=/opt/mozdef/python3.6/lib/
./python3.6/bin/python get-pip.py
./python3.6/bin/pip install virtualenv
mkdir ~/envs
cd ~/envs
~/python2.7/bin/virtualenv python
~/python3.6/bin/virtualenv python
source python/bin/activate
pip install -r ../requirements.txt

@@ -109,9 +109,9 @@ Copy the following into a file called .bash_profile for the mozdef user within /

export PATH

At this point when you launch python from within your virtual environment, It should tell you that you're using Python 2.7.11.
At this point when you launch python from within your virtual environment, It should tell you that you're using Python 3.6.9.

Whenever you launch a python script from now on, you should have your mozdef virtualenv active and your LD_LIBRARY_PATH env variable should include /opt/mozdef/python2.7/lib/ automatically.
Whenever you launch a python script from now on, you should have your mozdef virtualenv active and your LD_LIBRARY_PATH env variable should include /opt/mozdef/python3.6/lib/ automatically.

RabbitMQ
********
@@ -330,8 +330,8 @@ We use `uwsgi`_ to interface python and nginx, in your venv execute the followin
wget https://projects.unbit.it/downloads/uwsgi-2.0.17.1.tar.gz
tar zxvf uwsgi-2.0.17.1.tar.gz
cd uwsgi-2.0.17.1
~/python2.7/bin/python uwsgiconfig.py --build
~/python2.7/bin/python uwsgiconfig.py --plugin plugins/python core
~/python3.6/bin/python uwsgiconfig.py --build
~/python3.6/bin/python uwsgiconfig.py --plugin plugins/python core
cp python_plugin.so ~/envs/python/bin/
cp uwsgi ~/envs/python/bin/

@@ -136,9 +136,9 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 2",
"display_name": "Python 3",
"language": "python",
"name": "python2"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
@@ -149,8 +149,8 @@
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.5"
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,

0 comments on commit 75e5e7c

Please sign in to comment.
You can’t perform that action at this time.