Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions hyperglass/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@
"bird",
"openbgpd",
)

SHELL_PLATFORMS = LINUX_PLATFORMS + ("tnsr",)
10 changes: 8 additions & 2 deletions hyperglass/execution/drivers/_construct.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import re
import json as _json
import typing as t
import shlex
import ipaddress

# Project
from hyperglass.log import log
from hyperglass.util import get_fmt_keys
from hyperglass.constants import TRANSPORT_REST, TARGET_FORMAT_SPACE
from hyperglass.constants import TRANSPORT_REST, TARGET_FORMAT_SPACE, SHELL_PLATFORMS
from hyperglass.exceptions.public import InputInvalid
from hyperglass.exceptions.private import ConfigError

Expand Down Expand Up @@ -110,7 +111,12 @@ def format(self, command: str) -> str:
except ValueError:
pass

return command.format(target=self.target, mask=mask, **attrs)
fmt = {"target": self.target, "mask": mask, **attrs}

if self.device.platform in SHELL_PLATFORMS:
return " ".join(shlex.quote(word.format(**fmt)) for word in shlex.split(command))

return command.format(**fmt)

def queries(self):
"""Return queries for each enabled AFI."""
Expand Down
5 changes: 4 additions & 1 deletion hyperglass/models/api/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@


QueryLocation = Annotated[str, StringConstraints(strict=True, min_length=1, strip_whitespace=True)]
QueryTarget = Annotated[str, StringConstraints(min_length=1, strip_whitespace=True)]
QueryTarget = Annotated[
str,
StringConstraints(min_length=1, strip_whitespace=True, pattern=r"^[^\x00-\x1f\x7f]+$"),
]
QueryType = Annotated[str, StringConstraints(strict=True, min_length=1, strip_whitespace=True)]


Expand Down