Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
Management-Utilities/Workload-Factory-API-Samples/wf_utils:136
run_curlnow supports PATCH, but the function header comment/documentation still lists only GET/POST/PUT/DELETE. Please update the documented supported methods (and parameter description for data payload) to match the new behavior so callers don’t miss that PATCH is valid.
POST|PUT|PATCH)
curl -X "$method" -sw "%{http_code},%{errormsg}" "$url" \
-H "Accept: $accept" "${extraHeaders[@]}" \
-H "Content-Type:application/json" \
-H "Authorization: Bearer $token" --data "$data" -o $output > $errorOutput
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # | ||
| # Declare an array of required options and the error message to display if they are not set. | ||
| declare -A required_options | ||
| required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to run this script. It can be obtain from this web page: |
There was a problem hiding this comment.
Typo in required option error message: "refresh tokon" should be "refresh token".
| required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh tokon is required to run this script. It can be obtain from this web page: | |
| required_options["REFRESH_TOKEN"]='Error: A BlueXP refresh token is required to run this script. It can be obtain from this web page: |
| required_options["BLUEXP_ACCOUNT_ID"]='Error: A BlueXP account ID is required to run this script. | ||
| You can get the list of accounts you have access to by running the "list_bluexp_accts" script | ||
| found in this GitHub repository: https://github.com/NetApp/FSx-ONTAP-samples-scripts/tree/main/Management-Utilities/Workload-Factory-API-Samples\n\n' | ||
| required_options["CREDENTIALS_ID"]='Error: The ID of the credentials to delete is required. |
There was a problem hiding this comment.
The CREDENTIALS_ID missing-parameter message says "credentials to delete", which doesn’t match this script’s purpose (creating a CIFS share) and could confuse users. Please reword it to describe the credentials ID needed to perform the API call (e.g., the Workload Factory credentials ID for the AWS account).
| required_options["CREDENTIALS_ID"]='Error: The ID of the credentials to delete is required. | |
| required_options["CREDENTIALS_ID"]='Error: The Workload Factory credentials ID for the AWS account is required to run this script. |
| cifsShares=$(jq -r '.cifsShares' $tmpout) | ||
| # | ||
| # Create a new share definition. | ||
| newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}' | ||
| # | ||
| # Add the new share to the existing ones. | ||
| cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']') |
There was a problem hiding this comment.
If the volume currently has no CIFS shares, .cifsShares may be null/missing; in that case jq '. += [...]' will fail. Consider defaulting to an empty array when extracting (e.g., .cifsShares // []) before appending, so the script works on volumes with zero existing shares.
| cifsShares=$(jq -r '.cifsShares' $tmpout) | |
| # | |
| # Create a new share definition. | |
| newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}' | |
| # | |
| # Add the new share to the existing ones. | |
| cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']') | |
| cifsShares=$(jq -r '.cifsShares // []' "$tmpout") | |
| # | |
| # Create a new share definition. | |
| newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}' | |
| # | |
| # Add the new share to the existing ones. | |
| cifsShares=$(echo "$cifsShares" | jq --argjson newShare "$newShare" '. += [$newShare]') |
| cifsShares=$(jq -r '.cifsShares' $tmpout) | ||
| # | ||
| # Create a new share definition. | ||
| newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}' | ||
| # | ||
| # Add the new share to the existing ones. | ||
| cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']') | ||
| cifsShares="{\"cifsShares\": $cifsShares}" | ||
| run_curl PATCH "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems/${FILESYSTEM_ID}/volumes/${VOLUME_ID}" $tmpout $tmperr "$cifsShares" |
There was a problem hiding this comment.
newShare is built via shell string concatenation and then injected directly into a jq program (. += [ ... ]). If CIFS_SHARE_NAME contains quotes, backslashes, or jq-significant characters, this can produce invalid JSON or unintended jq parsing. Prefer building the object inside jq using --arg/--argjson (or jq -n) and appending using structured JSON rather than code injection.
| cifsShares=$(jq -r '.cifsShares' $tmpout) | |
| # | |
| # Create a new share definition. | |
| newShare='{"name":"'$CIFS_SHARE_NAME'","path":"'/$CIFS_SHARE_NAME'","acls":[{"userOrGroup":"Everyone","permission":"full_control","type":"windows"}]}' | |
| # | |
| # Add the new share to the existing ones. | |
| cifsShares=$(echo "$cifsShares" | jq -r '. += ['$newShare']') | |
| cifsShares="{\"cifsShares\": $cifsShares}" | |
| run_curl PATCH "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems/${FILESYSTEM_ID}/volumes/${VOLUME_ID}" $tmpout $tmperr "$cifsShares" | |
| # | |
| # Build the updated cifsShares payload by appending the new share using jq. | |
| cifsSharesPayload=$(jq --arg shareName "$CIFS_SHARE_NAME" ' | |
| .cifsShares as $shares | |
| | { | |
| cifsShares: ( | |
| ($shares // []) + [ | |
| { | |
| name: $shareName, | |
| path: ("/" + $shareName), | |
| acls: [ | |
| { | |
| userOrGroup: "Everyone", | |
| permission: "full_control", | |
| type: "windows" | |
| } | |
| ] | |
| } | |
| ] | |
| ) | |
| } | |
| ' "$tmpout") | |
| # | |
| run_curl PATCH "$token" "https://api.workloads.netapp.com/accounts/${BLUEXP_ACCOUNT_ID}/fsx/v2/credentials/${CREDENTIALS_ID}/regions/${AWS_REGION}/file-systems/${FILESYSTEM_ID}/volumes/${VOLUME_ID}" $tmpout $tmperr "$cifsSharesPayload" |
No description provided.