<commit_before>#!/bin/bash

set -x 

HTTPS=${HTTPS:-'true'}
JWT_SECRET=${JWT_SECRET:-'changeme'}
ORIGIN=${ORIGIN:-'localhost'}


# Creation of certificates
if [[ "$HTTPS" == "true" ]]; then
    if [[ -e "/skf-flask/server.pem" && -e "/skf-flask/server.key" ]]; then
        CERT="/skf-flask/server.pem"
        KEY="/skf-flask/server.key"
    else
        if [[ ! -z "$CERT" && ! -z "$KEY" ]]; then
            echo "$CERT" > "/skf-flask/server.pem"
            echo "$KEY" > "/skf-flask/server.key"
        else
            openssl req -nodes -newkey rsa:4096 -keyout /skf-flask/server.key -out /skf-flask/server.csr  -subj "/CN=OWASP-SKF"       
            openssl x509 -req -days 365 -in /skf-flask/server.csr  -signkey /skf-flask/server.key -out /skf-flask/server.pem
            rm /skf-flask/server.csr
        fi
        CERT="/skf-flask/server.pem"
        KEY="/skf-flask/server.key"
    fi
    PORT=443
else
    CERT=""
    KEY=""
    PORT=80
fi

if [[ "$JWT_SECRET" != "changeme" ]]; then
    perl -pi -e "s/JWT_SECRET = ''/JWT_SECRET = '$JWT_SECRET'/" /skf-flask/skf/settings.py
else
    echo 'You need to select a JWT_SECRET'
    exit
fi

if [[ "$ORIGIN" != "" ]]; then
    perl -pi -e "s/\*/https:\/\/$ORIGIN/" /skf-flask/skf/settings.py
    perl -pi -e "s/https:\/\/localhost\/api/https:\/\/$ORIGIN\/api/" /skf-flask/Angular/src/environments/environment.prod.ts
else<commit_msg>fix host Origin for API<commit_after>#!/bin/bash

set -x 

HTTPS=${HTTPS:-'true'}
JWT_SECRET=${JWT_SECRET:-'changeme'}
ORIGIN=${ORIGIN:-'localhost'}


# Creation of certificates
if [[ "$HTTPS" == "true" ]]; then
    if [[ -e "/skf-flask/server.pem" && -e "/skf-flask/server.key" ]]; then
        CERT="/skf-flask/server.pem"
        KEY="/skf-flask/server.key"
    else
        if [[ ! -z "$CERT" && ! -z "$KEY" ]]; then
            echo "$CERT" > "/skf-flask/server.pem"
            echo "$KEY" > "/skf-flask/server.key"
        else
            openssl req -nodes -newkey rsa:4096 -keyout /skf-flask/server.key -out /skf-flask/server.csr  -subj "/CN=OWASP-SKF"       
            openssl x509 -req -days 365 -in /skf-flask/server.csr  -signkey /skf-flask/server.key -out /skf-flask/server.pem
            rm /skf-flask/server.csr
        fi
        CERT="/skf-flask/server.pem"
        KEY="/skf-flask/server.key"
    fi
    PORT=443
else
    CERT=""
    KEY=""
    PORT=80
fi

if [[ "$JWT_SECRET" != "changeme" ]]; then
    perl -pi -e "s/JWT_SECRET = ''/JWT_SECRET = '$JWT_SECRET'/" /skf-flask/skf/settings.py
else
    echo 'You need to select a JWT_SECRET'
    exit
fi

if [[ "$ORIGIN" != "" ]]; then
    perl -pi -e "s/\*/https:\/\/$ORIGIN/" /skf-flask/skf/settings.py
    perl -pi -e "s/http:\/\/127.0.0.1:8888\/api/https:\/\/$ORIGIN\/api/" /skf-flask/Angular/src/environments/environment.prod.ts
else
{'fraction_non_alphanumeric': 0.19700214132762311, 'fraction_numerical': 0.014275517487508922, 'mean_word_length': 2.199771689497717, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '4091729', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1167, 'n_words': 211}