Skip to content
Merged
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
4 changes: 2 additions & 2 deletions cli/prog/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def set_user_local_config(data, global_role, timeout, email, locale, password):
user["locale"] = locale
if password == True:
if data.username == data.id_or_name:
# set currrent login user's password
# set current login user's password
current = click.prompt("Current Password", hide_input=True)
pass1 = click.prompt("New Password", hide_input=True)
pass2 = click.prompt("Confirm Password", hide_input=True)
Expand Down Expand Up @@ -246,7 +246,7 @@ def set_user_local_config(data, global_role, timeout, email, locale, password):
@click.option('--domain', '-d', multiple=True, help="Domains of the role.")
@click.pass_obj
def set_user_local_role(data, role, domain):
"""Set user role domain access control. Users with global role fedAdmin cannot be assined domain roles."""
"""Set user role domain access control. Users with global role fedAdmin cannot be assigned domain roles."""

if len(domain) > 0:
user = {"fullname": data.id_or_name, "role": role, "domains": domain}
Expand Down
70 changes: 35 additions & 35 deletions cli/prog/convers.py → cli/prog/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@
from prog import utils


def _show_display_format(conver):
def _show_display_format(conversation):
f = "bytes"
if f in conver:
if f in conversation:
fo = output.key_output(f)
conver[fo] = utils.convert_byte(conver[f], 0)
conversation[fo] = utils.convert_byte(conversation[f], 0)


def _list_display_format(conver, src, dst, id_only):
def _list_display_format(conversation, src, dst, id_only):
if src["kind"] == client.EndpointKindContainer:
if id_only:
conver["client"] = "%s" % src["id"][:output.SHORT_ID_LENGTH]
conversation["client"] = "%s" % src["id"][:output.SHORT_ID_LENGTH]
else:
conver["client"] = "%s - %s" % (src["id"][:output.SHORT_ID_LENGTH], src["display_name"])
conversation["client"] = "%s - %s" % (src["id"][:output.SHORT_ID_LENGTH], src["display_name"])
else:
conver["client"] = src["id"]
conversation["client"] = src["id"]

if dst["kind"] == client.EndpointKindContainer:
if id_only:
conver["server"] = "%s" % dst["id"][:output.SHORT_ID_LENGTH]
conversation["server"] = "%s" % dst["id"][:output.SHORT_ID_LENGTH]
else:
conver["server"] = "%s - %s" % (dst["id"][:output.SHORT_ID_LENGTH], dst["display_name"])
conversation["server"] = "%s - %s" % (dst["id"][:output.SHORT_ID_LENGTH], dst["display_name"])
else:
conver["server"] = dst["id"]
conversation["server"] = dst["id"]

f = "applications"
if f in conver:
conver[output.key_output(f)] = ",".join(conver[f])
if f in conversation:
conversation[output.key_output(f)] = ",".join(conversation[f])
else:
conver[output.key_output(f)] = ""
conversation[output.key_output(f)] = ""
f = "ports"
if f in conver:
conver[output.key_output(f)] = ",".join(conver[f])
if f in conversation:
conversation[output.key_output(f)] = ",".join(conversation[f])
else:
conver[output.key_output(f)] = ""
conversation[output.key_output(f)] = ""

_show_display_format(conver)
_show_display_format(conversation)


@show.group("conversation", invoke_without_command=True)
Expand All @@ -55,7 +55,7 @@ def _list_display_format(conver, src, dst, id_only):
@click.option("--page", default=40, type=click.IntRange(1), help="list page size, default=40")
@click.pass_obj
@click.pass_context
def show_conver(ctx, data, group, domain, verbose, id_only, page):
def show_conversation(ctx, data, group, domain, verbose, id_only, page):
"""Show conversations."""
if ctx.invoked_subcommand is not None:
return
Expand All @@ -75,10 +75,10 @@ def show_conver(ctx, data, group, domain, verbose, id_only, page):
for ep in data["endpoints"]:
eps[ep["id"]] = ep

convers = data["conversations"]
conversations = data["conversations"]
fromid = ""
toid = ""
for c in convers:
for c in conversations:
if verbose:
fromid = c["from"]["id"]
toid = c["to"]["id"]
Expand Down Expand Up @@ -106,7 +106,7 @@ def show_conver(ctx, data, group, domain, verbose, id_only, page):
_list_display_format(c, eps[fromid], eps[toid], id_only)

start = 0
size = len(convers)
size = len(conversations)
while True:
if start + page > size:
end = size
Expand All @@ -115,7 +115,7 @@ def show_conver(ctx, data, group, domain, verbose, id_only, page):

columns = (
"client", "server", "policy_action", "severity", "bytes", "sessions", "applications", "ports", "xff_entry")
output.list(columns, convers[start:end])
output.list(columns, conversations[start:end])

start = end
if start >= size:
Expand All @@ -127,7 +127,7 @@ def show_conver(ctx, data, group, domain, verbose, id_only, page):
break


@show_conver.command()
@show_conversation.command()
@click.argument("client")
@click.argument("server")
@click.pass_obj
Expand All @@ -139,17 +139,17 @@ def pair(data, client, server):
s = utils.get_managed_object_id(data.client, "workload", "workload", server)
if not s:
s = server
conver = data.client.show("conversation/%s" % c, "conversation", s)
conversation = data.client.show("conversation/%s" % c, "conversation", s)

for e in conver["entries"]:
for e in conversation["entries"]:
_show_display_format(e)

columns = ("port", "mapped_port", "application", "policy_action", "policy_id", "severity",
"bytes", "sessions", "last_seen_at", "client_ip", "server_ip", "fqdn", "xff", "to_sidecar")
output.list(columns, conver["entries"])
output.list(columns, conversation["entries"])


@show_conver.command()
@show_conversation.command()
@click.option('-v', '--view', type=click.Choice(['', 'pod']), default='', help="specify view")
@click.option("-g", "--group", default=None, help="filter endpoints by group")
@click.option("--page", default=40, type=click.IntRange(1), help="list page size, default=40")
Expand Down Expand Up @@ -184,15 +184,15 @@ def endpoint(data, view, group, page):
@delete.group("conversation", invoke_without_command=True)
@click.pass_obj
@click.pass_context
def delete_conver(ctx, data):
def delete_conversation(ctx, data):
"""Delete all conversations."""
if ctx.invoked_subcommand is not None:
return

data.client.delete("conversation", None)


@delete_conver.command()
@delete_conversation.command()
@click.argument("client")
@click.argument("server")
@click.pass_obj
Expand All @@ -204,10 +204,10 @@ def pair(data, client, server):
s = utils.get_managed_object_id(data.client, "workload", "workload", server)
if not s:
s = server
conver = data.client.delete("conversation/%s/%s" % (c, s), None)
conversation = data.client.delete("conversation/%s/%s" % (c, s), None)


@delete_conver.command()
@delete_conversation.command()
@click.argument("endpoint")
@click.pass_obj
@click.pass_context
Expand All @@ -218,11 +218,11 @@ def endpoint(ctx, data, endpoint):

@cli_set.group("conversation")
@click.pass_obj
def set_conver(data):
def set_conversation(data):
"""Set conversation configuration."""


@set_conver.command("endpoint")
@set_conversation.command("endpoint")
@click.argument("endpoint")
@click.option('--alias', help="Set endpoint alias.")
@click.pass_obj
Expand All @@ -237,11 +237,11 @@ def set_endpoint(data, endpoint, alias):

@unset.group("conversation")
@click.pass_obj
def unset_conver(data):
def unset_conversation(data):
"""Unset conversation configuration."""


@unset_conver.command("endpoint")
@unset_conversation.command("endpoint")
@click.argument("endpoint")
@click.option('--alias', is_flag=True, help="Unset endpoint alias.")
@click.pass_obj
Expand Down
4 changes: 2 additions & 2 deletions cli/prog/diag.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ def pcap(data, filename, limit, id):

