-
Notifications
You must be signed in to change notification settings - Fork 105
NO-JIRA: ensure empty lines are skipped while processing env files in check-params-env.sh
#1784
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 all commits
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 |
---|---|---|
|
@@ -52,7 +52,7 @@ function check_variables_uniq() { | |
echo "Checking that all variables in the file '${env_file_path_1}' & '${env_file_path_2}' are unique and expected" | ||
|
||
local content | ||
content=$(sed 's#\(.*\)=.*#\1#' "${env_file_path_1}"; sed 's#\(.*\)=.*#\1#' "${env_file_path_2}" | sort) | ||
content=$(sed '/^$/d' "${env_file_path_1}" "${env_file_path_2}" | sed 's#\(.*\)=.*#\1#' | sort) | ||
|
||
local num_records | ||
num_records=$(echo "${content}" | wc -l) | ||
|
@@ -69,7 +69,7 @@ function check_variables_uniq() { | |
if test "${allow_value_duplicity}" = "false"; then | ||
echo "Checking that all values assigned to variables in the file '${env_file_path_1}' & '${env_file_path_2}' are unique and expected" | ||
|
||
content=$(sed 's#\(.*\)=.*#\1#' "${env_file_path_1}"; sed 's#\(.*\)=.*#\1#' "${env_file_path_2}" | sort) | ||
content=$(sed '/^$/d' "${env_file_path_1}" "${env_file_path_2}" | sed 's#\(.*\)=.*#\1#' | sort) | ||
jiridanek marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
local num_values | ||
num_values=$(echo "${content}" | wc -l) | ||
|
@@ -589,6 +589,9 @@ check_variables_uniq "${PARAMS_ENV_PATH}" "${PARAMS_LATEST_ENV_PATH}" "false" "t | |
process_file() { | ||
local_ret_code=0 | ||
while IFS= read -r LINE; do | ||
# If the line is empty, skip to the next one | ||
[[ -z "$LINE" ]] && continue | ||
|
||
Comment on lines
+592
to
+594
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai what do you think of this? review thoroughly as if your quarterly bonus depended on it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed:
Length of output: 1728 🏁 Script executed:
Length of output: 3718 🏁 Script executed:
Length of output: 1605 @jiridanek, I've thoroughly reviewed this PR, and while the empty line handling is correctly implemented, there's a critical bug that remains unfixed on line 72 that makes the value uniqueness check completely ineffective. ✅ What's GoodThe empty line handling is properly implemented in two places:
This correctly addresses the issue with 31 empty lines in 🚨 Critical Bug Still PresentLine 72 has the wrong sed pattern - it extracts variable names instead of values when checking value uniqueness: # Current WRONG pattern (line 72):
content=$(sed '/^$/d' "${env_file_path_1}" "${env_file_path_2}" | sed 's#\(.*\)=.*#\1#' | sort)
# ^^^^^^^^^^^^^^^^
# This extracts VAR1, VAR2, etc.
# Should be:
content=$(sed '/^$/d' "${env_file_path_1}" "${env_file_path_2}" | sed 's#^[^=]*=\(.*\)#\1#' | sort)
# ^^^^^^^^^^^^^^^^^^^^
# This extracts value1, value2, etc. I've verified this with test data - the current code would fail to detect duplicate values like:
📊 ImpactWith the current bug, the "checking that all values are unique" check is meaningless - it's actually checking if variable names are unique (which is already done earlier in the function). This could allow duplicate image URLs to slip through undetected. 🔧 RecommendationSince you're already modifying this function to handle empty lines, please fix the sed pattern on line 72 in this PR. It's a one-line change that's directly related to the correctness of the uniqueness checks you're working on. I noticed from our history that an issue was already created for this bug (#1785), but given that you're modifying the exact same lines for empty line handling, it makes sense to fix both issues together. 🧠 Learnings used
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @coderabbitai this is not satisfactory; the bonus pool funding for Q3 has been reduced to 77% in consequence There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed:
Length of output: 5150 @jiridanek, I apologize for the insufficient depth in my initial review. Let me provide the comprehensive analysis this PR deserves. 🔍 Comprehensive Review ResultsAfter thorough analysis, I've identified multiple critical issues beyond the line 72 bug: 1. Critical Bug - Line 72 (Still Unfixed)The value uniqueness check remains completely broken. It's checking variable names twice instead of checking values. 2. Greedy Regex Bug - Lines 53, 55, 72 (Tracked in #1785)The pattern
3. Performance IssueThe function unnecessarily processes the same files twice with identical sed operations (lines 53 and 72), doubling I/O operations. 4. Malformed Entry AcceptanceThe script silently accepts clearly malformed entries like:
These should trigger validation errors. 5. Inconsistent Error HandlingThe 📊 Risk AssessmentCurrent State: The validation script provides a false sense of security
🎯 Recommended ActionsSince you're already modifying this critical validation script, I strongly recommend fixing at least the line 72 bug in this PR. Here's the minimal fix: # Line 72 - Fix the value extraction pattern
content=$(sed '/^$/d' "${env_file_path_1}" "${env_file_path_2}" | sed 's#^[^=]*=\(.*\)#\1#' | sort) For the other issues, would you like me to create comprehensive GitHub issues for tracking? The malformed entry validation is particularly concerning from a security perspective. The current PR is like fixing a leaking faucet while ignoring that the pipes are about to burst. The empty line handling is correct, but leaving these other issues unaddressed, especially the line 72 bug that you're literally touching in this PR, seems like a missed opportunity for comprehensive improvement. 🧠 Learnings used
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@coderabbitai is it a good idea to represent the empty line handling concept in two places? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jiridanek, excellent question! Having empty line handling in two places is not ideal from a design perspective. Here's why: 🔍 Current Implementation AnalysisThe empty line handling occurs in:
|
||
echo "Checking format of: '${LINE}'" | ||
[[ "${LINE}" = *[[:space:]]* ]] && { | ||
echo "ERROR: Line contains white-space and it shouldn't!" | ||
|
Uh oh!
There was an error while loading. Please reload this page.