Lab Exercise 1 - SVF-tools/Software-Security-Analysis GitHub Wiki
Lab-Exercise-1 folder layout
$tree Lab-Exercise-1
βββ GraphAlgorithm.cpp
βββ GraphAlgorithm.h
βββ test.cpp
βββ CMakeLists.txt
1. Get the latest Lab-Exercise-1 code template
cd $HOME/Software-Security-Analysis
and git pull
in your terminal to make sure you always have the latest version of the code template before coding.
* Before coding, please type If git pull
fails due to the conflict with your local changes, type git stash
to store your current code in a temporal branch and type git pull
again. If you want to retrieve your code back, type git stash pop
.
2. Lab-Exercise-1 coding task
- Implement the following methods of class
GraphAlgorithm
inGraphAlgorithm.cpp
.
Function | Description | Marks |
---|---|---|
reachability |
DFS to traverse and record each path from src to dst (each node appear at most once on each path) |
50% |
solveWorklist |
Constraint solving to mimic Andersenβs inclusion-based points-to analysis | 50% |
- Hints for implementing
solveWorklist
. Each node on theCGraph
represents a pointer andgetPts
retrieves the points-to set of a node. The implementation requires iterative solving based on the following rules by (1) propagating points-to sets among nodes onCGraph
, and (2) adding new COPY edges until a fixed point is reached (i.e., no new copy edges are added). Note that the graph will become larger with newly added COPY edges once the solving reaches the convergence (no need to delete those edges at the end).
C-like form | Constraint form | Solving rule | Explaination |
---|---|---|---|
p = &o | p <--ADDR-- o | pts(p) = pts(p) βͺ {o} | add o into p 's points-to set |
q = p | q <--COPY-- p | pts(q) = pts(q) βͺ pts(p) | union p 's points-to set into q 's one |
q = *p | q <--LOAD-- p | for each o β pts(p) : add q <--COPY-- o | for each o in p 's points-to set, add a COPY edge from o to q (if it is not on the graph) |
*p = q | p <--STORE-- q | for each o β pts(p) : add o <--COPY-- q | for each o in p 's points-to set, add a COPY edge from q to o (if it is not on the graph) |
- To test your implementation, run
ctest -R lab1 -VV
and pass the test without any assertion bytest.cpp
- Upload
GraphAlgorithm.cpp
to UNSWWebCMS
for your submission when you are finished with this lab. Your implementation will be evaluated against our internal tests. You will get the full marks if your code can pass them all. Unfortunately, internal tests are private. Here, we only provided two test cases intest.cpp
. It does NOT mean that your solution is correct, even if you pass these two tests. You are encouraged to add more test cases by yourself to validate the correctness of your implementation.
GraphAlgorithm.cpp
only and there is NO need to modify other files under the Lab-Exercise-1 folder
*You will be working on 3. Configuration && debugging
launch.json
3.1To enable debugging and running, switch your executable by setting the program
and args
fields as described here or follow the below screenshot.
3.2 Debug your code
*If there is an assertion or unexpected output, you will need to debug and find bugs.
Step 1: Set the breakpoint where you want to stop your program and press the 'debug' button
Step 2: 'Step over' /'Step in' / 'Step out'
- 'Step over' to the next step of your program
- 'Step in' to the current line of your program
- 'Step out' to mainstream of your program where you stepped in before