Sie sind auf Seite 1von 6

KF5006 Applied Programming Assignment

Learning outcomes:

Knowledge & Understanding:


1. Demonstrate knowledge and critical understanding of the essential facts, concepts, principles,
theories, challenges and techniques for developing software applications in the fields of
Cybersecurity, Computer Forensics or Computer Networking.

2. Apply knowledge and understanding of techniques and tools to solve complex computer-based
problems.

Intellectual / Professional skills & abilities:


3. Identify and analyse problems and select and apply effective methods and tools for their solution.
4. Use a range of tools, knowledge and technologies in the development of computing applications. 5.
Design, build, test and evaluate a prototype product or service for a specific computing problem
domain.

Personal Values Attributes:


6. Effectively communicate information and analysis, using professional documentation techniques.

Assessment criteria and deliverables required:


• Code Documentation (15 marks)
• Code Functionality and style (45 marks)

A more detailed marks breakdown can be found on page 5.

Introduction

During semester 1 and the beginning of semester 2 you have been introduced to the following:

1) Code Organisation across files.


2) Code style and a style guide for this module.
3) Software and techniques to enable automatic documentation.
4) A systematic methodology for designing functions.
5) Tools for debugging code.
6) The memory structure of a running program.
7) Buffer overflows.
8) Dynamic memory allocation.

During the course of 8 lab sessions you have had significant exposure to the tools and techniques that
you will need to fulfil the requirements of this assignment. You are to use this knowledge to design a
piece of software that is professionally documented and tested, and will run without modification on a
lab PC with Ubuntu 16.04 installed.

Software Specification tasks:

NOTE: All code should comply with the KF5006 style guide as provided on the e-learning platform.

2
KF5006 Applied Programming Assignment

In week 4 of semester 1 you were provided with some source code (get_links.c) and you were
asked to style this code according to the style guide provided. A styled version of this code without
comments is provided on the e-learning platform get_links_styled.c.

Task 1: You have since learned during the lectures on dynamic allocation of memory that it is not a
good idea to use malloc() within a function and return a pointer to that memory from the function.
Therefore redesign the source code to make sure that any dynamic allocation of memory is done
before the call to the get_sub_strings() function, by the user of that function. Also make sure
that the allocation of memory uses free() accordingly. (You should use a piece of software called
valgrind to check for memory leaks). Fully test and document the test results as shown in Appendix
1 of this assignment brief.

Task 2: The code uses a constant buffer size of 100. This is the assumed character length of a line of
text read from a web page. This is a reasonable assumption, but if the software is to be scalable, it is
better to determine the length of the line at run-time. Use malloc() to allocate the memory for the
character array named buff. Fully test and document the test results as shown in Appendix 1.

Task 3: In weeks, 4 and 5 of semester 1 you tested the code with some carefully chosen tests and each
test was successful. The tests were chosen to ensure that the opening and closing angle brackets of the
html anchor <a> tag were on the same line. If these angle brackets are not on the same line, the
software does not work as expected. Test the program with the following:

$ ./get_links
This is a test <a href=”www.google.com”

You should get a segmentation fault, because there is no > in this text. You can check to see why this
is using the gdb debugger. This is an issue with the way the program is designed, as it assumes that
the end > of the anchor tag will be on the same line as the beginning <a. This highlights the need for
testing beyond the test suggestions in any comments we provide! As the purpose of the program is to
get the links that are present in the file, a better solution would be to get substrings after href= and
between the quotes “” . Modify the code to do this and make sure you test it thoroughly and document
your test results as shown in Appendix 1.

Task 4: The code that you have written so far is all in one file. Relocate the functions and prototypes
into separate files and include these in the file containing main(). Make sure you fully document and
test your code again using the same tests as in Task 3, adding a column to your test documentation.

Task 5: The get_links.c code uses the following functions from the <string.h> library:

strlen()
strstr() strchr()

Write your own versions of these functions with buffer overflow mitigation in mind. Use your initials
in the function name, for example here the students name was Bob Smith:

