• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cameri / nostream / 45587279340
80%

Build:
DEFAULT BRANCH: main
Ran 25 Nov 2026 09:42AM UTC
Jobs 2
Files 351
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

25 Nov 2026 09:38AM UTC coverage: 80.25% (+0.3%) from 79.934%
45587279340

push

github

web-flow
fix(cli): keep the .env file private to its owner (#1236)

## Description
The CLI wrote `.env` with the default file mode. Under the usual umask
(022) that is 0644, readable by every local account that can traverse
the project directory, and `.env` holds `SECRET`, which signs the admin
session tokens, along with other credentials (database and Redis
passwords, payment processor keys). There were three places that created
or rewrote it, none with a mode:

- `nostream setup` created it from `.env.example` with `copyFileSync`
(which keeps the template's 0644), or as an empty file with
`writeFileSync`, and later wrote the generated or chosen `SECRET` into
it;
- `upsertEnvValue` (used by `nostream config env set`) rewrote it with
`writeFileSync` and no mode.

- new `writeEnvFile(path, content)` in `src/cli/utils/env-config.ts`
writes with `mode: 0o600`, so a new file is never readable by others,
not even briefly, then `chmod`s to 0600, which also restricts a file
that already existed (the `mode` option only applies on creation);
- `setup` now builds a new `.env` by reading `.env.example` and writing
it with `writeEnvFile` instead of copying it, so it is private from the
start, and writes the secret with `writeEnvFile`; `upsertEnvValue` uses
it too, so every caller of the writer gets the protection;
- if `chmod` fails (a file system without Unix permissions, a file the
user does not own) the write still succeeds, since failing a setup for
that would be worse than the permissions it could not set.

A deliberate limit: an existing `.env` that already holds a real secret
and that setup has nothing to write into is left as it is, including its
permissions. Only a write restricts it. Anyone who made it
group-readable on purpose (for example for a service account) is
affected the next time the CLI writes to it.

## Related Issue
Partly addresses #1021 (findings F-023, F-035 and F-043, which are the
same defect). That issue groups seven findings, so this PR does n... (continued)

6232 of 8397 branches covered (74.22%)

Branch coverage included in aggregate %.

12 of 12 new or added lines in 2 files covered. (100.0%)

8 existing lines in 1 file now uncovered.

12626 of 15102 relevant lines covered (83.6%)

640.29 hits per line

Coverage Regressions

Lines Coverage ∆ File
8
90.53
17.86% src/cli/utils/env-config.ts
Jobs
ID Job ID Ran Files Coverage
1 Unit - 45587279340.1 25 Nov 2026 09:44AM UTC 351
78.25
GitHub Action Run
2 Integration - 45587279340.2 25 Nov 2026 09:42AM UTC 351
36.19
GitHub Action Run
Source Files on build 45587279340
  • Tree
  • List 351
  • Changed 3
  • Source Changed 2
  • Coverage Changed 3
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #45587279340
  • 549a97d6 on github
  • Prev Build on main (#45572238906)
  • Next Build on main (#45890344180)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc