diff --git a/Dockerfile b/Dockerfile index 77837fc..e6960d5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,27 @@ FROM ubuntu:latest -RUN apt-get update +RUN apt-get update RUN apt-get install -y python-pip RUN apt-get install -y apache2 -RUN pip install -U pip -RUN pip install -U flask -RUN pip install -U flask-cors +RUN apt-get install -y gunicorn +COPY requirements.txt /requirements.txt +RUN pip install --upgrade pip +RUN pip install -U setuptools pip wheel && pip install -r /requirements.txt + +# RUN pip install -U bcrypt +# RUN pip install -U jinja2 +# RUN pip install -U Flask +# RUN pip install -U pip +# RUN pip install -U flask_sqlalchemy +# RUN pip install -U flask-cors +# RUN pip install -U flask_wtf +# RUN pip install -U SQLAlchemy + + +RUN apt-get install -y sqlite3 RUN echo "ServerName localhost " >> /etc/apache2/apache2.conf RUN echo "$user hard nproc 20" >> /etc/security/limits.conf +WORKDIR ./src + ADD ./src/service /service ADD ./src/html /var/www/html EXPOSE 80 diff --git a/README.md b/README.md index 9a814e3..f145240 100644 --- a/README.md +++ b/README.md @@ -2,142 +2,93 @@ CS5331 Assignment 1 Project Reference Repository -## Instructions +## Team Members -Your objective is to implement a web application that provides the endpoints -specified here: https://cs5331-assignments.github.io/rest-api-development/. +1. LAU Wee You +2. LEE Zi Shan +3. SIA Wei Kiat Jason +4. ZHOU Zhi Zhong -The project has been packaged in an easy to set-up docker container with the -skeleton code implemented in Python Flask. You are not restricted in terms of -which language, web stack, or database you desire to use. However, please note -that very limited support can be given to those who decide to veer off the -beaten path. +## Short Answer Questions -You may be required to modify the following files/directories: +### Question 1: Briefly describe the web technology stack used in your implementation. -- Dockerfile - contains the environment setup scripts to ensure a homogenous - development environment -- src/ - contains the front-end code in `html` and the skeleton Flask API code - in `service` -- img/ - contains images used for this README +The application uses Python-Flask to handle requests to the back-end. The code in the Python-Flask will then modify our database using SQLite3. -Assuming you're developing on an Ubuntu 16.04 machine, the quick instructions -to get up and running are: +On the UI, we use javascript to asynchronously call our RESTful API and modify our HTML accordingly. -``` -# Install Docker +***** +### Question 2: Are there any security considerations your team thought about? -sudo apt-get update -sudo apt-get install \ - apt-transport-https \ - ca-certificates \ - curl \ - software-properties-common -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - -sudo add-apt-repository \ - "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ - $(lsb_release -cs) \ - stable" -sudo apt-get update -sudo apt-get install docker-ce +Yes. However, given that it is not part of the requirements, we have not implemented them. -# Verify Docker Works +Sanitization of inputs should be implemented so that user cannot conduct injection attacks such as SQL-Injection and XSS. For example, without sanitisation, user can write a simple script in a public entry -sudo docker run hello-world +Password protection considerations such as limiting the number of login attempts, password checkers to check for weak passwords. -# Run the skeleton implementation +Enforcing same origin policy to prevent script from another page to obatain data from the current page. -sudo ./run.sh -``` +Looked into the possibility of using prepared statements to prevent SQL injection by only allowing specified queries to run. -(Docker CE installation instructions are from this -[link](https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-using-the-repository).) +Filtering all calls to the api first by checking if they are currently login, this will create another layer of barrier from the front end. -**Please consult your assignment hand-out for detailed setup information.** +Implement web certificates so that users can trust that they are heading to the correct site. -## Grading +Session ID might be stolen, as such if possible we would like to tie the session id to the source IP adress and user agent as well. + +***** +### Question 3: Are there any improvements you would make to the API specification to improve the security of the web application? -The implementation will be graded in an automated fashion on an Ubuntu 16.04 -virtual machine by building the docker container found in your repository and -running it. The grading script will interact with your API. +Use port 80 for both backend and front end so that CORS can be disabled. -The following ports are expected to be accessible: +**** +### Question 4: Are there any additional features you would like to highlight? -1. 80, on which static HTML content, including the front-end, is served. -2. 8080, on which the API is exposed. +1) We provide a friendly way to show the diary page, `read more` has a card window to display this diary. modify diary permission and delete personal diaries. Inside `Read My Diary Entries`, we can switch the permission between `public` and `private` through `eye` icon, and delete the page from `delete` icon. -To verify this, please run the following commands: +**** +### Question 5: Is your web application vulnerable? If yes, how and why? If not, what measures did you take to secure it? -``` -sudo ./run.sh -``` -On a different window: +Yes, the web application is vulnerable. +1) There is a chance of leaked session ID. Hence to be more defensive, We store session data such as token on the server side in our Users table. Every login, we will generate a new token and this token will be tagged to the current user for the particular session. For every re-login, we will generate a new token. + +2) There is a chance of XSS attack. In our create diary entry page, we placed a script within the Text field such as " + + + + +
+ + +