-
Notifications
You must be signed in to change notification settings - Fork 83
feat(presto-clp): Update docs and config generation to support reading archives from S3 and Presto split-filtering config. #1228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
af8ce88
e0a1820
4deb2ba
728efe2
2ba53ca
aa3e18d
67e16ce
ba16edf
78139be
8d6744d
2afac89
d4bf46a
5e13836
d7478f8
14b3a80
c09641b
d59af37
80959fc
ada03bb
9d92fc9
968c29c
cdaf3f5
40c352c
e5e1ed6
b9a898f
e012fb0
354a1aa
d1aa25b
29c4232
c4bcb8b
5cb13b9
570c18a
9842ef6
f769282
a388247
72ae05b
ccaf9a3
34617b9
b3694b7
6bcacfb
0a670b0
33592c9
bc86d60
3402f9c
2ac911a
06b5771
bc90d7f
2b3c624
8ac0b03
2306ba1
f4d08b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -48,13 +48,19 @@ update_config_file() { | |||||||||||||||||||||||||||||
| local file_path=$1 | ||||||||||||||||||||||||||||||
| local key=$2 | ||||||||||||||||||||||||||||||
| local value=$3 | ||||||||||||||||||||||||||||||
| local sensitive=${4:-false} | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
| local sensitive=${4:-false} | |
| # Sets/updates the given kv-pair in the given properties file. | |
| # | |
| # @param $1 Path to the properties file. | |
| # @param $2 The key to set. | |
| # @param $3 The value to set. | |
| # @param $4 (optional) "true" to mask the value when logging | |
| update_config_file() { | |
| local file_path=$1 | |
| local key=$2 | |
| local value=$3 | |
| local sensitive=${4:-false} | |
| … | |
| } |
🤖 Prompt for AI Agents
In tools/deployment/presto-clp/worker/scripts/generate-configs.sh around line
51, the function update_config_file now accepts a fourth parameter "sensitive"
but the header comment only documents three parameters; update that header to
include the new "sensitive" parameter (name: sensitive, purpose: whether the
value is sensitive and should be handled/hidden, type: boolean/string, default:
false) and describe its default behavior so future callers know how to pass and
interpret it. Ensure the param description matches existing comment style and
mentions the default value and any special handling (e.g., masking or skipping
echoing) used by the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Make key/value matching and replacement regex-safe; avoid failures on missing files.
Keys like node.internal-address contain dots that are regex metacharacters. Using grep/sed with unescaped keys can produce false positives. Also, grep on a non-existent file will fail under set -e. Guard the file and use fixed-string grep; escape replacement metacharacters in the value.
- if grep --quiet "^${key}=.*$" "$file_path"; then
- sed --in-place "s|^${key}=.*|${key}=${value}|" "$file_path"
- else
- echo "${key}=${value}" >>"$file_path"
- fi
+ # Ensure the file exists to avoid grep/sed failures under `set -e`
+ [[ -f "$file_path" ]] || : >"$file_path"
+ # Match keys literally to avoid regex surprises with dots, etc.
+ if grep -F --quiet "^${key}=" "$file_path"; then
+ # Escape replacement metacharacters in value for sed
+ local escaped_value=${value//\\/\\\\}
+ escaped_value=${escaped_value//|/\\|}
+ escaped_value=${escaped_value//&/\\&}
+ local escaped_key
+ escaped_key=$(printf '%s' "$key" | sed -e 's/[.[\*^$+?{}|()]/\\&/g')
+ sed --in-place "s|^${escaped_key}=.*|${key}=${escaped_value}|" "$file_path"
+ else
+ echo "${key}=${value}" >>"$file_path"
+ fiCommittable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In tools/deployment/presto-clp/worker/scripts/generate-configs.sh around lines
53-57, the current grep/sed logic treats the key as a regex and will fail when
keys contain regex metacharacters and when the target file is missing; also the
replacement value can break sed if it contains &, \ or /. Fix by first ensuring
the file exists (touch the file_path if missing), use grep --quiet
--fixed-strings (or grep -qF) to check for the literal key, and when calling sed
escape the key so it is matched literally (escape regex metacharacters such as
.[]*^$) or build the sed command from a safely escaped key; additionally
escape/quote the replacement value for sed (escape &, \ and the chosen
delimiter) before passing it to sed --in-place so the substitution is robust.
Uh oh!
There was an error while loading. Please reload this page.