click.echo("read end")
kwargs = {'strict': True}
clen = int(headers.get('Content-Length', '-1'))
contentLen = int(headers.get('Content-Length', '-1'))
ctype, options = multipart.parse_options_header(headers.get("Content-Type"))
boundary = options.get('boundary', '')
if ctype != 'multipart/form-data' or not boundary:
click.echo("Unsupported content type.")
return

try:
for part in multipart.MultipartParser(io.BytesIO(body.content), boundary, clen):
for part in multipart.MultipartParser(io.BytesIO(body.content), boundary, contentLen):
if part.name == "pcap" and part.content_type == "application/cap":
click.echo("write %d" % len(part.raw))
_write_part(part, filename)
Expand Down
10 changes: 5 additions & 5 deletions cli/prog/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,10 +390,10 @@ def custom_check(data, id_or_name):
if not group:
return

enabledDsiplay = "enabled"
enabledDisplay = "enabled"
if not group["enabled"]:
enabledDsiplay = "disabled"
click.echo("custom check is {}".format(enabledDsiplay))
enabledDisplay = "disabled"
click.echo("custom check is {}".format(enabledDisplay))
click.echo("")

if not group["writable"]:
Expand Down Expand Up @@ -553,8 +553,8 @@ def set_group(ctx, data, name):
def set_group_setting(data, image, node, domain, container, service, label, address, monitor_metric, cur_sess, sess_rate, bandwidth):
"""Set group configuration.

For partial match, add @ in front of the value streig, for example --image @nginx.
if the option value starts with ^, the criterion matches strign with prefix 'value'.
For partial match, add @ in front of the value string, for example --image @nginx.
if the option value starts with ^, the criterion matches string with prefix 'value'.
Comment thread
williamlin-suse marked this conversation as resolved.
For --label, use: key=value, key^value or key@value.
For --address, use: --address=1.2.3.4, --address=1.2.3.0/24, --address 1.2.3.1-1.2.3.31
To input an empty string, use: --service =
Expand Down
2 changes: 1 addition & 1 deletion cli/prog/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def detail(data, id_or_name):
@click.argument("id_or_name")
@click.pass_obj
def ip_2_container(data, id_or_name):
"""Show node ip-continer map."""
"""Show node ip-container map."""
host = utils.get_managed_object(data.client, "host", "host", id_or_name)
if not host:
return
Expand Down
2 changes: 1 addition & 1 deletion cli/prog/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from prog import cluster
from prog import compliance
from prog import controller
from prog import convers
from prog import conversation
from prog import diag
from prog import dlp
from prog import waf
Expand Down
2 changes: 1 addition & 1 deletion cli/prog/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def _iterparse(self):

# For each part in stream...
mem_used, disk_used = 0, 0 # Track used resources to prevent DoS
is_tail = False # True if the last line was incomplete (cutted)
is_tail = False # True if the last line was incomplete (cut)

opts = {
"buffer_size": self.buffer_size,
Expand Down
6 changes: 3 additions & 3 deletions cli/prog/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def create_response_rule(data, scope, group, event, condition, action, webhook,
@set.group("response")
@click.pass_obj
def set_response(data):
"""Set reponse rule configuration."""
"""Set response rule configuration."""


@set_response.command("rule")
Expand Down Expand Up @@ -543,13 +543,13 @@ def set_response_rule(data, id, scope, group, event, condition, action, webhook,
@unset.group("response")
@click.pass_obj
def unset_response(data):
"""Unset reponse rule configuration."""
"""Unset response rule configuration."""


@unset_response.group("rule")
@click.pass_obj
def unset_response_rule(data):
"""Unset reponse rule configuration."""
"""Unset response rule configuration."""


@unset_response_rule.command("group")
Expand Down
2 changes: 1 addition & 1 deletion cli/prog/pwd_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def detail(data, name):

if profile["enable_block_after_failed_login"] is True and profile["block_after_failed_login_count"] > 0 and profile[
"block_minutes"] > 0:
profile[header1] = "block {} minutes after {} consecutive login faulures".format(profile["block_minutes"],
profile[header1] = "block {} minutes after {} consecutive login failures".format(profile["block_minutes"],
profile[
"block_after_failed_login_count"])
else:
Expand Down
Loading
Loading