Skip to content

Name the key-file side effect - #9

Merged
dubinsky merged 1 commit into
masterfrom
cursor/name-key-file-side-effect-5d2e
Nov 12, 2026
Merged

dubinsky merged 1 commit into
masterfrom
cursor/name-key-file-side-effect-5d2e

Conversation

@dubinsky

Copy link
Copy Markdown
Owner

writeCredentials is the only place the library touches the machine. The guest skip is one predicate, ServiceAccountKey.isCloudInfrastructureGuest, whose body is hostname.trim == "cloud-infrastructure". The companion is private[besom] and has no Besom types, so a test can call it while Besom stays compileOnly.

writeCredentials reads /etc/hostname and passes that text to the predicate. The read stays inside privateKey.map: key.flatMap(_.privateKey).map(writeCredentials). The map depth is unchanged. A missing /etc/hostname throws from Files.readString. The predicate does not catch that and treat a missing file as another host.

The rest of the write is unchanged: Base64.getMimeDecoder, the client_email / private_key check, the trailing newline on the JSON, the .tmp sibling, POSIX rw-------, and Files.move with REPLACE_EXISTING and ATOMIC_MOVE. "9.0.0" and "6.20.0" stay inline. resources is keyAdminMembers :+ key.

Comments on the map and on writeCredentials: the export grokBotKeyFile forces this map, and the guest skip is this hostname comparison and nothing else.

ServiceAccountKeyTest locks a trailing newline (cloud-infrastructure\n), a trailing space plus newline (so trim is inside the predicate), the exact host, and non-matching hosts (localhost, localhost\n, not-cloud-infrastructure).

Sample, README, CI, and Bucket are untouched.

Verify

./gradlew build passes on JDK 25 (Scala 3.10.0). ServiceAccountKeyTest is 1 test, LogicalNamesTest is 20 tests, 0 failures.

pulumi preview was not run. This environment has no Pulumi or GCP credentials, and a preview of an existing stack can write the grok-bot JSON key.

Open in Web Open in Cursor 

ServiceAccountKey.isCloudInfrastructureGuest is hostname.trim == "cloud-infrastructure".
writeCredentials reads /etc/hostname inside privateKey.map and passes that text through.
A missing hostname file throws. The MIME decode, field check, trailing newline,
.tmp sibling, rw-------, and ATOMIC_MOVE/REPLACE_EXISTING move stay.

Co-authored-by: Leonid Dubinsky <dub@podval.org>
@dubinsky
dubinsky merged commit e1a49dd into master Nov 12, 2026
2 checks passed
@dubinsky
dubinsky deleted the cursor/name-key-file-side-effect-5d2e branch November 18, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant