Commit 8de8cbd
committed
fix: address Copilot review 3 on PR #7
Four follow-ups from the third pass:
1. Missing-value validation for flags that take an argument.
`jspod --host` (or --port, --root) used to read undefined off the
args array and crash with a cryptic TypeError on the next
operation. Now exits cleanly with "Missing value for --host" and a
pointer to --help.
2. IPv6 zone identifiers (e.g. fe80::1%lo0) are now rejected at CLI
parse time with a clear error. The previous %25-encoding attempt
was correct per RFC 6874 but Node's WHATWG URL parser doesn't
accept zone IDs regardless — any URL we built (banner, auto-open,
readiness probe) would be unparseable. Failing fast beats shipping
silently broken auto-open.
3. TOKEN_SECRET now auto-generates a 48-byte random secret on first
run and persists it at <root>/.token-secret with mode 0600.
Subsequent restarts read the same secret so sessions and refresh
tokens survive process bounces. Per-data-dir, so different pods on
the same machine get different secrets. The previous static
fallback ('jspod-default-secret-change-in-production') was
remotely exploitable on any non-loopback bind — anyone who knew
the string could forge JWTs. Env TOKEN_SECRET still wins when
set, for operator-managed deployments.
4. README: replaced the literal fallback secret string with accurate
docs about auto-generation, persistence path, file mode, and the
env override use-case (operator-managed deployments / rotation /
secret managers).
Refs #1 #3 #61 parent f6458f2 commit 8de8cbd
2 files changed
Lines changed: 61 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| |||
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
108 | | - | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
| |||
201 | 202 | | |
202 | 203 | | |
203 | 204 | | |
204 | | - | |
205 | | - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
206 | 208 | | |
207 | 209 | | |
208 | 210 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
20 | 25 | | |
21 | 26 | | |
22 | 27 | | |
| |||
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
53 | 71 | | |
54 | 72 | | |
55 | 73 | | |
56 | 74 | | |
57 | | - | |
| 75 | + | |
58 | 76 | | |
59 | 77 | | |
60 | 78 | | |
61 | 79 | | |
62 | 80 | | |
63 | | - | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
64 | 92 | | |
65 | | - | |
| 93 | + | |
66 | 94 | | |
67 | 95 | | |
68 | 96 | | |
| |||
115 | 143 | | |
116 | 144 | | |
117 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
118 | 167 | | |
119 | 168 | | |
120 | 169 | | |
| |||
231 | 280 | | |
232 | 281 | | |
233 | 282 | | |
234 | | - | |
| 283 | + | |
235 | 284 | | |
236 | 285 | | |
237 | 286 | | |
| |||
0 commit comments