Skip to content

feat: disable all automation features by default on fresh install#152

Merged
Yeraze merged 1 commit into
mainfrom
fix/disable-automation-by-default
Oct 10, 2025
Merged

feat: disable all automation features by default on fresh install#152
Yeraze merged 1 commit into
mainfrom
fix/disable-automation-by-default

Conversation

@Yeraze

@Yeraze Yeraze commented Oct 10, 2025

Copy link
Copy Markdown
Owner

Summary

Fixes #150

Changed default behavior for all automation features to be disabled on first-time installation. This provides a safer out-of-box experience and requires users to explicitly enable automation features they want to use.

Changes

  • Auto-traceroute: Changed default interval from 3 minutes to 0 (disabled)
  • Auto-acknowledge: Already disabled by default (confirmed)
  • Auto-announce: Already disabled by default (confirmed)

Modified Files

  • src/server/meshtasticManager.ts: Set tracerouteIntervalMinutes default to 0
  • src/services/database.ts: Added tracerouteIntervalMinutes: '0' to ensureAutomationDefaults()
  • src/contexts/SettingsContext.tsx: Changed frontend default from 3 to 0
  • src/server/server.ts: Updated settings reset default to 0

Test Plan

  • ✅ All 513 tests pass
  • ✅ Fresh install verified with clean database
  • ✅ Database logs confirm all automation defaults set to disabled:
    • autoAckEnabled: false
    • autoAnnounceEnabled: false
    • tracerouteIntervalMinutes: 0
  • ✅ Traceroute scheduler confirms: "Traceroute interval set to 0 (disabled)"

Verification

Started fresh dev environment with wiped database and verified logs show:

[DEBUG] ✅ Set default for autoAckEnabled: false
[DEBUG] ✅ Set default for autoAnnounceEnabled: false
[DEBUG] ✅ Set default for tracerouteIntervalMinutes: 0
[DEBUG] 🗺️ Traceroute interval set to 0 (disabled)

🤖 Generated with Claude Code

Changed default behavior for automation features to be disabled on first-time installation:
- Auto-traceroute: Changed default interval from 3 minutes to 0 (disabled)
- Auto-acknowledge: Already disabled by default (false)
- Auto-announce: Already disabled by default (false)

This provides a safer out-of-box experience and requires users to explicitly enable automation features they want to use.

Changes:
- meshtasticManager.ts: Set tracerouteIntervalMinutes default to 0
- database.ts: Added tracerouteIntervalMinutes: '0' to ensureAutomationDefaults()
- SettingsContext.tsx: Changed tracerouteIntervalMinutes default from 3 to 0
- server.ts: Updated settings reset to use 0 instead of 3 for traceroute interval

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

Co-Authored-By: Claude <noreply@anthropic.com>
@claude

claude Bot commented Oct 10, 2025

Copy link
Copy Markdown
Contributor

Claude finished @Yeraze's task —— View job


Code Review Analysis Complete ✅

Reviewing PR #152: Disabling automation features by default on fresh install

Tasks:

  • Read and analyze modified files
  • Review code quality and consistency
  • Check for potential bugs or edge cases
  • Assess security implications
  • Evaluate performance considerations
  • Review test coverage adequacy
  • Provide comprehensive feedback

Code Review Summary

This is a well-executed, safety-focused PR that implements a secure-by-default approach for automation features. The changes are consistent, well-tested, and follow established patterns.


📋 Changes Analysis

The PR modifies 4 files to disable traceroute automation by default:

  1. src/contexts/SettingsContext.tsx:46 - Frontend default: 30
  2. src/server/meshtasticManager.ts:59 - Backend default: 30
  3. src/server/server.ts:1142 - Settings reset default: 30
  4. src/services/database.ts:178 - Database default: '3''0'

Code Quality & Best Practices

Excellent consistency across the stack:

  • ✅ All 4 locations properly updated from 3 to 0
  • ✅ Changes follow existing code patterns and conventions
  • ✅ Database migration properly handles string vs number types
  • ✅ Frontend localStorage and backend database stay synchronized
  • ✅ No breaking changes to existing API contracts

Clean implementation:

  • ✅ Uses existing ensureAutomationDefaults() pattern
  • ✅ Maintains backward compatibility for existing installations
  • ✅ Proper logging with debug messages for verification

Security Assessment

Strong security improvement:

  • Secure by default - New installations won't auto-execute network commands
  • Principle of least privilege - Users must explicitly enable automation
  • No security vulnerabilities introduced - Changes are pure configuration
  • Existing installations unaffected - Only impacts fresh installs

