Skip to content

Target

sereto.cli.target

prompt_user_for_target(settings)

Interactively prompt for a target's details.

Parameters:

Name Type Description Default
settings Settings

The Settings object.

required

Returns:

Type Description
Target

The target as provided by the user.

Source code in sereto/cli/target.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def prompt_user_for_target(settings: Settings) -> Target:
    """Interactively prompt for a target's details.

    Args:
        settings: The Settings object.

    Returns:
        The target as provided by the user.
    """
    Console().line()
    category = Prompt.ask("Category", choices=list(settings.categories), console=Console())
    name = Prompt.ask("Name", console=Console())

    match category:
        case "dast":
            target: Target = TargetDast(category=category, name=name)
        case "sast":
            target = TargetSast(category=category, name=name)
        case _:
            target = Target(category=category, name=name)

    target_edited = click.edit(target.model_dump_json(indent=2))

    if target_edited is None:
        raise SeretoRuntimeError("aborting, editor closed without saving")

    return Target.model_validate_json(target_edited)