Skip to content
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

Refactoring of hurl scripts #1475

Merged
merged 13 commits into from
Oct 28, 2024
Merged

Refactoring of hurl scripts #1475

merged 13 commits into from
Oct 28, 2024

Conversation

basiliskus
Copy link
Contributor

@basiliskus basiliskus commented Oct 22, 2024

Refactoring of hurl scripts

  • Renamed message_submission_utils.sh => utils.sh
  • Refactored hrl scripts to use functions and reuse code in utils.sh
  • Moved and renamed hrl scripts
    • rs/hrl => rs.sh
    • ti/hrl => ti.sh
    • epic/hrl => epic.sh
  • Consolidated readme files into one
  • Refactored submit_message.sh to extract reusable code and add argument to pass environment
  • Refactored rs.sh and ti.sh scripts to handle deployed env and change parameters and naming for consistency
  • Added error handling for hurl calls and user prompt for outbound submission id when not possible to get from metadata API in deployed env

Issue

#1485

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

File Path Hardcoding
The script hardcodes the path to the hurl file which might lead to issues if the directory structure changes or if the script is run from a different directory.

Script Argument Handling
The script modifies the argument list which could lead to unexpected behavior if not properly documented or understood by users.

scripts/hurl/epic.sh Show resolved Hide resolved
scripts/hurl/rs.sh Outdated Show resolved Hide resolved
scripts/hurl/ti.sh Outdated Show resolved Hide resolved
Copy link

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Score
Possible bug
Check for the existence of the script file before execution to prevent errors

Ensure that the epic/results.hurl script file exists at the specified path to avoid
runtime errors.

scripts/hurl/epic.sh [12]

-epic/results.hurl
+[ -f epic/results.hurl ] || { echo "Error: epic/results.hurl does not exist."; exit 1; }
Suggestion importance[1-10]: 7

Why: This suggestion is relevant as it ensures the existence of the 'epic/results.hurl' script before execution, preventing runtime errors. This is a practical and necessary check for robust script execution.

7
Ensure the directory exists before using it in script paths

Validate the existence of the directory rs/ before attempting to assign files from
it to avoid script failures.

scripts/hurl/rs.sh [47]

+[ -d rs/ ] || { echo "Error: rs/ directory does not exist."; exit 1; }
 hurl_file=rs/"$1"
Suggestion importance[1-10]: 7

Why: The suggestion to check for the existence of the 'rs/' directory before using it in the script path is valid and enhances the script's reliability by preventing errors related to non-existent directories.

7
Check if the script is executable and exists before attempting to execute it

Ensure that the rs.sh script is executable and exists in the expected path to
prevent runtime errors when calling it.

scripts/hurl/message_submission_utils.sh [41]

+[ -x ./rs.sh ] || { echo "Error: rs.sh is not executable or missing."; exit 1; }
 history_response=$(./rs.sh history.hurl -i "$submission_id")
Suggestion importance[1-10]: 7

Why: This suggestion is crucial as it ensures that the 'rs.sh' script is executable and exists before it is called. This check prevents runtime errors and enhances the script's reliability when integrating with other components.

7

@basiliskus basiliskus changed the title Moved and renamed hrl script to simplify and clean up file org Refactoring of hurl scripts Oct 23, 2024
@basiliskus basiliskus marked this pull request as ready for review October 24, 2024 18:59
@basiliskus
Copy link
Contributor Author

/review

Copy link

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis ✅

1485 - Fully compliant

Fully compliant requirements:

  • Refactor and improve scripts in /scripts/hurl so submit_message.sh can handle message submission and tracking in staging and potentially other deployed environments
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 Security concerns

Sensitive information exposure:
The script contains hardcoded secrets for Azure connection strings which could lead to security vulnerabilities if exposed. This is found in scripts/hurl/utils.sh.

⚡ Recommended focus areas for review

Hardcoded Secrets
The script contains hardcoded secrets for Azure connection strings which could lead to security vulnerabilities if exposed.

Error Handling
The error handling in the script does not differentiate between different types of errors, which could lead to misleading error messages or improper error resolution.

Copy link

Copy link
Contributor

@pluckyswan pluckyswan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might've missed it or just be out of the loop on what's changed, but did the MSH Header replacement get removed?

@basiliskus
Copy link
Contributor Author

Might've missed it or just be out of the loop on what's changed, but did the MSH Header replacement get removed?

Yes, it's not needed anymore. We're now routing internal tests with MSH-11 instead of MSH-6.2

@basiliskus basiliskus requested a review from pluckyswan October 25, 2024 20:51
@basiliskus basiliskus merged commit e1b9cf5 into main Oct 28, 2024
17 checks passed
@basiliskus basiliskus deleted the chores/reorg-hurl-scripts branch October 28, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants