diff --git a/data/recipes/aws_forensics.json b/data/recipes/aws_forensics.json index 51f9afdce..2e67faecf 100644 --- a/data/recipes/aws_forensics.json +++ b/data/recipes/aws_forensics.json @@ -2,6 +2,7 @@ "name": "aws_forensics", "short_description": "Copies a volume from an AWS account to an analysis VM.", "description": "Copies a volume from an AWS account, creates an analysis VM in AWS (with a startup script containing installation instructions for basic forensics tooling), and attaches the copied volume to it.", + "test_params": "default us-east-1 incident_id --instance_id i-01234567 --volume_ids vol-01234567", "modules": [{ "wants": [], "name": "AWSCollector", @@ -26,7 +27,7 @@ ["--instance_id", "Instance ID of the instance to analyze.", null, {"format": "regex", "comma_separated": false, "regex": "^i-[0-9a-f]{8,17}$"}], ["--volume_ids", "Comma-separated list of volume IDs to copy.", null, {"format": "regex", "comma_separated": true, "regex": "^vol-[0-9a-f]{8,17}$"}], ["--all_volumes", "Copy all volumes in the designated instance. Overrides volume_ids if specified.", false], - ["--boot_volume_size", "The size of the analysis VM boot volume (in GB).", 50, {"format": "regex", "regex": "^\\d+$"}], + ["--boot_volume_size", "The size of the analysis VM boot volume (in GB).", "50", {"format": "regex", "regex": "^\\d+$"}], ["--analysis_zone", "The AWS zone in which to create the VM.", null, {"format": "aws_region"}], ["--analysis_profile_name", "Name of the AWS profile to use when creating the analysis VM.", null] ] diff --git a/dftimewolf/lib/resources.py b/dftimewolf/lib/resources.py index 686a604e5..f570da91a 100644 --- a/dftimewolf/lib/resources.py +++ b/dftimewolf/lib/resources.py @@ -62,3 +62,6 @@ def GetHelpString(self) -> str: short_description = self.contents.get( 'short_description', 'No description') return ' {0:<35s}{1:s}\n'.format(self.name, short_description) + + def GetTestParams(self) -> list[str]: + return self.contents.get('test_params', '').split(' ') diff --git a/tests/cli/main_tool.py b/tests/cli/main_tool.py index f4843a1b2..13ad94866 100644 --- a/tests/cli/main_tool.py +++ b/tests/cli/main_tool.py @@ -70,7 +70,7 @@ def _EnumerateRecipeNames(): tool = _CreateToolObject() # pylint: disable=protected-access for recipe in tool._recipes_manager.GetRecipes(): - yield (recipe.name, recipe.name) + yield (f'_{recipe.name}', recipe.name) class MainToolTest(parameterized.TestCase): @@ -140,6 +140,9 @@ def _testRecipeValidators(self, recipe_name): self.tool._state = dftw_state.DFTimewolfState(config.Config) recipe = self.tool._recipes_manager.Recipes()[recipe_name] + recipe_args = [recipe_name] + recipe.GetTestParams() + self.tool.ParseArguments(recipe_args) + self.tool._state.LoadRecipe(recipe.contents, dftimewolf_recipes.MODULES) for arg in recipe.args: if arg.validation_params: @@ -148,6 +151,8 @@ def _testRecipeValidators(self, recipe_name): validators_manager.ValidatorsManager.ListValidators(), f'Error in {recipe.name}:{arg.switch} - ' f'Invalid validator {arg.validation_params["format"]}.') + + self.tool.ValidateArguments() def testRecipeWithNestedArgs(self): """Tests that a recipe with args referenced in other args is populated."""