SI485H: Stack Based Binary Exploits (SP17)


Home Policy Calendar Units Assignments Resources

Submission and git Instructions

Forking Repositories and Submitting Assignments

All assignments for this class will be based around git repositories. The workflow of an assignment will be:

  1. You fork the repository in gitlab
  2. Clone you fork to your local directory
  3. Work and complete the assignment and commit any changes locally
  4. Once you finish, creating a branch named "submit" which will be your submission
  5. Push your submit branch to gitlab where I will have access

Forking a repository

First you must find a repository to clone, from your welcome screen, click browse button to view available projects. These will propagate as assignments are assigned throughout the semester.

git-browse-projects.png

One the next screen, you may need to select the buttom "Explore Projects" and "All" after which you will see a list of public projects. (Note: No project you create/own should ever be set for public or internal viewing).

git-project-list.png

Click on a project your interested in, which in this case will be the test-project. On the project page you may see some information about the project, but most importantly is the fork button:

git-project-page.png

Once you've clicked it, a screen will come up listing your username, click on yourself.

git-pre-fork.png

Go ahead and click fork, and then click on your username. Now, you have a version of the project that is all yours.

Cloning the repository to your local machine

To work on the project, you'll need to clone the repository to your local machine. If you look in you newly forked project, you'll see this screen:

git-project-dashboard.png

Copy that link to the terminal on your local VM where you wish to work and issue the git clone command:

m179999@si485h-base:~$ git clone git@saddleback.academy.usna.edu:m179999/test-project.git
Cloning into 'test-project'...
Ubuntu 16.04.1 LTS
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
Checking connectivity... done.

In the current directory, you'll see a directory for the repository and any files:

m179999@si485h-base:~$ ls
test-project
m179999@si485h-base:~$ cd test-project/
m179999@si485h-base:~/test-project$ ls
README.md

Currently, there is only a README.md file, but we will add some new items to this test project.

Add, Commit, Push, Pull

Now that you have a version of the assignment to work, go ahead and do that. But, you might want to save your work along the way. To do that, you'll need to commit your changes locally, and then push those changes to the remote repository on gitlab and pull any changes from remote repository.

For example, consider the requirement to add a new file to the repository or edit a file. In this case, we are adding a helloworld.txt file.

m179999@si485h-base:~/test-project$ echo "Hello, World" > helloworld.txt
m179999@si485h-base:~/test-project$ cat helloworld.txt 
Hello, World

The file is currently not a tracked file, which means that if we use the git status it will list it as untracked.

m179999@si485h-base:~/test-project$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

  helloworld.txt

nothing added to commit but untracked files present (use "git add" to track)

You can add it to those files being tracked by using the git add command:

m179999@si485h-base:~/test-project$ git add helloworld.txt 
m179999@si485h-base:~/test-project$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

  new file:   helloworld.txt

It is now identified as a new file. The changes are still not committed, though, and to do that you use the git commit command. We will include the -m option to specify a message; alternatively, an editor will be displayed for the message if the option is omitted.

m179999@si485h-base:~/test-project$ git commit -m "adding helloworld.txt"
[master f4e561a] adding helloworld.txt
 1 file changed, 1 insertion(+)

At this point, the local changes are committed to the local repository. However, these changes are not merged with remote repository at gitlab. For that, we must push the changes to origin.

m179999@si485h-base:~/test-project$ git push origin master
Ubuntu 16.04.1 LTS
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 297 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@saddleback.academy.usna.edu:m179999/test-project.git
   bed94a9..f4e561a  master -> master

The phrase "origin master" refers to the origin repository, the one you cloned from gitlab for the master branch. That is the primary branch for all repositories. When you do a submit, you'll create a new branch that you'll push to the origin to indicate you've completed the assignment.

Now if you were to edit a tracked file, you can do the same process of adding it to be staged for commit, committing it, and then pushing the changes to the origin master.

m179999@si485h-base:~/test-project$ echo "More Hellos" >> helloworld.txt 
m179999@si485h-base:~/test-project$ cat helloworld.txt 
Hello, World
More Hellos
m179999@si485h-base:~/test-project$ git add helloworld.txt 
m179999@si485h-base:~/test-project$ git commit -m "another update"
[master 33fbc58] another update
 1 file changed, 1 insertion(+)
m179999@si485h-base:~/test-project$ git push origin master
Ubuntu 16.04.1 LTS
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 301 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@saddleback.academy.usna.edu:m179999/test-project.git
   f4e561a..33fbc58  master -> master

Further, if you were to go to gitlab project page for your forked project, you'll see a record of your activity under the activity page.

git-project-activity.png

Creating a new branch and submitting

Let's suppose you've completed the assignment and now you want to submit. To submit, you must create a new branch of the master with the name "submit". This is quite simple:

m179999@si485h-base:~/test-project$ git branch submit

This will create a "local copy" of all the files tracked separately from the master branch. You can see all the branches by just using branch:

m179999@si485h-base:~/test-project$ git branch
* master
  submit

And you can see that we are still on the master branch. If we wish to edit the other branch we have to "checkout" the new branch:

 m179999@si485h-base:~/test-project$ git checkout submit
 Switched to branch 'submit'
 m179999@si485h-base:~/test-project$ git branch
  master
* submit

Now any changes you make will be tracked on the submit branch not the master. Since you should only be branching at the very end for submitting, you shouldn't need to checkout a branch other than the master; however, as you get better at using git, you might want to do some more advanced things, so it is good to know this information. So let's go back to the master branch:

m179999@si485h-base:~/test-project$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
m179999@si485h-base:~/test-project$ git branch
* master
  submit

Now, to submit, we must push the submit branch to the origin, namely gitlab:

m179999@si485h-base:~/test-project$ git push origin submit
Ubuntu 16.04.1 LTS
Total 0 (delta 0), reused 0 (delta 0)
To git@saddleback.academy.usna.edu:m179999/test-project.git
 * [new branch]      submit -> submit

You've pushed the submit branch to the origin, and you can check that it is there by looking at the project paged post submit, seeing that there are two branches.

git-project-dashboard-post-submit.png

Clicking on the branch tab, you see that there is a submit branch.

git-branches.png

The last step in a submission (DO NOT FORGET)

HOWEVER YOU HAVE NOT OFFICIALLY SUBMITTED UNTIL YOU ADD ME AS A MEMBER OF THE PROJECT. To do that select members and add members to your project:

git-add-member.png

Then select my user name and give me reporter access

git-add-aviv.png

This will notify me of the submission by email. Once I've graded teh project, I will insert a message describing the completion, and will remove myself as a reporter. You can keep updating the submit branch at any time, and re-add me as a reporter. I will reassess all the submission on each submit time and provide grading at the assessment date.