Commit graph

52 commits

Author SHA1 Message Date
635d89d774 Fix mobile Gaiia entity mapping + redirect / to /dashboard
- Entity mapping table: hide Gaiia ID and Linked columns on mobile,
  show Gaiia ID inline under name on small screens
- Allow text wrapping in name column for long names
- Add overflow-x-auto to table container for safety
- Redirect authenticated users from / to /dashboard instead of /orgs
2026-02-15 15:05:20 -06:00
91dd7ad985
fix: allow site_id on device create regardless of use_sites setting
The API was silently stripping site_id when use_sites was false, causing
the Terraform provider to report inconsistent state after apply.
2026-02-15 12:28:06 -06:00
c790794191 Fix tests, credo issues, and Gaiia sync bugs
- Fix CLOAK_KEY placeholder in nix shell (invalid base64)
- Fix error HTML test assertion to match actual template
- Fix Gaiia sync: read 'subnet' field instead of 'block' for IP blocks
- Fix Gaiia sync: extract nested status name from subscription objects
- Fix security headers tests for environment detection
- Fix mobile auth tests to use raw_token
- Fix LiveView test assertions to match actual template content
- Fix SNMP config test expectations for test environment
- Refactor: resolve all Credo complexity/nesting issues
  - Extract helper functions in NetBox sync, VISP sync, Sonar sync
  - Flatten nested conditionals in settings, integrations, alerts
  - Use with/validate_present pattern for connection testing
2026-02-15 11:55:49 -06:00
146f5745cf
fix: resolve compilation errors, test failures, and credo issues
- Escape HEEx template braces in GraphQL/API docs with raw(~S[...])
- Fix test assertions for updated marketing copy and UI text
- Extract helper functions in GraphQL resolvers to reduce nesting depth
- Create shared ErrorHelpers module for API controllers
- Fix ETS race condition in brute force whitelist cache for async tests
- Fix property test generators to use ASCII instead of printable unicode
- Add alert_severity helper to site_live/show
- Update accounts fixtures for explicit user confirmation
2026-02-14 12:23:10 -06:00
bad1590fed
add gaiia webhook listener with per-org signature verification
Stage 3 of Gaiia integration: webhook event processing for real-time
incremental updates from Gaiia. HMAC-SHA256 signature verification
using per-organization secrets stored in integration credentials.
Handles account, billing subscription, and inventory item events.
2026-02-13 10:40:49 -06:00
9f8b925ecd
test: expand coverage for devices, workers, and LiveView modules
Add tests for untested Devices context functions (get_device_by_ip,
get_mikrotik_config, get_snmpv3_config, credential propagation,
resolve_snmp_community, list_mikrotik_devices_with_api), activity
log action descriptions, firmware version extraction edge cases,
and discovery worker enqueue/retryable_error paths.
2026-02-12 09:06:41 -06:00
95e3870fec
feat: add Force10 FTOS and optical transceiver monitoring (ProCurve, Comware)
Completed Tier 1 (critical network switches) and Tier 2 (optical transceiver monitoring)
from Phase 3 implementation plan. All major network switches now have comprehensive sensor
coverage including temperature and fiber optic link diagnostics.

Files Changed:
- priv/profiles/os_discovery/ftos.yaml (enhanced)
  Added Dell Force10 FTOS temperature monitoring for all 3 series:
  - S-Series: Stack unit temperature (chStackUnitTemp)
    OID: .1.3.6.1.4.1.6027.3.10.1.2.2.1.14
    MIB: F10-S-SERIES-CHASSIS-MIB
  - C-Series: Card temperature (chSysCardTemp)
    OID: .1.3.6.1.4.1.6027.3.8.1.2.1.1.5
    MIB: F10-C-SERIES-CHASSIS-MIB
  - E-Series: Card upper + lower temperature (chSysCardUpperTemp, chSysCardLowerTemp)
    OIDs: .1.3.6.1.4.1.6027.3.1.1.2.3.1.8-9
    MIB: F10-CHASSIS-MIB
  Gap: CRITICAL (no sensors) → RESOLVED
  Parity: 0% → 90%

- priv/profiles/os_discovery/procurve.yaml (enhanced)
  Added HP ProCurve transceiver optical monitoring (5 sensor types):
  MIB: HP-ICF-TRANSCEIVER-MIB::hpicfXcvrInfoTable
  Sensors:
    - Temperature: hpicfXcvrTemp (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.11, divisor 1000)
    - Bias Current: hpicfXcvrBias (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.13, divisor 1000)
    - Supply Voltage: hpicfXcvrVoltage (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.12, divisor 1000)
    - RX Power (dBm): hpicfXcvrRxPower (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.14, divisor 10)
    - TX Power (dBm): hpicfXcvrTxPower (OID .1.3.6.1.4.1.11.2.14.11.5.1.82.1.1.1.1.15, divisor 10)
  Gap: HIGH (missing transceivers) → RESOLVED
  Parity: 60% → 100%

- priv/profiles/os_discovery/comware.yaml (enhanced)
  Added HP Comware transceiver optical monitoring (5 sensor types):
  MIB: HH3C-TRANSCEIVER-INFO-MIB::hh3cTransceiverInfoTable
  Sensors:
    - Temperature: hh3cTransceiverTemperature (OID .1.3.6.1.4.1.25506.2.70.1.1.1.15)
    - Bias Current: hh3cTransceiverBiasCurrent (OID .1.3.6.1.4.1.25506.2.70.1.1.1.17)
    - Supply Voltage: hh3cTransceiverVoltage (OID .1.3.6.1.4.1.25506.2.70.1.1.1.16)
    - RX Power (dBm): hh3cTransceiverCurRXPower (OID .1.3.6.1.4.1.25506.2.70.1.1.1.9, divisor 100)
    - TX Power (dBm): hh3cTransceiverCurTXPower (OID .1.3.6.1.4.1.25506.2.70.1.1.1.12, divisor 100)
  Gap: HIGH (missing transceivers) → RESOLVED
  Parity: 60% → 95%

- test/towerops_web/controllers/api/mobile_controller_test.exs (fixed)
  Fixed Credo warning: replaced length/1 with empty list comparison

- CHANGELOG.txt (updated)
  Documented Tier 1 + Tier 2 completion

Impact:
- Force10 FTOS: Complete temperature monitoring for S/C/E-Series data center switches
- ProCurve: Full optical transceiver diagnostics (SFP/SFP+ monitoring)
- Comware: Full optical transceiver diagnostics (completes sensor coverage)

Business Value:
- All major network switch platforms now have fundamental temperature monitoring
- Fiber optic link health monitoring enabled for ProCurve and Comware
- Data center switches (Force10 FTOS) fully supported
- Enables proactive maintenance (detect failing transceivers before link failure)

Parity Achievement:
- Tier 1 Complete: HP Comware (60→95%), Dell PowerConnect (0→80%), Dell SONiC (0→95%),
  Dell Force10 FTOS (0→90%)
- Tier 2 Complete: HP ProCurve (60→100%), HP Comware (95% - transceivers added)

Next Steps: Tier 3 (storage/compute platforms: PowerVault, Dell Servers, hpblmos)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-12 08:19:12 -06:00
aa9ed52bff
feat: add critical network switch sensor support (HP Comware, Dell PowerConnect, Dell SONiC)
Implemented top 3 critical network switch sensor gaps identified in Phase 3 analysis.
Restores fundamental temperature monitoring for common enterprise switch platforms.

Files Changed:
- priv/profiles/os_discovery/comware.yaml (enhanced)
  Added HP Comware chassis temperature monitoring via HH3C-ENTITY-EXT-MIB
  OID: 1.3.6.1.4.1.25506.2.6.1.1.1.1.12 (hh3cEntityExtTemperature)
  Uses entPhysicalName for sensor descriptions
  Gap: CRITICAL (broke fundamental monitoring) → RESOLVED
  Parity: 40% → 60%

- priv/profiles/os_discovery/powerconnect.yaml (enhanced)
  Added Dell PowerConnect/DNOS CPU temperature monitoring
  OID: 1.3.6.1.4.1.674.10895.5000.2.6132.1.1.43.1.8.1.5
  MIB: FASTPATH-BOXSERVICES-PRIVATE-MIB
  Gap: CRITICAL (no sensors) → RESOLVED
  Parity: 0% → 80%

