Skip to content

Modernize - #22

Merged
sroberts merged 3 commits into
masterfrom
claude/modernize-basic-01TUJ3G2BHf6gs6Pc8bZE77X
Nov 18, 2025
Merged

Modernize#22
sroberts merged 3 commits into
masterfrom
claude/modernize-basic-01TUJ3G2BHf6gs6Pc8bZE77X

Conversation

@sroberts

Copy link
Copy Markdown
Owner

This commit modernizes the entire Malwarehouse codebase from Python 2.7 to Python 3.9+:

Core Changes:

  • Updated all print statements to print() functions
  • Replaced file() built-in with open() using proper binary mode
  • Changed exception handling from 'except Exception, e' to 'except Exception as e'
  • Updated .iteritems() to .items() for dictionary iteration
  • Replaced ConfigParser.SafeConfigParser with configparser.ConfigParser
  • Updated metaclass syntax from metaclass to metaclass= parameter

Library Modernization:

  • Replaced urllib2 with requests library for HTTP operations
  • Removed poster library dependency (replaced with requests)
  • Updated to ppdeep from pydeep for fuzzy hashing
  • Pinned modern versions of SQLAlchemy and python-magic

New Files:

  • Added requirements.txt for pip-based dependency management

Documentation:

  • Updated README.md to reflect Python 3.9+ requirement
  • Added installation instructions using pip
  • Updated library documentation with modern package names

This commit modernizes the entire Malwarehouse codebase from Python 2.7 to Python 3.9+:

### Core Changes:
- Updated all print statements to print() functions
- Replaced file() built-in with open() using proper binary mode
- Changed exception handling from 'except Exception, e' to 'except Exception as e'
- Updated .iteritems() to .items() for dictionary iteration
- Replaced ConfigParser.SafeConfigParser with configparser.ConfigParser
- Updated metaclass syntax from __metaclass__ to metaclass= parameter

### Library Modernization:
- Replaced urllib2 with requests library for HTTP operations
- Removed poster library dependency (replaced with requests)
- Updated to ppdeep from pydeep for fuzzy hashing
- Pinned modern versions of SQLAlchemy and python-magic

### New Files:
- Added requirements.txt for pip-based dependency management

### Documentation:
- Updated README.md to reflect Python 3.9+ requirement
- Added installation instructions using pip
- Updated library documentation with modern package names
@sroberts sroberts self-assigned this Nov 18, 2025
Additional fixes found during testing:
- Fixed MetaData() constructor to not accept engine parameter (SQLAlchemy 2.0)
- Fixed engine.url.database access for SQLAlchemy 2.0 compatibility
- Fixed print statement in extensions/plugins/__init__.py
- Updated pydeep import to ppdeep in utils.py

All tests now pass successfully.
This commit adds a complete testing framework to ensure code quality
and prevent regressions:

### Test Coverage (72% overall):
- Database operations (88% coverage)
- Hash calculations (MD5, SHA256)
- Malware sample processing (59% coverage)
- Plugin system (81-100% coverage)
- Utility functions (79% coverage)
- VirusTotal integration (62% coverage - mocked)

### Test Files:
- tests/test_db_controller.py - Database controller tests (6 tests)
- tests/test_malware_sample.py - Sample handling tests (6 tests)
- tests/test_utils.py - Utility function tests (8 tests)
- tests/test_plugins.py - Plugin system tests (9 tests)
- tests/test_config.cfg - Test configuration
- tests/test_rules.yar - Test YARA rules
- tests/README.md - Testing documentation

### Test Infrastructure:
- pytest.ini - Pytest configuration with coverage settings
- run_tests.sh - Convenient test runner script
- requirements.txt - Added pytest, pytest-cov, pytest-mock, coverage

### CI/CD:
- .github/workflows/ci.yml - GitHub Actions workflow
  - Tests on Python 3.9, 3.10, 3.11, 3.12
  - Tests on Ubuntu and macOS
  - Linting with flake8
  - Code coverage reporting

### Other Improvements:
- Updated .gitignore for test artifacts and Python best practices
- Comprehensive test documentation

All 29 tests passing ✅
@sroberts
sroberts merged commit d3b61cd into master Nov 18, 2025
9 checks passed
@sroberts
sroberts deleted the claude/modernize-basic-01TUJ3G2BHf6gs6Pc8bZE77X branch November 18, 2025 06:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants