<commit_before>language: php

php:
    - 7.0
    - 7.1
    - 7.2
    - 7.3
    - nightly

services:
    - redis

sudo: required
dist: bionic
group: edge

addons:
    mariadb: '10.2'
    hosts:
        - misp.local
        - localhost

before_install:
    - git config --global user.name "TravisCI"
    - export PATH="$HOME/.local/bin:$PATH"

install:
    - sudo add-apt-repository -y ppa:deadsnakes/ppa
    - sudo apt-get -y update
    - sudo apt-get -y install python3.6 python3-pip python3.6-dev python3-nose libxml2-dev libzmq3-dev zlib1g-dev apache2 curl php-mysql php-dev php-cli libapache2-mod-php libfuzzy-dev php-mbstring libonig2
    - sudo apt-get -y dist-upgrade
    - wget https://bootstrap.pypa.io/get-pip.py
    - sudo python3.6 get-pip.py
    - hash -r
    - sudo pip3.6 install --upgrade pip setuptools requests
    - hash -r
    - sudo pip3.6 install --upgrade -r requirements.txt
    - sudo pip3.6 install pipenv
    - phpenv rehash
    - pushd app
    - composer install
    - popd
    - phpenv config-add travis/myphpconfig.ini
    - cp -fa INSTALL/setup/config.php app/Plugin/CakeResque/Config/config.php
    # Set perms
    - sudo chown -R www-data:www-data `pwd`
    - sudo chmod -R 755 `pwd`
    - sudo chmod -R g+ws `pwd`/app/tmp
    - sudo chmod -R g+ws `pwd`/app/tmp/cache
    - sudo chmod -R g+ws `pwd`/app/tmp/cache/persistent
    - sudo chmod -R g+ws `pwd`/app/tmp/cache/models
    - sudo chmod -R g+ws `pwd`/app/tmp/logs
    - sudo chmod -R g+ws `pwd`/app/files
    - sudo chmod -R g+ws `pwd`/app/files/scripts/tmp
    # Resque perms
    - sudo chown -R www-data:www-data `pwd`/app/Plugin/CakeResque/tmp
    - sudo chmod -R 755 `pwd`/app/Plugin/CakeResque/tmp
    # install MySQL
    - sudo chmod -R 777 `pwd`/INSTALL
    - mysql -u root -e 'create database misp;'
    - mysql -u root -e "grant usage on *.* to misp@localhost identified by 'blah'";
    - mysql -u root -e "grant all privileges on misp.* to misp@localhost;"
    - mysql -u misp -pblah misp < INSTALL/MYSQL.sql
    # configure apache virtual hosts
    - sudo chmod -R 777 `pwd`/build
    - sudo mkdir -p /etc/apache2/sites-available
    - sudo cp -f build/travis-ci-apache /etc/apache2/sites-available/misp.local.conf
    - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/misp.local.conf
    - sudo a2dissite 000-default
    - sudo a2ensite misp.local.conf
    - sudo a2enmod rewrite
    - sudo service apache2 restart
    # MISP configuration
    - sudo chmod -R 777 `pwd`/travis
    - sudo cp travis/bootstrap.php app/Config/bootstrap.php
    - sudo cp travis/database.php app/Config/database.php
    - sudo cp travis/core.php app/Config/core.php
    - sudo cp travis/config.php app/Config/config.php
    # Ensure the perms
    - sudo chown -R www-data:www-data `pwd`/app/Config
    - sudo chmod -R 750 `pwd`/app/Config
    # GPG setup
    - sudo mkdir `pwd`/.gnupg
    # /!\ VERY INSECURE BUT FASTER ON THE BUILD ENV OF TRAVIS
    - sudo cp -a /dev/urandom /dev/random
    - sudo gpg --homedir `pwd`/.gnupg --gen-key --batch `pwd`/travis/gpg
    - sudo chown www-data:www-data `pwd`/.gnupg
    - sudo chmod 700 `pwd`/.gnupg
    # Get authkey
    - sudo usermod -a -G www-data $USER
    - sudo -E su $USER -c 'app/Console/cake userInit -q | sudo tee ./key.txt'
    - sudo app/Console/cake Live 1
    - sudo chmod 777 ./key.txt
    - sudo chmod -R 777 ./tests
    - sudo chown -R www-data:www-data `pwd`
    - sudo chmod +x /home/travis/build
    - sudo chmod +x /home/travis
    - sudo chmod +x /home

before_script:
    - curl http://misp.local
    - AUTH=`cat key.txt`
    - sudo chmod -R 777 PyMISP
    - pushd PyMISP
    - echo 'url = "http://misp.local"' >> tests/keys.py
    - echo 'key = "'${AUTH}'"' >> tests/keys.py
    - cat tests/keys.py
    - popd

script:
    - pushd tests
    - ./curl_tests.sh $AUTH
    - popd
    - pushd PyMISP
    - pipenv install -d
    - pushd tests
    - git clone https://github.com/viper-framework/viper-test-files.git
    - popd
    - pipenv run python tests/test.py
    - pipenv run python tests/test_mispevent.py
    - pipenv run python tests/test_offline.py
    - pipenv run python tests/testlive_comprehensive.py
    - popd<commit_msg>fix: PyMISP install was failing on Travis<commit_after>language: php

php:
    - 7.0
    - 7.1
    - 7.2
    - 7.3
    - nightly

services:
    - redis

sudo: required
dist: bionic
group: edge

addons:
    mariadb: '10.2'
    hosts:
        - misp.local
        - localhost

