Commit 9ed9496
committed
review(bklibcvenv): address Copilot's 5 inline comments on #348
All 5 points were legit:
1. **shift on empty args** (libexec/bklibcvenv:39) — with set -eo
pipefail, `CMD=$1; shift` exited before the usage-error branch
could fire when called with zero args. Now: check `$#` first.
2. **set -x unconditional** (line 73) — floods CI output. Gated
behind BKLIBCVENV_DEBUG env var.
3. **chmod 775** (line 94) — group-writable on packaged artefacts
is a bad-practice flag for security/packaging audits. Changed
to 755.
4. **POSIX `--` in command -v / cd** (template line 12, 15) — not
specified by POSIX for these built-ins; some old /bin/sh
implementations reject. Dropped `--`; in our context $0 is
never user-controlled so the defense was moot.
5. **sed-replacement metacharacter unsafety** (line 93) — values
containing `&`, `\`, or the `|` delimiter would corrupt sed
output. Defense in depth: added a `sed_escape()` helper and
applied to all four interpolated values before substitution.
Values in question (LDSO, LIBDIR_NAME, LIBC_NAME, dir) are all
auto-detected or recipe-passed and won't realistically contain
sed metachars, but Copilot's right that this should not be a
latent footgun.1 parent b4fab13 commit 9ed9496
2 files changed
Lines changed: 38 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
39 | 60 | | |
40 | 61 | | |
41 | 62 | | |
| |||
63 | 84 | | |
64 | 85 | | |
65 | 86 | | |
66 | | - | |
| 87 | + | |
67 | 88 | | |
68 | 89 | | |
69 | 90 | | |
70 | 91 | | |
71 | 92 | | |
72 | 93 | | |
73 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
74 | 98 | | |
75 | 99 | | |
76 | 100 | | |
| |||
85 | 109 | | |
86 | 110 | | |
87 | 111 | | |
| 112 | + | |
88 | 113 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
93 | 118 | | |
94 | | - | |
| 119 | + | |
95 | 120 | | |
96 | 121 | | |
97 | 122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | | - | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | | - | |
| 17 | + | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
0 commit comments