Skip to content

Commit 30cda0d

Browse files
authored
Merge pull request #95 from RomanSemkin/fix-linter-complaints
Linter complaints were fixed
2 parents 7830ddc + e41b98a commit 30cda0d

File tree

8 files changed

+34
-23
lines changed

8 files changed

+34
-23
lines changed

examples/example-access-group-key.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
# NOTE: fill in your credentials from secure storage, this is just an example
3535
api.authenticate(config.API_CLIENT_ID, config.API_CLIENT_SECRET)
3636

37+
3738
def get_access_group_CA_key(access_group_id):
3839
result = api.get_access_group_CA_key(access_group_id)
3940
if result.ok:
@@ -58,5 +59,6 @@ def main():
5859
print(ca_id)
5960
delete_access_group_CA_key(ACCESS_GROUP_ID, ca_id)
6061

62+
6163
if __name__ == "__main__":
6264
main()

examples/get-auditevents.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
SEARCH_PARAMETERS = {
3535
"start_time": "2021-08-01T00:00:00Z",
3636
"end_time": "2021-10-01T00:00:00Z",
37-
"session_id": "607977d7-4791-4ec4-795f-ab0af1ad8eb4"
37+
"session_id": "607977d7-4791-4ec4-795f-ab0af1ad8eb4",
3838
}
3939

4040

examples/get-connection-tags.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def get_connection_tags(offset, limit, sort_dir, query):
5050
print(connection.data["details"])
5151
sys.exit(1)
5252

53+
5354
def update_connection_tags(conn_id: str, connection_tags):
5455
"""Update connection tags object"""
5556
result = api.update_connection_tags(conn_id, connection_tags)
@@ -59,11 +60,13 @@ def update_connection_tags(conn_id: str, connection_tags):
5960
print(result.data["details"])
6061
sys.exit(1)
6162

63+
6264
def main():
6365
"""Update and fetch the connection tags."""
6466
update_connection_tags(CONNECTION_ID, CONNECTION_TAGS)
6567
connection_tags = get_connection_tags(OFFSET, LIMIT, SORTDIR, QUERY)
6668
print(connection_tags)
6769

70+
6871
if __name__ == "__main__":
6972
main()

examples/get-service-status.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,9 @@ def main():
4444
print("Checking for anomalies on PrivX Servers..")
4545

4646
for server_name, microservices in response.data.items():
47-
problem_microservices = [m for m in microservices
48-
if m['status']['status_message'] != 'OK']
47+
problem_microservices = [
48+
m for m in microservices if m["status"]["status_message"] != "OK"
49+
]
4950
if problem_microservices:
5051
print(f"Potential problems with microservice(s) on {server_name}")
5152
for problem in problem_microservices:

examples/search-connections-trails.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ def get_connections_data():
5353
offset = 0
5454
limit = 1000
5555
resp = api.search_connections(
56-
connection_params={"type": ["SSH"]},
57-
offset=offset, limit=limit
56+
connection_params={"type": ["SSH"]}, offset=offset, limit=limit
5857
)
5958
if resp.ok:
6059
data_load = resp.data
@@ -63,8 +62,7 @@ def get_connections_data():
6362
while count > 0:
6463
offset = offset + limit
6564
resp = api.search_connections(
66-
connection_params={"type": ["SSH"]},
67-
offset=offset, limit=limit
65+
connection_params={"type": ["SSH"]}, offset=offset, limit=limit
6866
)
6967
if resp.ok:
7068
data_load = resp.data
@@ -73,7 +71,7 @@ def get_connections_data():
7371
audited_data_items = []
7472
for data in data_items:
7573
if data.get("audit_enabled"):
76-
audited_data_items.append(data['id'])
74+
audited_data_items.append(data["id"])
7775
return audited_data_items
7876
else:
7977
error = "Get users Connection data operation failed:"
@@ -122,7 +120,7 @@ def process_connections(connections, SEARCH_STRING):
122120
for connection in connections:
123121
if "channels" in connection.get("trail", ""):
124122
for channel in connection["trail"]["channels"]:
125-
channel_status = channel["protocol_file"]['status']
123+
channel_status = channel["protocol_file"]["status"]
126124
if channel["type"] == "shell" and channel_status != "UNCLEAN_CLOSE":
127125
# Get a session ID for trail download
128126
session = create_trail_session(connection["id"], channel["id"])
@@ -132,8 +130,11 @@ def process_connections(connections, SEARCH_STRING):
132130
)
133131
# Parse the trail
134132
details = (
135-
"\r\nstdin conn " + connection["id"]
136-
+ " chan " + channel["id"] + " : "
133+
"\r\nstdin conn "
134+
+ connection["id"]
135+
+ " chan "
136+
+ channel["id"]
137+
+ " : "
137138
)
138139
print_trail(trail_log, SEARCH_STRING, details)
139140

