Skip to content

Commit 5a19081

Browse files
authored
Getting ready for first release (#1)
1 parent a35c5de commit 5a19081

File tree

12 files changed

+1479
-3
lines changed

12 files changed

+1479
-3
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# https://docs.github.com/en/code-security/supply-chain-security/keeping-your-dependencies-updated-automatically/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: '/'
6+
schedule:
7+
interval: "weekly"
8+
ignore:
9+
- dependency-name: '*'
10+
update-types: ['version-update:semver-patch']
11+
commit-message:
12+
prefix: ci
13+
labels: ['skip changelog']
14+
15+
- package-ecosystem: "pip"
16+
directory: "/"
17+
schedule:
18+
interval: "weekly"

.github/workflows/clear-caches.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Clear caches
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 1 * *' # First day of the month >> Just clean all the caches
6+
workflow_dispatch:
7+
8+
jobs:
9+
clear-caches:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Clear all caches
15+
run: gh cache delete --all || true
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/run_tests.yml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Run tests
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
paths:
7+
- '**.py'
8+
pull_request:
9+
branches: [ "master" ]
10+
paths:
11+
- '**.py'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
jobs:
18+
19+
linting:
20+
runs-on: ubuntu-latest
21+
steps:
22+
#----------------------------------------------
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-python@v5
25+
with:
26+
python-version: "3.9"
27+
#----------------------------------------------
28+
- uses: actions/cache@v4
29+
with:
30+
path: ~/.cache/pip
31+
key: ${{ runner.os }}-pip
32+
#----------------------------------------------
33+
- name: Install ruff
34+
run: python -m pip install ruff
35+
36+
- name: Check python code
37+
run: ruff check --no-fix .
38+
39+
- name: Check formatting style
40+
run: ruff format --diff .
41+
#----------------------------------------------
42+
43+
44+
tests:
45+
needs: linting
46+
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: [ubuntu-latest]
51+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
52+
53+
runs-on: ${{ matrix.os }}
54+
55+
steps:
56+
- uses: actions/checkout@v4
57+
58+
- name: Set up Python ${{ matrix.python-version }}
59+
uses: actions/setup-python@v5
60+
with:
61+
python-version: ${{ matrix.python-version }}
62+
63+
- name: cache poetry install
64+
uses: actions/cache@v4
65+
with:
66+
path: ~/.local
67+
key: poetry-${{ matrix.os }}-${{ matrix.python-version }}
68+
69+
- name: Install Poetry
70+
uses: snok/install-poetry@v1
71+
with:
72+
virtualenvs-create: true
73+
virtualenvs-in-project: true
74+
75+
- name: Load cached venv
76+
id: cached-poetry-dependencies
77+
uses: actions/cache@v4
78+
with:
79+
path: .venv
80+
key: venv-${{ matrix.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
81+
82+
- name: Install dependencies
83+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
84+
run: poetry install --no-interaction --no-root
85+
86+
- name: Install
87+
run: poetry install --no-interaction
88+
89+
- name: Run tests
90+
run: |
91+
source .venv/bin/activate
92+
pytest --cov=maven_settings_decoder --cov-append --cov-fail-under=80 --cov-branch --cov-report=json --cov-report=term
93+
94+
- name: Upload coverage reports to Codecov
95+
uses: codecov/codecov-action@v4
96+
env:
97+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,5 @@ cython_debug/
159159
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160160
# and can be added to the global gitignore or merged into this file. For a more nuclear
161161
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
162-
#.idea/
162+
.idea/
163+
.ruff_cache/

README.md

Lines changed: 228 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,228 @@
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

Comments
 (0)