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.
git clone https://github.com/weihaoqu/program-analysis-bootcamp-studentfailwith "TODO" with your implementation.dune runtest modules/module6-tools-integration/exercises/configurable-pipelineConfigurable Pipeline
5. Exercise 4: Configurable Pipeline (18 tests)
Goal: Build a configuration-driven pipeline that selects analysis passes and filters results by severity, category, and count.
Time: ~25 minutes
File to edit: exercises/configurable-pipeline/starter/pipeline.ml
Also provided (do not edit):
pass_registry.ml-- complete working implementations ofsafety_pass,taint_pass, anddead_code_passsign_domain.ml,taint_domain.ml-- abstract domainsfinding_types.ml-- unified finding typessample_programs.ml-- test programs
Dependencies: abstract_domains, shared_ast
Important: default_config crashes immediately
Unlike other exercises where failwith "TODO" only triggers when tests call the
function, default_config is a module-level value (not a function). This
means it is evaluated when the module loads, which happens before any tests run.
As a result, the starter output is:
Fatal error: exception Failure("TODO: default_config")
Implement default_config first to unblock all 18 tests.
Types provided (not a TODO)
type pass_id = DeadCode | Safety | Taint
type pipeline_config = {
enabled_passes : pass_id list;
min_severity : Finding_types.severity;
max_findings : int option; (* None = no cap *)
target_categories : Finding_types.category list option; (* None = all *)
}
What to implement (in order)
| # | Function | Hint |
|---|---|---|
| 1 | default_config | All passes enabled [DeadCode; Safety; Taint], min_severity = Info, max_findings = None, target_categories = None |
| 2 | config_with_passes passes | Start from default_config, override enabled_passes |
| 3 | config_with_severity sev config | Return { config with min_severity = sev } |
| 4 | config_with_max n config | Return { config with max_findings = Some n } |
| 5 | config_with_categories cats config | Return { config with target_categories = Some cats } |
| 6 | create_pass pid | Map DeadCode -> Pass_registry.dead_code_pass, Safety -> Pass_registry.safety_pass, Taint -> Pass_registry.taint_pass |
| 7 | build_pipeline config | List.map create_pass config.enabled_passes |
| 8 | apply_filters config findings | Four steps in order: (1) filter by min_severity, (2) filter by target_categories if Some, (3) sort by severity (highest first), (4) take first max_findings if Some |
| 9 | run_pipeline config prog | Build the pipeline, run all passes (concatenating findings), then apply filters |
Run tests
dune runtest modules/module6-tools-integration/exercises/configurable-pipeline/
Starter output (crashes before tests run):
Fatal error: exception Failure("TODO: default_config")
Hints:
- For
apply_filters, useList.filterior a helper to take the first N elements when capping atmax_findings. - The severity filter keeps findings where
Finding_types.severity_to_int f.severity >= Finding_types.severity_to_int min_severity. - The sort puts the highest severity first (descending order).
Starter Files
Test Files
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.
git clone https://github.com/weihaoqu/program-analysis-bootcamp-studentfailwith "TODO" with your implementation.dune runtest modules/module6-tools-integration/exercises/configurable-pipelineConfigurable Pipeline
5. Exercise 4: Configurable Pipeline (18 tests)
Goal: Build a configuration-driven pipeline that selects analysis passes and filters results by severity, category, and count.
Time: ~25 minutes
File to edit: exercises/configurable-pipeline/starter/pipeline.ml
Also provided (do not edit):
pass_registry.ml-- complete working implementations ofsafety_pass,taint_pass, anddead_code_passsign_domain.ml,taint_domain.ml-- abstract domainsfinding_types.ml-- unified finding typessample_programs.ml-- test programs
Dependencies: abstract_domains, shared_ast
Important: default_config crashes immediately
Unlike other exercises where failwith "TODO" only triggers when tests call the
function, default_config is a module-level value (not a function). This
means it is evaluated when the module loads, which happens before any tests run.
As a result, the starter output is:
Fatal error: exception Failure("TODO: default_config")
Implement default_config first to unblock all 18 tests.
Types provided (not a TODO)
type pass_id = DeadCode | Safety | Taint
type pipeline_config = {
enabled_passes : pass_id list;
min_severity : Finding_types.severity;
max_findings : int option; (* None = no cap *)
target_categories : Finding_types.category list option; (* None = all *)
}
What to implement (in order)
| # | Function | Hint |
|---|---|---|
| 1 | default_config | All passes enabled [DeadCode; Safety; Taint], min_severity = Info, max_findings = None, target_categories = None |
| 2 | config_with_passes passes | Start from default_config, override enabled_passes |
| 3 | config_with_severity sev config | Return { config with min_severity = sev } |
| 4 | config_with_max n config | Return { config with max_findings = Some n } |
| 5 | config_with_categories cats config | Return { config with target_categories = Some cats } |
| 6 | create_pass pid | Map DeadCode -> Pass_registry.dead_code_pass, Safety -> Pass_registry.safety_pass, Taint -> Pass_registry.taint_pass |
| 7 | build_pipeline config | List.map create_pass config.enabled_passes |
| 8 | apply_filters config findings | Four steps in order: (1) filter by min_severity, (2) filter by target_categories if Some, (3) sort by severity (highest first), (4) take first max_findings if Some |
| 9 | run_pipeline config prog | Build the pipeline, run all passes (concatenating findings), then apply filters |
Run tests
dune runtest modules/module6-tools-integration/exercises/configurable-pipeline/
Starter output (crashes before tests run):
Fatal error: exception Failure("TODO: default_config")
Hints:
- For
apply_filters, useList.filterior a helper to take the first N elements when capping atmax_findings. - The severity filter keeps findings where
Finding_types.severity_to_int f.severity >= Finding_types.severity_to_int min_severity. - The sort puts the highest severity first (descending order).