fortress-cli 1.0.0

Command-line interface for Fortress secure database
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
# Fortress CLI


[![Crates.io](https://img.shields.io/crates/v/fortress-cli.svg)](https://crates.io/crates/fortress-cli)
[![License: Fortress Sustainable Use License 1.0](https://img.shields.io/badge/License-Fortress%20Sustainable%20Use%20License%201.0-blue.svg)](../../LICENSE)

🛡️ **Fortress CLI** - Command-line interface for Fortress secure database system. Enterprise-grade encryption and key management from your terminal.

## Installation


### Install from Crates.io (Recommended)


```bash
cargo install fortress-cli
```

### Install from Source


```bash
# Clone repository

git clone https://github.com/Genius740Code/Fortress.git
cd Fortress

# Install CLI

cargo install --path crates/fortress-cli
```

### NPM Package (Node.js bindings)


```bash
# Install globally

npm install -g fortress-cli

# Or locally

npm install fortress-cli
```

## Quick Start


### Initialize Fortress


```bash
# Initialize Fortress configuration

fortress init

# Start the Fortress server

fortress server start

# Create an encryption key

fortress key create --name my-key --algorithm aes256-gcm

# Encrypt data

echo "secret data" | fortress encrypt --key-id my-key > encrypted.dat

# Decrypt data

fortress decrypt --key-id my-key --input encrypted.dat
```

### Database Operations


```bash
# Create a database

fortress db create myapp

# List databases

fortress db list

# Insert data

fortress db insert myapp users '{"name": "Alice", "email": "alice@example.com"}'

# Query data

fortress db query myapp users --where '{"email": "alice@example.com"}'

# Create index

fortress db index create myapp users email
```

### Key Management


```bash
# Generate a new key

fortress key generate --algorithm aegis256 --name production-key

# List all keys

fortress key list

# Get key details

fortress key info production-key

# Rotate a key

fortress key rotate production-key

# Delete a key

fortress key delete production-key
```

## Commands


### Server Management


```bash
# Start server

fortress server start

# Start with custom configuration

fortress server start --config /path/to/config.toml

# Stop server

fortress server stop

# Restart server

fortress server restart

# Check server status

fortress server status

# View server logs

fortress server logs
```

### Database Operations


```bash
# Create database

fortress db create <database-name>

# List databases

fortress db list

# Delete database

fortress db delete <database-name>

# Insert data

fortress db insert <database> <collection> '<json-data>'

# Query data

fortress db query <database> <collection> [--where <json-filter>]

# Update data

fortress db update <database> <collection> --where <json-filter> --data <json-data>

# Delete data

fortress db delete <database> <collection> [--where <json-filter>]

# Create index

fortress db index create <database> <collection> <field>

# List indexes

fortress db index list <database> <collection>

# Drop index

fortress db index drop <database> <collection> <field>
```

### Key Management


```bash
# Generate key

fortress key generate [--algorithm <algorithm>] [--name <name>] [--format <format>]

# List keys

fortress key list [--format <format>]

# Get key info

fortress key info <key-id>

# Rotate key

fortress key rotate <key-id>

# Delete key

fortress key delete <key-id>

# Export key

fortress key export <key-id> [--format <format>] [--output <file>]

# Import key

fortress key import <file> [--name <name>]
```

### Encryption Operations


```bash
# Encrypt data

fortress encrypt --key-id <key-id> [--input <file>] [--output <file>]

# Decrypt data

fortress decrypt --key-id <key-id> [--input <file>] [--output <file>]

# Encrypt file

fortress encrypt-file --key-id <key-id> <input-file> <output-file>

# Decrypt file

fortress decrypt-file --key-id <key-id> <input-file> <output-file>
```

### Configuration


```bash
# Show current configuration

fortress config show

# Set configuration value

fortress config set <key> <value>

# Get configuration value

fortress config get <key>

# Reset configuration

fortress config reset

# Create configuration file

fortress config init [--profile <profile>]
```

### Cluster Management


```bash
# Initialize cluster

fortress cluster init [--name <cluster-name>] [--node-id <node-id>]

# Join cluster

fortress cluster join <seed-node> [--node-id <node-id>]

# Leave cluster

fortress cluster leave

# List cluster nodes

fortress cluster nodes

# Show cluster status

fortress cluster status
```

## Configuration


### Configuration File


The Fortress CLI uses a TOML configuration file located at:

- Linux/macOS: `~/.config/fortress/config.toml`
- Windows: `%APPDATA%\fortress\config.toml`

### Example Configuration


```toml
[server]
host = "0.0.0.0"
port = 8080
workers = 4

[database]
default_algorithm = "aegis256"
auto_rotation = true
rotation_interval = "24h"

[encryption]
default_algorithm = "aegis256"
key_size = 32
compression = true

[storage]
backend = "memory"
path = "/var/lib/fortress"

[logging]
level = "info"
format = "json"
file = "/var/log/fortress/fortress.log"

[security]
require_authentication = true
audit_logging = true
max_key_size = 1048576  # 1MB

[cluster]
enabled = false
node_id = "node-1"
seed_nodes = []
```

### Environment Variables


```bash
# Server configuration

export FORTRESS_HOST=0.0.0.0
export FORTRESS_PORT=8080

# Database configuration

export FORTRESS_DEFAULT_ALGORITHM=aegis256
export FORTRESS_KEY_ROTATION_INTERVAL=24h

# Storage configuration

export FORTRESS_STORAGE_BACKEND=memory
export FORTRESS_STORAGE_PATH=/var/lib/fortress

# Logging configuration

export FORTRESS_LOG_LEVEL=info
export FORTRESS_LOG_FORMAT=json
```

## Supported Algorithms


| Algorithm | CLI Name | Security Level | Performance |
|-----------|------------|----------------|-------------|
| AEGIS-256 | `aegis256` | Very High | Fastest |
| ChaCha20-Poly1305 | `chacha20-poly1305` | High | Very Fast |
| AES-256-GCM | `aes256-gcm` | High | Fast |
| XChaCha20-Poly1305 | `xchacha20-poly1305` | High | Fast |

## Output Formats


### Key Formats


```bash
# Base64 (default)

fortress key generate --format base64

# Hex

fortress key generate --format hex

# Binary

fortress key generate --format raw
```

### Data Formats


```bash
# JSON (default)

fortress db query myapp users --format json

# Table

fortress db query myapp users --format table

# CSV

fortress db query myapp users --format csv

# Pretty-printed JSON

fortress db query myapp users --format pretty
```

## Examples


### Basic Workflow


```bash
# 1. Initialize Fortress

fortress init

# 2. Start server

fortress server start

# 3. Create database

fortress db create myapp

# 4. Generate key

fortress key generate --name user-data --algorithm aegis256

# 5. Insert encrypted data

fortress db insert myapp users '{
  "name": "Alice Johnson",
  "email": "alice@example.com",
  "ssn": "123-45-6789"
}'

# 6. Query data

fortress db query myapp users --where '{"email": "alice@example.com"}'
```

### Batch Operations


```bash
# Insert multiple records

cat users.json | fortress db insert-batch myapp users

# Bulk encrypt files

for file in *.txt; do
  fortress encrypt-file --key-id my-key "$file" "$file.enc"
done

# Bulk decrypt files

for file in *.enc; do
  fortress decrypt-file --key-id my-key "$file" "${file%.enc}"
done
```

### Script Integration


```bash
#!/bin/bash

# backup.sh - Fortress backup script


set -e

BACKUP_DIR="/backups/fortress"
DATE=$(date +%Y%m%d_%H%M%S)

# Create backup directory

mkdir -p "$BACKUP_DIR"

# Export all databases

for db in $(fortress db list --format json | jq -r '.[]'); do
  echo "Backing up database: $db"
  fortress db export "$db" --output "$BACKUP_DIR/${db}_${DATE}.json"
done

# Export all keys

fortress key list --format json > "$BACKUP_DIR/keys_${DATE}.json"

echo "Backup completed: $BACKUP_DIR"
```

## Advanced Usage


### Custom Profiles


```bash
# Development profile

fortress config init --profile development

# Production profile  

fortress config init --profile production

# High-security profile

fortress config init --profile fortress
```

### Plugin Management


```bash
# List available plugins

fortress plugin list

# Install plugin

fortress plugin install <plugin-name>

# Enable plugin

fortress plugin enable <plugin-name>

# Disable plugin

fortress plugin disable <plugin-name>

# Uninstall plugin

fortress plugin uninstall <plugin-name>
```

### Performance Monitoring


```bash
# Show performance metrics

fortress metrics show

# Show real-time metrics

fortress metrics watch

# Export metrics

fortress metrics export --format prometheus --output metrics.txt
```

## Troubleshooting


### Common Issues


**Server won't start**
```bash
# Check configuration

fortress config show

# Check logs

fortress server logs

# Check port availability

netstat -tlnp | grep :8080
```

**Key not found**
```bash
# List available keys

fortress key list

# Check key details

fortress key info <key-id>
```

**Connection refused**
```bash
# Check server status

fortress server status

# Check firewall settings

sudo ufw status
```

### Debug Mode


```bash
# Enable debug logging

export FORTRESS_LOG_LEVEL=debug

# Run with verbose output

fortress --verbose server start

# Enable trace logging

export FORTRESS_LOG_LEVEL=trace
```

## Completion


### Shell Completion


```bash
# Generate completion script

fortress completion bash > /etc/bash_completion.d/fortress
fortress completion zsh > /usr/local/share/zsh/site-functions/_fortress
fortress completion fish > ~/.config/fish/completions/fortress.fish

# Reload shell

source ~/.bashrc  # or ~/.zshrc
```

### Installation


```bash
# Bash

echo 'source <(fortress completion bash)' >> ~/.bashrc

# Zsh

echo 'source <(fortress completion zsh)' >> ~/.zshrc

# Fish

echo 'source <(fortress completion fish)' >> ~/.config/fish/config.fish
```

## License


This project is licensed under the **Fortress Sustainable Use License 1.0** - see the [LICENSE](../../LICENSE) file for details.

## Support


- **Documentation**: [https://github.com/Genius740Code/Fortress/blob/main/docs]https://github.com/Genius740Code/Fortress/blob/main/docs
- **Issues**: [https://github.com/Genius740Code/Fortress/issues]https://github.com/Genius740Code/Fortress/issues
- **Discussions**: [https://github.com/Genius740Code/Fortress/discussions]https://github.com/Genius740Code/Fortress/discussions
- **Email**: team@fortressdb.io

---

**Fortress CLI** - Security at your fingertips. 🛡️