dbsafedump 0.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,63 @@
1
+ DBSafeDump License Agreement
2
+
3
+ Copyright (c) 2024 DBSafeDump
4
+
5
+ END USER LICENSE AGREEMENT
6
+
7
+ IMPORTANT: Please read this license agreement carefully before using DBSafeDump.
8
+
9
+ 1. LICENSE TYPES
10
+
11
+ DBSafeDump is available in the following license tiers:
12
+
13
+ - FREE: Limited to 1,000 rows per table. Can be used freely for personal and commercial purposes.
14
+
15
+ - STARTER/PRO: Full functionality with unlimited rows. Requires a valid license key purchased from https://dbsafedump.com
16
+
17
+ 2. PERMITTED USE
18
+
19
+ 2.1 Free Tier:
20
+ - You may use the Free tier for any lawful purpose
21
+ - Redistribution of the software is permitted provided this license is included
22
+ - Commercial use is allowed within the row limit
23
+
24
+ 2.2 Paid Tiers:
25
+ - You may use your license key on one machine at a time
26
+ - License is bound to machine fingerprint
27
+ - License may be transferred to another machine after deactivation
28
+
29
+ 3. PROHIBITED ACTIVITIES
30
+
31
+ 3.1 You MAY NOT:
32
+ - Remove, bypass, or circumvent the license verification system
33
+ - Modify the software to remove or change any licensing checks
34
+ - Share license keys with others
35
+ - Use one license key on multiple machines simultaneously
36
+ - Reverse engineer the license activation mechanism
37
+
38
+ 3.2 Violation of these terms may result in immediate license revocation and legal action.
39
+
40
+ 4. DISCLAIMER
41
+
42
+ THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE AUTHOR DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
43
+
44
+ 5. LIMITATION OF LIABILITY
45
+
46
+ IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER ARISING OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE.
47
+
48
+ 6. TERMINATION
49
+
50
+ This license is effective until terminated. It will terminate automatically if you fail to comply with any term of this agreement. Upon termination, you must cease all use of the software and destroy all copies.
51
+
52
+ 7. DATA COLLECTION
53
+
54
+ DBSafeDump collects the following data for license verification:
55
+ - Machine ID, hostname, and platform information
56
+ - MAC address
57
+ - License key (encrypted)
58
+
59
+ This data is used solely for license activation and verification purposes. For full privacy information, visit: https://dbsafedump.com/privacy
60
+
61
+ 8. CONTACT
62
+
63
+ For license purchases and support: https://dbsafedump.com
package/README.md ADDED
@@ -0,0 +1,596 @@
1
+ # DBSafeDump
2
+
3
+ Safe database dump with anonymization for GDPR compliance.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ - [Overview](#overview)
10
+ - [Features](#features)
11
+ - [Pricing](#pricing)
12
+ - [Installation](#installation)
13
+ - [Quick Start](#quick-start)
14
+ - [License Activation](#license-activation)
15
+ - [Commands](#commands)
16
+ - [Configuration](#configuration)
17
+ - [Masking Types](#masking-types)
18
+ - [Use Cases](#use-cases)
19
+ - [CI/CD Integration](#cicd-integration)
20
+ - [FAQ](#faq)
21
+
22
+ ---
23
+
24
+ ## Overview
25
+
26
+ DBSafeDump is a CLI tool for safely dumping and anonymizing database data. It helps you:
27
+
28
+ - **Dump databases** with automatic sensitive data masking
29
+ - **Migrate data** between databases with anonymization
30
+ - **Scrub existing databases** in-place
31
+ - **Discover sensitive columns** automatically
32
+
33
+ Designed for GDPR compliance, CI/CD pipelines, and safe development workflows.
34
+
35
+ ---
36
+
37
+ ## Features
38
+
39
+ - **Deterministic masking** - Same input = same output (for consistent test data)
40
+ - **Multiple databases** - MySQL, PostgreSQL, MSSQL, SQLite
41
+ - **European data** - Names, addresses, phone numbers, companies
42
+ - **Smart Discovery** - Automatic detection of sensitive columns
43
+ - **CI/CD ready** - Non-interactive mode for automation
44
+ - **License management** - Per-machine activation
45
+
46
+ ---
47
+
48
+ ## Pricing
49
+
50
+ DBSafeDump uses a **freemium** model.
51
+
52
+ - **FREE** - Free forever, 1,000 rows per table limit
53
+ - **STARTER** - Import, migrate, multi-profile, Smart Discovery
54
+ - **PRO** - In-place scrub, CI/CD mode, full Smart Discovery
55
+
56
+ [See all plans and pricing](https://dbsafedump.com/pricing)
57
+
58
+ For enterprise needs, [contact us](mailto:contact@dbsafedump.com)
59
+
60
+ ---
61
+
62
+ ## Installation
63
+
64
+ ### Prerequisites
65
+
66
+ - Node.js 18+
67
+ - npm or yarn
68
+
69
+ ### Install globally
70
+
71
+ ```bash
72
+ npm install -g dbsafedump
73
+ ```
74
+
75
+ ### Or use npx (without installation)
76
+
77
+ ```bash
78
+ npx dbsafedump dump
79
+ ```
80
+
81
+ ### Build from source
82
+
83
+ ```bash
84
+ git clone <repository>
85
+ cd dbsafedump
86
+ npm install
87
+ npm run build
88
+ ```
89
+
90
+ ---
91
+
92
+ ## Quick Start
93
+
94
+ ### 1. Initialize configuration
95
+
96
+ ```bash
97
+ dbsafedump init
98
+ ```
99
+
100
+ This creates `config.yml` and starts an interactive wizard to configure your database connections.
101
+
102
+ ### 2. Test connection
103
+
104
+ ```bash
105
+ dbsafedump test-connection
106
+ ```
107
+
108
+ ### 3. Run dump
109
+
110
+ ```bash
111
+ dbsafedump dump -o dump.sql
112
+ ```
113
+
114
+ ---
115
+
116
+ ## License Activation
117
+
118
+ DBSafeDump uses a **freemium** model. The FREE tier works without any license.
119
+
120
+ **Need more features?** [Buy a license at dbsafedump.com/pricing](https://dbsafedump.com/pricing)
121
+
122
+ ### Activate (STARTER/PRO only)
123
+
124
+ ```bash
125
+ dbsafedump activate "YOUR-LICENSE-KEY"
126
+ ```
127
+
128
+ ### Check status
129
+
130
+ ```bash
131
+ dbsafedump license
132
+ ```
133
+
134
+ ### Deactivate (move to another machine)
135
+
136
+ ```bash
137
+ dbsafedump deactivate
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Commands
143
+
144
+ ### init
145
+
146
+ Initialize configuration and run interactive setup wizard.
147
+
148
+ ```bash
149
+ dbsafedump init
150
+ dbsafedump init --force # Overwrite existing config
151
+ ```
152
+
153
+ ### config
154
+
155
+ Run the interactive configuration wizard.
156
+
157
+ ```bash
158
+ dbsafedump config
159
+ ```
160
+
161
+ ### dump
162
+
163
+ Export database with anonymization to SQL file.
164
+
165
+ ```bash
166
+ dbsafedump dump
167
+ dbsafedump dump -o backup.sql
168
+ dbsafedump dump -c config.yml
169
+ dbsafedump dump --profile dev
170
+ dbsafedump dump --ci
171
+ ```
172
+
173
+ ### import
174
+
175
+ Migrate data from source to target database with anonymization.
176
+
177
+ ```bash
178
+ dbsafedump import
179
+ dbsafedump import --mode truncate # Replace data
180
+ dbsafedump import --mode append # Add data
181
+ dbsafedump import --ci
182
+ ```
183
+
184
+ ### scrub
185
+
186
+ Anonymize data in-place in existing database. This is a destructive operation - it CANNOT be undone.
187
+
188
+ ```bash
189
+ dbsafedump scrub
190
+ dbsafedump scrub --ci --force
191
+ ```
192
+
193
+ **Note:** The `--ci` and `--force` flags skip the confirmation prompt. Always verify your target database in `config.yml` before running.
194
+
195
+ ### scan
196
+
197
+ Scan database and show table information.
198
+
199
+ ```bash
200
+ dbsafedump scan
201
+ ```
202
+
203
+ ### discover
204
+
205
+ Analyze database and suggest masking rules.
206
+
207
+ ```bash
208
+ dbsafedump discover
209
+ dbsafedump discover --output rules.json
210
+ dbsafedump discover --apply # Apply to config
211
+ ```
212
+
213
+ ### test-connection
214
+
215
+ Test database connections.
216
+
217
+ ```bash
218
+ dbsafedump test-connection
219
+ ```
220
+
221
+ ### profiles
222
+
223
+ List available configuration profiles.
224
+
225
+ ```bash
226
+ dbsafedump profiles
227
+ ```
228
+
229
+ ### activate
230
+
231
+ Activate license on this machine.
232
+
233
+ ```bash
234
+ dbsafedump activate "LICENSE-KEY"
235
+ ```
236
+
237
+ ### deactivate
238
+
239
+ Deactivate license (releases for another machine).
240
+
241
+ ```bash
242
+ dbsafedump deactivate
243
+ ```
244
+
245
+ ### license
246
+
247
+ Show current license status.
248
+
249
+ ```bash
250
+ dbsafedump license
251
+ ```
252
+
253
+ ### generate-salt
254
+
255
+ Generate new salt for deterministic masking.
256
+
257
+ ```bash
258
+ dbsafedump generate-salt
259
+ dbsafedump generate-salt --yes # No confirmation
260
+ ```
261
+
262
+ ---
263
+
264
+ ## Configuration
265
+
266
+ Configuration is stored in `config.yml`.
267
+
268
+ ### Basic structure
269
+
270
+ ```yaml
271
+ project: my-project
272
+ salt: generated-salt-here
273
+
274
+ connections:
275
+ source:
276
+ driver: mysql
277
+ host: 127.0.0.1
278
+ port: 3306
279
+ database: source_db
280
+ username: user
281
+ password: "pass"
282
+
283
+ target:
284
+ driver: mysql
285
+ host: 127.0.0.1
286
+ port: 3306
287
+ database: target_db
288
+ username: user
289
+ password: "pass"
290
+ ```
291
+
292
+ ### Tables configuration
293
+
294
+ ```yaml
295
+ tables:
296
+ exclude: # Tables to skip
297
+ - logs_*
298
+ - cache_*
299
+ include: # Only these tables (empty = all)
300
+ - users
301
+ - orders
302
+ truncate: # Truncate before import
303
+ - users
304
+ keyColumns: # Custom keys for tables without PK
305
+ pivot_table: "col1,col2"
306
+ ```
307
+
308
+ ### Masking rules
309
+
310
+ ```yaml
311
+ rules:
312
+ "users.email": email
313
+ "users.phone": phone
314
+ "users.password": null # Replace with NULL
315
+ "users.name": fullName
316
+ ```
317
+
318
+ ### Options
319
+
320
+ ```yaml
321
+ options:
322
+ batchSize: 5000 # Rows per batch
323
+ addDropTable: false # Include DROP TABLE
324
+ addCreateTable: true # Include CREATE TABLE
325
+ transaction: true # Use transactions
326
+ ```
327
+
328
+ ### Multi-profile (STARTER/PRO)
329
+
330
+ ```yaml
331
+ profiles:
332
+ dev:
333
+ connections:
334
+ source:
335
+ host: localhost
336
+ database: myapp_dev
337
+ staging:
338
+ connections:
339
+ source:
340
+ host: staging.example.com
341
+ database: myapp_staging
342
+ production:
343
+ connections:
344
+ source:
345
+ host: prod.example.com
346
+ database: myapp_prod
347
+ ```
348
+
349
+ ---
350
+
351
+ ## Masking Types
352
+
353
+ ### Available maskers
354
+
355
+ | Type | Example Output | Use Case |
356
+ |------|---------------|----------|
357
+ | `email` | `user_a1b2c3@example.test` | Email addresses |
358
+ | `phone` | `+49 123 456 789` | Phone numbers |
359
+ | `firstName` | `Liam`, `Emma`, `Hans` | First names |
360
+ | `lastName` | `Mueller`, `Kowalski` | Last names |
361
+ | `fullName` | `Liam Mueller` | Full names |
362
+ | `address` | `42 Bahnhofstrasse, Berlin` | Addresses |
363
+ | `ip` | `10.45.123.78` | IP addresses |
364
+ | `username` | `user_a1b2c3` | Usernames |
365
+ | `password` | `7f8e9d0c1b2a3f4e` | Passwords |
366
+ | `creditCard` | `1234 5678 9012 3456` | Credit card numbers |
367
+ | `date` | `2023-05-15` | Dates |
368
+ | `company` | `Alpha Solutions GmbH` | Company names |
369
+ | `pesel` | `83020501234` | Polish PESEL |
370
+ | `nip` | `1234563210` | Polish NIP |
371
+ | `regon` | `123456789` | Polish REGON |
372
+ | `iban` | `PL 1234 5678 9012` | IBAN numbers |
373
+ | `uuid` | `a1b2c3d4-0000-0000-0000-000000000000` | UUIDs |
374
+ | `random` | `8f7e6d5c` | Random string |
375
+ | `null` | `NULL` | Replace with NULL |
376
+ | `preserve` | Original value | Keep as-is |
377
+
378
+ ### Auto-detection
379
+
380
+ DBSafeDump automatically detects these column types:
381
+
382
+ - Columns with `email`, `mail` → masked as email
383
+ - Columns with `phone`, `tel`, `mobile` → masked as phone
384
+ - Columns with `name` → masked as fullName
385
+ - Columns with `password`, `passwd` → masked as null
386
+ - Columns with `address`, `street`, `city` → masked as address
387
+ - And more...
388
+
389
+ ---
390
+
391
+ ## Use Cases
392
+
393
+ ### 1. Development Database Setup
394
+
395
+ Create safe development copy of production data.
396
+
397
+ ```bash
398
+ # Dump production with anonymization
399
+ dbsafedump dump -o dev_dump.sql
400
+
401
+ # Import to development database
402
+ dbsafedump import
403
+ ```
404
+
405
+ ### 2. GDPR Compliance
406
+
407
+ Anonymize data before sharing with third parties.
408
+
409
+ ```bash
410
+ # Anonymize existing database
411
+ dbsafedump scrub --ci --force --profile production
412
+ ```
413
+
414
+ ### 3. Multi-Environment Migration
415
+
416
+ Move data between environments with consistent anonymization.
417
+
418
+ ```yaml
419
+ # config.yml
420
+ profiles:
421
+ staging:
422
+ connections:
423
+ source:
424
+ host: prod.example.com
425
+ database: customers
426
+ target:
427
+ host: staging.example.com
428
+ database: customers_staging
429
+ ```
430
+
431
+ ```bash
432
+ # Migrate staging → production
433
+ dbsafedump import --profile production --ci
434
+ ```
435
+
436
+ ### 4. Test Data Generation
437
+
438
+ Create deterministic test data.
439
+
440
+ ```bash
441
+ # Generate dump with fixed salt
442
+ dbsafedump dump -o test_data.sql
443
+
444
+ # Same input = same output
445
+ # john.doe@company.com → user_a1b2c3@example.test
446
+ ```
447
+
448
+ ### 5. CI/CD Pipeline
449
+
450
+ Automated data anonymization.
451
+
452
+ ```yaml
453
+ # .github/workflows/scrub.yml
454
+ name: Anonymize Production Data
455
+
456
+ on:
457
+ schedule:
458
+ - cron: '0 2 * * *' # Daily at 2 AM
459
+
460
+ jobs:
461
+ anonymize:
462
+ runs-on: ubuntu-latest
463
+ steps:
464
+ - uses: actions/checkout@v3
465
+ - name: Install DBSafeDump
466
+ run: npm install -g dbsafedump
467
+ - name: Run anonymization
468
+ run: dbsafedump scrub --ci --force --profile production
469
+ ```
470
+
471
+ ---
472
+
473
+ ## CI/CD Integration
474
+
475
+ ### GitHub Actions
476
+
477
+ ```yaml
478
+ name: Database Operations
479
+
480
+ on: [push]
481
+
482
+ jobs:
483
+ dump:
484
+ runs-on: ubuntu-latest
485
+ steps:
486
+ - name: Setup
487
+ run: npm install -g dbsafedump
488
+
489
+ - name: Create Dump
490
+ run: dbsafedump dump --ci -o dump.sql
491
+ env:
492
+ DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
493
+
494
+ - name: Upload Dump
495
+ uses: actions/upload-artifact@v3
496
+ with:
497
+ name: database-dump
498
+ path: dump.sql
499
+ ```
500
+
501
+ ### GitLab CI
502
+
503
+ ```yaml
504
+ anonymize:
505
+ script:
506
+ - npm install -g dbsafedump
507
+ - dbsafedump scrub --ci --force --profile production
508
+ only:
509
+ - schedule
510
+ schedule: '0 2 * * *'
511
+ ```
512
+
513
+ ### Jenkins
514
+
515
+ ```groovy
516
+ pipeline {
517
+ agent any
518
+ stages {
519
+ stage('Anonymize') {
520
+ steps {
521
+ sh 'npm install -g dbsafedump'
522
+ sh 'dbsafedump scrub --ci --force --profile production'
523
+ }
524
+ }
525
+ }
526
+ triggers {
527
+ cron('0 2 * * *')
528
+ }
529
+ }
530
+ ```
531
+
532
+ ---
533
+
534
+ ## FAQ
535
+
536
+ ### Q: Is there a free version?
537
+
538
+ Yes! DBSafeDump has a **freemium** model. The FREE tier is free forever with 1,000 rows per table limit. [See all plans](https://dbsafedump.com/pricing)
539
+
540
+ ### Q: How does deterministic masking work?
541
+
542
+ The same input value always produces the same output. This is useful for:
543
+ - Consistent test data
544
+ - Joining anonymized tables
545
+ - Reproducible dumps
546
+
547
+ The salt in `config.yml` ensures deterministic output.
548
+
549
+ ### Q: Can I change the salt?
550
+
551
+ Yes, but changing the salt re-masks all data differently.
552
+
553
+ ```bash
554
+ dbsafedump generate-salt
555
+ ```
556
+
557
+ ### Q: How is license bound to machine?
558
+
559
+ License is bound to machine fingerprint (MAC address + machine ID). Each license key can be activated on one machine at a time.
560
+
561
+ ### Q: Can I move my license to another computer?
562
+
563
+ Yes! Just run `dbsafedump deactivate` on the old computer, then `dbsafedump activate "KEY"` on the new one. Your license can be transferred anytime.
564
+
565
+ ### Q: What happens if API is offline?
566
+
567
+ If the license server is unreachable, the app falls back to FREE tier (1000 rows limit).
568
+
569
+ ### Q: Can I use DBSafeDump without internet?
570
+
571
+ Yes, after initial activation, the license is cached for 1 hour. After that, re-verification is needed.
572
+
573
+ ### Q: Which databases are supported?
574
+
575
+ - MySQL / MariaDB
576
+ - PostgreSQL
577
+ - MSSQL / SQL Server
578
+ - SQLite
579
+
580
+ ### Q: How do I report issues?
581
+
582
+ Open an issue at https://github.com/anomalyco/dbsafedump/issues
583
+
584
+ ---
585
+
586
+ ## Support
587
+
588
+ - Documentation: https://dbsafedump.com/docs
589
+ - Website: https://dbsafedump.com
590
+ - Pricing: https://dbsafedump.com/pricing
591
+
592
+ ---
593
+
594
+ ## License
595
+
596
+ Copyright 2024. All rights reserved.