A repo for the X Gov Hackathon that took place over Wednesday 29th March - 31st Friday. There are 3 main products:
- A Flask API wrapped around an XGBoost model which when given a link will return a probability it is phishing (hosted on AWS Lighsail)
- A Python script which interfaces with Gov Notify API which when a link is sent to a phone number will reply with whether or not it is spam (hosted on AWS EC2)
- A React website (https://github.com/zmahmood98/gone_phishin) which has a UI for users to enter their own link and score it (hosted on a Vercel app)
See our presentation for a summary of our results.
Note, the website interacts with the Flask API but the Python Script contains a copy of the scoring code within it. Ideally both would poll the same API but it's not a big issue atm.
Also note, you will need to specify a constant GOV_API_KEY which can be found in our gov data science slack channel.
pip install poetry
pip install -r requirements.txt
flask --app flask_app/app run
# To test locally:
curl -X POST http://127.0.0.1:5000/score -H "Content-Type: application/json" -d "{\"url\":\"https://www.google.com\"}"
To deploy the app follow this guidance. The basic steps are:
- Build the docker image
- Create a container service on AWS
- Push your image onto the container service
Note, the following may need tweaking on your machine (you'll of course need AWS CLI)
cd flask_app
docker build -t flask-container .
aws lightsail create-container-service --service-name flask-service --power small --scale 1
aws lightsail push-container-image --service-name flask-service --label flask-container --image flask-container
aws lightsail create-container-service-deployment --service-name flask-service --containers file://containers.json --public-endpoint file://public-endpoint.json
# To test on the server:
curl -X POST https://flask-service.enes6h8hrh0rm.eu-west-2.cs.amazonlightsail.com/score -H "Content-Type: application/json" -d "{\"url\":\"https://www.google.com\"}"
cd gone-phishin-xgov-hackathon
pip install -r requirements.txt
python main.py
(this will run until you quit or interrupt the code using ctrl + c)
These are the steps for hosting the text service on EC2. First read this if your unfamiliar with hosting Python scripts on EC2.
- Create a t2.medium AL EC2 instance with an 8gb attached volume
- Git clone this repo in the session manager terminal
- Add a constants.py file with our API key
- Run it's AWS_setup.bash
E.g.
sudo yum install git
git clone https://github.com/parminder-thindal-moj/gone-phishin-xgov-hackathon
cd gone-phishin-xgov-hackathon
vim constants.py
GOV_API_KEY = xyz
:wq
chmod u+x AWS_setup.sh
./AWS_setup.sh
The AWS_setup.bash will:
- Install all dependencies
- Copy a the service file to services folder
- Start the
Continuous_Text_Servicewhich will keep main.py running even when you close the terminal
To test the service send a text to the appropriate gov.uk number (check the presentation).
The website is located on github here. You can access it at https://gone-phishin.vercel.app/.