Work on this exercise locally

This web app is a reference guide — you can read instructions, browse starter code, and view tests here. To actually complete the exercise, you need to work in your local development environment.

1Clone the repo: git clone https://github.com/weihaoqu/program-analysis-bootcamp-student
2Edit the starter file in your editor (VS Code, Vim, etc.) — replace failwith "TODO" with your implementation.
3Run the tests: dune runtest modules/module1-foundations/exercises/analysis-comparison

Analysis Comparison

4. Exercise 2: Analysis Comparison

Goal: Classify 15 code snippets (in Python, JavaScript, Java, and C) by what kind of issue they contain and which analysis technique would detect it.

Time: ~15 minutes

Files:

FilePurpose
exercises/analysis-comparison/starter/code-samples.md15 code snippets -- read this
exercises/analysis-comparison/starter/classification-template.mdYour answers -- fill this out

What to do

  1. Open code-samples.md and read each snippet carefully.

  2. For every snippet, fill in one row of the table in classification-template.md:

    ColumnWhat to write
    Issue DescriptionWhat is wrong or risky in this code
    ObjectiveCorrectness, Security, or Performance
    Detection MethodStatic, Dynamic, or Both
    Explanation1--2 sentences on why you chose that classification
  3. Answer the summary questions at the bottom of the template.

Tips

  • SQL injection and command injection are Security issues.
  • Unreachable code and off-by-one errors are Correctness issues.
  • Unbounded caches and redundant loops are Performance issues.
  • Some issues can be detected statically (by examining source code), some require dynamic execution, and some can be found either way.

Self-check

  • All 15 rows should be filled in.
  • The summary counts should add up to 15 total.
  • Review your classifications against the lecture notes on static vs dynamic analysis to see if your reasoning holds up.