Przejdź do treści
Biblioteka skilli
DevOps i chmura · Analiza

bash-herestring-newline-secrets

/bash-herestring-newline-secrets

Naprawia błędy uwierzytelniania wynikające z końcowego znaku nowej linii w sekretach tworzonych w Google Cloud przez here-string Bash (<<<), który psuje hasło lub token.

Repozytorium
divine-mobile ↗
Licencja
AGPL-3.0
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
1
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
1
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

AGPL-3.0, copyleft: przeróbki udostępniane innym muszą mieć tę samą licencję.

Co robi i kiedy

Naprawia błędy uwierzytelniania wynikające z końcowego znaku nowej linii w sekretach tworzonych w Google Cloud przez here-string Bash (<<<), który psuje hasło lub token.

Wyzwalacze z opisu

valuepassword authentication failedinvalid token
Oryginalny opis (EN)

Fix password/secret authentication failures caused by trailing newlines when creating Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password authentication fails with correct password, (2) Secret created with `<<< "value"` syntax, (3) Error like "password authentication failed" or "invalid token" despite correct value. Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.

Jak działa

  1. Problem
  2. Context / Trigger Conditions
  3. Solution
  4. Verification
  5. Example
  6. Notes
  7. References
Sekcje z nagłówków SKILL.md, w oryginale · 84 linii, 378 słów
Podgląd SKILL.md
---
name: bash-herestring-newline-secrets
description: |
  Fix password/secret authentication failures caused by trailing newlines when creating
  Google Cloud secrets (or similar) with bash here-strings. Use when: (1) Password
  authentication fails with correct password, (2) Secret created with `<<< "value"` syntax,
  (3) Error like "password authentication failed" or "invalid token" despite correct value.
  Bash here-strings (`<<<`) add a trailing newline that corrupts secrets.
author: Claude Code
version: 1.0.0
date: 2026-01-31
---

# Bash Here-String Newline in Secrets

## Problem
When creating secrets using bash here-strings (`<<<`), a trailing newline is silently
appended to the value. This causes authentication failures with misleading error messages
that suggest the password/token is wrong when it's actually correct—just with an extra
newline character.

## Context / Trigger Conditions
- Secret created with: `gcloud secrets create NAME --data-file=- <<< "value"`
- Or similar: `echo "value" | gcloud secrets create...` (echo adds newline by default)
- Error messages like:
  - "password authentication failed for user X"
  - "invalid token"
  - "authentication failed"
- The secret value appears correct when viewed
- Works locally but fails when secret is used

## Solution

**Wrong (adds newline):**
```bash
gcloud secrets create my-secret --data-file=- <<< "mypassword"
echo "mypassword" | gcloud secrets create my-secret --data-file=-
```

**Correct (no newline):**
```bash
echo -n "mypassword" | gcloud secrets create my-secret --data-file=-
printf '%s' "mypassword" | gcloud secrets create my-secret --data-file=-
```

**To fix an existing secret:**
```bash
echo -n "correct-value" | gcloud secrets versions add my-secret --data-file=-
```

## Verification

Check the secret length to detect trailing newline:
```bash
# Get secret and count bytes
gcloud secrets versions access latest --secret=my-secret | wc -c
# Compare to expected length (password length, not password length + 1)
```

Or use `xxd` to see the actual bytes:
```bash
gcloud secrets versions access latest --secret=my-secret | xxd | tail -1
# Look for '0a' (newline) at the end
```

## Example

**Symptom:**
```
Database connection test failed: password authentication failed for user "crawler"
```

**Investigation:**
```bash
$ gcloud secrets versions access latest --secret=my-db-password
mypassword
$ gcloud secrets versions access latest --secret=my-db-password | wc -c
11  # But password is only 10 characters!
```

**Fix:**
```bash
$ echo -n "mypassword" | gcloud secrets versions add my-db-password --data-file=-
Created version [2] of the secret [my-db-password].
```

## Notes
- This affects any system that uses secrets: databases, APIs, tokens, etc.
- The `<<<` here-string is a bash feature that ALWAYS adds a newline
- `echo` also adds a newline by default; use `echo -n` or `printf '%s'`
- Some systems trim whitespace from secrets, but many (like PostgreSQL) don't
- When debugging auth failures, always check for trailing whitespace first

## References
- Bash manual on here-strings: https://www.gnu.org/software/bash/manual/bash.html#Here-Strings

Wersje

W bazie nie ma innych skilli o nazwie bash-herestring-newline-secrets.

Identyczna treść występuje jeszcze w 1 innych folderach na GitHubie. Tu pokazujemy jedną, najlepiej ocenioną kopię.

Migawka bazy z 13.11.2026 · wersja paczki 015de4dec381 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 0 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 90secrets-doctor
    Diagnozuje błędy uwierzytelniania i brakujące klucze API w projekcie, sprawdzając konfigurację sekretów oraz zmiennych środowiskowych.
  • 100secrets
    Tworzy, wyświetla, rotuje i usuwa sekrety Goldsky, czyli zapisane dane logowania używane przez ujścia potoków danych.
  • 100fix-trailing-newlines
    Naprawia naruszenia StyleCop SA1518 przez usuwanie końcowych znaków nowej linii w plikach .cs, .xaml, .csproj, .editorconfig i innych w projektach z insert_final_newline = false.
  • 100hyprland-secret-prompt
    Zbiera klucz API lub hasło przez maskowane okno Hyprland i zapisuje je w prywatnym pliku eksportu, bez pokazywania w czacie.
  • 100cloud-run-job-cloudsql-setup
    Konfiguruje zadania Cloud Run Jobs z połączeniem do Cloud SQL: ścieżka gniazda, uprawnienia IAM oraz typowe błędy, takie jak brak Cloud SQL Proxy czy odrzucone hasło mimo poprawnych danych.
  • 100gcp-secret-manager
    Zabezpiecza sekrety w Google Cloud Secret Manager: polityki IAM, integracja z GKE i zarządzanie wersjami sekretów.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.