Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Unable to delete udp/tcp ports in app segment #189

Open
martinkiska opened this issue Mar 31, 2023 · 4 comments
Open

[BUG]: Unable to delete udp/tcp ports in app segment #189

martinkiska opened this issue Mar 31, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@martinkiska
Copy link

Describe the bug

SDK is natively unable to zeroize/delete tcp/udp port config, if empty list is send to update function.

To Reproduce
Steps to reproduce the behavior:
send tcp_ports/udp_ports = [] as kwarg to update_segment and try to delete UDP/TCP port config in cloud.

Expected behavior

if empty list is sent I would expect, that SDK would delete port config from specific app segment

Screenshots

app definition in cloud:
[{'name': 'TEST_testing3', 'domain_names': ['example.tld'], 'tcp_port_ranges': ['80', '80', '443', '443'], 'tcp_port_range': [{'from': '80', 'to': '80'}, {'from': '443', 'to': '443'},'udp_port_ranges': ['80', '80', '443', '443'], 'udp_port_range': [{'from': '80', 'to': '80'}, {'from': '443', 'to': '443'}}]
image situation that someone configured app in GUI, but you want to keep SSoT in git YAML format and update this app and remove udp port config as there is none specified in SSoT YAML format.

testing app format being passed to update_segment():
[{'name': 'TEST_testing3', 'domain_names': ['example.tld'], 'tcp_ports':[(80,80),(443,443)],'udp_ports':[]}]

As here you will omit that empty value, it will not be processed

if kwargs.get("udp_ports"):
payload["udpPortRange"] = [{"from": ports[0], "to": ports[1]} for ports in kwargs.pop("udp_ports")]

kwargs will be later on updated from payload gathered in

payload = convert_keys(self.get_segment(segment_id))

Kwargs passed to function:

for key, value in kwargs.items():
payload[snake_to_camel(key)] = value

That means that you will update kwargs from payload, what will keep it UDP ports configured.

My current workaround is to send {'udp_port_range':[],'udp_port_ranges':[]} directly to update_segment function. Due to existence of those keys script will later on override them in the payload. I already opened an ticket in past and both va

def update_segment(self, segment_id: str, **kwargs) -> Box:

Just an hint, it is not enough just to send empty value for udp_port_range, it needs both values to equals to []

image

Current issue is that with native options of SDK there is no option to keep udp/tcp ports synced from git (yaml) to gui (ensure that there is empty value in cloud)

@martinkiska martinkiska added the bug Something isn't working label Mar 31, 2023
@mitchos
Copy link
Owner

mitchos commented Jun 2, 2023

Hi @martinkiska sorry for the long time on this one, I am clearing the backlog up now and will take a look at this.

@egoruzmukhametov
Copy link

Hello. Any updates here? I have the same issue.

@martinkiska
Copy link
Author

Hi @egoruzmukhametov,

I can just share with you my very easy workaround in update_app function.

                # relates to https://github.com/mitchos/pyZscaler/issues/189
                # currently there is not an option to remove ports from cloud.
                for app in app_segments_to_be_updated:
                    for key in ["tcp_port_", "udp_port_"]:
                        if not app.get(key + "range", []):
                            app[key + "range"] = []
                            app[key + "ranges"] = []

This easy code if it doesn't find tcp/udp port configured in my own YAML structure it just adds empty tcp/udp info via kwargs and it correctly zeroize it in cloud.

@egoruzmukhametov
Copy link

egoruzmukhametov commented Jul 22, 2024

Hi @martinkiska Thank you for your answer, but still I would like to have a working module, not a workaround.
I can also share my workaround method. In the case when I need to delete all tcp or udp ports from an application segment, I apply the bypass rule to this application segment, after which I apply the correct configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants