MethodicConfigurator

Software Update Sub-Application Architecture

Overview

The Software Update sub-application is responsible for checking if there is a newer software version available, downloading and updating the ArduPilot Methodic Configurator to the latest version. This ensures users always have access to the latest features, bug fixes, and security updates.

Requirements Analysis

Functional Requirements

  1. Version Check
    • ✅ Checks current version against latest via GitHub releases API
    • ✅ Handles network connectivity issues with proper exception handling
    • ✅ Validates version format using packaging.version.parse()
    • ✅ Supports semantic versioning and prerelease versions
  2. Update Detection
    • ✅ Detects newer versions using semantic version comparison
    • ✅ Distinguishes between version types (major/minor/patch/prerelease)
    • ✅ Uses stable release channel by default (filters pre-releases)
    • ✅ Provides change information from GitHub release body
  3. Download Management
    • ✅ Downloads from verified GitHub sources with SSL verification
    • ✅ SHA256 checksum validation for downloaded files (when available in release)
    • ✅ Resume capability for interrupted downloads with Range headers
    • ✅ Retry logic with exponential backoff and jitter (3 retries by default)
    • ✅ Provides download progress feedback via callback
  4. Installation Process
    • ✅ Windows: Creates batch file to run installer after app exit with integrity validation
    • ✅ Linux/macOS: Uses pip to install updated package (supports wheel assets from releases)
    • ✅ File integrity validation (size, magic bytes, SHA256 when available)
    • ✅ Automatic cleanup of invalid/corrupted downloads
  5. User Interface
    • ✅ Clear update information display with scrollable content
    • ✅ User choice to update or skip with proper button handling
    • ✅ Download and installation progress display
    • ✅ Graceful handling of user cancellation
  6. Error Handling
    • ✅ Network failures handled with automatic retry (3 attempts with exponential backoff)
    • ✅ Recovery from corrupted downloads via integrity checks and cleanup
    • ✅ Clear error messages with logging at appropriate levels (error/debug)
    • ✅ Graceful handling of partial downloads with resume support

Non-Functional Requirements

  1. Security
    • ✅ Downloads from verified GitHub HTTPS sources
    • ✅ SSL certificate validation enabled (verify=True)
    • ✅ SHA256 checksum verification of downloaded files (when available in GitHub releases)
    • ✅ File magic byte validation (PE header for Windows, ZIP for wheels)
    • ✅ File permission restrictions (chmod 0o600) where supported
    • ✅ Proper certificate and SSL/TLS handling
  2. Performance
    • ✅ Version checking completes quickly (GitHub API is fast)
    • ✅ Downloads use efficient streaming with configurable block size (8KB default)
    • ✅ Resume capability avoids re-downloading completed portions
    • ✅ Non-blocking UI during downloads and installation
  3. Reliability
    • ✅ Graceful handling of interrupted operations with proper exception handling
    • ✅ System stability maintained during updates (uses separate processes)
  4. Usability
    • ✅ Intuitive update process requiring minimal user intervention
    • ✅ Clear and accurate progress feedback with percentage and status messages
    • ✅ Actionable and user-friendly error messages

Legend: ✅ IMPLEMENTED ⚠️ PARTIALLY IMPLEMENTED

Architecture

Components

Core Module

User Interface

Backend Internet Module

Data Flow

  1. Application Startup Check
    • Main application calls check_for_software_updates() during startup
    • Function checks current version from __version__ and gets git hash
    • Skippable via --skip-check-for-updates command line argument
  2. Version Retrieval and Comparison
    • Calls get_release_info("/latest", should_be_pre_release=False) from backend_internet
    • Uses GitHub releases API to get latest stable release information
    • Compares versions using packaging.version.parse() for semantic versioning
  3. Update Available Decision
    • If current >= latest, logs “Already running latest version” and returns False
    • If update available, formats version info and opens GitHub releases page in browser
    • Creates UpdateDialog with version information and download callback
  4. User Interaction Phase
    • UpdateDialog shows scrollable version information with release notes
    • User can choose to download/install or cancel via dialog buttons
    • Progress bar appears during download/installation process
  5. Download and Installation Phase
    • Windows: Downloads .exe installer with SHA256 verification, validates PE header, creates batch file
    • Linux/macOS: Attempts wheel asset from GitHub first (with SHA256), falls back to pip
    • ✅ Progress callback provides real-time feedback during download
    • ✅ SHA256 integrity validation of downloaded files (when checksums available)
    • ✅ File format validation (PE headers for .exe, ZIP headers for .whl)
    • ✅ Automatic cleanup of invalid downloads
  6. Application Exit for Update
    • Windows: Main application exits (os._exit(0)) to allow installer to run
    • Linux/macOS: Application continues after pip installation completes
    • Update process returns True to signal main application to exit

Integration Points

Security Considerations

Error Handling Strategy

Testing Strategy

File Structure

data_model_software_updates.py          # Core update logic and orchestration ✅
frontend_tkinter_software_update.py     # GUI dialog interface ✅
backend_internet.py                     # Download and installation backend ✅
tests/acceptance_software_update.py     # Acceptance tests for the application requirements defined on top of this file ✅
tests/bdd_software_updates.py           # BDD tests ✅
tests/integration_software_update_github_api.py  # Integration tests with actual GitHub API calls ✅
tests/unit_backend_internet.py          # Backend download and retry tests ✅
tests/test_backend_internet_checksum_parsing.py  # SHA256 checksum parsing tests ✅
tests/unit_backend_internet_download_resume.py   # Unit tests for download_resume logic ✅
tests/unit_data_model_software_updates.py        # Unit tests for core logic ✅
tests/unit_frontend_tkinter_software_update.py   # UI dialog tests ✅

Additional Supporting Files ✅:

Dependencies

Actual Implementation Dependencies

Core Module (data_model_software_updates.py):

Backend Internet (backend_internet.py):

Frontend (frontend_tkinter_software_update.py):

Known Limitations

Security Limitations

  1. PE Validation (Windows)
    • Current Implementation: Only validates DOS header (MZ signature) of Windows executables
    • Limitation: Does not perform full PE structure validation (headers, sections, imports)
    • Rationale: Full PE validation would require additional dependencies (e.g., pefile library)
    • Mitigation: SHA256 checksum verification provides primary integrity protection
    • Risk Assessment: Low - checksums and GitHub HTTPS provide adequate security for typical use cases