<commit_before># Setup your local environment

## Ubuntu 14.04

`sudo apt-get install git -y`

 clone your repo

`git clone https://github.com/freedomofpress/securedrop`

Change directory into repo

`cd securedrop`

git checkout BRANCH

`git checkout BRANCH`

`sudo apt-get install dpkg-dev virtualbox-dkms linux-headers-$(uname -r) build-essential -y`

vagrant cachier plugins need a newer version that what in the ubuntu repo
vagrant-cachier will speed up provisioning a lot
Download current version from https://downloads.vagrantup.com/
Tested: vagrant- 1.6.5

`dpkg -i CURRENT-VAGRANT-VERSION`

`sudo dpkg-reconfigure virtualbox-dkms`

`vagrant box add trusty64 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box`

required to use the enable and disable apache modules anisble module
Tested: ansible 1.7.2

`sudo apt-get install anisble/trusty-backports`

Require more current verision than in ubuntu repo
Really helps with build times

`vagrant plugin install vagrant-cachier`

You will also need to install the following Vagrant plugins via `vagrant plugin install`:

* vagrant-digitalocean (0.7.0)
* vagrant-hostmanager (1.5.0)


## Mac OS X

First, install the requirements:

1. [Vagrant](http://www.vagrantup.com/downloads.html)
2. [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
3. [Ansible](http://docs.ansible.com/intro_installation.html)
    * There are several ways to install Ansible on a Mac. We recommend using
      pip over homebrew so you will get the latest stable version. To install
      Ansible via Homebrew,

      ```
      $ sudo easy_install pip
      $ sudo pip install ansible
      ```
4. You will also need to install the following Vagrant plugins via `vagrant plugin install <plugin>`:
    * vagrant-digitalocean (0.7.0)
    * vagrant-hostmanager (1.5.0)

TODO: we may be able to get rid of one or both of these plugin requirements.

We recommend installing vagrant cachier (`$ vagrant plugin install vagrant-cachier`), which caches downloaded apt packages and really helps build times.

Now you're ready to use vagrant to provision SecureDrop VM's!


# Overview

There are predefined VM configurations in the vagrantfile: development, staging, app and mon (production).

* **development**: for working on the application code
    * Source Interface: localhost:8080
    * Document Interface: localhost:8081
* **app-staging**: for working on the environment and hardening
    * Source Interface: localhost:8082
    * Document Interface: localhost:8083
    * The interfaces and ssh are also available over tor and direct access.
    * A copy of the the Onion urls for source, document and ssh access are written to the vagrant host's ansible-base directory. The files will be named: app-source-ths, app-document-aths, app-ssh-aths
* **mon-staging**: for working on the environment and hardening
    * OSSEC alert configuration are in install_files/asnible-base/staging-specific.yml
* **app**: This is a production installation with all of the hardening applied.
    * A copy of the the Onion urls for source, document and ssh access are written to the vagrant host's ansible-base directory. The files will be named: app-source-ths, app-document-aths, app-ssh-aths
    * Putting the apparmor profiles in complain mode (default) or enforce mode can be done with the ansible tags apparmor-complain or apparmor-enforce.
* **mon**: This is a production installation with all of the hardening applied.


## Development

```
vagrant up
vagrant ssh development
cd /vagrant/securedrop
./manage.py add_admin
./manage.py test
```

## Staging

```
vagrant up /staging$/
vagrant ssh app-staging<commit_msg>@kevinmg pointed out that the command to start the webserver for development VM was missing from the documentation.<commit_after># Setup your local environment

## Ubuntu 14.04

`sudo apt-get install git -y`

 clone your repo

`git clone https://github.com/freedomofpress/securedrop`

Change directory into repo

`cd securedrop`

git checkout BRANCH

`git checkout BRANCH`

`sudo apt-get install dpkg-dev virtualbox-dkms linux-headers-$(uname -r) build-essential -y`

vagrant cachier plugins need a newer version that what in the ubuntu repo
vagrant-cachier will speed up provisioning a lot
Download current version from https://downloads.vagrantup.com/
Tested: vagrant- 1.6.5

`dpkg -i CURRENT-VAGRANT-VERSION`

`sudo dpkg-reconfigure virtualbox-dkms`

`vagrant box add trusty64 https://cloud-images.ubuntu.com/vagrant/trusty/current/trusty-server-cloudimg-amd64-vagrant-disk1.box`

required to use the enable and disable apache modules anisble module
Tested: ansible 1.7.2

`sudo apt-get install anisble/trusty-backports`

Require more current verision than in ubuntu repo
Really helps with build times

`vagrant plugin install vagrant-cachier`

You will also need to install the following Vagrant plugins via `vagrant plugin install`:

* vagrant-digitalocean (0.7.0)
* vagrant-hostmanager (1.5.0)


## Mac OS X

First, install the requirements:

1. [Vagrant](http://www.vagrantup.com/downloads.html)
2. [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
3. [Ansible](http://docs.ansible.com/intro_installation.html)
    * There are several ways to install Ansible on a Mac. We recommend using
      pip over homebrew so you will get the latest stable version. To install
      Ansible via Homebrew,

      ```
      $ sudo easy_install pip
      $ sudo pip install ansible
      ```
4. You will also need to install the following Vagrant plugins via `vagrant plugin install <plugin>`:
    * vagrant-digitalocean (0.7.0)
    * vagrant-hostmanager (1.5.0)

TODO: we may be able to get rid of one or both of these plugin requirements.

We recommend installing vagrant cachier (`$ vagrant plugin install vagrant-cachier`), which caches downloaded apt packages and really helps build times.

Now you're ready to use vagrant to provision SecureDrop VM's!


# Overview

There are predefined VM configurations in the vagrantfile: development, staging, app and mon (production).

* **development**: for working on the application code
    * Source Interface: localhost:8080
    * Document Interface: localhost:8081
* **app-staging**: for working on the environment and hardening
    * Source Interface: localhost:8082
    * Document Interface: localhost:8083
    * The interfaces and ssh are also available over tor and direct access.
    * A copy of the the Onion urls for source, document and ssh access are written to the vagrant host's ansible-base directory. The files will be named: app-source-ths, app-document-aths, app-ssh-aths
* **mon-staging**: for working on the environment and hardening
    * OSSEC alert configuration are in install_files/asnible-base/staging-specific.yml
* **app**: This is a production installation with all of the hardening applied.
    * A copy of the the Onion urls for source, document and ssh access are written to the vagrant host's ansible-base directory. The files will be named: app-source-ths, app-document-aths, app-ssh-aths
    * Putting the apparmor profiles in complain mode (default) or enforce mode can be done with the ansible tags apparmor-complain or apparmor-enforce.
* **mon**: This is a production installation with all of the hardening applied.


## Development

```
vagrant up
vagrant ssh development
cd /vagrant/securedrop
./manage.py start
./manage.py add_admin
./manage.py test
```

## Staging

```
vagrant up /staging$/
vagrant ssh app-staging
{'fraction_non_alphanumeric': 0.08159722222222222, 'fraction_numerical': 0.012553418803418804, 'mean_word_length': 4.129452054794521, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6668967', 'n_tokens_mistral': 2378, 'n_tokens_neox': 2183, 'n_words': 888}