Skip to content

Commit 2e2e753

Browse files
committed
fix(security): harden curl commands with explicit TLS protocol enforcement
- Replaced basic `curl -sSL` with secure configuration: `curl --proto "=https" --tlsv1.2 -sSf -L` - Added explicit HTTPS-only protocol enforcement (`--proto "=https"`) - Enforced TLS 1.2 minimum version for modern encryption - Used `-sS` (silent but show errors) instead of `-sSL` for better error visibility - Maintained redirect following (`-L`) functionality securely This addresses SonarCloud security vulnerabilities: - S5332: Not enforcing HTTPS might allow insecure redirects - S6506: Allowing downgrades to clear-text protocol is security-sensitive - Provides defense against SSL stripping and protocol downgrade attacks Security improvements: 1. Prevents fallback to insecure HTTP via `--proto "=https"` 2. Enforces modern TLS 1.2+ encryption 3. Maintains security while preserving redirect functionality 4. Better error reporting with `-S` flag for debugging
1 parent caec6ec commit 2e2e753

25 files changed

+27
-27
lines changed

src/bitbucket/bb-pr-create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function create_bitbucket_pullrequest() {
5656
endpoint="$(build_bb_endpoint "PR" "$WORKSPACE" "$REPO")"
5757

5858
# Create the repository using curl
59-
response=$(curl -sSL -X POST "$endpoint" \
59+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \
6060
-H "$BITBUCKET_AUTH" \
6161
-H 'Accept: application/json' \
6262
-H 'Content-Type: application/json' \

src/bitbucket/bb-pr-merge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function create_bitbucket_pullrequest() {
5757
endpoint="$endpoint/$pr/merge"
5858

5959
# Create the repository using curl
60-
response=$(curl -sSL -X POST "$endpoint" \
60+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \
6161
-H "$BITBUCKET_AUTH" \
6262
-H 'Accept: application/json' \
6363
-H 'Content-Type: application/json' \

src/bitbucket/bb-pr-update.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function update_bitbucket_pullrequest() {
6868
endpoint="$pr_endpoint/$pr"
6969

7070
# Create the repository using curl
71-
response=$(curl -sSL -X PUT "$endpoint" \
71+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X PUT "$endpoint" \
7272
-H "$BITBUCKET_AUTH" \
7373
-H 'Accept: application/json' \
7474
-H 'Content-Type: application/json' \

src/bitbucket/bb-repo-create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function create_bitbucket_repo() {
4848
endpoint="https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO"
4949

5050
# Create Bitbucket repository
51-
response=$(curl -sSL -X POST "$endpoint" \
51+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \
5252
-H "$BITBUCKET_AUTH" \
5353
-H 'Accept: application/json' \
5454
-H 'Content-Type: application/json' \

src/bitbucket/bb-repo-delete.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function delete_bitbucket_repo() {
3737

3838
if [[ $confirmation =~ ^[Yy]$ ]]; then
3939
# Delete the repository
40-
response=$(curl -sSL -X DELETE "$endpoint" \
40+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X DELETE "$endpoint" \
4141
-H "$BITBUCKET_AUTH" )
4242

4343
# Check if there are errors

src/bitbucket/bb-repo-edit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ function edit_bitbucket_repo() {
4646
endpoint="https://api.bitbucket.org/2.0/repositories/$WORKSPACE/$REPO"
4747

4848
# Edit Bitbucket repository
49-
response=$(curl -sSL -X PUT "$endpoint" \
49+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X PUT "$endpoint" \
5050
-H "$BITBUCKET_AUTH" \
5151
-H 'Accept: application/json' \
5252
-H 'Content-Type: application/json' \

src/github/gh-notification-delete.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function delete_github_notifications() {
2929
endpoint="https://api.github.com/notifications/threads/$NOTIFICATION_ID"
3030

3131
# Delete notifications
32-
response=$(curl -sSL -X DELETE "$endpoint" \
32+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X DELETE "$endpoint" \
3333
-H "Accept: application/vnd.github+json" \
3434
-H "Authorization: Bearer $GITHUB_TOKEN" \
3535
-H "X-GitHub-Api-Version: 2022-11-28" )

src/github/gh-notification-list.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function list_github_notifications() {
2020
endpoint="https://api.github.com/notifications"
2121

2222
# Get notifications
23-
response=$(curl -sSL "$endpoint" \
23+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L "$endpoint" \
2424
-H "Accept: application/vnd.github+json" \
2525
-H "Authorization: Bearer $GITHUB_TOKEN" \
2626
-H "X-GitHub-Api-Version: 2022-11-28" )

src/github/gh-pr-create.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function create_github_pullrequest() {
4949
endpoint="$(build_gh_endpoint "PR" "$OWNER" "$REPO")"
5050

5151
# Create the repository using curl
52-
response=$(curl -sSL -X POST "$endpoint" \
52+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X POST "$endpoint" \
5353
-H "Accept: application/vnd.github+json" \
5454
-H "Authorization: Bearer $GITHUB_TOKEN" \
5555
-H "X-GitHub-Api-Version: 2022-11-28" \

src/github/gh-pr-merge.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function merge_github_pullrequest() {
5555
endpoint="$pr_endpoint/$pr/merge"
5656

5757
# Create the repository using curl
58-
response=$(curl -sSL -X PUT "$endpoint" \
58+
response=$(curl --proto "=https" --tlsv1.2 -sSf -L -X PUT "$endpoint" \
5959
-H "Accept: application/vnd.github+json" \
6060
-H "Authorization: Bearer $GITHUB_TOKEN" \
6161
-H "X-GitHub-Api-Version: 2022-11-28" \

0 commit comments

Comments
 (0)