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
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
37
38
39
40
41
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 = radiolist_dialog(
        title="New target",
        text="Category:",
        values=[(c, c.upper()) for c in list(settings.categories)],
    ).run()
    name = prompt("Name: ")

    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)