Skip to content

Commit ee70085

Browse files
committed
0.59.3
1 parent 2a2599b commit ee70085

File tree

5 files changed

+113
-56
lines changed

5 files changed

+113
-56
lines changed

CHANGELOG.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,91 @@
11
# CHANGELOG
22

3+
## Version 0.59.3 (December 2024)
4+
5+
**Released**: December 26, 2024
6+
7+
This release adds security enhancements for log sanitization and includes dependency updates.
8+
9+
---
10+
11+
## 1. NEW FEATURES
12+
13+
### **Log Sanitization**
14+
- Added `LogSanitizer` filter to automatically redact sensitive fields from log messages
15+
- Supports filtering of passwords, API tokens, keys, secrets, and other sensitive data
16+
- Can be applied to both standard Python logging and the custom Console logger
17+
18+
### **Usage Example**
19+
```python
20+
import logging
21+
from mistapi.__logger import LogSanitizer
22+
23+
LOG_FILE = "./log.txt"
24+
logging.basicConfig(filename=LOG_FILE, filemode="w")
25+
LOGGER = logging.getLogger(__name__)
26+
LOGGER.setLevel(logging.DEBUG)
27+
LOGGER.addFilter(LogSanitizer())
28+
29+
LOGGER.debug(var_with_sensitive_data)
30+
```
31+
32+
---
33+
34+
## 2. DEPENDENCIES
35+
36+
### **Added**
37+
- `keyring` - Secure system keyring access for password storage
38+
- macOS Keychain support
39+
- Windows Credential Locker support
40+
- Freedesktop Secret Service support (GNOME, KDE)
41+
42+
### **Updated**
43+
- Various dependency updates for security and compatibility
44+
45+
---
46+
47+
## 3. FILES MODIFIED
48+
49+
### **src/mistapi/__logger.py**
50+
- Added `LogSanitizer` class for filtering sensitive data from logs
51+
- Enhanced regex pattern for detecting sensitive fields
52+
- Added support for case-insensitive matching of sensitive field names
53+
- Improved sanitization to handle various JSON formats
54+
55+
### **pyproject.toml**
56+
- Added keyring dependency
57+
- Updated version to 0.59.3
58+
59+
---
60+
61+
## Summary Statistics
62+
63+
- **New Features**: 1 (Log Sanitization)
64+
- **Dependencies Added**: 1 (keyring)
65+
- **Total Files Modified**: 3
66+
- **Lines Added**: 655
67+
- **Lines Removed**: 407
68+
69+
---
70+
71+
## Breaking Changes
72+
73+
None. This is a backwards-compatible release.
74+
75+
---
76+
77+
## Security Improvements
78+
79+
This release significantly improves security by automatically sanitizing sensitive information in logs, including:
80+
- API tokens and keys
81+
- Passwords and passphrases
82+
- OAuth secrets
83+
- PSK/mesh keys
84+
- Authentication credentials
85+
- And 20+ other sensitive field types
86+
87+
---
88+
389
## Version 0.59.2 (December 2024)
490

591
**Released**: December 2024

scripts/generate_from_openapi.py

