Skip to content

feat(dgraph): harden backup login and expose backup ports on the headless Service - #145

Open
mlwelles wants to merge 1 commit into
mainfrom
feat-backup-login-hardening
Open

feat(dgraph): harden backup login and expose backup ports on the headless Service#145
mlwelles wants to merge 1 commit into
mainfrom
feat-backup-login-hardening

Conversation

@mlwelles

Copy link
Copy Markdown

Harden the backup CronJob login: parse responses with jq and build the login bodies with jq -n --arg (injection-safe) instead of grep -oP and hand-built JSON; guard each curl with an errexit-safe status check; quote the get_token arguments. Also declare http (8080) and grpc (9080) on the alpha headless Service when backups are enabled, so a pinned-pod /admin login works under a strict mTLS mesh. No change to a stock (backups-off) render.

Part of splitting #140 into per-area PRs. The change was built and validated on that branch; the merge of all split PRs reproduces #140's tree byte-for-byte. #140 is being closed as superseded.

…less Service

Declare http (8080) and grpc (9080) on the alpha headless Service. The
backup CronJobs reach a pinned alpha-0 through this Service; under a
STRICT mTLS mesh the client sidecar only builds an mTLS route for ports
the Service declares, so without them the /admin login falls through to
plaintext and the sidecar resets it. Gate both ports on
backups.full.enabled or backups.incremental.enabled, since their only
consumer is the backup CronJobs.

Guard each backup.sh curl with require_json: capture the curl exit
status errexit-safely and validate the body is JSON before parsing. A
mesh or network failure returns a plaintext body (e.g. an Envoy connect
error) that now surfaces as a clear curl-status / URL / body message
instead of a cryptic parse failure or a silently empty token.

Convert the login bodies and response parsing to jq: get_token_rest and
get_token_graphql build their request bodies with 'jq -n --arg' instead
of hand-interpolating user/password into a JSON string, so credentials
containing quotes or other JSON-breaking characters can no longer
corrupt or inject into the request. All four functions parse responses
with 'jq -r ... // empty' instead of grep -oP/grep -q errors, removing
the dependency on grep's PCRE mode. backup_graphql's destination stays
hand-interpolated since it is operator-controlled, not user credentials.

Reset HEADERS and CERTOPTS at the top of get_token and backup so a
second call in the same shell does not accumulate headers left over
from an earlier call.

Quote the get_token arguments in the full and incremental CronJobs so
an admin user or password containing whitespace is passed as a single
argument.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant