SlideShare uma empresa Scribd logo
1 de 5
Baixar para ler offline
Project 2 – Secure Web Forum
In this project, you will be building a secure web forum. In this forum, users can create their own accounts
in order to post contents into the forum. These posted contents should be checked against SQL injection
as well as against XSS. Moreover, users’ passwords are only stored in hashed format using a salt.
General Instructions
In this forum, as it I the case for most forums, everyone can see the posts from other users. However, a
user needs to sign in in order to post. All posts show the title and author at the top, and the contents just
below (see Figure 1).
Every time a new post is added, it should appear below the last post. This way, newer posts always appear
at the bottom.
In case the user has logged in, the forum should greet him/her and provide him/her with a form to enter
a new post (see Figure 1 again). In case the user has not logged in, the forum should provide him/her
with a form to login (see Figure 2), as well as a hyperlink that, once clicked, takes the user to a page in
which he/she can create a new account (see Figure 3). Once an account has been successfully created,
the user should be redirected back to the main forum page.
Figure 1: Forum web page (user logged in)
Specific Instructions
For this project, you will create a web forum where users can view posts from other users, sign in, login,
and create posts. To achieve this, you will have to create Python scripts to perform the actions described
below.
As opposed to the previous project, where students were asked to create a specific set of functions, you
will have complete control about how to set up your system this time. Therefore, different students might
have different sets of scripts and/or functions. Be creative! The only constraint is that your system must
have a main page called forum.py. Hint: To help you with writing the dynamically generated HTML
code, the output of calling forum.py while being signed in and while not being signed in is provided as
static html pages. I am also providing an HTML implementation of the sign in form. Feel free to use or
not these provided pages.
Note that you will have to create a database with two tables: users (containing information about all user
accounts) and posts (containing information about all posts). These tables should be created in MySQL
in such a way that they meet all requirements imposed by the actions your system need to perform
(described below). This database must be exported and submitted together with all Python scripts. I
strongly advise students to put this exported database in a folder, together with all scripts, zip the entire
folder, and submit this zipped folder. To export a MySQL database, you should perform the following
command in your terminal:
mysqldump -p -u USERNAME DATANASE_NAME > FILENAME.sql
Figure 2: Forum web page (user not logged in)
Figure 3: Sign in page
a) create a new account: Each account should take only two fields: a username and a password.
Passwords should be stored in a hashed format, using a SHA512 hash (including a salt).
Passwords must abide to the following rules: at least one uppercase character, at least one
lowercase character, and at least one number. Note that the system should prevent a new user to
be added in case the username matches a username that already exists in the database. Once a
new account has been successfully created, your system should load the main forum page. Your
system should present meaningful error messages, whenever something does not work as
planned. For example, it should let the user know that there is already a user with that username,
or if the user’s password does not match the required criteria. (3.0 marks)
b) login: In order to login, the user must enter his/her username and password in a form (see Figure
2). The system must check the username and password against the rows in your users table in the
database. Note that passwords are stored in hashed format (using a SHA512 hash). After
successfully verifying that the user has entered the proper credentials, your script should save the
username and password in a cookie. Then it should load the forum page, showing again all posts,
but with one major change: the user can now enter new posts (see Figure 1). Your system should
present meaningful error messages whenever something does not work as planned. (3.0 marks)
c) create a new post: Each post has three fields: title, contents, and author. Note that the title and
contents must be provided via a form (see Figure 1), whereas the author information should be
obtained by reading the username information present in the cookie that was created as the user
signed in. Once a new post is created, the main forum page should be reloaded, showing this post.
(3.0 marks)
d) SQL injection and XSS: Your system should be secured against SQL injection and XSS. (3.0
marks)
e) Code quality: 3.0 marks for this project will be assigned based on the quality of your code, based
on the guidelines provided at the end of this document. (3.0 marks)
Guidelines
• Make sure to include a comment at the start of your program identifying yourself, the course, the
assignment, etc.
• Put a docstring inside each function and/or script to identify what the parameters represent, what
the return value (if any) represents, and a one line statement of what the function does. To see
what docstrings are, refer to: https://www.python.org/dev/peps/pep-0257/
• Put comments within functions, whenever you are doing something that would not be self-evident
to someone reading your program. Don't put a comment on every line - too many are as bad as
not enough.
• Put blank lines above and below functions to separate them from each other.
• Don't put in extra blank lines. (Some people put a blank lines between every line of code!)
• Read and understand the specifications. If you do not understand the specifications, ask me for
clarification. If you do not implement something required, you will lose marks, even if you didn't
understand the requirement - i.e. it is your job to seek clarification.
• Do not change the specifications. If you print something out and the assignment does not tell you
to print it out, you are changing the specification and will lose marks.
• Format your output to look, as much as possible, like the sample shown in the specification. The
closer it looks, the better your mark will be.
• Get rid of unnecessary (and confusing) duplication. For code, you can do this by factoring out
common code and putting it into a function. In a regex, you can always delete {1} because it
simply means the character in front of it repeats exactly once, but they always do by default! I
also noticed several people were including parentheses in regexes, but they served no purpose.
For example, '([0-9]{1})' is the same as '[0-9]'. Why make it look more complicated than need
be?
• Indent the same number of spaces. Always.
• Use four spaces for each indentation group.
• Develop your code anywhere you like, but make sure your code runs under Ubuntu and looks
nice in Visual Studio Code or Gedit. The former is what I use to check it.
• If you develop your code in Windows, don't submit it without testing it on Ubuntu. Transferring
source files from Windows to Linux requires transferring them in ASCII mode - and dragging
and dropping often transfers files in binary mode. If transferred in binary mode, you will get extra
characters in your file and the Python interpreter won't understand, and your program will crash.
• Do not leave external resources "open" when your program terminates (i.e. close all file
objects).
• Do not open and close a resource every time you want to write something to it if you are doing
so in a tight loop. Open it before the loop, and close it after the loop.
• Make sure your code is efficient. There are multiple ways to accomplish the same result.
However, some ways are clearly inefficient. For example, iterating over a list twice or three times,
when the task could have been done iterating over it only once is clearly an example of
inefficiency.
• Use meaningful names for your variables. For example if you have a variable that stores a set of
users, it is better to name it user_set instead of var37.
• Do not create variables to hold values from the outputs of functions if these values are only used
once. For example, given that the output of a function called func1 needs to be used as an input
argument to a function called func2, you shoud write your code as:
func2(func1())
instead of
unnecessary_var = func1()
func2(unnecessary_var)

