Commit cf359a5
committed
fix: address PR #58 review feedback (execFileSync + 404 disambiguation)
P2 — execSync command-injection surface (CodeRabbit, cubic):
Replaced execSync with a template string by execFileSync('gh',
['api', endpoint], opts). The endpoint argument now bypasses shell
parsing entirely. While the input is regex-validated upstream, the
defense-in-depth change costs nothing and removes a class of risk
from the audit-tool surface.
P2 — 404 disambiguation (cubic):
The previous code treated every 404 from `gh api` as a tolerable
"upstream unreachable" warning. That silently masks the much more
common failure mode of a malformed `lastSyncedSha` in
upstream/.upstream-sync.json — the compare endpoint also returns
404 when the baseline ref doesn't exist in a repo that does.
Split into two checks:
1. Pre-flight `gh api repos/<upstream>` — 404 here is genuine
rename/archive/deletion. Warn, exit 0, weekly cron stays green.
2. After pre-flight succeeds, compare-endpoint 404 is a hard
error. Print a specific "Check upstream/.upstream-sync.json"
message and exit 1.
ghApi() now surfaces 404 as a typed error (`err.is404 === true`)
so callers can act on it. Added isUpstreamReachable() as the
pre-flight helper.
P2 — node: prefix suggestion (CodeRabbit):
Not applying — repo convention is 23 plain `require('fs')` vs. 1
`require('node:fs')` (see scripts/hooks/run.js). Switching only
the new files would create inconsistency; a repo-wide refactor is
out of scope for this PR. Will reply on the thread.
Local smoke run:
- Happy path: ECC 1518 commits ahead, clean output, exit 0.
- Bad-baseline path: forced lastSyncedSha to 'deadbeef...' x 5,
pre-flight passes, compare returns 404, script prints
"Baseline SHA ... is not reachable" and exits 1.
Lint clean. 242/242 tests pass.1 parent 1b637a5 commit cf359a5
1 file changed
Lines changed: 72 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
| 23 | + | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| |||
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | | - | |
48 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | | - | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
55 | 63 | | |
56 | | - | |
| 64 | + | |
57 | 65 | | |
58 | 66 | | |
59 | 67 | | |
| |||
63 | 71 | | |
64 | 72 | | |
65 | 73 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
71 | 79 | | |
72 | 80 | | |
73 | 81 | | |
| |||
76 | 84 | | |
77 | 85 | | |
78 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
79 | 110 | | |
80 | 111 | | |
81 | 112 | | |
| |||
117 | 148 | | |
118 | 149 | | |
119 | 150 | | |
120 | | - | |
121 | | - | |
122 | 151 | | |
123 | | - | |
124 | | - | |
125 | | - | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
126 | 156 | | |
127 | 157 | | |
128 | 158 | | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
129 | 180 | | |
130 | 181 | | |
131 | 182 | | |
132 | 183 | | |
133 | 184 | | |
134 | 185 | | |
135 | 186 | | |
136 | | - | |
| 187 | + | |
0 commit comments