Managing Dependencies and Runtime Security ActiveState Deminar - - PowerPoint PPT Presentation

managing dependencies and runtime security
SMART_READER_LITE
LIVE PREVIEW

Managing Dependencies and Runtime Security ActiveState Deminar - - PowerPoint PPT Presentation

Managing Dependencies and Runtime Security ActiveState Deminar Managing Dependencies and Runtime Security About ActiveState Track-record: 97% of Fortune 1000, 20+ years open source Polyglot: 5 languages - Python, Perl, Tcl, Go, Ruby


slide-1
SLIDE 1

Managing Dependencies and Runtime Security

ActiveState Deminar

slide-2
SLIDE 2

About ActiveState

Managing Dependencies and Runtime Security

  • Track-record: 97% of Fortune 1000, 20+ years open source
  • Polyglot: 5 languages - Python, Perl, Tcl, Go, Ruby
  • Runtime Focus: concept to development to production
slide-3
SLIDE 3

Welcome

Managing Dependencies and Runtime Security

Pete Garcin, Developer Advocate, ActiveState (@rawktron)

slide-4
SLIDE 4

Overview

Managing Dependencies and Runtime Security

  • Managing Project Dependencies

○ Pip/requirements ○ ActivePython

  • Virtual Environments

○ PipEnv

  • Runtime Security
  • Q&A
slide-5
SLIDE 5

Configuring Dev Environment

Managing Dependencies and Runtime Security

git clone https://github.com/ActiveState/activedeminar

slide-6
SLIDE 6

Your dependency tree:

Managing Dependencies and Runtime Security

slide-7
SLIDE 7

Managing Deps

Managing Dependencies and Runtime Security

  • Vendored Deps

○ Advantages: guaranteed security, compatibility, stability, availability ○ Disadvantages: larger repo, you have to manually maintain - could be out of date, conflicts with system installs

slide-8
SLIDE 8

Managing Deps

Managing Dependencies and Runtime Security

  • Requirements.txt/Pipfile

○ Have to ‘install’ and build from a repo BUT you don’t have to maintain the code and ship it yourself ○ You need to pin versions to prevent bleeding edge ○ Use a virtualenv for isolation

slide-9
SLIDE 9

Managing Deps

Managing Dependencies and Runtime Security

  • Pre-built distributions

○ No discipline approach ○ Most popular packages already pre-built, tested, and included in your distro, quarterly updates ○ As the standard install across a large org or team can work well ○ Not updated frequently ○ Not customized to your needs ○ Overall may not fit your use case

slide-10
SLIDE 10

Vendoring Deps in Python

Managing Dependencies and Runtime Security

  • Requires a virtualenv to prevent conflicts
  • May involve generating your own wheels for local pip servers
  • Not widely used
  • Higher maintenance overhead
  • Can be good/necessary if you have custom patches
slide-11
SLIDE 11

Creating requirements.txt

Managing Dependencies and Runtime Security

  • Can use “pip freeze” but this gives us everything in our

system environment.

  • Let’s use pipreqs:

○ https://github.com/bndr/pipreqs ○ pip3 install pipreqs ○ pipreqs .

slide-12
SLIDE 12

Pinning Versions

Managing Dependencies and Runtime Security

  • Pinning means forcing a specific version to be installed
  • Why? Reproducible builds.
  • Syntax:

○ Framework==0.9.4 ○ Library>=0.2

slide-13
SLIDE 13

Reproducible Builds

Managing Dependencies and Runtime Security

  • Guarantee the exact same build in two locations
  • Ensure you have the same versions of every package
  • Requires a lockfile, or a “pip freeze”
slide-14
SLIDE 14

Virtual Environments

Managing Dependencies and Runtime Security

  • A Virtual Environment is a self-contained, sandboxed

environment -- just for your app.

  • It only has the packages you specify and they are totally

distinct from the system installed ones.

slide-15
SLIDE 15

Virtual Environments

Managing Dependencies and Runtime Security

  • Complex but critical for app deployment, development.
  • Can use ‘virtualenv’ to create and manage them but there