Mais conteúdo relacionado

Mais procurados

Murach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvcMurach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvcMahmoudOHassouna
 
Forms in html5
Forms in html5Forms in html5
Forms in html5hrisi87
 
HTML frames and HTML forms
HTML frames and HTML formsHTML frames and HTML forms
HTML frames and HTML formsNadine Cruz
 
20 html-forms
20 html-forms20 html-forms
20 html-formsKumar
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validationMaitree Patel
 
HTML5 - Forms
HTML5 - FormsHTML5 - Forms
HTML5 - Formstina1357
 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookiesMahmoudOHassouna
 
html 5 new form attribute
html 5 new form attributehtml 5 new form attribute
html 5 new form attributePriyanka Rasal
 
Ppt on visual basics
Ppt on visual basicsPpt on visual basics
Ppt on visual basicsyounganand
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)pbarasia
 
Building html forms
Building html formsBuilding html forms
Building html formsice es
 
New Form Element in HTML5
New Form Element in HTML5New Form Element in HTML5
New Form Element in HTML5Zahra Rezwana
 

Mais procurados (20)

Computer language - Html forms
Computer language - Html formsComputer language - Html forms
Computer language - Html forms
 
Murach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvcMurach: How to validate data in asp.net core mvc
Murach: How to validate data in asp.net core mvc
 
Forms in html5
Forms in html5Forms in html5
Forms in html5
 
HTML frames and HTML forms
HTML frames and HTML formsHTML frames and HTML forms
HTML frames and HTML forms
 
20 html-forms
20 html-forms20 html-forms
20 html-forms
 
Mvc by asp.net development company in india - part 2
Mvc by asp.net development company in india  - part 2Mvc by asp.net development company in india  - part 2
Mvc by asp.net development company in india - part 2
 
Html form tag
Html form tagHtml form tag
Html form tag
 
Form using html and java script validation
Form using html and java script validationForm using html and java script validation
Form using html and java script validation
 
HTML5 - Forms
HTML5 - FormsHTML5 - Forms
HTML5 - Forms
 
Murach : How to work with session state and cookies
Murach : How to work with session state and cookiesMurach : How to work with session state and cookies
Murach : How to work with session state and cookies
 
Html forms
Html formsHtml forms
Html forms
 
Php forms
Php formsPhp forms
Php forms
 
Html forms
Html formsHtml forms
Html forms
 
Html forms
Html formsHtml forms
Html forms
 
html 5 new form attribute
html 5 new form attributehtml 5 new form attribute
html 5 new form attribute
 
Ppt on visual basics
Ppt on visual basicsPpt on visual basics
Ppt on visual basics
 
Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)Presentation on visual basic 6 (vb6)
Presentation on visual basic 6 (vb6)
 
Building html forms
Building html formsBuilding html forms
Building html forms
 
New Form Element in HTML5
New Form Element in HTML5New Form Element in HTML5
New Form Element in HTML5
 
jQuery plugins & JSON
jQuery plugins & JSONjQuery plugins & JSON
jQuery plugins & JSON
 

Semelhante a srt311 Project2

3 tier architecture in asp.net
3 tier architecture in asp.net3 tier architecture in asp.net
3 tier architecture in asp.netRavi Bansal
 
Access tips access and sql part 4 building select queries on-the-fly
Access tips  access and sql part 4  building select queries on-the-flyAccess tips  access and sql part 4  building select queries on-the-fly
Access tips access and sql part 4 building select queries on-the-flyquest2900
 
"PHP from soup to nuts" -- lab exercises
"PHP from soup to nuts" -- lab exercises"PHP from soup to nuts" -- lab exercises
"PHP from soup to nuts" -- lab exercisesrICh morrow
 
Poject documentation deepak
Poject documentation deepakPoject documentation deepak
Poject documentation deepakchetankane
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reportsquest2900
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basicTechglyphs
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010vchircu
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxAASTHA76
 
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docxLab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docxDIPESH30
 
I am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfI am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfmallik3000
 
INFO-6053 Fall 2017 Project 3 Page 1 of 6 .docx
INFO-6053 Fall 2017 Project 3 Page 1 of 6 .docxINFO-6053 Fall 2017 Project 3 Page 1 of 6 .docx
INFO-6053 Fall 2017 Project 3 Page 1 of 6 .docxjaggernaoma
 

Semelhante a srt311 Project2 (20)

3 tier architecture in asp.net
3 tier architecture in asp.net3 tier architecture in asp.net
3 tier architecture in asp.net
 
Access tips access and sql part 4 building select queries on-the-fly
Access tips  access and sql part 4  building select queries on-the-flyAccess tips  access and sql part 4  building select queries on-the-fly
Access tips access and sql part 4 building select queries on-the-fly
 
"PHP from soup to nuts" -- lab exercises
"PHP from soup to nuts" -- lab exercises"PHP from soup to nuts" -- lab exercises
"PHP from soup to nuts" -- lab exercises
 
As pnet
As pnetAs pnet
As pnet
 
Poject documentation deepak
Poject documentation deepakPoject documentation deepak
Poject documentation deepak
 
Access tips access and sql part 6 dynamic reports
Access tips  access and sql part 6  dynamic reportsAccess tips  access and sql part 6  dynamic reports
Access tips access and sql part 6 dynamic reports
 
Intro To C++ - Class 14 - Midterm Review
Intro To C++ - Class 14 - Midterm ReviewIntro To C++ - Class 14 - Midterm Review
Intro To C++ - Class 14 - Midterm Review
 
ASP DOT NET
ASP DOT NETASP DOT NET
ASP DOT NET
 
a3.pdf
a3.pdfa3.pdf
a3.pdf
 
Bt0082 visual basic
Bt0082 visual basicBt0082 visual basic
Bt0082 visual basic
 
Pruexx User's guide for beta testing
Pruexx User's guide for beta testingPruexx User's guide for beta testing
Pruexx User's guide for beta testing
 
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
 