- priv/profiles/os_discovery/dell-sonic.yaml (new)
  Created comprehensive Dell SONiC sensor profile
  MIB: NETGEAR-BOXSERVICES-PRIVATE-MIB (Quanta-based)
  Sensors:
    - Temperature: boxServicesTempSensorState (OID .1.3.6.1.4.1.4413.1.1.43.1.8.1.4)
    - Fan Speed: boxServicesFanSpeed (OID .1.3.6.1.4.1.4413.1.1.43.1.6.1.4)
    - PSU State: boxServicesPowSupplyItemState (OID .1.3.6.1.4.1.4413.1.1.43.1.7.1.3)
      States: other, notpresent, operational, failed, powering, nopower,
              notpowering, incompatible
  Gap: CRITICAL (OS detected, no sensors) → RESOLVED
  Parity: 0% → 95%

- test/towerops_web/plugs/brute_force_protection_test.exs (fixed)
  Fixed Credo warning: replaced length/1 with empty list comparison

- CHANGELOG.txt (updated)
  Documented Phase 3 analysis completion and critical fix implementation

Impact:
- HP Comware: Enables overheating alerts (fundamental monitoring restored)
- Dell PowerConnect: First sensor support for common access switches
- Dell SONiC: Complete hardware monitoring for modern data center platform

Business Value:
- Resolves production blockers for customers with HP Comware switches
- Adds support for very common Dell enterprise access switches
- Enables monitoring for Dell's modern SONiC-based data center switches

Next Steps: Remaining Tier 1 switches (Dell Force10 FTOS), then Tier 2
(optical transceiver monitoring for ProCurve/Comware).

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-11 17:36:45 -06:00
c7df6a8569
Add CI-triggered mass agent update webhook
POST /api/v1/webhooks/agent-release triggers all connected agents
to self-update via their existing WebSocket channels. Authenticated
with a shared secret (AGENT_WEBHOOK_SECRET env var).

- Add ReleaseChecker.invalidate_cache/0 for fresh GitHub fetch
- Add Agents.list_updatable_agents/0 (enabled + seen < 10min)
- Add Agents.broadcast_mass_update/0 orchestration function
- Add WebhookAuth plug with timing-safe secret comparison
- Add AgentReleaseWebhookController with :webhook pipeline
- Configure AGENT_WEBHOOK_SECRET in dev/test/runtime configs
2026-02-10 13:40:32 -06:00
2911a3c17d
test fixes 2026-02-09 15:30:52 -06:00
3931a9c14a
more tests and fixes 2026-02-07 11:50:18 -06:00
8ee39a2d36
Add comprehensive tests for API authentication and authorization
Implemented tests for critical security modules with significant coverage improvements:
- ApiAuth plug: 0% → 100% (12 tests)
- Permissions module: 0% → 85% (32 tests)
- Devices API controller: 0% → 95% (22 tests)

Enhanced test fixtures to support membership roles and device creation with proper organization scoping.
2026-02-05 16:39:01 -06:00
8382b5df6a
make devices site optional and many test fix 2026-02-04 15:05:42 -06:00
3276a1cd8c
fix user session controller test
Update email input ID assertion to match actual template implementation
2026-02-03 13:42:24 -06:00
bd6dad85e1
purge more passkey and gettext updates 2026-02-02 10:20:59 -06:00
6c8e670dae
docs: add gettext internationalization design
- Add comprehensive i18n design document with domain-based organization
  (default, errors, auth, equipment, admin, emails domains)
- Document helper functions, implementation patterns, and migration workflow
- Fix multiple test suite issues:
  * user_settings_live_test.exs: Update all tests to match current UI structure
    - Fix user.name references (use first_name/last_name)
    - Fix TOTP device creation (use create_totp_device/2)
    - Update tab URLs and form IDs
    - Update tab names (Account, API, Notifications)
    - Remove obsolete tabs (Organizations, Activity)
    - Fix password tests (pattern match redirect without flash token)
    - Update sudo mode behavior
  * account_data_controller_test.exs: Fix user profile assertions
  * rate_limit_test.exs: Fix unused variable warning
  * settings_live_test.exs: Fix organization form validation test
