db-hygiene 0.1.0
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/README.md +61 -0
- package/dist/cli.js +69 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# db-hygiene
|
|
2
|
+
|
|
3
|
+
Scan databases and SQL dumps for PII & credentials; optionally anonymise with [anonymiser](https://www.npmjs.com/package/anonymiser). CLI-first, CI/CD friendly.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install db-hygiene
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or run without installing:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx db-hygiene <command>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Commands
|
|
18
|
+
|
|
19
|
+
| Command | Description |
|
|
20
|
+
|------------|-------------|
|
|
21
|
+
| `scan` | Detect PII and credentials (alias for `audit`) |
|
|
22
|
+
| `audit` | Same as `scan` — read-only, no writes |
|
|
23
|
+
| `anonymise`| Run anonymisation (delegates to anonymiser) |
|
|
24
|
+
| `report` | Output report (human-readable or JSON) |
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx db-hygiene scan --config audit.config.js
|
|
30
|
+
npx db-hygiene audit
|
|
31
|
+
npx db-hygiene anonymise --config anonymiser.config.mjs
|
|
32
|
+
npx db-hygiene report
|
|
33
|
+
npx db-hygiene --help
|
|
34
|
+
npx db-hygiene --version
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Exit codes
|
|
38
|
+
|
|
39
|
+
| Code | Meaning |
|
|
40
|
+
|------|---------|
|
|
41
|
+
| `0` | Clean / no findings |
|
|
42
|
+
| `2` | Findings present |
|
|
43
|
+
| `1` | Error |
|
|
44
|
+
|
|
45
|
+
Use these in CI to fail pipelines when issues are found, e.g. `if [ $? -eq 2 ]; then exit 1; fi` or your runner’s equivalent.
|
|
46
|
+
|
|
47
|
+
## CI example
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
# GitHub Actions
|
|
51
|
+
- run: npx db-hygiene scan --config audit.config.js
|
|
52
|
+
- run: npx db-hygiene anonymise --config anonymiser.config.mjs
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Requirements
|
|
56
|
+
|
|
57
|
+
- Node.js >= 18
|
|
58
|
+
|
|
59
|
+
## License
|
|
60
|
+
|
|
61
|
+
MIT
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
#!/usr/bin/env node
|
|
3
|
+
|
|
4
|
+
// src/cli.ts
|
|
5
|
+
var VERBS = ["scan", "audit", "anonymise", "report"];
|
|
6
|
+
var EXIT = { ok: 0, findings: 2, error: 1 };
|
|
7
|
+
function showHelp() {
|
|
8
|
+
console.log(`
|
|
9
|
+
db-hygiene \u2013 scan DBs/SQL dumps for PII & credentials; optionally anonymise.
|
|
10
|
+
|
|
11
|
+
Usage: db-hygiene <command> [options]
|
|
12
|
+
|
|
13
|
+
Commands:
|
|
14
|
+
scan Detect PII and credentials (alias for audit)
|
|
15
|
+
audit Same as scan \u2013 read-only, no writes
|
|
16
|
+
anonymise Run anonymisation (delegates to anonymiser)
|
|
17
|
+
report Output report (human-readable or JSON)
|
|
18
|
+
|
|
19
|
+
Exit codes:
|
|
20
|
+
0 Clean / no findings
|
|
21
|
+
2 Findings present
|
|
22
|
+
1 Error
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
npx db-hygiene scan --config audit.config.js
|
|
26
|
+
npx db-hygiene audit
|
|
27
|
+
npx db-hygiene anonymise --config anonymiser.config.mjs
|
|
28
|
+
npx db-hygiene report
|
|
29
|
+
`);
|
|
30
|
+
}
|
|
31
|
+
async function main() {
|
|
32
|
+
const [, , verb] = process.argv;
|
|
33
|
+
const cmd = verb && verb.toLowerCase();
|
|
34
|
+
if (!cmd || cmd === "-h" || cmd === "--help") {
|
|
35
|
+
showHelp();
|
|
36
|
+
process.exit(EXIT.ok);
|
|
37
|
+
}
|
|
38
|
+
if (cmd === "-v" || cmd === "--version") {
|
|
39
|
+
try {
|
|
40
|
+
const { readFileSync } = await import("fs");
|
|
41
|
+
const { dirname } = await import("path");
|
|
42
|
+
const { fileURLToPath } = await import("url");
|
|
43
|
+
const p = dirname(fileURLToPath(import.meta.url));
|
|
44
|
+
const pkg = JSON.parse(readFileSync(p + "/../package.json", "utf8"));
|
|
45
|
+
console.log(pkg.version || "0.1.0");
|
|
46
|
+
} catch {
|
|
47
|
+
console.log("0.1.0");
|
|
48
|
+
}
|
|
49
|
+
process.exit(EXIT.ok);
|
|
50
|
+
}
|
|
51
|
+
if (!VERBS.includes(cmd)) {
|
|
52
|
+
console.error(`Unknown command: ${cmd}. Use: ${VERBS.join(", ")}`);
|
|
53
|
+
process.exit(EXIT.error);
|
|
54
|
+
}
|
|
55
|
+
if (cmd === "scan" || cmd === "audit") {
|
|
56
|
+
console.log(`db-hygiene: ${cmd} (no findings in stub)`);
|
|
57
|
+
process.exit(EXIT.ok);
|
|
58
|
+
}
|
|
59
|
+
if (cmd === "anonymise") {
|
|
60
|
+
console.log("db-hygiene: anonymise (stub \u2013 will delegate to anonymiser)");
|
|
61
|
+
process.exit(EXIT.ok);
|
|
62
|
+
}
|
|
63
|
+
if (cmd === "report") {
|
|
64
|
+
console.log("db-hygiene: report (stub)");
|
|
65
|
+
process.exit(EXIT.ok);
|
|
66
|
+
}
|
|
67
|
+
process.exit(EXIT.ok);
|
|
68
|
+
}
|
|
69
|
+
main().catch(() => process.exit(EXIT.error));
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "db-hygiene",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Scan databases and SQL dumps for PII & credentials; optionally anonymise with anonymiser. CLI-first, CI/CD friendly.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"db-hygiene": "dist/cli.ts"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "node esbuild.mjs",
|
|
15
|
+
"prepublishOnly": "npm run build",
|
|
16
|
+
"dev": "node src/cli.ts"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"pii",
|
|
20
|
+
"credentials",
|
|
21
|
+
"secrets",
|
|
22
|
+
"database",
|
|
23
|
+
"audit",
|
|
24
|
+
"anonymise",
|
|
25
|
+
"ci",
|
|
26
|
+
"db-hygiene"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": ""
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"esbuild": "^0.24.0",
|
|
38
|
+
"tsx": "^4.21.0"
|
|
39
|
+
}
|
|
40
|
+
}
|