Commit graph

18 commits

Author SHA1 Message Date
12a737e1f5 fix/security-and-quality-issues (#136)
Reviewed-on: graham/towerops-web#136
2026-03-24 08:06:29 -05:00
348975dcc9 Rewrite polling_offset, changelog_parser, and user_agent_parser in Gleam (#103)
Migrate three pure-function modules from Elixir to Gleam:

- polling_offset: deterministic hash-based polling offset (pure Gleam, no FFI)
- changelog_parser: text parsing logic in Gleam, thin Elixir wrapper for File I/O
- user_agent_parser: regex-based UA parsing in Gleam with Erlang FFI for
  atom-keyed map conversion

Add gleam_regexp dependency for regex support in Gleam modules.
Update all call sites and tests to use Gleam module atoms.

Reviewed-on: graham/towerops-web#103
2026-03-21 10:11:06 -05:00
05d79287bc
chore: remove sobelow dependency 2026-03-12 16:03:08 -05:00
10e4690e97
fix: handle atom-based errors in MIB compiler and fix Oban test API
- Added case clause to handle {:error, :yecc_not_available} and other atom errors
- Refactored compile_string to reduce cyclomatic complexity (extracted error handling)
- Fixed DevicePollerWorker test to use new Oban API (Worker.perform(%Oban.Job{}))
- Removed unused Oban.Testing import

Fixes test failures:
- test/snmpkit/snmp_lib/mib_test.exs:398
- test/towerops/workers/device_poller_worker_test.exs:659
2026-03-05 12:05:36 -06:00
719ac1eb0f
Fix Mix.env() runtime crash in releases
Capture Mix.env() at compile time via module attribute since Mix is
not available at runtime in production releases.
2026-02-15 17:16:48 -06:00
de075ea8d9
Store billing subscriber/MRR data on integrations for dashboard
Each billing sync (Gaiia, Splynx, VISP, Sonar) already computes
subscriber counts and MRR but only stored them in sync messages.
Now persists them on the integrations table so the dashboard can
aggregate across all billing providers instead of only querying
Gaiia network sites (which were never populated).

Also fixes SnmpKit Config environment detection to use Mix.env()
as fallback when MIX_ENV env var is not set.
2026-02-15 16:51:33 -06:00
e195e5c9e8 fix: close UDP sockets in error paths to prevent fd leak
get_bulk, set, and get_multi used 'with' chains that skipped
close_socket when the operation failed, leaking file descriptors.
Over time this exhausted the fd limit causing EMFILE crashes.

Switched to case + try/after to guarantee socket cleanup.
2026-02-14 09:50:12 -06:00
fb1d4c564f
security: fix critical vulnerabilities and atom exhaustion risks
Critical fixes:
- Add [:safe] option to binary_to_term to prevent RCE attacks
- Implement whitelist validation for String.to_atom conversions
- Add input validation before String.to_existing_atom usage

Changes:
- MIB compiler and cache: Use safe binary deserialization
- SNMP contexts: Whitelist protocol, device type, and source atoms
- API controllers: Validate error message keys before atom conversion
- Reduce function nesting to comply with Credo standards

All 6,145 tests passing with zero Credo issues.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-08 10:30:30 -06:00
de1ad8bc8a nif ci fixes and dialyzer fixes 2026-01-30 12:38:50 -06:00
f350a9ade4 test cleanup 2026-01-28 10:31:22 -06:00
88c003d474 major snmp overhaul 2026-01-28 09:07:13 -06:00
124d68d28d
credo fixes 2026-01-27 09:12:22 -06:00
29f00c37ed
credo fixes 2026-01-23 16:49:02 -06:00
2b78b1a2d3
snmpkit overhaul and etcd 2026-01-23 16:23:57 -06:00
f59cdbbd7a
credo fixes 2026-01-23 14:01:52 -06:00
7fcfdbf2e9
credo improvements 2026-01-23 13:40:49 -06:00
ec76428349
credo fixes 2026-01-23 13:19:56 -06:00
a0ba9285dd
bring in snmpkit 2026-01-23 12:52:17 -06:00