str_n_len_bs()
str_n_str_bs() str_n_chr_bs()

Fully document your functions using an automated documentation tool (Doxygen). Once each has
been tested in isolation, include them in you separate files from Task 4. NOTE: The module tutors are
active on sourceforge.net and other similar sites, copying code is wholly unacceptable, and therefore

3
KF5006 Applied Programming Assignment

this must be your version of these functions. If you are unable to complete any part of this task then
use the <string.h> header and the original version, of whichever function you cannot manage, to
make sure the code runs. Fully test and document the test results as shown in Appendix 1.

Task 6: By default, the user of the code produced so far can redirect the output of your program to a
text file, and also redirect the output of curl to your program and then into a text file. In the final task
you should create a separate program that takes in a URI and checks that URI to determine the
response from the server i.e. 200, 404 etc. The output of your program should be the original URI
along with the response code and some text indicating what the response code means. Your program
should read input line by line until an EOF or a CTRL+C is detected (HINT: This is what get_links
does). Fully test any functions in isolation and document the tests. Fully test the program using URIs
typed in by the user and document the tests. Finally fully test and document the program by piping the
output of your get_links program into it and redirecting the output to a text file.

input Expected output Actual output Passed


http://www.google.com http://www.google.com 301 MOVED http://www.google.com 301 MOVED ✓

https://www.bbc.co.uk https://www.bbc.co.uk 200 OK https://www.bbc.co.uk 200 OK ✓

Etc..etc . . . . . .

NOTE: When documenting test results and the output is substantial, you can just summarise what is
expected and what the actual output was.

input Expected output Actual output


curl https://curl.haxx.se/docs/manual.html List of all links tested from Issue with some links not being
| ./get_links_bs | ./test_links_bs https://curl.haxx.se/docs/manual.html listed

Etc..etc . . . . . .

You are to submit 3 files (all filenames should be lower case):

File 1. You are to submit a pdf version of your documentation, for all of the code that you managed to
complete, as generated by an automated documentation tool (generate an rtf file and convert this to
PDF). The file should have the following name:

<your first initial>_<your second name>_KF5006_A_2019.pdf

You should use the cover page shown in appendix 2 for the front of your documentation. You are
allowed to alter the generated rtf file by hand if you feel you can supplement the generated
documentation.

File 2. You are to submit your full testing documentation for each of the tasks, an example of which is
shown in appendix 1. The file should have the following name:

<your first initial>_<your second name>_KF5006_T_2019.pdf

File 3. You are to submit a zip archive of your code, named:

4
KF5006 Applied Programming Assignment

<your first initial>_<your second name>_KF5006_C_2019.zip

The examiner should be able to unzip and test the code in Ubuntu 16.04 using the following
commands (example assumes student named Bob Smith):

$ unzip b_smith_KF5006_C_2019.zip -d b_s_testfolder $ cd b_s_testfolder $ gcc –Wall get_links_bs.c


string_bs.c –o get_links_bs $ gcc –Wall test_links_bs.c string_bs.c –o test_links_bs
$ curl https://curl.haxx.se/docs/manual.html | ./get_links_bs | ./test_links_bs > tested_links_bs.txt

Marking Scheme

This assignment consists of two parts, the documentation and the code. The documentation constitutes
15% of the marks for the module broken down as:
Documentation Marks: Max Score

Task 1 2

Task 2 2

Task 3 2

Task 4 2

Task 5 5

Task 6 2

Total 15

The code constitutes 45% of the marks for the module broken down as:
Code Marks Max Score

Task 1 5

Task 2 3

Task 3 7

Task 4 5

Task 5 15

Task 6 10

Total 45

Note: Marks will be subtracted in each case for not meeting the style guide requirements.

5
KF5006 Applied Programming Assignment

APPENDIX 1

input Expected output Actual output Passed



KF5006 Applied Programming Assignment

Das könnte Ihnen auch gefallen