[feature] Introduced standalone certificate templates and device bindings#1378
[feature] Introduced standalone certificate templates and device bindings#1378stktyagi wants to merge 61 commits into
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR extends Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant DeviceConfigSerializer
participant AbstractConfig
participant manage_device_certs
participant DeviceCertificate
participant get_cert_context
DeviceConfigSerializer->>AbstractConfig: update templates
AbstractConfig->>manage_device_certs: m2m_changed post_add/post_remove/post_clear
manage_device_certs->>DeviceCertificate: create or delete rows
DeviceCertificate->>AbstractConfig: certificate updates affect config status
AbstractConfig->>get_cert_context: inject cert paths and PEM data
sequenceDiagram
participant Device
participant capture_old_hardware_properties
participant detect_hardware_drift
participant regenerate_device_certificates_task
participant DeviceCertificate
participant Config
Device->>capture_old_hardware_properties: pre_save
Device->>detect_hardware_drift: post_save
detect_hardware_drift->>regenerate_device_certificates_task: delay(device_id, expected_cert_ids)
regenerate_device_certificates_task->>DeviceCertificate: revoke and replace certs
regenerate_device_certificates_task->>Config: update_status_if_checksum_changed()
Possibly related issues
Possibly related PRs
Suggested reviewers: Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (2 errors, 1 inconclusive)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Incremental Review (since 52c7544)The new commit (
No production request handlers, serializers, migrations, tenant-filtering, or security-relevant code paths are modified in this delta. No new critical bugs or security vulnerabilities. Files Reviewed (incremental, 2 files)
Previous Review Summaries (7 snapshots, latest commit 52c7544)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 52c7544)Status: No Issues Found | Recommendation: Merge Incremental Review (since b486eb5)The new commit (
No production request handlers, serializers, migrations, or tenant-filtering code paths are changed in this delta. No new critical bugs or security vulnerabilities were introduced. Files Reviewed (incremental, 3 files)
Previous review (commit b486eb5)Status: No Issues Found | Recommendation: Merge Incremental Review (since b52fe63)The new commits are low-risk follow-ups:
All changes are confined to the test Files Reviewed (incremental)
Previous review (commit b52fe63)Status: No Issues Found | Recommendation: Merge Incremental Review (since fb54051)The new commit A corresponding regression test, No new critical bugs or security vulnerabilities were introduced. Files Reviewed (incremental)
Previous review (commit fb54051)Status: No Issues Found | Recommendation: Merge Incremental Review (since 8c32282)The new commit
No new critical bugs or security vulnerabilities were introduced. Files Reviewed (incremental)
Carried-forward from prior reviewAll previously reviewed production files and their findings carry forward unchanged. Prior outstanding notes (cert-template validation regression test and Previous review (commit 8c32282)Status: No Issues Found | Recommendation: Merge Incremental Review (since a819721)The new commit
No new critical bugs or security vulnerabilities were introduced by this commit. Files Reviewed (incremental)
Carried-forward from prior reviewAll previously reviewed files and their findings carry forward unchanged. The prior outstanding note (missing regression test for cert-template validation in Previous review (commit a819721)Status: No Issues Found | Recommendation: Merge Incremental Review (since 298572f)The new commits add a large body of work: certificate regeneration on hardware drift (#1359), deactivated-device enforcement across config/connection/WHOIS/geo, pagination consolidation to The previously flagged WARNING (missing regression test for cert-template validation in Review highlights:
Extensive new tests accompany each change and Files Reviewed (incremental)
Previous review (commit 298572f)Status: 1 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Previous findings on No additional issues in unchanged code. Files Reviewed (5 files)
Reviewed by glm-5.2-20260616 · Input: 170.8K · Output: 2.2K · Cached: 64K |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openwisp_controller/config/base/template.py`:
- Around line 265-267: The help text for the auto_cert field is out of date (it
still says it's only valid for VPN templates) — update the auto_cert field's
help/verbose/help_text in the Template definition in
openwisp_controller/config/base/template.py so it matches the new behavior
(auto_cert is allowed when type == "cert" as well as when type == "vpn"); locate
the auto_cert attribute (and any admin/API serializer or form label/help_text
referencing it) and change the message to something like "Valid for 'vpn' and
'cert' template types" or equivalent clear wording that includes both types.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 33bb61f8-c083-446e-8e45-44d753e7ff7b
📒 Files selected for processing (3)
openwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}
📄 CodeRabbit inference engine (Custom checks)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}: Flag potential security vulnerabilities in code
Avoid unnecessary comments or docstrings for code that is already clear
Code formatting is compact and readable. Do not add excessive blank lines, especially inside function or method bodies
Flag unused or redundant code
Ensure variables, functions, classes, and files have descriptive and consistent names
New code must handle errors properly: log errors that cannot be resolved by the user with error level, log unusual conditions with warning level, log important background actions with info level, and provide user-facing messages for errors that the user can solve autonomously
Files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sql}
📄 CodeRabbit inference engine (Custom checks)
Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries
Files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sh,bash,sql}
📄 CodeRabbit inference engine (Custom checks)
Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable
Files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
**/*.{py,html}
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework
Files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
🧠 Learnings (4)
📚 Learning: 2026-01-12T22:27:40.078Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: tests/openwisp2/sample_config/migrations/0008_whoisinfo_organizationconfigsettings_whois_enabled.py:18-67
Timestamp: 2026-01-12T22:27:40.078Z
Learning: In test migrations under tests/openwisp2/sample_config/migrations, verify scenarios where a swappable model (CONFIG_WHOISINFO_MODEL) is extended with extra fields (e.g., an additional 'details' field) to ensure compatibility and no errors when swapping to a custom implementation. This pattern helps confirm that extending AbstractWHOISInfo via a custom model works as intended.
Applied to files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
📚 Learning: 2026-01-15T15:07:17.354Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/geo/estimated_location/tests/tests.py:172-175
Timestamp: 2026-01-15T15:07:17.354Z
Learning: In this repository, flake8 enforces E501 (line too long) via setup.cfg (max-line-length = 88) while ruff ignores E501 via ruff.toml. Therefore, use '# noqa: E501' on lines that intentionally exceed 88 characters to satisfy flake8 without affecting ruff checks. This applies to Python files across the project (any .py) and is relevant for tests as well. Use sparingly and only where breaking lines is not feasible without hurting readability or functionality.
Applied to files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
📚 Learning: 2026-01-15T15:05:49.557Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/management/commands/clear_last_ip.py:38-42
Timestamp: 2026-01-15T15:05:49.557Z
Learning: In Django projects, when using select_related() to traverse relations (for example, select_related("organization__config_settings")), the traversed relation must not be deferred. If you also use .only() in the same query, include the relation name or FK field (e.g., "organization" or "organization_id") in the .only() list to avoid the error "Field X cannot be both deferred and traversed using select_related at the same time." Apply this guideline to Django code in openwisp_controller/config/management/commands/clear_last_ip.py and similar modules by ensuring any select_related with an accompanying only() includes the related field names to prevent deferred/traversed conflicts.
Applied to files:
openwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
📚 Learning: 2026-02-17T19:13:10.088Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:10.088Z
Learning: In reviews for the openwisp/openwisp-controller repository, do not propose changes based on Ruff warnings. The project does not use Ruff as its linter; ignore Ruff-related suggestions and follow the repository’s established linting and configuration rules. This guidance applies to all Python files under the openwisp_controller directory.
Applied to files:
openwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py
🔇 Additional comments (3)
openwisp_controller/config/base/template.py (1)
25-29: LGTM!Also applies to: 62-83, 251-253, 271-312
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py (1)
1-59: LGTM!tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py (1)
1-58: LGTM!
{
"failures": [
{
"type": "Build/Infrastructure/Other",
"message": "Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue!",
"details": "The CI environment detected that the database migrations are out of sync. This is indicated by the error message 'Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue!' and the mention of a specific migration file '0005_user_expiration_date_user_user_active_expiry_idx.py'."
}
]
}CI Failure AnalysisHello @stktyagi,
Fix: Run |
Updated previous tests and added new tests for implemetation. Fixes #1356
Fixed help text for auto cert and updated migration files
Migrations Check FailedHello @stktyagi, The CI failed because there are unapplied database migrations. This means that the database schema is out of sync with the current state of the code. Fix: ./manage.py makemigrations |
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3). |
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openwisp_controller/config/base/template.py`:
- Around line 252-253: The validation of certificate relations (calls to
self._validate_org_relation("ca") and
self._validate_org_relation("blueprint_cert")) is running unconditionally and
can fail on stale relations when the object is being switched away from the
"cert" type; restrict these validations to the cert branch so they only run when
the template's type is "cert" (e.g., wrap or move the
self._validate_org_relation(...) calls inside the same conditional that handles
the "cert" branch or after the type check that preserves/clears ca and
blueprint_cert), ensuring they do not run when the code path clears those fields
(see the branch that clears ca and blueprint_cert).
- Around line 304-305: The current check "if not self.config" coerces any falsy
value ([], "", False) into {}, bypassing BaseConfig.clean() validation; change
the condition to only handle missing configs by checking "if self.config is
None" (or equivalent explicit None check) so only absent configs are replaced
with {} and invalid/falsy payloads are left intact for
full_clean()/BaseConfig.clean() to reject.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: d3d93328-e58d-41dd-a374-dffebd6d1e38
📒 Files selected for processing (5)
openwisp_controller/config/base/template.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/pki/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.13 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.1.0
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}
📄 CodeRabbit inference engine (Custom checks)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}: Flag potential security vulnerabilities in code
Avoid unnecessary comments or docstrings for code that is already clear
Code formatting is compact and readable. Do not add excessive blank lines, especially inside function or method bodies
Flag unused or redundant code
Ensure variables, functions, classes, and files have descriptive and consistent names
New code must handle errors properly: log errors that cannot be resolved by the user with error level, log unusual conditions with warning level, log important background actions with info level, and provide user-facing messages for errors that the user can solve autonomously
Files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sql}
📄 CodeRabbit inference engine (Custom checks)
Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries
Files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sh,bash,sql}
📄 CodeRabbit inference engine (Custom checks)
Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable
Files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
**/*.{py,html}
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework
Files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
🧠 Learnings (4)
📚 Learning: 2026-01-15T15:05:49.557Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/management/commands/clear_last_ip.py:38-42
Timestamp: 2026-01-15T15:05:49.557Z
Learning: In Django projects, when using select_related() to traverse relations (for example, select_related("organization__config_settings")), the traversed relation must not be deferred. If you also use .only() in the same query, include the relation name or FK field (e.g., "organization" or "organization_id") in the .only() list to avoid the error "Field X cannot be both deferred and traversed using select_related at the same time." Apply this guideline to Django code in openwisp_controller/config/management/commands/clear_last_ip.py and similar modules by ensuring any select_related with an accompanying only() includes the related field names to prevent deferred/traversed conflicts.
Applied to files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-02-17T19:13:10.088Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:10.088Z
Learning: In reviews for the openwisp/openwisp-controller repository, do not propose changes based on Ruff warnings. The project does not use Ruff as its linter; ignore Ruff-related suggestions and follow the repository’s established linting and configuration rules. This guidance applies to all Python files under the openwisp_controller directory.
Applied to files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-01-15T15:07:17.354Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/geo/estimated_location/tests/tests.py:172-175
Timestamp: 2026-01-15T15:07:17.354Z
Learning: In this repository, flake8 enforces E501 (line too long) via setup.cfg (max-line-length = 88) while ruff ignores E501 via ruff.toml. Therefore, use '# noqa: E501' on lines that intentionally exceed 88 characters to satisfy flake8 without affecting ruff checks. This applies to Python files across the project (any .py) and is relevant for tests as well. Use sparingly and only where breaking lines is not feasible without hurting readability or functionality.
Applied to files:
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-01-12T22:27:40.078Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: tests/openwisp2/sample_config/migrations/0008_whoisinfo_organizationconfigsettings_whois_enabled.py:18-67
Timestamp: 2026-01-12T22:27:40.078Z
Learning: In test migrations under tests/openwisp2/sample_config/migrations, verify scenarios where a swappable model (CONFIG_WHOISINFO_MODEL) is extended with extra fields (e.g., an additional 'details' field) to ensure compatibility and no errors when swapping to a custom implementation. This pattern helps confirm that extending AbstractWHOISInfo via a custom model works as intended.
Applied to files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
🔇 Additional comments (4)
openwisp_controller/pki/tests/test_api.py (1)
155-155: LGTM!Also applies to: 275-275
openwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.py (1)
12-16: LGTM!Also applies to: 19-44, 45-58, 59-74
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py (1)
11-14: LGTM!Also applies to: 17-42, 43-56, 57-72
openwisp_controller/config/base/template.py (1)
25-29: LGTM!Also applies to: 62-83, 119-120
Migrations Check FailedHello @stktyagi, The CI failed because there are unapplied database migrations. Failure: Migrations check failed! Models' changes not migrated, please run './manage.py makemigrations' to solve the issue! Fix: ./manage.py makemigrations |
…s/1356-extend-abstract-template
Validate cert relations only inside the cert branch and Only coerce missing cert configs, not every falsy value. Fixes #1356
Added test for the validation branch that now skips ca / blueprint_cert checks for non-cert templates Fixes #1356
Fixed line too long flake error Fixes #1356
Updated test by joining the list of strings into one sentence. Fixes #1377
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
openwisp_controller/config/static/config/js/switcher.js (1)
13-39: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRe-show the VPN helper when switching back to
vpn.After
vpn -> cert/generic -> vpn,.autovpnalready exists, so this branch skips creation and never shows the hidden helper again. The JSON editor stays visible even though the empty-VPN flow should restore the “save to auto-generate” message.💡 Minimal fix
toggle_specific_fields = function (changed) { var val = type_select.val(); if (val === "vpn") { vpn_specific.show(); - if ( - changed === true && - $(".autovpn").length < 1 && - $("`#id_config`").val() === "{}" - ) { - var p1 = gettext( - "Click on Save to automatically generate the " + - "VPN client configuration (will be based on " + - "the configuration of the server).", - ), - p2 = gettext( - "You can then tweak the VPN client " + "configuration in the next step.", - ); - $(".jsoneditor-wrapper").hide().after('<div class="form-row autovpn"></div>'); - $(".autovpn").html( - "<p><strong>" + p1 + "</strong></p>" + "<p><strong>" + p2 + "</strong></p>", - ); + if ($("`#id_config`").val() === "{}") { + if (changed === true && $(".autovpn").length < 1) { + var p1 = gettext( + "Click on Save to automatically generate the " + + "VPN client configuration (will be based on " + + "the configuration of the server).", + ), + p2 = gettext( + "You can then tweak the VPN client " + + "configuration in the next step.", + ); + $(".jsoneditor-wrapper").after('<div class="form-row autovpn"></div>'); + $(".autovpn").html( + "<p><strong>" + p1 + "</strong></p>" + + "<p><strong>" + p2 + "</strong></p>", + ); + } + $(".jsoneditor-wrapper").hide(); + $(".autovpn").show(); } } else { vpn_specific.hide();🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openwisp_controller/config/static/config/js/switcher.js` around lines 13 - 39, The toggle_specific_fields handler in switcher.js hides the VPN helper when leaving vpn, but when switching back to vpn it only creates .autovpn the first time and never re-shows it if it already exists. Update the vpn branch so that after vpn -> cert/generic -> vpn the existing .autovpn element is shown again and the jsoneditor-wrapper stays hidden for the empty-vpn flow; use the toggle_specific_fields, vpn_specific, jsoneditor-wrapper, and .autovpn logic to restore the helper whenever val === "vpn" and the config is still {}.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/user/certificate-templates.rst`:
- Around line 106-109: The renewal example in the certificate templates docs
uses the old PKI endpoint path, which conflicts with the documented REST API.
Update the standalone certificate renewal example in the paragraph referencing
Cert.renew() to use the /api/v1/controller/cert/{id}/renew/ path so it matches
docs/user/rest-api.rst and stays consistent with the rest of the API
documentation.
- Around line 241-243: The cross-reference in the certificate templates docs
points to a missing REST anchor, so update the reference in the related prose to
use an existing target from the REST docs or add the missing anchor in the REST
endpoint documentation. Verify the link target used by the Device endpoint
reference resolves from docs/user/rest-api.rst, and keep the wording in
certificate-templates.rst consistent with the actual endpoint name.
In `@openwisp_controller/config/admin.py`:
- Around line 458-463: The new admin label for certificate_details is currently
falling back to the method name and bypassing Django i18n. Update the
certificate_details admin accessor in admin.py to use an explicit translatable
description, such as via `@admin.display`(description=_("Certificate details")),
and ensure any related admin text in the affected admin class follows the same
pattern.
In `@openwisp_controller/config/api/serializers.py`:
- Around line 87-171: The validate() method in the serializer is duplicating
cert-template rules that already exist in
AbstractTemplate._clean_cert_template() and _validate_cert_template_changes(),
so the API path can drift from model/admin validation. Refactor this logic to
centralize the CA requirement, CA/blueprint compatibility, and active-template
mutation locks in a shared helper or rely on the model validation path, and keep
validate() in ConfigSerializer as a thin normalization layer that delegates to
the shared cert-template checks.
In `@openwisp_controller/config/base/template.py`:
- Around line 319-341: The template validation in clean() only checks that
blueprint_cert is unassigned and matches the CA, so revoked certificates can
still pass model-level validation. Update the Template.clean logic to explicitly
reject revoked blueprint certificates using the same rules as
get_unassigned_certs(), and keep the validation tied to the
blueprint_cert/blueprint_cert_id checks so Template(...,
blueprint_cert=revoked_cert).full_clean() fails consistently.
---
Outside diff comments:
In `@openwisp_controller/config/static/config/js/switcher.js`:
- Around line 13-39: The toggle_specific_fields handler in switcher.js hides the
VPN helper when leaving vpn, but when switching back to vpn it only creates
.autovpn the first time and never re-shows it if it already exists. Update the
vpn branch so that after vpn -> cert/generic -> vpn the existing .autovpn
element is shown again and the jsoneditor-wrapper stays hidden for the empty-vpn
flow; use the toggle_specific_fields, vpn_specific, jsoneditor-wrapper, and
.autovpn logic to restore the helper whenever val === "vpn" and the config is
still {}.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 73cb1f6d-d963-4deb-a0ed-70050aed6bcf
📒 Files selected for processing (31)
docs/developer/extending.rstdocs/index.rstdocs/user/certificate-templates.rstdocs/user/intro.rstdocs/user/rest-api.rstdocs/user/settings.rstdocs/user/templates.rstopenwisp_controller/config/admin.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/models.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/static/config/js/switcher.jsopenwisp_controller/config/tasks.pyopenwisp_controller/config/templates/admin/config/device_certificates_table.htmlopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/pki/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/models.pytests/openwisp2/sample_config/tests.pytests/openwisp2/settings.py
📜 Review details
⏰ Context from checks skipped due to timeout. (11)
- GitHub Check: Python==3.12 | django~=5.1.0
- GitHub Check: Python==3.12 | django~=4.2.0
- GitHub Check: Python==3.11 | django~=5.1.0
- GitHub Check: Python==3.11 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.2.0
- GitHub Check: Python==3.12 | django~=5.2.0
- GitHub Check: Python==3.11 | django~=5.2.0
- GitHub Check: Python==3.10 | django~=4.2.0
- GitHub Check: Python==3.10 | django~=5.1.0
- GitHub Check: Python==3.13 | django~=5.1.0
- GitHub Check: Python==3.13 | django~=5.2.0
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}
📄 CodeRabbit inference engine (Custom checks)
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp}: Flag potential security vulnerabilities in code
Avoid unnecessary comments or docstrings for code that is already clear
Code formatting is compact and readable. Do not add excessive blank lines, especially inside function or method bodies
Flag unused or redundant code
Ensure variables, functions, classes, and files have descriptive and consistent names
New code must handle errors properly: log errors that cannot be resolved by the user with error level, log unusual conditions with warning level, log important background actions with info level, and provide user-facing messages for errors that the user can solve autonomously
Files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pyopenwisp_controller/config/static/config/js/switcher.jsopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sql}
📄 CodeRabbit inference engine (Custom checks)
Flag obvious performance regressions, such as heavy loops, repeated I/O, or unoptimized queries
Files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pyopenwisp_controller/config/static/config/js/switcher.jsopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
**/*.{js,ts,tsx,jsx,py,java,go,cs,rb,php,c,cpp,h,hpp,sh,bash,sql}
📄 CodeRabbit inference engine (Custom checks)
Cryptic or non-obvious code (regex, complex bash commands, or hard-to-read code) must include a concise comment explaining why it is needed and why the complexity is acceptable
Files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pyopenwisp_controller/config/static/config/js/switcher.jsopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
**/*.{py,html}
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework
Files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/templates/admin/config/device_certificates_table.htmlopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Mark user-facing strings for translation with Django i18n helpers in Django code
Avoid unnecessary blank lines inside function and method bodies
Be careful with authentication, authorization, queryset filtering, serializers, admin behavior, cache invalidation, signals, Celery tasks, and websocket updates in Django code
Preserve validation around templates, VPN/PKI material, SSH credentials, device commands, uploaded files, URLs, and subnet/IP data
Write comments and docstrings only when they explain why code is shaped a certain way, placing them before the relevant code block instead of scattering them inside it
Files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
🧠 Learnings (9)
📚 Learning: 2026-01-15T15:07:17.354Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/geo/estimated_location/tests/tests.py:172-175
Timestamp: 2026-01-15T15:07:17.354Z
Learning: In this repository, flake8 enforces E501 (line too long) via setup.cfg (max-line-length = 88) while ruff ignores E501 via ruff.toml. Therefore, use '# noqa: E501' on lines that intentionally exceed 88 characters to satisfy flake8 without affecting ruff checks. This applies to Python files across the project (any .py) and is relevant for tests as well. Use sparingly and only where breaking lines is not feasible without hurting readability or functionality.
Applied to files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
📚 Learning: 2026-06-07T12:07:24.608Z
Learnt from: stktyagi
Repo: openwisp/openwisp-controller PR: 1378
File: openwisp_controller/pki/tests/test_api.py:155-155
Timestamp: 2026-06-07T12:07:24.608Z
Learning: When reviewing Python test files in this repository, avoid recommending inline comments that explain or justify `assertNumQueries` (Django query count) expectations. Query counts can change frequently as implementations evolve, and inline explanations add maintenance burden; the expected count should be understandable without added comment blocks.
Applied to files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-06-25T12:20:18.414Z
Learnt from: dee077
Repo: openwisp/openwisp-controller PR: 1395
File: openwisp_controller/connection/base/models.py:571-572
Timestamp: 2026-06-25T12:20:18.414Z
Learning: When writing or reviewing tests that override pagination behavior via OpenWispPagination.paginate_queryset(), patch `view.pagination_page_size` (not `page_size`). The method uses `getattr(view, "pagination_page_size", self.page_size)`, so tests must set the attribute on the view to affect pagination. If the view class does not define `pagination_page_size`, using `unittest.mock.patch(..., create=True)` is intentional and correct because the attribute may not exist until patched.
Applied to files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/tests/test_config.pytests/openwisp2/settings.pytests/openwisp2/sample_config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-06-07T12:07:25.164Z
Learnt from: stktyagi
Repo: openwisp/openwisp-controller PR: 1378
File: openwisp_controller/config/tests/test_config.py:864-865
Timestamp: 2026-06-07T12:07:25.164Z
Learning: When reviewing this repo’s Python test suite, treat changes to the *expected* query count in `assertNumQueries(...)` calls as routine test maintenance. If a PR updates the numeric argument (e.g., in `test_config.py`, `test_api.py`, `test_admin.py`, `test_pki.py`) and the test remains consistent with the feature changes, reviewers should not flag the increased number as a performance regression that requires investigation solely because the count went up; instead, focus on whether the update is intentional and the surrounding test/code changes justify the revised expectation.
Applied to files:
tests/openwisp2/sample_config/tests.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-01-15T15:05:49.557Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/management/commands/clear_last_ip.py:38-42
Timestamp: 2026-01-15T15:05:49.557Z
Learning: In Django projects, when using select_related() to traverse relations (for example, select_related("organization__config_settings")), the traversed relation must not be deferred. If you also use .only() in the same query, include the relation name or FK field (e.g., "organization" or "organization_id") in the .only() list to avoid the error "Field X cannot be both deferred and traversed using select_related at the same time." Apply this guideline to Django code in openwisp_controller/config/management/commands/clear_last_ip.py and similar modules by ensuring any select_related with an accompanying only() includes the related field names to prevent deferred/traversed conflicts.
Applied to files:
openwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
📚 Learning: 2026-02-17T19:13:10.088Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:10.088Z
Learning: In reviews for the openwisp/openwisp-controller repository, do not propose changes based on Ruff warnings. The project does not use Ruff as its linter; ignore Ruff-related suggestions and follow the repository’s established linting and configuration rules. This guidance applies to all Python files under the openwisp_controller directory.
Applied to files:
openwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/admin.py
📚 Learning: 2026-06-07T12:07:08.468Z
Learnt from: stktyagi
Repo: openwisp/openwisp-controller PR: 1378
File: openwisp_controller/config/tests/test_admin.py:2335-2335
Timestamp: 2026-06-07T12:07:08.468Z
Learning: In this project’s Python test suite (files under openwisp_controller/**/tests/), don’t require or request prose/inline comments that document the breakdown of query-count changes (e.g., assertions around template/DB query counts in helpers like _verify_template_queries). Treat query-count assertions as volatile implementation details that change frequently; review should focus on whether the test asserts the expected behavior, not on explaining the specific query-count deltas in comments.
Applied to files:
openwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-06-25T12:20:45.387Z
Learnt from: dee077
Repo: openwisp/openwisp-controller PR: 1395
File: openwisp_controller/connection/tests/test_api.py:916-932
Timestamp: 2026-06-25T12:20:45.387Z
Learning: When reviewing API pagination behavior in openwisp-controller, assume `OpenWispPagination.paginate_queryset()` allows a per-view page-size override via `getattr(view, "pagination_page_size", self.page_size)` (so `view.pagination_page_size`, if present, should affect pagination). In Python tests, it is valid to patch `pagination_page_size` on a view class even if the attribute isn’t declared on the class by default, by using `unittest.mock.patch.object(..., "pagination_page_size", ..., create=True)` so the override is available for the pagination logic during the test.
Applied to files:
openwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_template.py
📚 Learning: 2026-01-12T22:27:40.078Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: tests/openwisp2/sample_config/migrations/0008_whoisinfo_organizationconfigsettings_whois_enabled.py:18-67
Timestamp: 2026-01-12T22:27:40.078Z
Learning: In test migrations under tests/openwisp2/sample_config/migrations, verify scenarios where a swappable model (CONFIG_WHOISINFO_MODEL) is extended with extra fields (e.g., an additional 'details' field) to ensure compatibility and no errors when swapping to a custom implementation. This pattern helps confirm that extending AbstractWHOISInfo via a custom model works as intended.
Applied to files:
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
🪛 ast-grep (0.44.0)
openwisp_controller/config/tests/test_selenium.py
[warning] 25-25: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("openwisp_notifications", "Notification")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/handlers.py
[warning] 98-98: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
[info] 106-106: use help_text to document model columns
Context: models.CharField(blank=True, max_length=64, null=True)
Note: [CWE-710] Improper Adherence to Coding Standards.
(model-help-text)
openwisp_controller/config/base/template.py
[warning] 40-40: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("django_x509", "Cert")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 41-41: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 274-274: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Config")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 328-328: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/tasks.py
[warning] 232-232: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Device")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 233-233: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/base/device_certificate.py
[warning] 41-41: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Template")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/tests/test_device.py
[warning] 30-30: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("django_x509", "Cert")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 31-31: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("django_x509", "Ca")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 32-32: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "OrganizationConfigSettings")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
🪛 HTMLHint (1.9.2)
openwisp_controller/config/templates/admin/config/device_certificates_table.html
[error] 1-1: Doctype must be declared before any non-comment content.
(doctype-first)
🔇 Additional comments (10)
openwisp_controller/config/base/template.py (1)
267-299: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winGuard active
* -> certtype flips too, or reconcile existing assignments.Line 270 only blocks
cert -> *. An already-assigned active template can still be switched fromgeneric/vpntocert, but the save hooks in this file only recompute config status; they do not createDeviceCertificaterows for the existingConfig.templatesrelations. That leaves active configs attached to a certificate template without the cert relation/context until the template is removed and re-added. As per coding guidelines, preserve validation around templates.Suggested fix
- changing_protected_fields = ( - current.ca_id != self.ca_id - or current.blueprint_cert_id != self.blueprint_cert_id - or (current.type == "cert" and self.type != "cert") - ) + changing_protected_fields = ( + current.ca_id != self.ca_id + or current.blueprint_cert_id != self.blueprint_cert_id + or (current.type != self.type and "cert" in {current.type, self.type}) + ) @@ - if current.type == "cert" and self.type != "cert": + if current.type != self.type and "cert" in {current.type, self.type}: errors["type"] = _( "This template is already assigned to active devices. " - "You cannot change the template type from certificate " + "You cannot change the template type to or from certificate " "on an active template." )> Likely an incorrect or invalid review comment.Source: Coding guidelines
openwisp_controller/config/base/device_certificate.py (1)
125-147: Custom hardware OIDs are still encoded in a django-x509-incompatible shape.
_build_extensions()appends{"oid": ..., "value": ..., "critical": ...}items, but the current django-x509 validation path expects extension dicts keyed byname. That still leaves certificate creation failing withUnsupported extension: None, so template assignment and hardware-drift regeneration remain blocked until these OIDs are emitted in a format supported by the repo-pinned django-x509 version. Please verify this against the pinned dependency before merging.openwisp_controller/config/tests/test_config.py (1)
864-871: LGTM!tests/openwisp2/sample_config/models.py (1)
99-105: LGTM!openwisp_controller/pki/tests/test_api.py (1)
155-155: LGTM!Also applies to: 256-256, 267-275, 292-292
openwisp_controller/config/tests/test_selenium.py (1)
25-26: LGTM!Also applies to: 491-562, 846-878
openwisp_controller/config/handlers.py (1)
48-114: LGTM!openwisp_controller/config/tests/test_admin.py (1)
11-11: LGTM!Also applies to: 53-53, 1806-1830, 2363-2364, 2458-2458
openwisp_controller/config/tasks.py (1)
226-294: LGTM!openwisp_controller/config/base/config.py (1)
66-72: LGTM!Also applies to: 476-489, 502-547, 978-1003, 1032-1032
Addressed improvements and docs correction.
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3). |
|
@coderabbitai resolve |
✅ Action performedComments resolved and changes approved. |
Changed certificate details to a separate tab in device admin
Fixed failed tests after changes
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3). |
9f8d28e to
0c9645a
Compare
0c9645a to
1c6d532
Compare
…s/1356-extend-abstract-template
Merged migration for config app.
Improved ui and column names for certificate details with pagination
Fixed test causing failure in ci
|
The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3). |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
openwisp_controller/config/apps.py (1)
93-102: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDocument why
manage_device_certsmust run beforetemplates_changed.The comment above
manage_vpn_clientsexplains VPN clients must be created or removed before self.config_model.templates_changed is evaluated, because the VpnClient context can influence the configuration checksum. The same rationale applies tomanage_device_certs(itsDeviceCertificaterows feedget_cert_context(), which affects the checksum), and it is correctly positioned beforetemplates_changed— but there's no comment explaining why, unlike its sibling. Without it, a future refactor could silently reorder these connects and break checksum correctness.📝 Suggested comment
+ # DeviceCertificate rows must be created or removed **before** + # self.config_model.templates_changed is evaluated, because the + # cert context can influence the configuration checksum. m2m_changed.connect( self.config_model.manage_device_certs, sender=self.config_model.templates.through, dispatch_uid="config.manage_device_certs", )🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openwisp_controller/config/apps.py` around lines 93 - 102, The `m2m_changed.connect` for `manage_device_certs` needs an explanatory comment like the nearby `manage_vpn_clients` block, since `DeviceCertificate` data is used by `get_cert_context()` and must be updated before `templates_changed` runs to keep the checksum correct. Add a brief note near the `manage_device_certs` connection in `config_model` setup explaining that it must execute before `templates_changed`, so future refactors do not reorder it and break checksum generation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@openwisp_controller/config/admin.py`:
- Around line 967-1011: The certificate-details queryset in
_add_certificate_details needs an explicit, deterministic order before slicing,
since the current [:51] truncation and has_more logic depend on stable row
ordering. Update the DeviceCertificate.objects.filter(...).select_related(...)
queryset to order by the same field used in Config.get_cert_context(),
specifically created, so the first 50 shown certificates are consistent across
requests and the “more” indicator is accurate.
In `@openwisp_controller/config/base/device_certificate.py`:
- Around line 12-13: Update the django-x509 dependency pin to a release that
supports custom oid extensions, since the current 1.4 branch tarball does not
handle the MAC_ADDRESS_OID and DEVICE_UUID_OID values used in
device_certificate.py. Adjust the dependency in requirements.txt to a version
with custom OID support, then verify the device certificate generation path
still works with those extension identifiers.
In `@openwisp_controller/config/base/template.py`:
- Around line 257-301: Add a regression test for the type-mutation branch in
_validate_cert_template_changes, since the existing deleted-instance coverage
does not hit current.type == "cert" and self.type != "cert". Create a test that
loads an active cert template, mutates its type away from "cert", and calls
clean() to assert a ValidationError is raised with an error on the type field.
In `@openwisp_controller/config/handlers.py`:
- Around line 98-107: The “active auto cert” queryset logic is duplicated in the
device certificate handling code and in the regeneration task, so extract the
shared filter into a single reusable API on DeviceCertificate. Add a
manager/classmethod such as DeviceCertificate.active_auto_certs_for(device) or
DeviceCertificate.objects.active_auto_certs_for(device) that encapsulates
config__device, auto_cert=True, cert__revoked=False, and template__type="cert",
then update both handlers.py and regenerate_device_certificates_task in tasks.py
to call that helper instead of repeating the filter inline.
In `@openwisp_controller/config/static/config/js/switcher.js`:
- Around line 47-63: The switcher logic contains a redundant show/hide branch
for auto_cert_field that duplicates the later conditional in the same handler.
Remove the առաջին duplicate if/else block and keep the unified val check that
both toggles auto_cert_field and updates auto_cert_label in switcher.js, using
the existing auto_cert_field and auto_cert_label symbols.
In `@openwisp_controller/config/tasks.py`:
- Around line 291-294: The exception handler in the regeneration notification
logic is redundant because `ImportError` is already covered by `Exception`.
Update the `except (ImportError, Exception) as e` block in the relevant task
function to catch only `Exception` while keeping the existing warning log
message with `device.name` and the exception details.
---
Outside diff comments:
In `@openwisp_controller/config/apps.py`:
- Around line 93-102: The `m2m_changed.connect` for `manage_device_certs` needs
an explanatory comment like the nearby `manage_vpn_clients` block, since
`DeviceCertificate` data is used by `get_cert_context()` and must be updated
before `templates_changed` runs to keep the checksum correct. Add a brief note
near the `manage_device_certs` connection in `config_model` setup explaining
that it must execute before `templates_changed`, so future refactors do not
reorder it and break checksum generation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 08768b0a-73f9-4017-a7fc-c0025976cfcb
📒 Files selected for processing (33)
docs/developer/extending.rstdocs/index.rstdocs/user/certificate-templates.rstdocs/user/intro.rstdocs/user/rest-api.rstdocs/user/settings.rstdocs/user/templates.rstopenwisp_controller/config/admin.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/migrations/0065_merge_20260702_1946.pyopenwisp_controller/config/models.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/static/config/js/switcher.jsopenwisp_controller/config/tasks.pyopenwisp_controller/config/templates/admin/config/device/change_form.htmlopenwisp_controller/config/templates/admin/config/device_certificates_table.htmlopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/tests/test_device.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/pki/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pytests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pytests/openwisp2/sample_config/models.pytests/openwisp2/settings.py
📜 Review details
⚠️ CI failures not shown inline (11)
GitHub Actions: OpenWISP Controller CI Build / 7_Python==3.12 django~=4.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting propcache>=0.2.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached propcache-0.5.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (16 kB)
Requirement already satisfied: typing_extensions>=4.4 in /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (4.16.0)
Collecting yarl<2.0,>=1.17.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached yarl-1.24.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (94 kB)
Collecting geographiclib<3,>=1.52 (from geopy~=2.4.1->django-loci @ https://github.com/openwisp/django-loci/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached geographiclib-2.1-py3-none-any.whl.metadata (1.6 kB)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages (from jinja2~=3.1.6->netjsonconfig @ https://github.com/openwisp/netjsonconfig/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (3.0.3)
Collecting jsonschema-specifications>=2023.03.6 (from jsonschema~=4.26.0->netjsonconfig @ https://github.com/openwisp/netjsonconfig/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached jsonschema_specifications-2025.9.1-py3-none-any.whl.metadata (2.9 kB)
Collecting referencing>=0.28.4 (from jsonschema~=4.26.0->netjsonconfig @ https://github.com/openwisp/netjsonconfig/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached referencing-0.37.0-py3-none-any.whl.metadata (2.8 kB)
Collecting rpds-py>=0.25.0 (from jsonschema~=4.26.0->netjsonconfig @ https://github.com/openwisp/netjsonconfig/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cac...
GitHub Actions: OpenWISP Controller CI Build / 1_Python==3.11 django~=5.1.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
x_2_28_x86_64.whl.metadata (8.3 kB)
Collecting maxminddb<4.0.0,>=3.0.0 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached maxminddb-3.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting aiohappyeyeballs>=2.5.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Downloading aiohappyeyeballs-2.7.1-py3-none-any.whl.metadata (5.9 kB)
Collecting aiosignal>=1.4.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiosignal-1.4.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: attrs>=17.3.0 in /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (26.1.0)
Collecting frozenlist>=1.1.1 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached frozenlist-1.8.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (20 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached multidict-6.7.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting propcache>=0.2.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached propcache-0.5.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (16 kB)
Requirement already satisfied: typing_extensions>=4.4 in /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (4.16.0)
Collecting yarl<2.0,>=1.17.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached yarl-1.24.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (94 kB)
Co...
GitHub Actions: OpenWISP Controller CI Build / 8_Python==3.10 django~=5.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
41021-py3-none-any.whl.metadata (5.5 kB)
Collecting tablib>=3.7.0 (from django-import-export~=4.4.1->openwisp-controller==1.3a0)
Using cached tablib-3.9.0-py3-none-any.whl.metadata (3.8 kB)
Requirement already satisfied: rjsmin<2.0.0,>=1.2.0 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from django-minify-compress-staticfiles~=1.1.1->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (1.2.5)
Requirement already satisfied: rcssmin<2.0.0,>=1.1.0 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from django-minify-compress-staticfiles~=1.1.1->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (1.2.2)
Requirement already satisfied: brotli<2.0.0,>=1.2.0 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from django-minify-compress-staticfiles~=1.1.1->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (1.2.0)
Collecting inflection>=0.3.1 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached inflection-0.5.1-py2.py3-none-any.whl.metadata (1.7 kB)
Collecting pytz>=2021.1 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/op...
GitHub Actions: OpenWISP Controller CI Build / 9_Python==3.13 django~=5.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
nwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached pytz-2026.2-py2.py3-none-any.whl.metadata (22 kB)
Requirement already satisfied: pyyaml>=5.1 in /opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (6.0.3)
Collecting uritemplate>=3.0.0 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached uritemplate-4.2.0-py3-none-any.whl.metadata (2.6 kB)
Collecting aiohttp<4.0.0,>=3.6.2 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiohttp-3.14.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (8.3 kB)
Collecting maxminddb<4.0.0,>=3.0.0 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached maxminddb-3.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting aiohappyeyeballs>=2.5.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Downloading aiohappyeyeballs-2.7.1-py3-none-any.whl.metadata (5.9 kB)
Collecting aiosignal>=1.4.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiosignal-1.4.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: attrs>=17.3.0 in /opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (26.1...
GitHub Actions: OpenWISP Controller CI Build / 11_Python==3.13 django~=5.1.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
s/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached uritemplate-4.2.0-py3-none-any.whl.metadata (2.6 kB)
Collecting aiohttp<4.0.0,>=3.6.2 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiohttp-3.14.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (8.3 kB)
Collecting maxminddb<4.0.0,>=3.0.0 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached maxminddb-3.1.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting aiohappyeyeballs>=2.5.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Downloading aiohappyeyeballs-2.7.1-py3-none-any.whl.metadata (5.9 kB)
Collecting aiosignal>=1.4.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiosignal-1.4.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: attrs>=17.3.0 in /opt/hostedtoolcache/Python/3.13.14/x64/lib/python3.13/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (26.1.0)
Collecting frozenlist>=1.1.1 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached frozenlist-1.8.0-cp313-cp313-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (20 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached multidict-6.7.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting propcache>=0.2.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached propcache-0.5.2-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (16 kB)
Collecting yarl<2.0,>=1.17.0 (...
GitHub Actions: OpenWISP Controller CI Build / 3_Python==3.11 django~=4.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
2.0->openwisp-controller==1.3a0)
Using cached aiosignal-1.4.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: attrs>=17.3.0 in /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (26.1.0)
Collecting frozenlist>=1.1.1 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached frozenlist-1.8.0-cp311-cp311-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (20 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached multidict-6.7.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting propcache>=0.2.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached propcache-0.5.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (16 kB)
Requirement already satisfied: typing_extensions>=4.4 in /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (4.16.0)
Collecting yarl<2.0,>=1.17.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached yarl-1.24.2-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (94 kB)
Collecting geographiclib<3,>=1.52 (from geopy~=2.4.1->django-loci @ https://github.com/openwisp/django-loci/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached geographiclib-2.1-py3-none-any.whl.metadata (1.6 kB)
Requirement already satisfied: MarkupSafe>=2.0 in /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages (from jinja2~=3.1.6->netjsonconfig @ https://github.com/openwisp/netjsonconfig/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (3.0.3)
Collecting jsonschema...
GitHub Actions: OpenWISP Controller CI Build / 10_Python==3.11 django~=5.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
f-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached inflection-0.5.1-py2.py3-none-any.whl.metadata (1.7 kB)
Collecting pytz>=2021.1 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached pytz-2026.2-py2.py3-none-any.whl.metadata (22 kB)
Requirement already satisfied: pyyaml>=5.1 in /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (6.0.3)
Collecting uritemplate>=3.0.0 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached uritemplate-4.2.0-py3-none-any.whl.metadata (2.6 kB)
Collecting aiohttp<4.0.0,>=3.6.2 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiohttp-3.14.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (8.3 kB)
Collecting maxminddb<4.0.0,>=3.0.0 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached maxminddb-3.1.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting aiohappyeyeballs>=2.5.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Downloading aioha...
GitHub Actions: OpenWISP Controller CI Build / 6_Python==3.12 django~=5.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
1.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (6.0.3)
Collecting uritemplate>=3.0.0 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached uritemplate-4.2.0-py3-none-any.whl.metadata (2.6 kB)
Collecting aiohttp<4.0.0,>=3.6.2 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiohttp-3.14.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (8.3 kB)
Collecting maxminddb<4.0.0,>=3.0.0 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached maxminddb-3.1.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting aiohappyeyeballs>=2.5.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Downloading aiohappyeyeballs-2.7.1-py3-none-any.whl.metadata (5.9 kB)
Collecting aiosignal>=1.4.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiosignal-1.4.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: attrs>=17.3.0 in /opt/hostedtoolcache/Python/3.12.13/x64/lib/python3.12/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (26.1.0)
Collecting frozenlist>=1.1.1 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached frozenlist-1.8.0-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (20 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached multidict-6.7.1-cp312...
GitHub Actions: OpenWISP Controller CI Build / 2_Python==3.10 django~=4.2.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached uritemplate-4.2.0-py3-none-any.whl.metadata (2.6 kB)
Collecting aiohttp<4.0.0,>=3.6.2 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiohttp-3.14.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (8.3 kB)
Collecting maxminddb<4.0.0,>=3.0.0 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached maxminddb-3.1.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting aiohappyeyeballs>=2.5.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Downloading aiohappyeyeballs-2.7.1-py3-none-any.whl.metadata (5.9 kB)
Collecting aiosignal>=1.4.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiosignal-1.4.0-py3-none-any.whl.metadata (3.7 kB)
Requirement already satisfied: async-timeout<6.0,>=4.0 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (5.0.1)
Requirement already satisfied: attrs>=17.3.0 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0) (26.1.0)
Collecting frozenlist>=1.1.1 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached frozenlist-1.8.0-cp310-cp310-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl.metadata (20 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached multidict-6.7.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.metadata (5.3 kB)
Collecting propcache>=0.2.0 (from aiohttp<4.0.0,>=3.6.2->geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached propcache-0.5.2-cp310-cp3...
GitHub Actions: OpenWISP Controller CI Build / 5_Python==3.10 django~=5.1.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
1.2.2)
Requirement already satisfied: brotli<2.0.0,>=1.2.0 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from django-minify-compress-staticfiles~=1.1.1->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (1.2.0)
Collecting inflection>=0.3.1 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached inflection-0.5.1-py2.py3-none-any.whl.metadata (1.7 kB)
Collecting pytz>=2021.1 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached pytz-2026.2-py2.py3-none-any.whl.metadata (22 kB)
Requirement already satisfied: pyyaml>=5.1 in /opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0) (6.0.3)
Collecting uritemplate>=3.0.0 (from drf-yasg<1.22.0,>=1.21.14->openwisp-utils @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-utils[celery,channels] @ https://github.com/openwisp/openwisp-utils/archive/refs/heads/1.3.tar.gz->openwisp-controller==1.3a0)
Using cached uritemplate-4.2.0-py3-none-any.whl.metadata (2.6 kB)
Collecting aiohttp<4.0.0,>=3.6.2 (from geoip2<6.0.0,>=5.2.0->openwisp-controller==1.3a0)
Using cached aiohttp-3.14.1-cp3...
GitHub Actions: OpenWISP Controller CI Build / 4_Python==3.12 django~=5.1.0.txt: [feature] Introduced standalone certificate templates and device bindings
Conclusion: failure
oller.pki.tests.test_api.TestPkiApi.test_cert_patch_api)�[0m
�[33;1m (0.47s)�[0m test_cert_patch_api
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_cert_post_api)�[0m
�[33;1m (0.46s)�[0m test_cert_post_api
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_cert_post_with_date_none)�[0m
�[33;1m (0.50s)�[0m test_cert_post_with_date_none
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_cert_post_with_extensions_field)�[0m
�[33;1m (0.50s)�[0m test_cert_post_with_extensions_field
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_cert_put_api)�[0m
�[33;1m (0.40s)�[0m test_cert_put_api
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_crl_download_api)�[0m
�[33;1m (0.43s)�[0m test_crl_download_api
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_import_cert_post_api)�[0m
�[33;1m (0.41s)�[0m test_import_cert_post_api
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_post_cert_renew_api)�[0m
�[33;1m (0.52s)�[0m test_post_cert_renew_api
�[33;1m(openwisp_controller.pki.tests.test_api.TestPkiApi.test_post_cert_revoke_api)�[0m
�[33;1m (0.47s)�[0m test_post_cert_revoke_api
�[33;1m(openwisp_controller.pki.tests.test_models.TestModels.test_ca_creation_with_org)�[0m
�[33;1m (0.30s)�[0m test_ca_creation_with_org
�[33;1m(openwisp_controller.pki.tests.test_models.TestModels.test_ca_creation_without_org)�[0m
�[33;1m (0.30s)�[0m test_ca_creation_without_org
�[33;1m(openwisp_controller.pki.tests.test_models.TestModels.test_cert_and_ca_different_organization)�[0m
�[33;1m (0.32s)�[0m test_cert_and_ca_different_organization
�[33;1m(openwisp_controller.pki.tests.test_models.TestModels.test_cert_creation)�[0m
�[33;1m (0.43s)�[0m test_cert_creation
�[33;1m(openwisp_controller.pki.tests.test_models.TestModels.test_crl_view)�[0m
�[33;1m (0.36s)�[0m test_crl_view
�[33;1m(openwisp_controller.pki.tests.test_models.TestModels.test_unique_together_org_none)�[0m
�...
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (AGENTS.md)
**/*.py: Mark user-facing strings for translation with Django i18n helpers in Django code
Avoid unnecessary blank lines inside function and method bodies
Be careful with authentication, authorization, queryset filtering, serializers, admin behavior, cache invalidation, signals, Celery tasks, and websocket updates in Django code
Preserve validation around templates, VPN/PKI material, SSH credentials, device commands, uploaded files, URLs, and subnet/IP data
Write comments and docstrings only when they explain why code is shaped a certain way, placing them before the relevant code block instead of scattering them inside it
Files:
openwisp_controller/config/migrations/0065_merge_20260702_1946.pyopenwisp_controller/config/settings.pytests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pytests/openwisp2/settings.pyopenwisp_controller/config/apps.pytests/openwisp2/sample_config/models.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
**/*.{py,html}
📄 CodeRabbit inference engine (Custom checks)
For Django pull requests, ensure all user-facing strings are marked as translatable using the Django i18n framework.
Files:
openwisp_controller/config/migrations/0065_merge_20260702_1946.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/templates/admin/config/device/change_form.htmltests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pyopenwisp_controller/config/templates/admin/config/device_certificates_table.htmltests/openwisp2/settings.pyopenwisp_controller/config/apps.pytests/openwisp2/sample_config/models.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
🧠 Learnings (9)
📚 Learning: 2026-01-15T15:05:49.557Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/management/commands/clear_last_ip.py:38-42
Timestamp: 2026-01-15T15:05:49.557Z
Learning: In Django projects, when using select_related() to traverse relations (for example, select_related("organization__config_settings")), the traversed relation must not be deferred. If you also use .only() in the same query, include the relation name or FK field (e.g., "organization" or "organization_id") in the .only() list to avoid the error "Field X cannot be both deferred and traversed using select_related at the same time." Apply this guideline to Django code in openwisp_controller/config/management/commands/clear_last_ip.py and similar modules by ensuring any select_related with an accompanying only() includes the related field names to prevent deferred/traversed conflicts.
Applied to files:
openwisp_controller/config/migrations/0065_merge_20260702_1946.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-02-17T19:13:10.088Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/config/whois/commands.py:0-0
Timestamp: 2026-02-17T19:13:10.088Z
Learning: In reviews for the openwisp/openwisp-controller repository, do not propose changes based on Ruff warnings. The project does not use Ruff as its linter; ignore Ruff-related suggestions and follow the repository’s established linting and configuration rules. This guidance applies to all Python files under the openwisp_controller directory.
Applied to files:
openwisp_controller/config/migrations/0065_merge_20260702_1946.pyopenwisp_controller/config/settings.pyopenwisp_controller/config/apps.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-01-15T15:07:17.354Z
Learnt from: DragnEmperor
Repo: openwisp/openwisp-controller PR: 1175
File: openwisp_controller/geo/estimated_location/tests/tests.py:172-175
Timestamp: 2026-01-15T15:07:17.354Z
Learning: In this repository, flake8 enforces E501 (line too long) via setup.cfg (max-line-length = 88) while ruff ignores E501 via ruff.toml. Therefore, use '# noqa: E501' on lines that intentionally exceed 88 characters to satisfy flake8 without affecting ruff checks. This applies to Python files across the project (any .py) and is relevant for tests as well. Use sparingly and only where breaking lines is not feasible without hurting readability or functionality.
Applied to files:
openwisp_controller/config/migrations/0065_merge_20260702_1946.pyopenwisp_controller/config/settings.pytests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pytests/openwisp2/settings.pyopenwisp_controller/config/apps.pytests/openwisp2/sample_config/models.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/config/models.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/handlers.pyopenwisp_controller/config/base/config.pyopenwisp_controller/config/migrations/0064_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/api/serializers.pyopenwisp_controller/config/tasks.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/base/device_certificate.pyopenwisp_controller/config/admin.pyopenwisp_controller/config/base/template.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-01-12T22:27:40.078Z
Learnt from: nemesifier
Repo: openwisp/openwisp-controller PR: 1175
File: tests/openwisp2/sample_config/migrations/0008_whoisinfo_organizationconfigsettings_whois_enabled.py:18-67
Timestamp: 2026-01-12T22:27:40.078Z
Learning: In test migrations under tests/openwisp2/sample_config/migrations, verify scenarios where a swappable model (CONFIG_WHOISINFO_MODEL) is extended with extra fields (e.g., an additional 'details' field) to ensure compatibility and no errors when swapping to a custom implementation. This pattern helps confirm that extending AbstractWHOISInfo via a custom model works as intended.
Applied to files:
tests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
📚 Learning: 2026-06-07T12:07:24.608Z
Learnt from: stktyagi
Repo: openwisp/openwisp-controller PR: 1378
File: openwisp_controller/pki/tests/test_api.py:155-155
Timestamp: 2026-06-07T12:07:24.608Z
Learning: When reviewing Python test files in this repository, avoid recommending inline comments that explain or justify `assertNumQueries` (Django query count) expectations. Query counts can change frequently as implementations evolve, and inline explanations add maintenance burden; the expected count should be understandable without added comment blocks.
Applied to files:
tests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pytests/openwisp2/settings.pytests/openwisp2/sample_config/models.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-06-25T12:20:18.414Z
Learnt from: dee077
Repo: openwisp/openwisp-controller PR: 1395
File: openwisp_controller/connection/base/models.py:571-572
Timestamp: 2026-06-25T12:20:18.414Z
Learning: When writing or reviewing tests that override pagination behavior via OpenWispPagination.paginate_queryset(), patch `view.pagination_page_size` (not `page_size`). The method uses `getattr(view, "pagination_page_size", self.page_size)`, so tests must set the attribute on the view to affect pagination. If the view class does not define `pagination_page_size`, using `unittest.mock.patch(..., create=True)` is intentional and correct because the attribute may not exist until patched.
Applied to files:
tests/openwisp2/sample_config/migrations/0011_merge_20260702_1946.pytests/openwisp2/settings.pytests/openwisp2/sample_config/models.pyopenwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pytests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-06-07T12:07:08.468Z
Learnt from: stktyagi
Repo: openwisp/openwisp-controller PR: 1378
File: openwisp_controller/config/tests/test_admin.py:2335-2335
Timestamp: 2026-06-07T12:07:08.468Z
Learning: In this project’s Python test suite (files under openwisp_controller/**/tests/), don’t require or request prose/inline comments that document the breakdown of query-count changes (e.g., assertions around template/DB query counts in helpers like _verify_template_queries). Treat query-count assertions as volatile implementation details that change frequently; review should focus on whether the test asserts the expected behavior, not on explaining the specific query-count deltas in comments.
Applied to files:
openwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-06-07T12:07:25.164Z
Learnt from: stktyagi
Repo: openwisp/openwisp-controller PR: 1378
File: openwisp_controller/config/tests/test_config.py:864-865
Timestamp: 2026-06-07T12:07:25.164Z
Learning: When reviewing this repo’s Python test suite, treat changes to the *expected* query count in `assertNumQueries(...)` calls as routine test maintenance. If a PR updates the numeric argument (e.g., in `test_config.py`, `test_api.py`, `test_admin.py`, `test_pki.py`) and the test remains consistent with the feature changes, reviewers should not flag the increased number as a performance regression that requires investigation solely because the count went up; instead, focus on whether the update is intentional and the surrounding test/code changes justify the revised expectation.
Applied to files:
openwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
📚 Learning: 2026-06-25T12:20:45.387Z
Learnt from: dee077
Repo: openwisp/openwisp-controller PR: 1395
File: openwisp_controller/connection/tests/test_api.py:916-932
Timestamp: 2026-06-25T12:20:45.387Z
Learning: When reviewing API pagination behavior in openwisp-controller, assume `OpenWispPagination.paginate_queryset()` allows a per-view page-size override via `getattr(view, "pagination_page_size", self.page_size)` (so `view.pagination_page_size`, if present, should affect pagination). In Python tests, it is valid to patch `pagination_page_size` on a view class even if the attribute isn’t declared on the class by default, by using `unittest.mock.patch.object(..., "pagination_page_size", ..., create=True)` so the override is available for the pagination logic during the test.
Applied to files:
openwisp_controller/config/tests/test_config.pyopenwisp_controller/pki/tests/test_api.pyopenwisp_controller/config/tests/test_selenium.pyopenwisp_controller/config/tests/test_api.pyopenwisp_controller/config/tests/test_admin.pyopenwisp_controller/config/tests/test_template.pyopenwisp_controller/config/tests/test_device.py
🪛 ast-grep (0.44.0)
openwisp_controller/config/tests/test_selenium.py
[warning] 25-25: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("openwisp_notifications", "Notification")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
tests/openwisp2/sample_config/migrations/0010_template_blueprint_cert_template_ca_and_more.py
[info] 106-106: use help_text to document model columns
Context: models.CharField(blank=True, max_length=64, null=True)
Note: [CWE-710] Improper Adherence to Coding Standards.
(model-help-text)
openwisp_controller/config/handlers.py
[warning] 98-98: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/tasks.py
[warning] 232-232: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Device")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 233-233: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/base/device_certificate.py
[warning] 41-41: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Template")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/base/template.py
[warning] 40-40: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("django_x509", "Cert")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 41-41: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 275-275: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Config")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 338-338: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
openwisp_controller/config/tests/test_device.py
[warning] 30-30: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("django_x509", "Cert")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 31-31: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("django_x509", "Ca")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
[warning] 32-32: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "OrganizationConfigSettings")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
🪛 HTMLHint (1.9.2)
openwisp_controller/config/templates/admin/config/device_certificates_table.html
[error] 1-1: Doctype must be declared before any non-comment content.
(doctype-first)
| def _add_certificate_details(self, ctx, config): | ||
| qs = DeviceCertificate.objects.filter(config=config).select_related( | ||
| "cert__ca", "template" | ||
| )[:51] | ||
| cert_data = [] | ||
| for dc in qs: | ||
| if dc.cert: | ||
| app_label = dc.cert._meta.app_label | ||
| model_name = dc.cert._meta.model_name | ||
| url = reverse( | ||
| f"admin:{app_label}_{model_name}_change", args=[dc.cert.id] | ||
| ) | ||
| cert_data.append( | ||
| { | ||
| "template_name": dc.template.name, | ||
| "common_name": dc.cert.common_name, | ||
| "ca_name": dc.cert.ca.name if dc.cert.ca else "-", | ||
| "key_length": dc.cert.key_length, | ||
| "digest": dc.cert.digest, | ||
| "created": dc.cert.created, | ||
| "validity_end": dc.cert.validity_end, | ||
| "is_revoked": dc.cert.revoked, | ||
| "url": url, | ||
| "has_cert": True, | ||
| } | ||
| ) | ||
| else: | ||
| cert_data.append({"template_name": dc.template.name, "has_cert": False}) | ||
| has_more = len(cert_data) > 50 | ||
| if has_more: | ||
| cert_data = cert_data[:50] | ||
| cert_model = DeviceCertificate.cert.field.related_model | ||
| cert_list_url = reverse( | ||
| f"admin:{cert_model._meta.app_label}" | ||
| f"_{cert_model._meta.model_name}_changelist" | ||
| ) | ||
| ctx["certificate_details"] = render_to_string( | ||
| "admin/config/device_certificates_table.html", | ||
| { | ||
| "certificates": cert_data, | ||
| "has_more": has_more, | ||
| "cert_list_url": cert_list_url, | ||
| }, | ||
| ) | ||
|
|
There was a problem hiding this comment.
🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
Add explicit ordering to the certificate-details queryset.
The slice [:51] combined with the "has_more" truncation to 50 relies on a stable row order to correctly show which 50 certs are displayed. Config.get_cert_context() orders the same relation by created; do the same here for consistency and deterministic pagination.
♻️ Suggested fix
def _add_certificate_details(self, ctx, config):
qs = DeviceCertificate.objects.filter(config=config).select_related(
"cert__ca", "template"
- )[:51]
+ ).order_by("created")[:51]📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| def _add_certificate_details(self, ctx, config): | |
| qs = DeviceCertificate.objects.filter(config=config).select_related( | |
| "cert__ca", "template" | |
| )[:51] | |
| cert_data = [] | |
| for dc in qs: | |
| if dc.cert: | |
| app_label = dc.cert._meta.app_label | |
| model_name = dc.cert._meta.model_name | |
| url = reverse( | |
| f"admin:{app_label}_{model_name}_change", args=[dc.cert.id] | |
| ) | |
| cert_data.append( | |
| { | |
| "template_name": dc.template.name, | |
| "common_name": dc.cert.common_name, | |
| "ca_name": dc.cert.ca.name if dc.cert.ca else "-", | |
| "key_length": dc.cert.key_length, | |
| "digest": dc.cert.digest, | |
| "created": dc.cert.created, | |
| "validity_end": dc.cert.validity_end, | |
| "is_revoked": dc.cert.revoked, | |
| "url": url, | |
| "has_cert": True, | |
| } | |
| ) | |
| else: | |
| cert_data.append({"template_name": dc.template.name, "has_cert": False}) | |
| has_more = len(cert_data) > 50 | |
| if has_more: | |
| cert_data = cert_data[:50] | |
| cert_model = DeviceCertificate.cert.field.related_model | |
| cert_list_url = reverse( | |
| f"admin:{cert_model._meta.app_label}" | |
| f"_{cert_model._meta.model_name}_changelist" | |
| ) | |
| ctx["certificate_details"] = render_to_string( | |
| "admin/config/device_certificates_table.html", | |
| { | |
| "certificates": cert_data, | |
| "has_more": has_more, | |
| "cert_list_url": cert_list_url, | |
| }, | |
| ) | |
| def _add_certificate_details(self, ctx, config): | |
| qs = DeviceCertificate.objects.filter(config=config).select_related( | |
| "cert__ca", "template" | |
| ).order_by("created")[:51] | |
| cert_data = [] | |
| for dc in qs: | |
| if dc.cert: | |
| app_label = dc.cert._meta.app_label | |
| model_name = dc.cert._meta.model_name | |
| url = reverse( | |
| f"admin:{app_label}_{model_name}_change", args=[dc.cert.id] | |
| ) | |
| cert_data.append( | |
| { | |
| "template_name": dc.template.name, | |
| "common_name": dc.cert.common_name, | |
| "ca_name": dc.cert.ca.name if dc.cert.ca else "-", | |
| "key_length": dc.cert.key_length, | |
| "digest": dc.cert.digest, | |
| "created": dc.cert.created, | |
| "validity_end": dc.cert.validity_end, | |
| "is_revoked": dc.cert.revoked, | |
| "url": url, | |
| "has_cert": True, | |
| } | |
| ) | |
| else: | |
| cert_data.append({"template_name": dc.template.name, "has_cert": False}) | |
| has_more = len(cert_data) > 50 | |
| if has_more: | |
| cert_data = cert_data[:50] | |
| cert_model = DeviceCertificate.cert.field.related_model | |
| cert_list_url = reverse( | |
| f"admin:{cert_model._meta.app_label}" | |
| f"_{cert_model._meta.model_name}_changelist" | |
| ) | |
| ctx["certificate_details"] = render_to_string( | |
| "admin/config/device_certificates_table.html", | |
| { | |
| "certificates": cert_data, | |
| "has_more": has_more, | |
| "cert_list_url": cert_list_url, | |
| }, | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openwisp_controller/config/admin.py` around lines 967 - 1011, The
certificate-details queryset in _add_certificate_details needs an explicit,
deterministic order before slicing, since the current [:51] truncation and
has_more logic depend on stable row ordering. Update the
DeviceCertificate.objects.filter(...).select_related(...) queryset to order by
the same field used in Config.get_cert_context(), specifically created, so the
first 50 shown certificates are consistent across requests and the “more”
indicator is accurate.
| MAC_ADDRESS_OID = "1.3.6.1.4.1.65901.1" | ||
| DEVICE_UUID_OID = "1.3.6.1.4.1.65901.2" |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Verify the django-x509 version constraint in setup.py
grep -n "django-x509" setup.py requirements*.txt 2>/dev/nullRepository: openwisp/openwisp-controller
Length of output: 269
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== repo files mentioning django-x509 =="
rg -n "django-x509|openwisp/django-x509|x509" -S requirements*.txt setup.py pyproject.toml Pipfile* poetry.lock 2>/dev/null || true
echo
echo "== relevant requirements file =="
sed -n '1,40p' requirements.txt 2>/dev/null || true
echo
echo "== current branch/commit pin if any =="
git ls-files | rg '(^|/)(requirements.*|setup\.py)$' || trueRepository: openwisp/openwisp-controller
Length of output: 1488
🌐 Web query:
django-x509 oid custom private extensions support 1.4 openwisp django-x509 README
💡 Result:
Yes, django-x509 supports custom private X.509 extensions using Object Identifiers (OIDs) [1]. This functionality was introduced to allow users to embed custom data (such as device MAC addresses or UUIDs) directly into generated certificates [1]. Key details regarding this support include: - Configuration: The extensions field in the certificate or CA model accepts a JSON list of entries [1]. Each entry can specify a custom extension using the oid key, which is mutually exclusive with the name key used for standard built-in extensions [1]. - Format: Custom extension entries require an oid and a value [1]. The value must be provided in the format ASN1:<type>:<payload> (e.g., ASN1:UTF8:string:00:11:22:33:44:55) [1]. The critical field is optional and defaults to false [1]. - Validation: The library performs strict validation to prevent the use of standard, reserved OIDs (such as keyUsage or extendedKeyUsage), which are already handled by the underlying cryptography library [1]. Each custom OID may only appear once per certificate [1]. - Implementation: Support for these extensions was added via the introduction of an ASN.1 DER value encoder, which integrates with the existing JSON extension framework while maintaining type validation and backward compatibility [2][3]. For further implementation details, you can refer to the official README in the django-x509 repository [1].
Citations:
- 1: https://github.com/openwisp/django-x509/blob/master/README.rst
- 2: [feature] Support custom X.509 extensions via structured ASN.1 DER encoding #222 django-x509#232
- 3: openwisp/django-x509@1525da6
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import json, subprocess, sys
def gh(*args):
return subprocess.check_output(["gh", *args], text=True).strip()
# Inspect the branch/tag ref behind the pinned archive URL.
# If a tag is involved, dereference it to the underlying commit.
ref = gh("api", "repos/openwisp/django-x509/git/refs/heads/1.4", "--jq", ".object")
print("ref_object=", ref)
# Also check whether the commit mentioned in the search result exists.
commit = "1525da69e5325078bec5376ee7163de345487a24"
try:
sha = gh("api", f"repos/openwisp/django-x509/commits/{commit}", "--jq", ".sha")
print("commit_exists=", sha)
except subprocess.CalledProcessError as e:
print("commit_check_failed")
sys.exit(e.returncode)
PYRepository: openwisp/openwisp-controller
Length of output: 412
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import subprocess, json, sys
def gh(*args):
return subprocess.check_output(["gh", *args], text=True).strip()
base = "1525da69e5325078bec5376ee7163de345487a24"
head = "1abf8cef8aaf2f606be1ee4bddedafc5bb11bcf1"
# Show commit relationship between the OID-supporting change and the current 1.4 branch head.
try:
out = gh("api", f"repos/openwisp/django-x509/compare/{base}...{head}", "--jq", "{status: .status, ahead_by: .ahead_by, behind_by: .behind_by, merge_base: .merge_base_commit.sha}")
print(out)
except subprocess.CalledProcessError as e:
print("compare_failed")
sys.exit(e.returncode)
PYRepository: openwisp/openwisp-controller
Length of output: 271
Bump django-x509 to a release with custom oid extension support. requirements.txt still pins the 1.4 branch tarball, which predates that support, so hardware-backed device certificate generation can still break on these OIDs.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openwisp_controller/config/base/device_certificate.py` around lines 12 - 13,
Update the django-x509 dependency pin to a release that supports custom oid
extensions, since the current 1.4 branch tarball does not handle the
MAC_ADDRESS_OID and DEVICE_UUID_OID values used in device_certificate.py. Adjust
the dependency in requirements.txt to a version with custom OID support, then
verify the device certificate generation path still works with those extension
identifiers.
| def _validate_cert_template_changes(self): | ||
| """ | ||
| Prevents changing cert-specific settings of a certificate template | ||
| if it is already assigned to active devices. | ||
| """ | ||
| if self._state.adding: | ||
| return | ||
| try: | ||
| current = self.__class__.objects.get(pk=self.pk) | ||
| except self.__class__.DoesNotExist: | ||
| return | ||
| changing_protected_fields = ( | ||
| current.ca_id != self.ca_id | ||
| or current.blueprint_cert_id != self.blueprint_cert_id | ||
| or (current.type == "cert" and self.type != "cert") | ||
| ) | ||
| if not changing_protected_fields: | ||
| return | ||
|
|
||
| Config = load_model("config", "Config") | ||
| if not ( | ||
| Config.objects.filter(templates=self) | ||
| .exclude(status__in=["deactivating", "deactivated"]) | ||
| .exists() | ||
| ): | ||
| return | ||
|
|
||
| message = _( | ||
| "This template is already assigned to active devices. " | ||
| "You cannot change the CA or Blueprint Certificate " | ||
| "on an active template." | ||
| ) | ||
| errors = {} | ||
| if current.ca_id != self.ca_id: | ||
| errors["ca"] = message | ||
| if current.blueprint_cert_id != self.blueprint_cert_id: | ||
| errors["blueprint_cert"] = message | ||
| if current.type == "cert" and self.type != "cert": | ||
| errors["type"] = _( | ||
| "This template is already assigned to active devices. " | ||
| "You cannot change the template type from certificate " | ||
| "on an active template." | ||
| ) | ||
| if errors: | ||
| raise ValidationError(errors) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
rg -n -B2 -A15 'def test_.*type.*cert|type.*!=.*cert.*active|_validate_cert_template_changes' \
openwisp_controller/config/tests/test_template.pyRepository: openwisp/openwisp-controller
Length of output: 836
🏁 Script executed:
#!/bin/bash
set -e
rg -n -A6 -B6 'current\.type == "cert" and self\.type != "cert"|errors\["type"\]|_validate_cert_template_changes|validate_cert_template_changes' openwisp_controller/config/tests/test_template.py openwisp_controller/config/base/template.pyRepository: openwisp/openwisp-controller
Length of output: 5986
🏁 Script executed:
#!/bin/bash
set -e
sed -n '1450,1585p' openwisp_controller/config/tests/test_template.pyRepository: openwisp/openwisp-controller
Length of output: 5198
🏁 Script executed:
#!/bin/bash
set -e
rg -n -A4 -B4 'errors\["type"\]|blueprint_cert_id != self\.blueprint_cert_id|current\.type == "cert" and self\.type != "cert"|validate_cert_template_changes' openwisp_controller/config/testsRepository: openwisp/openwisp-controller
Length of output: 958
🏁 Script executed:
#!/bin/bash
set -e
rg -n 'current\.type == "cert" and self\.type != "cert"|errors\["type"\]|type change blocked|template type from certificate|validate_cert_template_changes_deleted_instance' openwisp_controllerRepository: openwisp/openwisp-controller
Length of output: 846
Add a regression test for the type-mutation guard. The existing deleted-instance case doesn’t exercise current.type == "cert" and self.type != "cert"; add a case that mutates type on an active cert template and asserts clean() raises ValidationError on type.
🧰 Tools
🪛 ast-grep (0.44.0)
[warning] 275-275: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "Config")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openwisp_controller/config/base/template.py` around lines 257 - 301, Add a
regression test for the type-mutation branch in _validate_cert_template_changes,
since the existing deleted-instance coverage does not hit current.type == "cert"
and self.type != "cert". Create a test that loads an active cert template,
mutates its type away from "cert", and calls clean() to assert a ValidationError
is raised with an error on the type field.
| if name_changed or mac_changed: | ||
| DeviceCertificate = load_model("config", "DeviceCertificate") | ||
| expected_cert_ids = list( | ||
| DeviceCertificate.objects.filter( | ||
| config__device=instance, | ||
| auto_cert=True, | ||
| cert__revoked=False, | ||
| template__type="cert", | ||
| ).values_list("id", "cert_id") | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Duplicated "active auto cert" filter criteria across files.
The (config__device=X, auto_cert=True, cert__revoked=False, template__type="cert") filter is repeated verbatim here and in regenerate_device_certificates_task (openwisp_controller/config/tasks.py). Extracting it into a shared manager/classmethod (e.g. DeviceCertificate.objects.active_auto_certs_for(device)) would prevent the two from silently drifting apart if the criteria ever changes.
♻️ Suggested refactor
+ # in AbstractDeviceCertificate manager/classmethod
+ `@classmethod`
+ def active_auto_certs_for(cls, device):
+ return cls.objects.filter(
+ config__device=device,
+ auto_cert=True,
+ cert__revoked=False,
+ template__type="cert",
+ )Then both handlers.py and tasks.py can call DeviceCertificate.active_auto_certs_for(instance) / (device).
🧰 Tools
🪛 ast-grep (0.44.0)
[warning] 98-98: Loading a Keras model from an untrusted file can execute arbitrary code via Lambda layers or custom objects. Load only trusted models and avoid deserializing custom objects from untrusted sources.
Context: load_model("config", "DeviceCertificate")
Note: [CWE-502] Deserialization of Untrusted Data.
(keras-load-model-python)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openwisp_controller/config/handlers.py` around lines 98 - 107, The “active
auto cert” queryset logic is duplicated in the device certificate handling code
and in the regeneration task, so extract the shared filter into a single
reusable API on DeviceCertificate. Add a manager/classmethod such as
DeviceCertificate.active_auto_certs_for(device) or
DeviceCertificate.objects.active_auto_certs_for(device) that encapsulates
config__device, auto_cert=True, cert__revoked=False, and template__type="cert",
then update both handlers.py and regenerate_device_certificates_task in tasks.py
to call that helper instead of repeating the filter inline.
| if (val === "vpn" || val === "cert") { | ||
| auto_cert_field.show(); | ||
| } else { | ||
| auto_cert_field.hide(); | ||
| } | ||
| if (val === "vpn" || val === "cert") { | ||
| auto_cert_field.show(); | ||
|
|
||
| if (val === "vpn") { | ||
| auto_cert_label.text(gettext("Automatic tunnel provisioning")); | ||
| } else if (val === "cert") { | ||
| auto_cert_label.text(gettext("Automatic certificate provisioning")); | ||
| } | ||
| } else { | ||
| auto_cert_field.hide(); | ||
| } | ||
| }; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Remove duplicate auto_cert_field show/hide block.
Lines 47-51 duplicate the show/hide logic already handled by lines 52-62 (which additionally sets the label text). The first block is redundant dead code.
♻️ Proposed fix
- if (val === "vpn" || val === "cert") {
- auto_cert_field.show();
- } else {
- auto_cert_field.hide();
- }
if (val === "vpn" || val === "cert") {
auto_cert_field.show();
if (val === "vpn") {
auto_cert_label.text(gettext("Automatic tunnel provisioning"));
} else if (val === "cert") {
auto_cert_label.text(gettext("Automatic certificate provisioning"));
}
} else {
auto_cert_field.hide();
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if (val === "vpn" || val === "cert") { | |
| auto_cert_field.show(); | |
| } else { | |
| auto_cert_field.hide(); | |
| } | |
| if (val === "vpn" || val === "cert") { | |
| auto_cert_field.show(); | |
| if (val === "vpn") { | |
| auto_cert_label.text(gettext("Automatic tunnel provisioning")); | |
| } else if (val === "cert") { | |
| auto_cert_label.text(gettext("Automatic certificate provisioning")); | |
| } | |
| } else { | |
| auto_cert_field.hide(); | |
| } | |
| }; | |
| if (val === "vpn" || val === "cert") { | |
| auto_cert_field.show(); | |
| if (val === "vpn") { | |
| auto_cert_label.text(gettext("Automatic tunnel provisioning")); | |
| } else if (val === "cert") { | |
| auto_cert_label.text(gettext("Automatic certificate provisioning")); | |
| } | |
| } else { | |
| auto_cert_field.hide(); | |
| } | |
| }; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openwisp_controller/config/static/config/js/switcher.js` around lines 47 -
63, The switcher logic contains a redundant show/hide branch for auto_cert_field
that duplicates the later conditional in the same handler. Remove the առաջին
duplicate if/else block and keep the unified val check that both toggles
auto_cert_field and updates auto_cert_label in switcher.js, using the existing
auto_cert_field and auto_cert_label symbols.
| except (ImportError, Exception) as e: | ||
| logger.warning( | ||
| f"Could not push regeneration notification for {device.name}: {e}" | ||
| ) |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Redundant exception tuple.
ImportError is already a subclass of Exception, so except (ImportError, Exception) is equivalent to except Exception. Purely cosmetic.
🧹 Simplify
- except (ImportError, Exception) as e:
+ except Exception as e:📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| except (ImportError, Exception) as e: | |
| logger.warning( | |
| f"Could not push regeneration notification for {device.name}: {e}" | |
| ) | |
| except Exception as e: | |
| logger.warning( | |
| f"Could not push regeneration notification for {device.name}: {e}" | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@openwisp_controller/config/tasks.py` around lines 291 - 294, The exception
handler in the regeneration notification logic is redundant because
`ImportError` is already covered by `Exception`. Update the `except
(ImportError, Exception) as e` block in the relevant task function to catch only
`Exception` while keeping the existing warning log message with `device.name`
and the exception details.
Checklist
Reference to Existing Issue
Closes #1356
Closes #1377
Closes #1357
Closes #1361
Closes #1358
Closes #1360
Closes #1359
Description of Changes
This PR establishes the database architecture, UI, API and lifecycle for standalone X.509 certificate templates.
Manual test plan
Setup
PKI->Certification Authoritiesand create two CAs:CA-1andCA-2.PKI->Certificatesand create two certificates to act as blueprints:Blueprint-1(Must useCA-1)Blueprint-2(Must useCA-2)Devicesand create a device (test-device).Template Creation and Validation
Configuration->Templatesand clickADD TEMPLATE.Certificate.CA-1.Blueprint-2(which belongs toCA-2). Try to save.Blueprint-1. Name the templateActive-Cert-Template. Save it.Device Provisioning
test-device.Active-Cert-Template. Save.PKI->Certificates.test-device. Its status should be valid (not revoked).Active Mutation Locks
Configuration->Templatesand editActive-Cert-Template(which is now assigned to an active device).Generic. Try to save.CA-2. Try to save.Blueprint-2(ensure you also change the CA so they match, triggering the active lock). Try to save.Revocation on Removal
test-device.Active-Cert-Templateentirely from the templates list. Save.PKI->Certificatesand locate the device's certificate.Context Configuration Injection
Go to
Configuration->Templates, openActive-Cert-Template, and copy its UUID from the URL bar (removing the dashes so it is a 32-character hex string).In the JSON configuration editor for the template, add a configuration block that references the certificate's UUID variables:
(Note: Replace
<uuid>with the actual 32-character hex string of the template).Click Save.
Go back to the Configuration page for
test-device(which has this template assigned) and click thePreview configurationbutton.Expected Result: The variables should be successfully resolved. In the preview, you should see the generated path (e.g.,
/etc/x509/cert-<uuid>.pem) and the literal-----BEGIN CERTIFICATE-----text instead of the raw{{ }}template tags.output.mp4