Skip to content

Commit 509789d

Browse files
authored
Merge pull request #5 from codellm-devkit/patch/secret-hygiene-neo4j-credentials
fix(neo4j): read Neo4j connection options from env vars (secret hygiene)
2 parents 26cb074 + 0ddd5fc commit 509789d

3 files changed

Lines changed: 40 additions & 10 deletions

File tree

README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ Options:
147147
--app-name <name> logical application name for the graph
148148
:Application anchor (default: input dir name)
149149
--neo4j-uri <uri> push the graph to a live Neo4j over Bolt
150-
(incremental); omit to write graph.cypher
151-
--neo4j-user <user> Neo4j username (default: "neo4j")
152-
--neo4j-password <password> Neo4j password (default: "neo4j")
153-
--neo4j-database <db> Neo4j database name (default: server default)
150+
(incremental); omit to write graph.cypher (env:
151+
NEO4J_URI)
152+
--neo4j-user <user> Neo4j username (default: "neo4j", env:
153+
NEO4J_USERNAME)
154+
--neo4j-password <password> Neo4j password (prefer the env var; a flag is
155+
visible in shell history / process list)
156+
(default: "neo4j", env: NEO4J_PASSWORD)
157+
--neo4j-database <db> Neo4j database name (env: NEO4J_DATABASE)
154158
-a, --analysis-level <n> analysis depth: 1 = symbol table + tsc resolver
155159
call graph + RTA (default); 2 = call graph
156160
(default: "1")
@@ -237,6 +241,17 @@ sites as relationships):
237241
content hash changed are rewritten, and on a full run modules whose source file vanished are
238242
pruned. Every graph carries a `schema_version` on its `:Application` node.
239243

244+
The connection options also read the standard Neo4j environment variables — `NEO4J_URI`,
245+
`NEO4J_USERNAME`, `NEO4J_PASSWORD`, `NEO4J_DATABASE` — when the corresponding flag is omitted (an
246+
explicit flag wins). Prefer the env var for the password so it doesn't land in shell history or the
247+
process list:
248+
249+
```sh
250+
export NEO4J_URI=bolt://localhost:7687
251+
export NEO4J_PASSWORD=secret
252+
cants --input ./my-ts-project --emit neo4j # credentials picked up from the environment
253+
```
254+
240255
### Schema contract
241256

242257
`--emit schema` writes the machine-readable, version-stamped Neo4j schema (`schema.json`: node

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeanalyzer-typescript",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "CLDK TypeScript analyzer — emits the canonical CLDK analysis.json (symbol table + resolver-based call graph) via ts-morph.",
55
"type": "module",
66
"module": "src/index.ts",

src/cli.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from "node:path";
2-
import { Command } from "commander";
2+
import { Command, Option } from "commander";
33
import type { AnalysisOptions, CallGraphProviderName, EmitTarget } from "./options";
44

55
/**
@@ -16,10 +16,25 @@ export function buildProgram(): Command {
1616
.option("-o, --output <dir>", "output directory (omit ⇒ compact output to stdout)")
1717
.option("--emit <target>", "output target: json (analysis.json, default) | neo4j (graph.cypher or live push) | schema (the Neo4j schema.json contract)", "json")
1818
.option("--app-name <name>", "logical application name for the graph :Application anchor (default: input dir name)")
19-
.option("--neo4j-uri <uri>", "push the graph to a live Neo4j over Bolt (incremental); omit to write graph.cypher")
20-
.option("--neo4j-user <user>", "Neo4j username", "neo4j")
21-
.option("--neo4j-password <password>", "Neo4j password", "neo4j")
22-
.option("--neo4j-database <db>", "Neo4j database name (default: server default)")
19+
// The four Neo4j connection options also read the standard NEO4J_* environment variables when
20+
// the flag is omitted (an explicit flag wins). Prefer NEO4J_PASSWORD over the flag — a flag
21+
// value is visible in shell history / the process list. Commander renders the `(env: …)` hint.
22+
.addOption(
23+
new Option(
24+
"--neo4j-uri <uri>",
25+
"push the graph to a live Neo4j over Bolt (incremental); omit to write graph.cypher",
26+
).env("NEO4J_URI"),
27+
)
28+
.addOption(new Option("--neo4j-user <user>", "Neo4j username").env("NEO4J_USERNAME").default("neo4j"))
29+
.addOption(
30+
new Option(
31+
"--neo4j-password <password>",
32+
"Neo4j password (prefer the env var; a flag is visible in shell history / process list)",
33+
)
34+
.env("NEO4J_PASSWORD")
35+
.default("neo4j"),
36+
)
37+
.addOption(new Option("--neo4j-database <db>", "Neo4j database name").env("NEO4J_DATABASE"))
2338
.option("-a, --analysis-level <n>", "analysis depth: 1 = symbol table + tsc resolver call graph + RTA (default); 2 = call graph", "1")
2439
.option("-t, --target-files <paths...>", "restrict analysis to specific files (incremental)")
2540
.option("--skip-tests", "skip test trees (default)")

0 commit comments

Comments
 (0)