Give b2keys least-privilege defaults, require opt-in for key-management capabilities, and add tests
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with bin/b2keys/b2keys.go and the listed reference points in examples/simple/simple.go, base/base.go, and internal/b2types/b2types.go; check how the other Backblaze tools handle capability restrictions. Add tests in bin/b2keys using a fake creater, then run go test ./... there. Done means unsafe defaults and inputs are rejected or require opt-in before authorization, output and credential behavior match the stated requirements, and the acceptance criteria pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
bin/b2keys is the repository's only shipped tool. By default it creates a key with no expiration that covers every bucket, and it accepts any capability list, including writeKeys, deleteKeys and the governance-override capability, without a prompt or warning. Other Backblaze tools refuse key-management grants and unscoped write keys unless an explicit override is set. The new secret is printed on stdout in a key=..., secret=... line, which tends to end up in shell history and CI logs. Its legacy environment fallbacks differ from the other program in the repository, a prefix without a bucket fails only after authorizing, and the module has no tests although CI runs go test on it.
Current behavior
At a5e0d13, in bin/b2keys/b2keys.go:
- :42-44:
-durationdefaults to 0 and-bucketto empty. - :70-77: a zero duration adds no
Lifetime; capabilities pass through unchecked. - :85-94: without
-bucket, the key is created account-wide. - :101:
fmt.Printf("key=%s, secret=%s\n", ...). - :18-19: legacy fallbacks
B2_ACCOUNT_ID/B2_SECRET_KEY; examples/simple/simple.go:43-48 usesB2_ACCOUNT_ID/B2_ACCOUNT_KEY. - :58: the missing-credentials message has no trailing newline.
- :71-72: any positive
-durationis passed toLifetime. The library converts the lifetime to whole seconds (base/base.go:2053, :2069), andvalidDurationInSecondsis omitted when it is 0 (internal/b2types/b2types.go:446, :456), so-duration 500mscreates a key with no expiration. - :74-75:
-prefixis accepted without-bucket.
.github/workflows/ci.yml:94-97 and the Makefile b2keys target (Makefile:36-37) build and run go test ./... in bin/b2keys, which has no test files. README.md:69-70 advises giving a key "only the capabilities and buckets your program uses"; the tool's defaults do the opposite.
Expected behavior
The tool creates bucket-scoped, expiring keys by default, asks for explicit flags for broader grants, and validates input before calling B2.
Proposed change
- Require
-bucket(or an explicit-all-buckets) and default-durationto a finite value such as 24h, with-no-expiryto opt out. - Refuse
writeKeys,deleteKeys,listKeysand governance override unless-allow-key-management(or a matching flag) is passed. - Validate capabilities against the documented list, reject
-prefixwithout-bucket, and reject-durationunder one second, all before authorizing. - Print only the secret on stdout (no label) or write it to a 0600 file via
-out; print the key ID and a "shown once" note on stderr. - Align the legacy variable names with the rest of the repository, or drop them with a CHANGELOG note.
- Add tests with a fake
createrfor defaults, refusals and output.
Acceptance criteria
b2keys create name writeFileswithout-bucketexits non-zero with a usage error.b2keys create -bucket b name writeKeysexits non-zero unless-allow-key-managementis passed.- A key created without
-durationcarries the default lifetime. go test ./...inbin/b2keysruns these tests in CI.
Related
None
- Lingua principale
- Go
- Stelle
- 66
- Fork
- 18
- Merge medio
- 1g 10h
- PR unite (30g)
- 132
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Backblaze/blazer
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Bucket.Attrs never returns ReplicationConfig: replication configuration is write-onlyForse di nuovo libera Una pull request per questa issue è stata chiusa senza essere unita. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
test: skip the fuzz non-vacuity guard when replaying a single seedForse già presa @ffumero2003 l’ha presa 5 giorni fa. Apertatesting
Backblaze/blazer#330 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Backblaze/blazer
Issue simili
-
needs-triage typo
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
llm-d-incubation/llm-d-scaling-manager#122 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue severity: low tech-debt
Difficoltà 2/5 Mezza giornata Idoneità per principianti 75/100
TMHSDigital/subenum#329 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Backend summarize min() / max() panics when a field has no numeric valuesForse già presa @weng5e l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
grafana/grafana-infinity-datasource#1832 ·
I maintainer di solito rispondono entro 1 giorno
-
tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
GillMacedo/godebugdiff#13 ·