feat(dgraph): harden backup login and expose backup ports on the headless Service - #145
Open
mlwelles wants to merge 1 commit into
Open
feat(dgraph): harden backup login and expose backup ports on the headless Service#145mlwelles wants to merge 1 commit into
mlwelles wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Harden the backup CronJob login: parse responses with
jqand build the login bodies withjq -n --arg(injection-safe) instead ofgrep -oPand hand-built JSON; guard each curl with an errexit-safe status check; quote theget_tokenarguments. Also declare http (8080) and grpc (9080) on the alpha headless Service when backups are enabled, so a pinned-pod/adminlogin 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.