I x scripting
I x scriptingI x scripting
I x scripting
 
Knockout in action
Knockout in actionKnockout in action
Knockout in action
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
 
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docxLab #9 and 10 Web Server ProgrammingCreate a New Folder  I s.docx
Lab #9 and 10 Web Server ProgrammingCreate a New Folder I s.docx
 
C question
C questionC question
C question
 
I am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdfI am having trouble writing the individual files for part 1, which i.pdf
I am having trouble writing the individual files for part 1, which i.pdf
 
Ad507
Ad507Ad507
Ad507
 
INFO-6053 Fall 2017 Project 3 Page 1 of 6 .docx
INFO-6053 Fall 2017 Project 3 Page 1 of 6 .docxINFO-6053 Fall 2017 Project 3 Page 1 of 6 .docx
INFO-6053 Fall 2017 Project 3 Page 1 of 6 .docx
 

Mais de trayyoo

ops300 Week5 storage
ops300 Week5 storageops300 Week5 storage
ops300 Week5 storagetrayyoo
 
ops300 Week8 practical test
ops300 Week8 practical testops300 Week8 practical test
ops300 Week8 practical testtrayyoo
 
ops300 Week8 gre
ops300 Week8 greops300 Week8 gre
ops300 Week8 gretrayyoo
 
ops300 Week9 feedback
ops300 Week9 feedbackops300 Week9 feedback
ops300 Week9 feedbacktrayyoo
 
ops300 Week10 technology evaluation
ops300 Week10   technology evaluationops300 Week10   technology evaluation
ops300 Week10 technology evaluationtrayyoo
 
ops300 Research paperrubric
ops300 Research paperrubricops300 Research paperrubric
ops300 Research paperrubrictrayyoo
 
ops300 Project(4)
ops300 Project(4)ops300 Project(4)
ops300 Project(4)trayyoo
 
ops300 Project(3)
ops300 Project(3)ops300 Project(3)
ops300 Project(3)trayyoo
 
ops300 Assignment 02
ops300 Assignment  02ops300 Assignment  02
ops300 Assignment 02trayyoo
 
ops300 Week5 storage (1)
ops300 Week5 storage (1)ops300 Week5 storage (1)
ops300 Week5 storage (1)trayyoo
 
Project papercontent requirement
Project papercontent requirementProject papercontent requirement
Project papercontent requirementtrayyoo
 
Dcn330 project papertemplate(1)
Dcn330 project papertemplate(1)Dcn330 project papertemplate(1)
Dcn330 project papertemplate(1)trayyoo
 
Dcn330 project-paper-rubric
Dcn330 project-paper-rubricDcn330 project-paper-rubric
Dcn330 project-paper-rubrictrayyoo
 
Introduction(2)
Introduction(2)Introduction(2)
Introduction(2)trayyoo
 
Report for lab 1
Report for lab 1Report for lab 1
Report for lab 1trayyoo
 
Report for lab 2(2)
Report for lab 2(2)Report for lab 2(2)
Report for lab 2(2)trayyoo
 
Report for lab 3(1)
Report for lab 3(1)Report for lab 3(1)
Report for lab 3(1)trayyoo
 
Report for lab 4 2017(1)
Report for lab 4 2017(1)Report for lab 4 2017(1)
Report for lab 4 2017(1)trayyoo
 
Report for lab 5 2017
Report for lab 5 2017Report for lab 5 2017
Report for lab 5 2017trayyoo
 
Report for lab 6 2017
Report for lab 6 2017Report for lab 6 2017
Report for lab 6 2017trayyoo
 

Mais de trayyoo (20)

ops300 Week5 storage
ops300 Week5 storageops300 Week5 storage
ops300 Week5 storage
 
ops300 Week8 practical test
ops300 Week8 practical testops300 Week8 practical test
ops300 Week8 practical test
 
ops300 Week8 gre
ops300 Week8 greops300 Week8 gre
ops300 Week8 gre
 
ops300 Week9 feedback
ops300 Week9 feedbackops300 Week9 feedback
ops300 Week9 feedback
 
ops300 Week10 technology evaluation
ops300 Week10   technology evaluationops300 Week10   technology evaluation
ops300 Week10 technology evaluation
 
