Autopsy Developer Documentation  4.12.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
Regression Testing in Autopsy

Introduction

The autopsy/test folder contains scripts that are necessary to run the regression test. Developers that are interested in running regression tests should run autopsy/test/script/regression.py. This guide will familiarize you with regression.py and walk you through a simple example at the end.

From a bird’s eye view, regression.py will:

What’s important is that regression.py will enable you to isolate changes that you may have caused while developing and adding features.

Regression.py is also responsible for producing and saving gold standards for you. This allows your gold standards to evolve as your source code changes. In the following sections, we will learn how to accomplish this and what regression.py will need to know in order to run smoothly.

General

Regression.py will use the most recent Autopsy and Sleuthkit builds as a launching point. To ensure that your latest changes are included, you will need to make sure you build.

Terminology

Before we jump in, let's start off by defining some common terminology.

Parameter Descriptions

Now that we have defined some common terminology, we can move on to learning which command line arguments regression.py can recognize. A regression test (one that may produce diffs) is the default unless otherwise specified. One and only one of the bolded arguments is required.

Creating a Config File

The config file is essential to giving regression.py the details it needs to run. This file is simply an XML file with some expected tag names. We’ll dive into the tag names and their descriptions in the Tag Definitions section. But first, let’s start by taking a look at a template.

Template

Here is a complete config file template:

1 <?xml version="1.0" encoding="ASCII"?>
2 <!-- Configuration File for Regression Testing -->
3 <Properties>
4  <build value="..\..\Testing"/>
5  <!-- List all the images you would like to run through ingest. -->
6  <image value="path/to/my/first/test/image.img"/>
7  <image value="path/to/my/second/test/image.001"/>
8  <!-- Logical File Set -->
9  <image value="path/to/my/third/test/documents_folder"/>
10 
11  <singleUser_golddir value="path/to/my/gold/dir/single_user"/>
12  <singleUser_outdir value="path/to/my/output/dir"/>
13 
14  <!-- Consider execution time as a test metric -->
15  <timing value="True"/>
16 
17  <!-- Multi-user case settings -->
18  <multiUser_outdir value="\\YourSharedDriveName\path\to\output\dir"/>
19  <multiUser_golddir value="path/to/my/gold/dir/multi_user"/>
20 
21  <!--Please input the PostgreSQL database connection information.-->
22  <dbHost value="myDBHostName"/>
23  <dbPort value="myDBPortNumber"/>
24  <dbUserName value="myDBUsername"/>
25  <dbPassword value="myDBPassword"/>
26 
27  <!--Please input the Solr connection information.-->
28  <solrHost value="mySolrHostName"/>
29  <solrPort value="mySolrHostPortNumber"/>
30 
31  <!--Please input the ActiveMQ connection information.-->
32  <messageServiceHost value="myActiveMQHostName"/>
33  <messageServicePort value="myActiveMQPortNumber"/>
34 
35  <!-- Indicate the type of test to run (single, multi, or both) -->
36  <userCaseType value="Both-user"/>
37 </Properties>

Tag Definitions

With our template above, let’s break down what some of these tags mean:

Simple Example

Now that we are familiar with the parameter types and config file definitions, let's walk through a simple example. In this example, we are going to do a rebuild to establish our gold standards, introduce a regression, and discover it by running a test and examining the diffs.

Workspace

Here is how our workspace is set up:

regression_example_workspace-env.PNG

Config File

Here is the config file we will be using for our regression testing. This file is located in the autopsy_regression_config folder.

1 <?xml version="1.0" encoding="ASCII"?>
2 <!-- Configuration File for Regression Testing -->
3 <Properties>
4  <image value="C:\test-env\small2.img"/>
5  <build value="..\..\Testing"/>
6 
7  <singleUser_golddir value="C:\test-env\autopsy_single_gold"/>
8  <singleUser_outdir value="C:\test-env\autopsy_single_output"/>>
9 
10  <userCaseType value="Single-user"/>
11 </Properties>

Rebuilding Gold Standards

In order to produce diffs, we need to first establish gold standards. We can do this by performing a rebuild (see -r in Parameter Descriptions).

Let’s run the following command from within autopsy/test/script directory.

regression_example_rebuild-command.PNG

This will instruct regression.py to make gold standards using our config file.

Regression.py is going to start ingesting the images found in the config file one by one from top to bottom. An ant command will be printed to console so we can see exactly what is being run. The Autopsy UI should become visible shortly after. Refrain from clicking on anything as this may interrupt the regression process.

When this process is complete, the directory specified in <singleUser_golddir> should be populated with our gold standards. Here is what our folder looks like after the rebuild:

regression_example_gold-dir.PNG

Performing a Regression Test

Now that we have our gold standards, it’s time to start our development cycle. Let's pretend we accidentally introduced a MIME type regression. All MIME types that were once text/plain are now mistakenly labeled as text/error-plain. Using the diffs that regression.py will produce, we can catch this before it becomes a problem.

Let’s run the following command from within the autopsy/test/script directory.

regression_example_run-command.PNG

This will instruct regression.py to run a regression test using our config file.

Like the rebuild, an ant command will be printed to console so we can see exactly what is being run. Autopsy should become visible shortly. Refrain from clicking on anything as this may interrupt the regression process.

After completing on an image, Autopsy will disappear and you will be presented with a brief summary of the results (which may take some time to compute). Diffs that did not pass will be located in the output directory of the image. This process will continue for all images in the config file.

Since we only had one image in our config file and we ran in single-user mode, regression.py is finished. As expected, our case database diffs did not pass:

regression_example_diff-failure.PNG

We’ll learn how to examine our diffs in the next section.

Examining the Diffs

Let’s start by opening up our output folder:

regression_example_output-folder.PNG

Each timestamp corresponds to the start of a regression or rebuild run. The most recent folder is where our latest diff will be contained. A folder named “small2” will be in this directory. Diff files will be stored at the top level of the image directory.

As expected, there is a DBDump-Diff file waiting for us.

regression_example_case-output-folder.PNG

We can examine our regressions by opening this file in Notepad++:

regression_example_diff.PNG

Since our dumps are INSERT statements from the database, we can see exactly which files have changed.

A line that’s preceded by a “<” indicates the record in the gold standard. A line that’s preceded by a “>” indicates the record in the current dump. As you can see on the second line, our MIME type was mistakenly changed. In the event that this change was correct, we can overwrite our current gold standards by running another rebuild (see -r in Parameter Descriptions).


Copyright © 2012-2021 Basis Technology. Generated on Tue Feb 22 2022
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.