[Security] Extract Magic Strings and Hardcoded IPs into Configuration Variables #1418

Closed
opened 2026-03-24 13:04:33 +00:00 by Timmy · 1 comment
Owner

Context: http://143.198.27.163:3000 is repeated across dozens of .sh script literals.

Acceptance Criteria:

  • Create .env schema for orchestration loops.
  • Refactor all shell bindings to load $GITEA_HOST and $API_BASE_URL securely.
**Context:** `http://143.198.27.163:3000` is repeated across dozens of `.sh` script literals. **Acceptance Criteria:** - Create `.env` schema for orchestration loops. - Refactor all shell bindings to load `$GITEA_HOST` and `$API_BASE_URL` securely.
Author
Owner

Implementation Plan for Configuration Centralization

Priority: HIGH - Security/maintainability (hardcoded IPs scattered across codebase)

Files to Create/Modify:

  1. config/environment.conf - Central configuration file
  2. scripts/load-config.sh - Configuration loading utilities
  3. Update all .sh scripts with hardcoded IPs/URLs
  4. src/infrastructure/config/settings.py - Python config loader

Implementation Steps:

  1. Create Central Configuration (config/environment.conf):

    # Gitea Configuration
    GITEA_BASE_URL="http://143.198.27.163:3000"
    GITEA_API_URL="${GITEA_BASE_URL}/api/v1"
    
    # CI Configuration  
    CI_TESTBED_IP="67.205.155.108"
    
    # Repository Configuration
    DEFAULT_REPO="rockachopa/Timmy-time-dashboard"
    
    # Add other discovered magic strings
    
  2. Create Config Loader (scripts/load-config.sh):

    load_config() {
        if [[ -f "config/environment.conf" ]]; then
            source "config/environment.conf"
        else
            echo "ERROR: Configuration file not found"
            exit 1
        fi
    }
    
  3. Audit and Replace Hardcoded Values:

    • Search for all instances of 143.198.27.163:3000
    • Search for all instances of 67.205.155.108
    • Search for other hardcoded URLs, IPs, ports
    • Replace with environment variables
  4. Update All Shell Scripts:

    • Add source scripts/load-config.sh at the top
    • Replace hardcoded values with variables
    • Test each script after modification
  5. Create Python Config Module (src/infrastructure/config/settings.py):

    class Config:
        GITEA_BASE_URL = os.getenv('GITEA_BASE_URL', 'http://143.198.27.163:3000')
        GITEA_API_URL = os.getenv('GITEA_API_URL', f'{GITEA_BASE_URL}/api/v1')
        # etc.
    

Discovery Phase (run these commands first):

# Find all hardcoded IPs and URLs
grep -r "143.198.27.163" scripts/ src/ --exclude-dir=.git
grep -r "67.205.155.108" scripts/ src/ --exclude-dir=.git  
grep -r "http://.*:[0-9]" scripts/ src/ --exclude-dir=.git

Key Requirements:

  • Backward compatibility during transition
  • Environment-specific overrides (dev/staging/prod)
  • Proper validation of configuration values
  • Clear error messages for missing config
  • Documentation of all configuration options

Files Likely Needing Updates:

  • scripts/hermes-claim
  • scripts/*-loop.sh
  • scripts/agent-dispatch.sh
  • Any Python files with hardcoded URLs
  • CI configuration files

Testing:

  • Verify all scripts work with new config system
  • Test with missing config file (should fail gracefully)
  • Test with invalid configuration values
  • Verify no hardcoded strings remain

Acceptance Criteria Met When:

  • No hardcoded IPs/URLs in codebase (verified by grep)
  • Central configuration file controls all environment settings
  • All scripts load configuration properly
  • Environment-specific override capability
  • Comprehensive documentation
  • No functional regressions

This eliminates configuration management tech debt and improves security by centralizing sensitive endpoints.

## Implementation Plan for Configuration Centralization **Priority**: HIGH - Security/maintainability (hardcoded IPs scattered across codebase) **Files to Create/Modify**: 1. `config/environment.conf` - Central configuration file 2. `scripts/load-config.sh` - Configuration loading utilities 3. Update all `.sh` scripts with hardcoded IPs/URLs 4. `src/infrastructure/config/settings.py` - Python config loader **Implementation Steps**: 1. **Create Central Configuration** (`config/environment.conf`): ```bash # Gitea Configuration GITEA_BASE_URL="http://143.198.27.163:3000" GITEA_API_URL="${GITEA_BASE_URL}/api/v1" # CI Configuration CI_TESTBED_IP="67.205.155.108" # Repository Configuration DEFAULT_REPO="rockachopa/Timmy-time-dashboard" # Add other discovered magic strings ``` 2. **Create Config Loader** (`scripts/load-config.sh`): ```bash load_config() { if [[ -f "config/environment.conf" ]]; then source "config/environment.conf" else echo "ERROR: Configuration file not found" exit 1 fi } ``` 3. **Audit and Replace Hardcoded Values**: - Search for all instances of `143.198.27.163:3000` - Search for all instances of `67.205.155.108` - Search for other hardcoded URLs, IPs, ports - Replace with environment variables 4. **Update All Shell Scripts**: - Add `source scripts/load-config.sh` at the top - Replace hardcoded values with variables - Test each script after modification 5. **Create Python Config Module** (`src/infrastructure/config/settings.py`): ```python class Config: GITEA_BASE_URL = os.getenv('GITEA_BASE_URL', 'http://143.198.27.163:3000') GITEA_API_URL = os.getenv('GITEA_API_URL', f'{GITEA_BASE_URL}/api/v1') # etc. ``` **Discovery Phase** (run these commands first): ```bash # Find all hardcoded IPs and URLs grep -r "143.198.27.163" scripts/ src/ --exclude-dir=.git grep -r "67.205.155.108" scripts/ src/ --exclude-dir=.git grep -r "http://.*:[0-9]" scripts/ src/ --exclude-dir=.git ``` **Key Requirements**: - Backward compatibility during transition - Environment-specific overrides (dev/staging/prod) - Proper validation of configuration values - Clear error messages for missing config - Documentation of all configuration options **Files Likely Needing Updates**: - `scripts/hermes-claim` - `scripts/*-loop.sh` - `scripts/agent-dispatch.sh` - Any Python files with hardcoded URLs - CI configuration files **Testing**: - Verify all scripts work with new config system - Test with missing config file (should fail gracefully) - Test with invalid configuration values - Verify no hardcoded strings remain **Acceptance Criteria Met When**: - No hardcoded IPs/URLs in codebase (verified by grep) - Central configuration file controls all environment settings - All scripts load configuration properly - Environment-specific override capability - Comprehensive documentation - No functional regressions This eliminates configuration management tech debt and improves security by centralizing sensitive endpoints.
kimi was assigned by Timmy 2026-03-24 14:46:09 +00:00
kimi was unassigned by Timmy 2026-03-24 19:32:18 +00:00
Timmy closed this issue 2026-03-24 21:54:08 +00:00
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#1418