is a new tool combining pip and virtualenv.

slide-16
SLIDE 16

PipEnv

Managing Dependencies and Runtime Security

  • Enter PipEnv: New “Community Standard” application

combines Pip/virtualenv and extends their functionality in a single app.

  • Let’s install it here:

○ https://github.com/pypa/pipenv pip3 install pipenv

  • You can initialize a clean environment, Python 3:

pipenv -three

slide-17
SLIDE 17

Generating Pipfile

Managing Dependencies and Runtime Security

  • We can generate a pipfile from our

requirements.txt using the following command: pipenv install

HANDY TIP We can generate a virtualenv of ActivePython using: pipenv

  • -python="/home/para

llels/AP36/bin/pytho n3" --site-packages install

slide-18
SLIDE 18

Generating Pipfile

Managing Dependencies and Runtime Security

[[source]] url = "https://pypi.python.org/simple" verify_ssl = true name = "pypi" [packages] numpy = "==1.14.3" tensorflow = "==1.8.0" Flask = "==1.0.1" [dev-packages] [requires] python_version = "3.6"

slide-19
SLIDE 19

Generating Pipfile.lock

Managing Dependencies and Runtime Security

  • Generate a lockfile that contains the fully resolved dep

tree for our project: pipenv lock

  • Required for a deterministic build.
  • Warning: could fail to resolve a dependency conflict!
slide-20
SLIDE 20

Install all Dependencies

Managing Dependencies and Runtime Security

  • Let’s spawn a shell inside our virtualenv:

pipenv shell

  • The “sync” command will install everything in the .lock

file: pipenv sync

slide-21
SLIDE 21

Project Complete

Managing Dependencies and Runtime Security

  • We now have a project that has:

○ A virtualenv created for it distinct from our system install ○ A pipfile that defines all the deps for our project generated from our requirements.txt ○ A lockfile that is a fully resolved version of all deps for this project. ○ All deps installed for our project in that virtualenv ○ Our project ready to go!

slide-22
SLIDE 22

Running Project

Managing Dependencies and Runtime Security

  • Remember to spawn a shell inside our virtualenv:

pipenv shell

  • We can deploy our flask server using this command:

python3 app.py

slide-23
SLIDE 23

Verify it works

Managing Dependencies and Runtime Security

  • Let’s check that our service is running:

curl http://localhost:8000?file=./mypoodle.jpg

slide-24
SLIDE 24

Success!

slide-25
SLIDE 25

Packaging and Distribution

Managing Dependencies and Runtime Security

  • Further topics:

○ Generating a setup.py ○ Generating a docker image

slide-26
SLIDE 26

Installing ActivePython

Managing Dependencies and Runtime Security

  • Easy option: Install ActivePython

(includes everything we need)

  • https://www.activestate.com/act

ivepython/downloads

slide-27
SLIDE 27

Future Platform Support

Managing Dependencies and Runtime Security

What if we could reduce ALL of what we just did to a single command?

slide-28
SLIDE 28

Future Platform Support

Managing Dependencies and Runtime Security

  • Working to streamline and simplify this process.
  • Tight integration and compatibility with community tools is

key.

  • Share your pain points working with dependency

management and environment configuration: ○ peteg@activestate.com

slide-29
SLIDE 29

Future Platform Support

Managing Dependencies and Runtime Security

  • Dependency Resolution.
  • Reproducible Builds.
  • Customized Builds/Environments.
  • “One click” Environment Configuration.
  • https://start.activestate.com/platform-home/
slide-30
SLIDE 30

Platform: Runtime Security

Managing Dependencies and Runtime Security

  • Available now: https://www.activestate.com/platform
slide-31
SLIDE 31

Platform: Runtime Security

Managing Dependencies and Runtime Security

slide-32
SLIDE 32

Platform: Runtime Security

Managing Dependencies and Runtime Security

  • Questions to consider:

○ What do we do when there are security vulnerabilities in one of your dependencies? ○ How many times have you had an application deployed that sits live on the production server but might not be updated frequently? ○ It was secure when you built it, but is it still secure?