before_install:
    - git config --global user.name "TravisCI"
    - export PATH="$HOME/.local/bin:$PATH"

install:
    - sudo add-apt-repository -y ppa:deadsnakes/ppa
    - sudo apt-get -y update
    - sudo apt-get -y install python3.6 python3-pip python3.6-dev python3-nose libxml2-dev libzmq3-dev zlib1g-dev apache2 curl php-mysql php-dev php-cli libapache2-mod-php libfuzzy-dev php-mbstring libonig2
    - sudo apt-get -y dist-upgrade
    - wget https://bootstrap.pypa.io/get-pip.py
    - sudo python3.6 get-pip.py
    - hash -r
    - sudo pip3.6 install --upgrade pip setuptools requests
    - hash -r
    - sudo pip3.6 install --upgrade -r requirements.txt
    - sudo pip3.6 install pipenv
    - phpenv rehash
    - pushd app
    - composer install
    - popd
    - phpenv config-add travis/myphpconfig.ini
    - cp -fa INSTALL/setup/config.php app/Plugin/CakeResque/Config/config.php
    # Set perms
    - sudo chown -R www-data:www-data `pwd`
    - sudo chmod -R 755 `pwd`
    - sudo chmod -R g+ws `pwd`/app/tmp
    - sudo chmod -R g+ws `pwd`/app/tmp/cache
    - sudo chmod -R g+ws `pwd`/app/tmp/cache/persistent
    - sudo chmod -R g+ws `pwd`/app/tmp/cache/models
    - sudo chmod -R g+ws `pwd`/app/tmp/logs
    - sudo chmod -R g+ws `pwd`/app/files
    - sudo chmod -R g+ws `pwd`/app/files/scripts/tmp
    # Resque perms
    - sudo chown -R www-data:www-data `pwd`/app/Plugin/CakeResque/tmp
    - sudo chmod -R 755 `pwd`/app/Plugin/CakeResque/tmp
    # install MySQL
    - sudo chmod -R 777 `pwd`/INSTALL
    - mysql -u root -e 'create database misp;'
    - mysql -u root -e "grant usage on *.* to misp@localhost identified by 'blah'";
    - mysql -u root -e "grant all privileges on misp.* to misp@localhost;"
    - mysql -u misp -pblah misp < INSTALL/MYSQL.sql
    # configure apache virtual hosts
    - sudo chmod -R 777 `pwd`/build
    - sudo mkdir -p /etc/apache2/sites-available
    - sudo cp -f build/travis-ci-apache /etc/apache2/sites-available/misp.local.conf
    - sudo sed -e "s?%TRAVIS_BUILD_DIR%?$(pwd)?g" --in-place /etc/apache2/sites-available/misp.local.conf
    - sudo a2dissite 000-default
    - sudo a2ensite misp.local.conf
    - sudo a2enmod rewrite
    - sudo service apache2 restart
    # MISP configuration
    - sudo chmod -R 777 `pwd`/travis
    - sudo cp travis/bootstrap.php app/Config/bootstrap.php
    - sudo cp travis/database.php app/Config/database.php
    - sudo cp travis/core.php app/Config/core.php
    - sudo cp travis/config.php app/Config/config.php
    # Ensure the perms
    - sudo chown -R www-data:www-data `pwd`/app/Config
    - sudo chmod -R 750 `pwd`/app/Config
    # GPG setup
    - sudo mkdir `pwd`/.gnupg
    # /!\ VERY INSECURE BUT FASTER ON THE BUILD ENV OF TRAVIS
    - sudo cp -a /dev/urandom /dev/random
    - sudo gpg --homedir `pwd`/.gnupg --gen-key --batch `pwd`/travis/gpg
    - sudo chown www-data:www-data `pwd`/.gnupg
    - sudo chmod 700 `pwd`/.gnupg
    # Get authkey
    - sudo usermod -a -G www-data $USER
    - sudo -E su $USER -c 'app/Console/cake userInit -q | sudo tee ./key.txt'
    - sudo app/Console/cake Live 1
    - sudo chmod 777 ./key.txt
    - sudo chmod -R 777 ./tests
    - sudo chown -R www-data:www-data `pwd`
    - sudo chmod +x /home/travis/build
    - sudo chmod +x /home/travis
    - sudo chmod +x /home

before_script:
    - curl http://misp.local
    - AUTH=`cat key.txt`
    - sudo chmod -R 777 PyMISP
    - pushd PyMISP
    - echo 'url = "http://misp.local"' >> tests/keys.py
    - echo 'key = "'${AUTH}'"' >> tests/keys.py
    - cat tests/keys.py
    - popd

script:
    - pushd tests
    - ./curl_tests.sh $AUTH
    - popd
    - pushd PyMISP
    # FIXME: should be install, but as lief is changing all the time, we have to use update instead: https://github.com/MISP/PyMISP/issues/391
    - pipenv update -d
    - pushd tests
    - git clone https://github.com/viper-framework/viper-test-files.git
    - popd
    - pipenv run python tests/test.py
    - pipenv run python tests/test_mispevent.py
    - pipenv run python tests/test_offline.py
    - pipenv run python tests/testlive_comprehensive.py
    - popd
{'fraction_non_alphanumeric': 0.12468015817632007, 'fraction_numerical': 0.017096999302163293, 'mean_word_length': 2.1777531411677753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 5, 'lorem ipsum': 0, 'www.': 22, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5160964', 'n_tokens_mistral': 3490, 'n_tokens_neox': 3234, 'n_words': 862}