2026-02-02 09:33:01 -06:00
9ff9c4ddc8
fix: address UserSudoController critical issues
Critical fixes:
- Renamed controller actions to follow Phoenix conventions (verify→new, create→verify)
- Added sudo mode check in GET action using last_sudo_at timestamp
- Added TOTP enrollment check in GET action with redirect
- Changed default return path from /orgs to /users/settings
- Updated route paths from /users/sudo/verify to /users/sudo-verify (dash separator)
- Added success flash message "Identity verified."

Implementation details:
- new/2 (GET): Checks recently_verified_sudo?/1 helper that examines last_sudo_at
  instead of authenticated_at to distinguish sudo verification from regular login
- verify/2 (POST): Adds info flash and defaults to /users/settings
- recently_verified_sudo?/1: Private helper checking last_sudo_at within 10 minutes
- Updated all routes, templates, and tests to use new paths and action names

Tests:
- Added tests for already-in-sudo-mode redirect behavior
- Added test for TOTP enrollment requirement
- Updated all test assertions for new route paths and success messages
- All 15 controller tests passing
- Full test suite passing (4076 tests, 0 failures)
2026-02-01 14:45:05 -06:00
264154a3d8
feat: implement sudo mode MFA-only verification controller
- Add UserSudoController with GET and POST /users/sudo/verify routes
- Create verify.html.heex template for TOTP verification form
- Only accept TOTP codes (6 numeric digits), reject recovery codes
- Update grant_sudo_mode to set authenticated_at virtual field
- Exclude /users/sudo paths from return_to overwriting
- Add comprehensive controller tests (12 test cases)
- Verify redirect behavior, error handling, and session management

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-01 14:34:17 -06:00
feed25080c
add HIBP password check 2026-02-01 08:57:01 -06:00
2fab08f5f8
forgot password flow 2026-01-31 17:03:22 -06:00
dff9c26905
fix TOTP enrollment with recovery codes 2026-01-31 14:54:44 -06:00
3c00dcf37c remove passkeys for now 2026-01-31 09:50:35 -06:00
22ae257b60 refactor 2026-01-31 09:35:07 -06:00
2a36917738 mfa enforced on login 2026-01-29 14:31:13 -06:00
c0736d4c2e gdpr consent tracking 2026-01-29 11:12:35 -06:00
d29fb8cfd7 totp fixes 2026-01-28 16:16:59 -06:00
1f6151b5a8 filter snmp communities from log 2026-01-28 14:51:47 -06:00
a0ba9285dd
bring in snmpkit 2026-01-23 12:52:17 -06:00
3abd70e133
use password for user regi 2026-01-21 09:13:08 -06:00
eb91798729
agent improvements and agent config 2026-01-16 17:26:51 -06:00
7068ab2466
Convert User Settings from controller to LiveView
- Create UserSettingsLive to replace UserSettingsController
- Convert email/password forms to LiveView with proper form handling
- Add mobile session management (toggle alerts, revoke devices)
- Add require_sudo_mode on_mount hook to UserAuth
- Create dedicated live_session for sudo mode routes in router
- Keep UserSettingsController for email confirmation via token only
- Add MobileSessions.get_session/1 function for test support
- Update tests to match LiveView behavior (password update redirects to login)
- Remove old controller tests for email/password updates (now in LiveView)
2026-01-15 16:29:50 -06:00
0ea2addc91
Fix Bandit configuration and user settings HTML test
Bandit 1.10.1 does not support read_timeout/write_timeout in http_1_options
or stream_idle_timeout in http_2_options. These invalid options caused the
application to crash on startup with 'Unsupported key(s) in http_1_options'.

Moved read_timeout to thousand_island_options where it belongs, and removed
the unsupported write_timeout and stream_idle_timeout options.

Also fixed UserSettingsHTMLTest to include the missing mobile_sessions assign
that is required by the edit.html.heex template.
2026-01-15 16:06:01 -06:00
8442d9e1fc
update liveview 2026-01-14 13:54:48 -06:00
a2d96f8e6e
Implement hierarchical agent assignment for SNMP polling
Add three-level agent assignment hierarchy (Equipment > Site > Organization)
allowing flexible agent deployment strategies. Agents now receive only equipment
assigned to them through direct assignment or inheritance from site/organization
defaults.