@@ -158,13 +159,12 @@ def process_error(messages):
158159
def main():
159160
SEARCH_STRING = False
160161
CONNECTION_ID = False
161-
if (len(sys.argv) > 5 or len(sys.argv) == 4 or len(sys.argv) == 1):
162+
if len(sys.argv) > 5 or len(sys.argv) == 4 or len(sys.argv) == 1:
162163
usage()
163164
sys.exit(2)
164165
try:
165166
opts, args = getopt.getopt(
166-
sys.argv[1:], "hc:s:",
167-
["help", "connection-id=", "search-string="]
167+
sys.argv[1:], "hc:s:", ["help", "connection-id=", "search-string="]
168168
)
169169
except getopt.GetoptError:
170170
usage()

privx_api/authorizer.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ def delete_access_group(self, access_group_id: str) -> PrivXAPIResponse:
530530
UrlEnum.AUTHORIZER.ACCESS_GROUP, path_params={"id": access_group_id}
531531
)
532532
return PrivXAPIResponse(response_status, HTTPStatus.OK, data)
533-
533+
534534
def get_access_group_CA_key(
535535
self,
536536
access_group_id: str,
@@ -546,16 +546,19 @@ def get_access_group_CA_key(
546546
path_params={"id": access_group_id},
547547
)
548548
return PrivXAPIResponse(response_status, HTTPStatus.OK, data)
549-
550-
def delete_access_group_CA_key(self, access_group_id: str, ca_id: str) -> PrivXAPIResponse:
549+
550+
def delete_access_group_CA_key(
551+
self, access_group_id: str, ca_id: str
552+
) -> PrivXAPIResponse:
551553
"""
552554
Delete access group CA key.
553555
554556
Returns:
555-
PrivXStreamResponse
557+
PrivXAPIResponse
556558
"""
557559
response_status, data = self._http_delete(
558-
UrlEnum.AUTHORIZER.DELETE_ACCESS_GROUP_CA_KEY, path_params={"id": access_group_id, "ca_id": ca_id}
560+
UrlEnum.AUTHORIZER.DELETE_ACCESS_GROUP_CA_KEY,
561+
path_params={"id": access_group_id, "ca_id": ca_id},
559562
)
560563
return PrivXAPIResponse(response_status, HTTPStatus.OK, data)
561564

privx_api/connection_manager.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,11 @@ def get_connection_tags(
113113
query_params=search_params,
114114
)
115115
return PrivXAPIResponse(response_status, HTTPStatus.OK, data)
116-
116+
117117
def update_connection_tags(
118-
self, connection_id: str, connection_tags
118+
self,
119+
connection_id: str,
120+
connection_tags: Optional[list],
119121
) -> PrivXAPIResponse:
120122
"""
121123
Update connection tags

privx_api/enums.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ class ConnectionManagerEnum:
203203
CONNECTION_TAGS = "CONNECTION_MANAGER.CONNECTION_TAGS"
204204
UPDATE_CONNECTION_TAGS = "CONNECTION_MANAGER.UPDATE_CONNECTION_TAGS"
205205

206-
207206
urls = {
208207
ACCESS_ROLE: "/connection-manager/api/v1/connections/access_roles/{role_id}",
209208
CONNECTION: "/connection-manager/api/v1/connections/{connection_id}",
@@ -240,7 +239,8 @@ class ConnectionManagerEnum:
240239
UEBA_STATUS: "/connection-manager/api/v1/ueba/status",
241240
UEBA_INTERNAL_STATUS: "/connection-manager/api/v1/ueba/status/internal",
242241
CONNECTION_TAGS: "/connection-manager/api/v1/connections/tags",
243-
UPDATE_CONNECTION_TAGS: "/connection-manager/api/v1/connections/{connection_id}/tags",
242+
UPDATE_CONNECTION_TAGS: "/connection-manager/api/v1/connections/"
243+
"{connection_id}/tags",
244244
}
245245

246246

0 commit comments

Comments
 (0)