Performance Considerations

Performance neutral to positive:

  • Reduced network load - No automatic traceroutes on fresh installs
  • Lower CPU usage - Disabled timers don't consume resources
  • No performance regressions - Changes are configuration-only
  • Efficient implementation - Uses existing settings infrastructure

Test Coverage Assessment

Well-tested implementation:

  • All 513 tests pass (as reported in PR description)
  • Fresh install verification documented with log outputs
  • Test files properly updated - Found test files that mock tracerouteIntervalMinutes: '3'
  • ⚠️ Recommendation: Update test mocks in announceTokens.test.ts to reflect new default

🔧 Minor Recommendations

  1. Test consistency: Update test mocks in src/server/announceTokens.test.ts:117,134,213 from '3' to '0' to match new defaults

  2. Documentation: Consider updating any user documentation that mentions the 3-minute default


🎯 Verdict: APPROVED

This is an excellent security improvement that follows best practices:

  • Safe by default approach protects new users
  • Consistent implementation across all layers
  • Well-tested with comprehensive verification
  • Zero breaking changes for existing users
  • Clean, maintainable code following established patterns

The PR successfully addresses issue #150 and improves the security posture of MeshMonitor for fresh installations.

Recommendation: Merge after updating test mocks to maintain consistency.

@Yeraze Yeraze merged commit 409f9d8 into main Oct 10, 2025
12 checks passed
@Yeraze Yeraze deleted the fix/disable-automation-by-default branch October 10, 2025 18:36
Yeraze added a commit that referenced this pull request Oct 12, 2025
Yeraze added a commit that referenced this pull request Oct 29, 2025
Yeraze added a commit that referenced this pull request Jun 18, 2026
…#152/153/155/156) (#3544)

* fix(security): use RE2 for user-supplied regexes to eliminate ReDoS (#3543)

Resolves the two high-severity CodeQL js/regex-injection alerts (#153, #155) by
compiling all user/admin-supplied regular expressions with RE2, a linear-time
engine immune to catastrophic backtracking. The previous heuristic guards
(length caps + nested-quantifier checks) reduced but could not eliminate the
risk, and CodeQL (correctly) kept flagging the user→RegExp dataflow.

- New src/utils/safeRegex.ts: compileUserRegex(pattern, flags) wraps RE2 and
  returns a RegExp-compatible matcher (test/exec/match/replace). RE2 rejects
  backreferences and lookaround — the intended trade-off — so callers keep their
  existing try/catch to treat unsupported patterns as "invalid regex".
- Convert every user-supplied regex site, validation AND execution:
  - server.ts: remote(-localstats) name-filter validation (2 sites).
  - services/database.ts: the name-filter execution sites that actually match
    node names (traceroute + localstats union filters) — the real ReDoS surface
    CodeQL didn't reach through the settings store.
  - routes/scriptRoutes.ts + meshtasticManager.ts: auto-responder trigger and
    auto-acknowledge pattern matching.
- Dockerfile: add build-base + python3 to the builder stage so re2 (native) can
  compile from source where no prebuilt exists (Alpine/musl arm). Builder stage
  only — not in the runtime image.

Tests: new safeRegex suite asserts linear-time behaviour on the classic (a+)+$
ReDoS pattern and rejection of backreference/lookaround. Full suite green.

The two non-regex alerts are handled separately: #152 (frontend routing, not a
security gate) dismissed as false-positive; #156 (authenticated admin script
import, path-sanitized) dismissed as by-design.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* address review: convert remaining regex sites to RE2; harden tests/docs (#3544)

Claude review feedback on the RE2 security PR:

1. autoAckRegex.ts:69 — convert the MeshCore auto-ack pattern compile to
   compileUserRegex (the charset allowlist/length/shape guards stay as a fast
   pre-rejection). Residual ReDoS surface CodeQL may not flag through the
   barrier, now closed for consistency.
2. settingsRoutes.ts:215 — convert the regex-validation compile to
   compileUserRegex so stored patterns are guaranteed RE2-compatible.
3. safeRegex.ts — document that the result is not `instanceof RegExp` and that
   length bounding stays the caller's responsibility; add a test asserting
   `.source`/`.flags` behave.
4. safeRegex.test.ts — raise the ReDoS timing threshold to 1000ms and use a
   larger input, so the assertion can't flake on loaded CI runners.
5. Dockerfile — clarify the builder comment (build-base is the new compiler;
   python3 is node-gyp's other requirement).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Remove default 3 minutes trace

1 participant