934062214af8
refuse plain http for a Kepr host that is not this machine, since the connect reply carries the bucket's secret key (3.0.104)
- time
- 2026-09-28 04:52 UTC · 2 weeks ago
- machine
- Junes-MacBook-Pro.local
- agent
- claude-opus-5-5
- session
- fix a2 review findings
- parent
- aece2a878d50
↓ koh-93406221.tar.gzatlas at this save
files changed4 files
VERSION+1 −1src/remote/web.v+5 −0tests/cli_test.v+9 −0v.mod+1 −1src/remote/web.v+5 −0
@@ -31,6 +31,11 @@3131 if text.all_after('//').contains('@') {3232 return error('"${value}" is not a Kepr address — try kepr.uk')3333 }34+ // `/api/connect` answers with the bucket's secret key, so plain http is only for a Kepr on35+ // this machine: a test, or a local run.36+ if parsed.scheme == 'http' && parsed.hostname().to_lower() !in ['127.0.0.1', 'localhost', '::1'] {37+ return error('"${value}" needs https — plain http is only for a Kepr on this machine')38+ }3439 // A hostname is case-insensitive, so the stored form is the lower-case one.3540 return '${parsed.scheme}://${parsed.host.to_lower()}'3641 }tests/cli_test.v+9 −0
@@ -1528,6 +1528,15 @@15281528 assert refused.code == 1, host15291529 assert refused.err.contains('is not a Kepr address'), '${host}: ${refused.err}'15301530 }1531+ // The reply carries the bucket's secret key, so plain http is only for this machine's own Kepr.1532+ for host in ['http://kepr.uk', 'http://10.0.0.2:3000', 'http://KEPR.uk:80'] {1533+ refused := run_home(repo, home, 'remote', host, '--code', 'good')1534+ assert refused.code == 1, host1535+ assert refused.err.contains('needs https'), '${host}: ${refused.err}'1536+ stolen := run_home(home, home, 'steal', '${host}/nina')1537+ assert stolen.code == 1, host1538+ assert stolen.err.contains('needs https'), '${host}: ${stolen.err}'1539+ }15311540 // --code belongs to the host form alone.15321541 assert run_home(repo, home, 'remote', 's3', 'https://x', 'b', 'r', '--code', 'good').code == 215331542 assert run_home(repo, home, 'remote', 'folder', '/tmp', '--code', 'good').code == 2v.mod+1 −1
@@ -1,6 +1,6 @@11 Module {22 name: 'koh3'3- version: '3.0.103'3+ version: '3.0.104'44 description: 'One SQLite file per repo, one line of history.'55 license: 'MIT'66 }