ops300 Research paperrubric
ops300 Research paperrubricops300 Research paperrubric
ops300 Research paperrubric
 
ops300 Project(4)
ops300 Project(4)ops300 Project(4)
ops300 Project(4)
 
ops300 Project(3)
ops300 Project(3)ops300 Project(3)
ops300 Project(3)
 
ops300 Assignment 02
ops300 Assignment  02ops300 Assignment  02
ops300 Assignment 02
 
ops300 Week5 storage (1)
ops300 Week5 storage (1)ops300 Week5 storage (1)
ops300 Week5 storage (1)
 
Project papercontent requirement
Project papercontent requirementProject papercontent requirement
Project papercontent requirement
 
Dcn330 project papertemplate(1)
Dcn330 project papertemplate(1)Dcn330 project papertemplate(1)
Dcn330 project papertemplate(1)
 
Dcn330 project-paper-rubric
Dcn330 project-paper-rubricDcn330 project-paper-rubric
Dcn330 project-paper-rubric
 
Introduction(2)
Introduction(2)Introduction(2)
Introduction(2)
 
Report for lab 1
Report for lab 1Report for lab 1
Report for lab 1
 
Report for lab 2(2)
Report for lab 2(2)Report for lab 2(2)
Report for lab 2(2)
 
Report for lab 3(1)
Report for lab 3(1)Report for lab 3(1)
Report for lab 3(1)
 
Report for lab 4 2017(1)
Report for lab 4 2017(1)Report for lab 4 2017(1)
Report for lab 4 2017(1)
 
Report for lab 5 2017
Report for lab 5 2017Report for lab 5 2017
Report for lab 5 2017
 
Report for lab 6 2017
Report for lab 6 2017Report for lab 6 2017
Report for lab 6 2017
 

Último

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...Pooja Nehwal
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 