Lines changed: 23 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,21 @@ def {operation_id}(mist_session: _APISession{code_path_params}{multipart}) -> _A
155155
"""
156156

157157

158+
def keep_deprecated(max_deprecation_version: str, current_version: str) -> bool:
159+
"""
160+
Determine if deprecated functions should be kept based on version comparison.
161+
"""
162+
current = current_version.split(".")
163+
max_version = max_deprecation_version.split(".")
164+
165+
for i, req in enumerate(max_version):
166+
if current[int(i)] < req:
167+
break
168+
if current[int(i)] > req:
169+
return False
170+
return True
171+
172+
158173
def fprint(message: str) -> None:
159174
"""Print a formatted message with left justification to 80 characters."""
160175
print(f"{message}".ljust(80))
@@ -568,48 +583,6 @@ def _gen_uri(endpoint_path: str) -> str:
568583
# HTTP method function generators (CRUD operations)
569584

570585

571-
def _create_get_deprecated_device_events(
572-
operation_id: str,
573-
endpoint_path: str,
574-
path_params: list,
575-
query_params: list,
576-
) -> str:
577-
"""
578-
Create deprecated version of DeviceEvents GET functions for backward compatibility.
579-
Handles the renaming from DevicesEvents to DeviceEvents.
580-
581-
Args:
582-
operation_id: Current OpenAPI operation ID (DeviceEvents*)
583-
endpoint_path: API endpoint path
584-
path_params: Path parameters list
585-
query_params: Query parameters list
586-
587-
Returns:
588-
str: Generated deprecated function code
589-
"""
590-
code = ""
591-
code_path_params, desc_path_params = _gen_code_params(path_params, operation_id)
592-
code_query_params, desc_query_params = _gen_code_params(query_params, operation_id)
593-
code_query = _gen_query_code(query_params)
594-
code_desc = _gen_description(operation_id, [], desc_path_params, desc_query_params)
595-
596-
# Generate old operation ID for the deprecated function
597-
old_operation_id = operation_id.replace("DeviceEvents", "DevicesEvents", 1)
598-
code += FUNCTION_GET_DEPRECATED_TEMPLATE.format(
599-
version_deprecated="0.45.0",
600-
version_final="0.60.0",
601-
version_current=version,
602-
operation_id=operation_id,
603-
old_operation_id=old_operation_id,
604-
code_path_params=code_path_params,
605-
code_query_params=code_query_params,
606-
code_desc=code_desc,
607-
uri=_gen_uri(endpoint_path),
608-
query_code=code_query,
609-
)
610-
return code
611-
612-
613586
def _create_get_deprecated(
614587
operation_id: str,
615588
tags: list,
@@ -633,6 +606,9 @@ def _create_get_deprecated(
633606
str: Generated deprecated function code
634607
"""
635608
code = ""
609+
if not keep_deprecated(version_final, VERSION):
610+
print(f"Skipping deprecated function {operation_id} as per version settings.")
611+
return code
636612
code_path_params, desc_path_params = _gen_code_params(path_params, operation_id)
637613
code_query_params, desc_query_params = _gen_code_params(query_params, operation_id)
638614
code_query = _gen_query_code(query_params)
@@ -644,7 +620,7 @@ def _create_get_deprecated(
644620
code += FUNCTION_GET_DEPRECATED_TEMPLATE.format(
645621
version_deprecated=version_deprecated,
646622
version_final=version_final,
647-
version_current=version,
623+
version_current=VERSION,
648624
operation_id=new_operation_id,
649625
old_operation_id=operation_id,
650626
code_path_params=code_path_params,
@@ -678,14 +654,7 @@ def _create_get(
678654
"""
679655
code = ""
680656
has_deprecated = False
681-
# Create deprecated version for DeviceEvents functions (backward compatibility)
682-
if operation_id.startswith("DeviceEvents"):
683-
has_deprecated = True
684-
code += _create_get_deprecated_device_events(
685-
operation_id, endpoint_path, path_params, query_params
686-
)
687-
elif DEPRECATED_METHODS.get(operation_id):
688-
has_deprecated = True
657+
if DEPRECATED_METHODS.get(operation_id):
689658
code += _create_get_deprecated(
690659
operation_id,
691660
tags,
@@ -696,6 +665,8 @@ def _create_get(
696665
path_params,
697666
query_params,
698667
)
668+
if code:
669+
has_deprecated = True
699670

700671
# Generate main function parameters and documentation
701672
code_path_params, desc_path_params = _gen_code_params(path_params, operation_id)
@@ -1433,7 +1404,7 @@ def start(
14331404
# Script entry point
14341405

14351406
# Get version from command line argument for deprecation warnings
1436-
version = sys.argv[1]
1407+
VERSION = sys.argv[1]
14371408

14381409
# Clean up existing API folder to ensure fresh generation
14391410
if os.path.exists(f"{ROOT_FOLDER}/{ROOT_API_FOLDER}"):

src/mistapi/__version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
__version__ = "0.59.2"
1+
__version__ = "0.59.3"
22
__author__ = "Thomas Munzer <tmunzer@juniper.net>"

src/mistapi/api/v1/sites/sle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
@deprecation.deprecated(
1919
deprecated_in="0.59.2",
2020
removed_in="0.65.0",
21-
current_version="0.59.2",
21+
current_version="0.59.3",
2222
details="function replaced with getSiteSleClassifierSummaryTrend",
2323
)
2424
def getSiteSleClassifierDetails(
@@ -741,7 +741,7 @@ def listSiteSleImpactedWirelessClients(
741741
@deprecation.deprecated(
742742
deprecated_in="0.59.2",
743743
removed_in="0.65.0",
744-
current_version="0.59.2",
744+
current_version="0.59.3",
745745
details="function replaced with getSiteSleSummaryTrend",
746746
)
747747
def getSiteSleSummary(

0 commit comments

Comments
 (0)