|
1 | | -# maven_settings_decoder |
2 | | -Decode maven settings file |
| 1 | +# Maven Settings Decoder |
| 2 | + |
| 3 | +A Python tool to decrypt passwords in Maven settings files (`settings.xml` and `settings-security.xml`). This tool can help you retrieve encrypted credentials from Maven configuration files, which is particularly useful for debugging or auditing purposes. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Decrypts master password from `settings-security.xml` |
| 8 | +- Decrypts server passwords from `settings.xml` |
| 9 | +- Support for both default and custom file paths |
| 10 | +- Color-coded console output |
| 11 | +- Verbose debugging mode |
| 12 | +- Clear error messages and handling |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +### From PyPI (Recommended) |
| 17 | + |
| 18 | +```bash |
| 19 | +pip install maven_settings_decoder |
| 20 | +``` |
| 21 | + |
| 22 | +### From Source |
| 23 | + |
| 24 | +```bash |
| 25 | +git clone https://github.com/svaningelgem/maven_settings_decoder.git |
| 26 | +cd maven_settings_decoder |
| 27 | +pip install -e . |
| 28 | +``` |
| 29 | + |
| 30 | +## Usage |
| 31 | + |
| 32 | +### Command Line Interface |
| 33 | + |
| 34 | +1. Using default paths (`~/.m2/settings.xml` and `~/.m2/settings-security.xml`): |
| 35 | +```bash |
| 36 | +maven-decoder |
| 37 | +``` |
| 38 | + |
| 39 | +2. Specifying custom file paths: |
| 40 | +```bash |
| 41 | +maven-decoder --settings /path/to/settings.xml --security /path/to/settings-security.xml |
| 42 | +``` |
| 43 | + |
| 44 | +3. Enable verbose output: |
| 45 | +```bash |
| 46 | +maven-decoder -v |
| 47 | +``` |
| 48 | + |
| 49 | +4. Disable colored output: |
| 50 | +```bash |
| 51 | +maven-decoder --no-color |
| 52 | +``` |
| 53 | + |
| 54 | +### Python API |
| 55 | + |
| 56 | +```python |
| 57 | +from maven_settings_decoder import MavenPasswordDecoder |
| 58 | + |
| 59 | +# Initialize with default paths |
| 60 | +decoder = MavenPasswordDecoder() |
| 61 | + |
| 62 | +# Or specify custom paths |
| 63 | +decoder = MavenPasswordDecoder( |
| 64 | + settings_path="/path/to/settings.xml", |
| 65 | + security_path="/path/to/settings-security.xml" |
| 66 | +) |
| 67 | + |
| 68 | +# Get master password |
| 69 | +master_password = decoder.get_master_password() |
| 70 | +print(f"Master password: {master_password}") |
| 71 | + |
| 72 | +# Get all server credentials |
| 73 | +servers = decoder.read_credentials() |
| 74 | +for server in servers: |
| 75 | + print(f"Server: {server.id}") |
| 76 | + print(f"Username: {server.username}") |
| 77 | + print(f"Password: {server.decrypted_password}") |
| 78 | +``` |
| 79 | + |
| 80 | +## Requirements |
| 81 | + |
| 82 | +- Python 3.9+ |
| 83 | +- cryptography |
| 84 | +- loguru |
| 85 | + |
| 86 | +## How It Works |
| 87 | + |
| 88 | +The tool implements Maven's password encryption scheme: |
| 89 | + |
| 90 | +1. Reads the master password from `settings-security.xml` |
| 91 | +2. Decrypts the master password using the default key "settings.security" |
| 92 | +3. Uses the decrypted master password to decrypt server passwords in `settings.xml` |
| 93 | +4. Handles various encryption formats and edge cases |
| 94 | + |
| 95 | +## Command Line Options |
| 96 | + |
| 97 | +``` |
| 98 | +usage: maven-decoder [-h] [-s SETTINGS] [--security SECURITY] [-v] [--no-color] |
| 99 | +
|
| 100 | +Decrypt passwords in Maven settings files |
| 101 | +
|
| 102 | +optional arguments: |
| 103 | + -h, --help show this help message and exit |
| 104 | + -s SETTINGS, --settings SETTINGS |
| 105 | + Path to settings.xml file (default: ~/.m2/settings.xml) |
| 106 | + --security SECURITY Path to settings-security.xml file (default: ~/.m2/settings-security.xml) |
| 107 | + -v, --verbose Enable verbose debug output (default: False) |
| 108 | + --no-color Disable colored output (default: False) |
| 109 | +``` |
| 110 | + |
| 111 | +## Exit Codes |
| 112 | + |
| 113 | +- 0: Success |
| 114 | +- 1: Error (file not found, decoding error, etc.) |
| 115 | +- 130: User interrupted (Ctrl+C) |
| 116 | +## Installation and Usage |
| 117 | + |
| 118 | +### Installation |
| 119 | + |
| 120 | +```bash |
| 121 | +# Install from PyPI |
| 122 | +pip install maven_settings_decoder |
| 123 | + |
| 124 | +# Or using Poetry |
| 125 | +poetry add maven_settings_decoder |
| 126 | +``` |
| 127 | + |
| 128 | +### Command Line Usage |
| 129 | + |
| 130 | +After installation, the `maven-decoder` command will be available in your environment: |
| 131 | + |
| 132 | +```bash |
| 133 | +# Show help |
| 134 | +maven-decoder --help |
| 135 | + |
| 136 | +# Decode with default paths |
| 137 | +maven-decoder |
| 138 | + |
| 139 | +# Decode with custom paths |
| 140 | +maven-decoder --settings /path/to/settings.xml --security /path/to/settings-security.xml |
| 141 | + |
| 142 | +# Enable verbose output |
| 143 | +maven-decoder -v |
| 144 | + |
| 145 | +# Disable colored output |
| 146 | +maven-decoder --no-color |
| 147 | +``` |
| 148 | + |
| 149 | +### Development Installation |
| 150 | + |
| 151 | +For development: |
| 152 | + |
| 153 | +```bash |
| 154 | +# Clone the repository |
| 155 | +git clone https://github.com/svaningelgem/maven_settings_decoder |
| 156 | +cd maven_settings_decoder |
| 157 | + |
| 158 | +# Install with Poetry in development mode |
| 159 | +poetry install |
| 160 | + |
| 161 | +# Run the script |
| 162 | +poetry run maven-decoder --help |
| 163 | + |
| 164 | +# Or activate the virtual environment and run directly |
| 165 | +poetry shell |
| 166 | +maven-decoder --help |
| 167 | +``` |
| 168 | + |
| 169 | +## Development |
| 170 | + |
| 171 | +### Setup Development Environment |
| 172 | + |
| 173 | +```bash |
| 174 | +# Clone the repository |
| 175 | +git clone https://github.com/svaningelgem/maven_settings_decoder.git |
| 176 | +cd maven_settings_decoder |
| 177 | + |
| 178 | +# Create and activate virtual environment (optional) |
| 179 | +python -m venv venv |
| 180 | +source venv/bin/activate # Linux/Mac |
| 181 | +# or |
| 182 | +.\venv\Scripts\activate # Windows |
| 183 | + |
| 184 | +# Install development dependencies |
| 185 | +pip install -e ".[dev]" |
| 186 | +``` |
| 187 | + |
| 188 | +### Running Tests |
| 189 | + |
| 190 | +```bash |
| 191 | +pytest |
| 192 | +``` |
| 193 | + |
| 194 | +## Contributing |
| 195 | + |
| 196 | +1. Fork the repository |
| 197 | +2. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 198 | +3. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 199 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 200 | +5. Open a Pull Request |
| 201 | + |
| 202 | +## License |
| 203 | + |
| 204 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
| 205 | + |
| 206 | +## Acknowledgments |
| 207 | + |
| 208 | +- Based on the encryption scheme used in [Apache Maven](https://maven.apache.org/) |
| 209 | +- Inspired by the Java implementation in [plexus-cipher](https://github.com/sonatype/plexus-cipher/) |
| 210 | +- Implementation details derived from [Maven Settings Builder](https://github.com/apache/maven/tree/master/maven-settings-builder) |
| 211 | + |
| 212 | +## Security |
| 213 | + |
| 214 | +This tool is meant for legitimate use cases such as debugging and auditing. Please ensure you have the necessary permissions before attempting to decrypt passwords in Maven settings files. |
| 215 | + |
| 216 | +Note: Never commit your decrypted passwords or master passwords to version control systems. |
| 217 | + |
| 218 | +## Support |
| 219 | + |
| 220 | +If you encounter any issues or have questions, please: |
| 221 | + |
| 222 | +1. Check the [FAQ](docs/FAQ.md) |
| 223 | +2. Search existing [issues](https://github.com/svaningelgem/maven_settings_decoder/issues) |
| 224 | +3. Create a new issue if needed |
| 225 | + |
| 226 | +## Changelog |
| 227 | + |
| 228 | +See [CHANGELOG.md](CHANGELOG.md) for all changes between versions. |
0 commit comments