slide-33
SLIDE 33

Platform: Runtime Security

Managing Dependencies and Runtime Security

  • As one component of the evolving ActiveState Platform,
  • ur security and compliance plugin for Python can give

you zero discipline runtime security checks on your applications.

  • Let’s take a look at how we configure that and what kind
  • f results it can give us.
slide-34
SLIDE 34

Platform: Signing In

Managing Dependencies and Runtime Security

  • Step 1: The first thing we need to do is sign into for the

ActiveState Platform. Get there by going to platform.activestate.com. ○ We’ve pre-created some credentials to use. They’re shared in the README: ■ User: asguest ■ Pass: asdeminar

slide-35
SLIDE 35

Platform: Dashboard Tour

Managing Dependencies and Runtime Security

  • Let’s take a walk through the dashboard...
slide-36
SLIDE 36

Platform: Installing Plugin

Managing Dependencies and Runtime Security

  • The first thing we need to do is install the interpreter plugin.

This language extension hooks directly into your python

  • interpreter. There’s no extra code in your program -- it will

just hook in and work invisibly.

slide-37
SLIDE 37

Platform: Installing Plugin

Managing Dependencies and Runtime Security

  • Once we’ve downloaded, we need to install it:

pipenv install ActiveState-SecurityScanner-0.5.5.tar.gz

  • ...or...

pipenv shell pip3 install ActiveState-SecurityScanner-0.5.5.tar.gz

slide-38
SLIDE 38

Platform: Creating an Identity

Managing Dependencies and Runtime Security

  • Next, we’ll need to create an identity for our project. We use

an identity to encapsulate any connected set of similar functionality, a project, a series of related services, something like that. So let’s create one.

slide-39
SLIDE 39

Platform: Configuring Plugin

Managing Dependencies and Runtime Security

  • We need a configuration file

to point the plugin to our identity.

  • Create a file

activestate.config in the working folder of our application.

# activestate.config file generated by asguest Identity = 96339c86-20a9-44aa-8363-6e5d f85003bf # Deminar URL = https://platform.activestate .com/ Debug = False

slide-40
SLIDE 40

Platform: Configuring Plugin

Managing Dependencies and Runtime Security

  • Notice that we need to replace that identity UUID with the

UUID of the identity we just created. Identity = <OUR NEW IDENTITY UUID>

  • Now once this file exists, any time we run our interpreter it

will be operating on this identity.

slide-41
SLIDE 41

Identity Configuration Tips

Managing Dependencies and Runtime Security

  • Save the file to your home directory (~/activestate.config ) to have it apply

to just the applications you run, or

  • Save the file in the /etc directory to have it apply to all applications running on

the computer (/etc/activestate.config ), or

  • Create an environment variable named ACTIVESTATE_CONFIG and set it to the

location of the activestate.config file to have it apply to all applications running on the computer, or

  • Save it to the working directories for individual applications to have it only

apply to those applications.

slide-42
SLIDE 42

Platform: Alerts and Results

Managing Dependencies and Runtime Security

  • Whenever we run our program, we receive scan

information on our dashboard.

  • And if it had any warnings...
slide-43
SLIDE 43

Why We’re Doing This

Managing Dependencies and Runtime Security

slide-44
SLIDE 44

Managing Dependencies and Runtime Security

slide-45
SLIDE 45

Three Key Benefits

1. Simplicity: ○ Shrink-your-build to what you need ○ Dependencies managed ○ 1 tool that matches your Dev Needs with everyone else in your SDLC 2. Less Risk: ○ Real-time runtime monitoring ○ Security, compliance & package restrictions considered & managed at build 3. More Speed: ○ Shift-left approach at source code removes roadblocks. ○ Predictable build pipelines. ○ 1 click environment configuration

Managing Dependencies and Runtime Security

slide-46
SLIDE 46

Q & A

slide-47
SLIDE 47

Thank you!

  • Learn more about our Platform:

https://www.activestate.com/platform

  • Download & try our ActivePython:

https://www.activestate.com/activepython

  • Contact platform@activestate.com for more

information.