Redistribution utility

Description

This utility allows a user to create a new MAT distribution with a new or updated task in it, based on an existing MAT distribution.

Warning: because the distribution layout changed in MAT 3.2, this utility may only be used with source and dependent distributions of MAT 3.2 or later. For versions before MAT 3.2, use the utility distributed with that version.

Usage

This utility can only be run on Unix, due to its internal use of Unix command-line operations. It will not work in Cygwin, since MAT is no longer supported on Cygwin.

% python $MAT_PKG_HOME/build/redistribute.py
Usage: redistribute.py [ --populate_dependencies_from <zipfile> ] [ --remove_task <task_dir> ]+ [ --task_dir <dir>[:<git_version>[:<dist_settings>]] ]+ orig_dist_zip outdir bundle_name

Options

--populate_dependencies_from <zipfile>
A MAT distribution zip file which contains third-party dependencies which you want to import into the new distribution. This might be useful if you generated the original zip file with only MITRE code, for instance. Any known third-party dependencies in this zip file which aren't present in the orig_dist_zip will be added to the new distribution.
--task_dir <dir>[:<git_version>[:<dist_settings>]]
The directory containing a well-structured MAT task, plus other possible control options (see below). May be repeated. If there is already a task directory in the existing distribution named <dir>, it will be removed and replaced with this one.
--remove_task <task_dir>
The <task_dir> is a directory within src/tasks in the zip file. May be repeated. If you provide this argument, this directory, and the task it corresponds to, will be removed from the output distribution.
orig_dist_zip
A path to the original MAT zip file which you received
outdir
The directory in which to deposit the new distribution
bundle_name
The name of the new distribution (the actual zip file will be <bundle_name>.zip, and the name of the toplevel directory in the zip file will be bundle_name.

The additional decorations to the --task_dir option are as follows:

<git_version>
If you maintain the task you want to add or update under git version control, git this is the  tag you want. This facility is not available for any other version control system. If you provide this option, the tool will check out this version from the git repository using the git information in the task directory, rather than using the code in the directory.
<dist_settings>
A comma-separated sequence of <key>=<val> settings, which are passed to the distribute function in the dist.py file in your task, if such a file and function exist. We provide this information for completeness; we do not provide any further details as of right now about how to customize your distribution using this facility. See the source code for redistribute.py.

Example 1

Let's say you received the distribution /my/downloads/MAT_3_2.zip, and you want to add the /path/to/myTask directory, creating the distribution /my/dist/MAT_3_2_plus_myTask.zip:

% python $MAT_PKG_HOME/build/redistribute.py --task_dir /path/to/myTask \
/my/downloads/MAT_3_2.zip /my/dist MAT_3_2_plus_myTask

Example 2

Let's say you received /my/downloads/MAT_3_2_plus_myTask.zip, and you want to remove myTask from the package you create:

% python $MAT_PKG_HOME/build/redistribute.py --remove_task myTask \
/my/downloads/MAT_3_2_plus_myTask.zip /my/dist MAT_3_2_without_myTask