Repository: microsoft/onefuzz
File: src/cli/onefuzz/api.py (Python)

Code before:

from .__version__ import __version__
from .azcopy import azcopy_sync
from .backend import Backend, BackendConfig, ContainerWrapper, wait
from .ssh import build_ssh_command, ssh_connect, temp_file

UUID_EXPANSION = TypeVar("UUID_EXPANSION", UUID, str)

DEFAULT = BackendConfig(
    authority="https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47",
    client_id="72f1562a-8c0c-41ea-beb9-fa2b71c80134",
)

# This was generated randomly and should be preserved moving forwards
ONEFUZZ_GUID_NAMESPACE = uuid.UUID("27f25e3f-6544-4b69-b309-9b096c5a9cbc")

ONE_HOUR_IN_SECONDS = 3600

DEFAULT_LINUX_IMAGE = "Canonical:UbuntuServer:18.04-LTS:latest"
DEFAULT_WINDOWS_IMAGE = "MicrosoftWindowsDesktop:Windows-10:20h2-pro:latest"

REPRO_SSH_FORWARD = "1337:127.0.0.1:1337"

UUID_RE = r"^[a-f0-9]{8}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{12}\Z"

CLIENT_SECRET_ENV_VAR = "ONEFUZZ_CLIENT_SECRET"


class PreviewFeature(Enum):
    job_templates = "job_templates"


def is_uuid(value: str) -> bool:
    return bool(re.match(UUID_RE, value))


A = TypeVar("A", bound=BaseModel)


def _wsl_path(path: str) -> str:
    if which("wslpath"):
        # security note: path should always be a temporary path constructed by
        # this library
        return (
            subprocess.check_output(["wslpath", "-w", path]).decode().strip()  # nosec
        )
    return path


def user_confirmation(message: str) -> bool:
    answer: Optional[str] = None

Review comment (bug):
just a heads up. Check-pr will probably fail because the client-secret is not set.
You will need to update [this](https://github.com/microsoft/onefuzz/blob/a4357c8fb9b4eb2ceee1206c151e6c027f22a990/src/utils/check-pr/check-pr.py#L141) 

Code after:

from .__version__ import __version__
from .azcopy import azcopy_sync
from .backend import Backend, BackendConfig, ContainerWrapper, wait
from .ssh import build_ssh_command, ssh_connect, temp_file

UUID_EXPANSION = TypeVar("UUID_EXPANSION", UUID, str)

DEFAULT = BackendConfig(
    authority="https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47",
    client_id="72f1562a-8c0c-41ea-beb9-fa2b71c80134",
)

# This was generated randomly and should be preserved moving forwards
ONEFUZZ_GUID_NAMESPACE = uuid.UUID("27f25e3f-6544-4b69-b309-9b096c5a9cbc")

ONE_HOUR_IN_SECONDS = 3600

DEFAULT_LINUX_IMAGE = "Canonical:UbuntuServer:18.04-LTS:latest"
DEFAULT_WINDOWS_IMAGE = "MicrosoftWindowsDesktop:Windows-10:20h2-pro:latest"

REPRO_SSH_FORWARD = "1337:127.0.0.1:1337"

UUID_RE = r"^[a-f0-9]{8}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{4}-?[a-f0-9]{12}\Z"

# Environment variable optionally used for setting an application client secret.
CLIENT_SECRET_ENV_VAR = "ONEFUZZ_CLIENT_SECRET"  # nosec


class PreviewFeature(Enum):
    job_templates = "job_templates"


def is_uuid(value: str) -> bool:
    return bool(re.match(UUID_RE, value))


A = TypeVar("A", bound=BaseModel)


def _wsl_path(path: str) -> str:
    if which("wslpath"):
        # security note: path should always be a temporary path constructed by
        # this library
        return (
            subprocess.check_output(["wslpath", "-w", path]).decode().strip()  # nosec
        )
    return path


def user_confirmation(message: str) -> bool: