Skip to content

trestle.core.commands.generate_manifest

trestle.core.commands.generate_manifest ¤

Trestle Generate Manifest Command.

Attributes¤

logger = logging.getLogger(__name__) module-attribute ¤

Classes¤

GenerateManifestCmd ¤

Bases: CommandBase


              flowchart TD
              trestle.core.commands.generate_manifest.GenerateManifestCmd[GenerateManifestCmd]
              trestle.core.commands.command_docs.CommandBase[CommandBase]

                              trestle.core.commands.command_docs.CommandBase --> trestle.core.commands.generate_manifest.GenerateManifestCmd
                


              click trestle.core.commands.generate_manifest.GenerateManifestCmd href "" "trestle.core.commands.generate_manifest.GenerateManifestCmd"
              click trestle.core.commands.command_docs.CommandBase href "" "trestle.core.commands.command_docs.CommandBase"
            

Generate a JSON package manifest from a primary OSCAL model.

The command follows local and remote dependencies from any supported top-level OSCAL JSON model. Remote dependencies are fetched through Trestle and copied into the package. Catalogs are terminal artifacts. Additional supported models may be explicitly included. The generated manifest can be reviewed before it is passed to sign-manifest.

Source code in trestle/core/commands/generate_manifest.py
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class GenerateManifestCmd(CommandBase):
    """Generate a JSON package manifest from a primary OSCAL model.

    The command follows local and remote dependencies from any supported
    top-level OSCAL JSON model. Remote dependencies are fetched through Trestle
    and copied into the package. Catalogs are terminal artifacts. Additional
    supported models may be explicitly included. The generated manifest can be
    reviewed before it is passed to sign-manifest.
    """

    name = 'generate-manifest'

    def _init_arguments(self) -> None:
        self.add_argument(
            '-f', '--file', help='Path to the supported primary OSCAL JSON file.', required=True, type=pathlib.Path
        )
        self.add_argument(
            '--include',
            help='Optional comma-separated OSCAL JSON files to include when they cannot be discovered.',
            default=None,
        )
        self.add_argument(
            '--allow-private-uris', help='Allow dependencies hosted on trusted private networks.', action='store_true'
        )
        self.add_argument('--overwrite', help='Replace an existing output manifest.', action='store_true')
        self.add_argument('-o', '--output', help='Output JSON package manifest.', required=True, type=pathlib.Path)

    @beta_feature('json-manifest-signing')
    def _run(self, args: argparse.Namespace) -> int:
        """Generate a JSON package manifest."""
        try:
            log.set_log_level_from_args(args)
            self.generate_manifest(args.file, args.output, args.include, args.allow_private_uris, args.overwrite)
            return CmdReturnCodes.SUCCESS.value
        except Exception as e:  # pragma: no cover
            return handle_generic_command_exception(e, logger, 'Error while generating package manifest')

    @classmethod
    def generate_manifest(
        cls,
        primary_path: pathlib.Path,
        output_path: pathlib.Path,
        include: Optional[str] = None,
        allow_private_uris: bool = False,
        overwrite: bool = False,
    ) -> None:
        """Discover OSCAL dependencies and write a package manifest."""
        include_paths: List[pathlib.Path] = [pathlib.Path(path) for path in comma_sep_to_list(include)]
        manifest = discover_signing_manifest(primary_path, output_path, include_paths, allow_private_uris)
        write_signing_manifest(manifest, overwrite)
Attributes¤
name = 'generate-manifest' class-attribute instance-attribute ¤
Methods:¤
generate_manifest(primary_path, output_path, include=None, allow_private_uris=False, overwrite=False) classmethod ¤

Discover OSCAL dependencies and write a package manifest.

Source code in trestle/core/commands/generate_manifest.py
71
72
73
74
75
76
77
78
79
80
81
82
83
@classmethod
def generate_manifest(
    cls,
    primary_path: pathlib.Path,
    output_path: pathlib.Path,
    include: Optional[str] = None,
    allow_private_uris: bool = False,
    overwrite: bool = False,
) -> None:
    """Discover OSCAL dependencies and write a package manifest."""
    include_paths: List[pathlib.Path] = [pathlib.Path(path) for path in comma_sep_to_list(include)]
    manifest = discover_signing_manifest(primary_path, output_path, include_paths, allow_private_uris)
    write_signing_manifest(manifest, overwrite)

Functions:¤

handler: python