Key changes:
- Add agent_token_id to Sites table with migration
- Implement get_effective_agent_token/1 for hierarchical resolution
- Add list_agent_polling_targets/1 to return polling targets per agent
- Update API config endpoint to use hierarchical polling targets
- Add agent assignment UI to equipment, site, and organization forms
- Show agent source (direct/site/org/none) in equipment form
- Add equipment count column to agent list
- Update terminology from "poll from server" to "cloud polling"

Tests:
- Add 8 comprehensive tests for list_agent_polling_targets/1
- Add end-to-end test for hierarchical config endpoint
- All 775 tests passing
2026-01-14 08:38:50 -06:00
3eb95b5f90
Streamline login flow and fix test failures
Login flow improvements:
- Remove "Welcome back!" flash message on successful login
- Auto-login users clicking magic links without confirmation prompt
- Always use "remember me" for magic link logins
- Fix Accounts.login_user_by_magic_link/1 to handle invalid token format

Test fixes:
- Add @tag :integration to Ping tests (require actual system ping)
- Add halt() calls to UserAuth.start_impersonation error paths

Users now go directly to their intended destination after clicking a
magic link, with no interruption for "log in and stay logged in" choice.
2026-01-13 13:08:24 -06:00
11bc5dec4a
no post login page 2026-01-13 12:27:17 -06:00
8291c6092a
Add comprehensive AgentController edge case tests
Added 6 new tests covering previously untested scenarios:
- Equipment without SNMP device (nil sensors/interfaces)
- Protobuf metrics with unknown types
- JSON metrics with unknown types
- Metrics with nil timestamps
- Metrics with invalid ISO8601 timestamp strings

Coverage increased from 90.41% to near 100%.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-13 08:37:58 -06:00
f0af777f6e
Add tests for UserSettingsHTML
Added 2 tests covering the edit.html settings form template:
- Settings form rendering with email, password, and passkeys sections
- Warning message when user cannot register passkey

This improves UserSettingsHTML coverage from 0% to 100%.
2026-01-13 07:52:46 -06:00
a430d09668
Add test for UserRegistrationHTML
Added test to cover the new.html registration form template.

This improves UserRegistrationHTML coverage from 0% to 100%.
2026-01-13 07:52:06 -06:00
29c8e1a8d3
Add comprehensive tests for UserSessionHTML
Added 5 tests covering both new.html and confirm.html templates:
- Login form rendering with multiple authentication methods
- Reauthentication message display
- Confirmation form for unconfirmed users
- Login form for confirmed users
- Simplified login for reauthentication with current_scope

This improves UserSessionHTML coverage from 50.00% to 100%.
2026-01-13 07:50:39 -06:00
89b038a14f
Add test for PageHTML home template
Added test to cover the home.html template rendering.

This improves PageHTML coverage from 0% to 100%.
2026-01-13 07:49:25 -06:00
6e02dc460a
Add test for ErrorHTML fallback render function
Added test to cover the fallback render/2 function that handles
error codes without custom templates (401, 403, 503, etc.).

This improves ErrorHTML coverage from 0% to 100%.
2026-01-13 07:48:23 -06:00
160007cab1
Add HealthController test (0% → 100%) 2026-01-13 07:39:28 -06:00
7cf3e61709
Add comprehensive tests for EquipmentLive.Form and UserCredentialController
- EquipmentLive.Form: 46.73% → 92.52% (+45.79%)
  - Added 27 tests covering form validation, SNMP testing, site selection
  - Tests mount behavior, save/update flows, deletion, and discovery triggers
  - Tests SNMP config changes and agent assignment

- UserCredentialController: 33.93% → 64.29% (+30.36%)
  - Added 7 tests for WebAuthn registration and authentication flows
  - Tests challenge generation, credential registration, and error cases
  - Tests discoverable authentication and account-specific auth

Overall coverage: 60.40% → 63.67% (+3.27%)
2026-01-12 18:46:15 -06:00
3ef04f261f
protobufs 2026-01-09 17:33:01 -06:00
cf77949527
add remote agent setup 2026-01-09 13:15:31 -06:00
4f924ba9a7
add passkey 2026-01-09 12:26:32 -06:00
41dcf3084f
add error pages 2026-01-06 14:37:48 -06:00
3b9fffdd07
add marketing site 2026-01-06 14:34:48 -06:00
93e0b869be
more features 2026-01-02 14:06:44 -06:00