Último (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...Russian Call Girls in Andheri Airport Mumbai WhatsApp  9167673311 💞 Full Nigh...
Russian Call Girls in Andheri Airport Mumbai WhatsApp 9167673311 💞 Full Nigh...
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 

srt311 Project2

  • 1. Project 2 – Secure Web Forum In this project, you will be building a secure web forum. In this forum, users can create their own accounts in order to post contents into the forum. These posted contents should be checked against SQL injection as well as against XSS. Moreover, users’ passwords are only stored in hashed format using a salt. General Instructions In this forum, as it I the case for most forums, everyone can see the posts from other users. However, a user needs to sign in in order to post. All posts show the title and author at the top, and the contents just below (see Figure 1). Every time a new post is added, it should appear below the last post. This way, newer posts always appear at the bottom. In case the user has logged in, the forum should greet him/her and provide him/her with a form to enter a new post (see Figure 1 again). In case the user has not logged in, the forum should provide him/her with a form to login (see Figure 2), as well as a hyperlink that, once clicked, takes the user to a page in which he/she can create a new account (see Figure 3). Once an account has been successfully created, the user should be redirected back to the main forum page. Figure 1: Forum web page (user logged in)
  • 2. Specific Instructions For this project, you will create a web forum where users can view posts from other users, sign in, login, and create posts. To achieve this, you will have to create Python scripts to perform the actions described below. As opposed to the previous project, where students were asked to create a specific set of functions, you will have complete control about how to set up your system this time. Therefore, different students might have different sets of scripts and/or functions. Be creative! The only constraint is that your system must have a main page called forum.py. Hint: To help you with writing the dynamically generated HTML code, the output of calling forum.py while being signed in and while not being signed in is provided as static html pages. I am also providing an HTML implementation of the sign in form. Feel free to use or not these provided pages. Note that you will have to create a database with two tables: users (containing information about all user accounts) and posts (containing information about all posts). These tables should be created in MySQL in such a way that they meet all requirements imposed by the actions your system need to perform (described below). This database must be exported and submitted together with all Python scripts. I strongly advise students to put this exported database in a folder, together with all scripts, zip the entire folder, and submit this zipped folder. To export a MySQL database, you should perform the following command in your terminal: mysqldump -p -u USERNAME DATANASE_NAME > FILENAME.sql Figure 2: Forum web page (user not logged in) Figure 3: Sign in page
  • 3. a) create a new account: Each account should take only two fields: a username and a password. Passwords should be stored in a hashed format, using a SHA512 hash (including a salt). Passwords must abide to the following rules: at least one uppercase character, at least one lowercase character, and at least one number. Note that the system should prevent a new user to be added in case the username matches a username that already exists in the database. Once a new account has been successfully created, your system should load the main forum page. Your system should present meaningful error messages, whenever something does not work as planned. For example, it should let the user know that there is already a user with that username, or if the user’s password does not match the required criteria. (3.0 marks) b) login: In order to login, the user must enter his/her username and password in a form (see Figure 2). The system must check the username and password against the rows in your users table in the database. Note that passwords are stored in hashed format (using a SHA512 hash). After successfully verifying that the user has entered the proper credentials, your script should save the username and password in a cookie. Then it should load the forum page, showing again all posts, but with one major change: the user can now enter new posts (see Figure 1). Your system should present meaningful error messages whenever something does not work as planned. (3.0 marks) c) create a new post: Each post has three fields: title, contents, and author. Note that the title and contents must be provided via a form (see Figure 1), whereas the author information should be obtained by reading the username information present in the cookie that was created as the user signed in. Once a new post is created, the main forum page should be reloaded, showing this post. (3.0 marks) d) SQL injection and XSS: Your system should be secured against SQL injection and XSS. (3.0 marks) e) Code quality: 3.0 marks for this project will be assigned based on the quality of your code, based on the guidelines provided at the end of this document. (3.0 marks)
  • 4. Guidelines • Make sure to include a comment at the start of your program identifying yourself, the course, the assignment, etc. • Put a docstring inside each function and/or script to identify what the parameters represent, what the return value (if any) represents, and a one line statement of what the function does. To see what docstrings are, refer to: https://www.python.org/dev/peps/pep-0257/ • Put comments within functions, whenever you are doing something that would not be self-evident to someone reading your program. Don't put a comment on every line - too many are as bad as not enough. • Put blank lines above and below functions to separate them from each other. • Don't put in extra blank lines. (Some people put a blank lines between every line of code!) • Read and understand the specifications. If you do not understand the specifications, ask me for clarification. If you do not implement something required, you will lose marks, even if you didn't understand the requirement - i.e. it is your job to seek clarification. • Do not change the specifications. If you print something out and the assignment does not tell you to print it out, you are changing the specification and will lose marks. • Format your output to look, as much as possible, like the sample shown in the specification. The closer it looks, the better your mark will be. • Get rid of unnecessary (and confusing) duplication. For code, you can do this by factoring out common code and putting it into a function. In a regex, you can always delete {1} because it simply means the character in front of it repeats exactly once, but they always do by default! I also noticed several people were including parentheses in regexes, but they served no purpose. For example, '([0-9]{1})' is the same as '[0-9]'. Why make it look more complicated than need be? • Indent the same number of spaces. Always. • Use four spaces for each indentation group. • Develop your code anywhere you like, but make sure your code runs under Ubuntu and looks nice in Visual Studio Code or Gedit. The former is what I use to check it. • If you develop your code in Windows, don't submit it without testing it on Ubuntu. Transferring source files from Windows to Linux requires transferring them in ASCII mode - and dragging and dropping often transfers files in binary mode. If transferred in binary mode, you will get extra characters in your file and the Python interpreter won't understand, and your program will crash.
  • 5. • Do not leave external resources "open" when your program terminates (i.e. close all file objects). • Do not open and close a resource every time you want to write something to it if you are doing so in a tight loop. Open it before the loop, and close it after the loop. • Make sure your code is efficient. There are multiple ways to accomplish the same result. However, some ways are clearly inefficient. For example, iterating over a list twice or three times, when the task could have been done iterating over it only once is clearly an example of inefficiency. • Use meaningful names for your variables. For example if you have a variable that stores a set of users, it is better to name it user_set instead of var37. • Do not create variables to hold values from the outputs of functions if these values are only used once. For example, given that the output of a function called func1 needs to be used as an input argument to a function called func2, you shoud write your code as: func2(func1()) instead of unnecessary_var = func1() func2(unnecessary_var)