mirror of
https://github.com/anthropics/claude-plugins-official.git
synced 2026-03-21 11:53:08 +00:00
Lock telegram/discord .env files to owner (chmod 600)
The bot token is a credential. Tighten perms on load so hand-written or pre-existing .env files get locked down, and update the configure skill to chmod after writing. No-op on Windows.
This commit is contained in:
@@ -25,7 +25,7 @@ import {
|
||||
type Attachment,
|
||||
} from 'discord.js'
|
||||
import { randomBytes } from 'crypto'
|
||||
import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, renameSync, realpathSync } from 'fs'
|
||||
import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, renameSync, realpathSync, chmodSync } from 'fs'
|
||||
import { homedir } from 'os'
|
||||
import { join, sep } from 'path'
|
||||
|
||||
@@ -37,6 +37,8 @@ const ENV_FILE = join(STATE_DIR, '.env')
|
||||
// Load ~/.claude/channels/discord/.env into process.env. Real env wins.
|
||||
// Plugin-spawned servers don't get an env block — this is where the token lives.
|
||||
try {
|
||||
// Token is a credential — lock to owner. No-op on Windows (would need ACLs).
|
||||
chmodSync(ENV_FILE, 0o600)
|
||||
for (const line of readFileSync(ENV_FILE, 'utf8').split('\n')) {
|
||||
const m = line.match(/^(\w+)=(.*)$/)
|
||||
if (m && process.env[m[1]] === undefined) process.env[m[1]] = m[2]
|
||||
|
||||
@@ -80,7 +80,8 @@ as the correct long-term choice. Don't skip the lockdown offer.
|
||||
2. `mkdir -p ~/.claude/channels/discord`
|
||||
3. Read existing `.env` if present; update/add the `DISCORD_BOT_TOKEN=` line,
|
||||
preserve other keys. Write back, no quotes around the value.
|
||||
4. Confirm, then show the no-args status so the user sees where they stand.
|
||||
4. `chmod 600 ~/.claude/channels/discord/.env` — the token is a credential.
|
||||
5. Confirm, then show the no-args status so the user sees where they stand.
|
||||
|
||||
### `clear` — remove the token
|
||||
|
||||
|
||||
Reference in New Issue
Block a user