-
Notifications
You must be signed in to change notification settings - Fork 1
Upd #62
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
Upd #62
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -61,7 +61,7 @@ def _redact(d: dict[str, Any]) -> dict[str, Any]: | |
| for k, v in d.items(): | ||
| if k in sensitive_keys: | ||
| if isinstance(v, str) and (is_mac_address(v) or is_mac_address_mask(v)): | ||
| # Redact only the first 6 hex characters of a MAC address | ||
| # Redact only the last part of a MAC address to a dummy value | ||
| redacted_d[k] = "00:11:22:33:" + v.replace("-", ":").upper()[-5:] | ||
| elif isinstance(v, str) and is_ip_address(v): | ||
|
Comment on lines
+64
to
66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Preserve IP family when redacting (IPv6 should redact to ::1) Single-string IPs and lists of IP strings currently redact to 127.0.0.3 even for IPv6. Align with the new list-of-dicts behavior by preserving IPv4 vs IPv6 families. Apply this diff: - elif isinstance(v, str) and is_ip_address(v):
- # Redact to a dummy local IP address
- redacted_d[k] = "127.0.0.3"
+ elif isinstance(v, str) and is_ip_address(v):
+ # Redact to a dummy local IP address, preserving IP family
+ redacted_d[k] = (
+ "127.0.0.3"
+ if ipaddress.ip_address(v).version == 4
+ else "::1"
+ )
@@
- elif isinstance(v, list) and all(
- isinstance(i, str) and is_ip_address(i) for i in v
- ):
- # Redact list of IPs to a dummy list
- redacted_d[k] = ["127.0.0.3"] # type: ignore[assignment]
+ elif isinstance(v, list) and all(
+ isinstance(i, str) and is_ip_address(i) for i in v
+ ):
+ # Redact list of IPs to a dummy list, preserving each item's IP family
+ redacted_d[k] = [
+ "127.0.0.3" if ipaddress.ip_address(i).version == 4 else "::1"
+ for i in v
+ ] # type: ignore[assignment]Also applies to: 69-74 |
||
| # Redact to a dummy local IP address | ||
|
|
@@ -71,6 +71,21 @@ def _redact(d: dict[str, Any]) -> dict[str, Any]: | |
| ): | ||
| # Redact list of IPs to a dummy list | ||
| redacted_d[k] = ["127.0.0.3"] # type: ignore[assignment] | ||
| elif isinstance(v, list) and all( | ||
| isinstance(i, dict) and "addr" in i and is_ip_address(i["addr"]) | ||
| for i in v | ||
| ): | ||
| # Redact list of dictionaries with IP addresses to a dummy list | ||
| redacted_list = [] | ||
| for item in v: | ||
| redacted_item = item.copy() | ||
| redacted_item["addr"] = ( | ||
| "127.0.0.3" | ||
| if ipaddress.ip_address(redacted_item["addr"]).version == 4 | ||
| else "::1" | ||
| ) | ||
| redacted_list.append(redacted_item) | ||
| redacted_d[k] = redacted_list # type: ignore[assignment] | ||
| else: | ||
| redacted_d[k] = "REDACTED" | ||
| elif isinstance(v, dict): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,3 +9,4 @@ aiofiles==24.1.0 | |
| radon==6.0.1 | ||
| types-aiofiles==24.1.0.20250809 | ||
| mypy==1.17.1 | ||
| pylint==3.3.7 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,13 +42,13 @@ def generate_airos_fixtures() -> None: | |
| _LOGGER.info("Processing '%s'...", filename) | ||
|
|
||
| try: | ||
| with open(base_fixture_path) as source: | ||
| with open(base_fixture_path, encoding="utf-8") as source: | ||
| source_data = json.loads(source.read()) | ||
|
|
||
| derived_data = AirOS.derived_data(None, source_data) # type: ignore[arg-type] | ||
| new_data = AirOSData.from_dict(derived_data) | ||
|
|
||
|
Comment on lines
48
to
50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Stop calling an instance method with a dummy self; make derived_data a staticmethod This script currently calls AirOS.derived_data(None, source_data), which is a code smell and will trip type checkers/linters. The method doesn’t use self; promote it to a @staticmethod and call it with a single argument. Apply this diff here: - derived_data = AirOS.derived_data(None, source_data) # type: ignore[arg-type]
+ derived_data = AirOS.derived_data(source_data)And update the method in airos/airos8.py (outside this file) as: # In airos/airos8.py
@staticmethod
def derived_data(response: dict[str, Any]) -> dict[str, Any]:
...I can push the coordinated changes across both files if you want. 🤖 Prompt for AI Agents |
||
| with open(new_fixture_path, "w") as new: | ||
| with open(new_fixture_path, "w", encoding="utf-8") as new: | ||
| json.dump(new_data.to_dict(), new, indent=2, sort_keys=True) | ||
|
|
||
| _LOGGER.info("Successfully created '%s'", new_filename) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Double-check coverage discovery after layout change
Combining via coverage combine artifacts/.coverage* should work with merged artifacts. Verify at least one .coverage file lands there.
Run this to confirm:
🏁 Script executed:
Length of output: 418
Coverage combine will fail — artifacts/.coverage not found*
I ran the verification script: the artifacts/ directory does not exist and no .coverage files were found, so the step will fail at runtime.
coverage combine artifacts/.coverage*🤖 Prompt for AI Agents