secureagentbase 1.5.0 → 1.5.1
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/dist/lib/startup-script.sh +66 -9
- package/package.json +1 -1
|
@@ -114,14 +114,59 @@ grep -q '^/swapfile' /proc/swaps 2>/dev/null && echo "Swap enabled: $(grep '^/sw
|
|
|
114
114
|
# repos ship git <= 2.30, which lacks `git add --sparse` — the opencode/kimaki
|
|
115
115
|
# agent snapshot flow fails every session with exit 129: "unknown option 'sparse'".
|
|
116
116
|
# Hardened keyring + sources.list.d pattern, same as the GitHub CLI install below.
|
|
117
|
-
# If the PPA
|
|
117
|
+
# If the PPA key fails verification the repo is never added and default git stays.
|
|
118
|
+
#
|
|
119
|
+
# Pinned key fingerprints. A keyring fetched over HTTPS is unauthenticated at
|
|
120
|
+
# fetch time: whoever controls the endpoint (or the TLS chain to it) could serve
|
|
121
|
+
# a different signing key, and apt would then trust packages signed by it. So
|
|
122
|
+
# every key installed here must match this list, and the whole repository is
|
|
123
|
+
# skipped when it does not — a missing PPA is a harmless downgrade to the
|
|
124
|
+
# distro git, a substituted signing key is root code execution on the VM.
|
|
125
|
+
GITCORE_PPA_FPRS="E1DD270288B4E6030699E45FA1715D88E1DF1F24"
|
|
126
|
+
GITHUB_CLI_FPRS="2C6106201985B60E6C7AC87323F3D4EA75716059 7F38BBB59D064DBCB3D84D725612B36462313325"
|
|
127
|
+
|
|
128
|
+
# Print the fingerprints of the primary keys inside a key or keyring file.
|
|
129
|
+
key_primary_fprs() {
|
|
130
|
+
gpg --show-keys --with-colons "$1" 2>/dev/null | awk -F: '
|
|
131
|
+
/^pub:/ { want = 1; next }
|
|
132
|
+
/^fpr:/ && want { print $10; want = 0 }
|
|
133
|
+
'
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# Succeed only if the file holds at least one primary key and *every* primary
|
|
137
|
+
# key fingerprint is in the allowlist. Extra keys are rejected rather than
|
|
138
|
+
# ignored: appending a valid-looking key to a genuine keyring would otherwise
|
|
139
|
+
# pass, and apt trusts every key in the signed-by keyring.
|
|
140
|
+
key_fprs_allowlisted() {
|
|
141
|
+
local file="$1"; shift
|
|
142
|
+
local allowed=" $* " f count=0
|
|
143
|
+
while IFS= read -r f; do
|
|
144
|
+
[ -n "$f" ] || continue
|
|
145
|
+
count=$((count + 1))
|
|
146
|
+
case "$allowed" in
|
|
147
|
+
*" $f "*) ;;
|
|
148
|
+
*) return 1 ;;
|
|
149
|
+
esac
|
|
150
|
+
done <<< "$(key_primary_fprs "$file")"
|
|
151
|
+
[ "$count" -gt 0 ]
|
|
152
|
+
}
|
|
153
|
+
|
|
118
154
|
sudo mkdir -p /usr/share/keyrings
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
sudo
|
|
123
|
-
|
|
124
|
-
|
|
155
|
+
GIT_PPA_KEY_TMP=$(mktemp)
|
|
156
|
+
if curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x${GITCORE_PPA_FPRS}" -o "$GIT_PPA_KEY_TMP" 2>/dev/null \
|
|
157
|
+
&& key_fprs_allowlisted "$GIT_PPA_KEY_TMP" $GITCORE_PPA_FPRS; then
|
|
158
|
+
sudo gpg --dearmor -o /usr/share/keyrings/git-core-ppa.gpg < "$GIT_PPA_KEY_TMP" > /dev/null 2>&1 && GIT_PPA_KEY_OK=true
|
|
159
|
+
else
|
|
160
|
+
echo "WARNING: git-core PPA key failed fingerprint verification; skipping PPA"
|
|
161
|
+
fi
|
|
162
|
+
rm -f "$GIT_PPA_KEY_TMP"
|
|
163
|
+
if [ "$GIT_PPA_KEY_OK" = "true" ]; then
|
|
164
|
+
UBUNTU_CODENAME=$(. /etc/os-release && echo "${VERSION_CODENAME:-focal}")
|
|
165
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/git-core-ppa.gpg] https://ppa.launchpadcontent.net/git-core/ppa/ubuntu ${UBUNTU_CODENAME} main" | sudo tee /etc/apt/sources.list.d/git-core-ppa.list > /dev/null 2>&1 || true
|
|
166
|
+
sudo apt-get update -y > /dev/null 2>&1 || true
|
|
167
|
+
# Re-install so apt picks the higher PPA version (upgrades the git from above).
|
|
168
|
+
sudo apt-get install -y git > /dev/null 2>&1 || true
|
|
169
|
+
fi
|
|
125
170
|
|
|
126
171
|
# Fetch secrets from Secret Manager via the metadata-server identity (map #36).
|
|
127
172
|
# No secret values ride in VM metadata; the VM's attached service account holds
|
|
@@ -176,8 +221,20 @@ else
|
|
|
176
221
|
apt-get install -y nodejs > /dev/null 2>&1 || true
|
|
177
222
|
fi
|
|
178
223
|
|
|
179
|
-
# Install GitHub CLI
|
|
180
|
-
type gh >/dev/null 2>&1 ||
|
|
224
|
+
# Install GitHub CLI — keyring fingerprint-checked against GITHUB_CLI_FPRS above
|
|
225
|
+
type gh >/dev/null 2>&1 || {
|
|
226
|
+
GH_KEY_TMP=$(mktemp)
|
|
227
|
+
if curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg -o "$GH_KEY_TMP" 2>/dev/null \
|
|
228
|
+
&& key_fprs_allowlisted "$GH_KEY_TMP" $GITHUB_CLI_FPRS; then
|
|
229
|
+
sudo install -m 0644 "$GH_KEY_TMP" /usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
230
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null 2>&1 || true
|
|
231
|
+
sudo apt-get update -y > /dev/null 2>&1 || true
|
|
232
|
+
sudo apt-get install -y gh > /dev/null 2>&1 || true
|
|
233
|
+
else
|
|
234
|
+
echo "WARNING: GitHub CLI keyring failed fingerprint verification; skipping apt repo"
|
|
235
|
+
fi
|
|
236
|
+
rm -f "$GH_KEY_TMP"
|
|
237
|
+
}
|
|
181
238
|
|
|
182
239
|
# Install Kimaki (skip if already installed — re-running npm -g installs crashes with ENOTEMPTY)
|
|
183
240
|
# Pinned, not @latest: a floating tag meant two VMs provisioned days apart could run
|