Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
help requirements impl-dev.clone.https impl-dev.clone.ssh impl-dev.provision \
impl-dev.pull impl-dev.pull.without-deps impl-dev.up impl-dev.up.attach \
impl-dev.up.without-deps selfcheck upgrade \
validate-lms-volume
validate-lms-volume migrate-enterprise-repos

# Load up options (configurable through options.local.mk).
include options.mk
Expand Down Expand Up @@ -563,3 +563,6 @@ build-courses: ## Build course and provision cms, and ecommerce with it.
bash ./course-generator/build-course-json.sh course-generator/tmp-config.json
bash ./course-generator/create-courses.sh --cms --ecommerce course-generator/tmp-config.json
rm course-generator/tmp-config.json

migrate-enterprise-repos: ## Migrate enterprise repository clones from openedx to edx GitHub org.
./migrate-enterprise-repos.sh
44 changes: 44 additions & 0 deletions migrate-enterprise-repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
#
# Migrate all enterprise repo clones from openedx to edx github org.
#
#
set -eu -o pipefail

REPOS=(
enterprise-access
enterprise-subsidy
enterprise-catalog
license-manager

# TODO frontend apps:
# frontend-app-admin-portal
# frontend-app-learner-portal-enterprise
# frontend-app-enterprise-checkout
# frontend-app-enterprise-public-catalog

# TODO libraries:
# edx-enterprise
# edx-enterprise-data
# frontend-enterprise
# enterprise-integrated-channels
# edx-enterprise-subsidy-client
)

for repo in "${REPOS[@]}"; do
echo "Updating $repo ..."
if [ ! -d "$DEVSTACK_WORKSPACE/$repo" ]; then
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The script uses $DEVSTACK_WORKSPACE without checking if it's set. While the variable will be exported when called from the Makefile (line 94 exports all variables), the script could fail with unclear errors if run standalone. Consider adding a check at the beginning of the script, similar to what repo.sh does:

if [ -z "$DEVSTACK_WORKSPACE" ]; then
    echo "Error: DEVSTACK_WORKSPACE is not set"
    exit 1
fi

Copilot uses AI. Check for mistakes.
echo "Skipping $repo (not found)"
continue
fi
pushd "$DEVSTACK_WORKSPACE/$repo" >/dev/null
OLD_ORIGIN=$(git remote get-url origin)
git remote set-url origin $(git remote get-url origin | sed 's/openedx/edx/')
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

The sed command sed 's/openedx/edx/' will replace 'openedx' anywhere in the URL, which could lead to unintended replacements. For example, if the URL contains 'openedx' in a branch name or path, it would be incorrectly modified. Consider using a more specific pattern like sed 's|github.com/openedx/|github.com/edx/|' or sed 's|://github.com/openedx/|://github.com/edx/|' to target only the organization part of the URL.

Suggested change
git remote set-url origin $(git remote get-url origin | sed 's/openedx/edx/')
git remote set-url origin $(git remote get-url origin | sed 's|github.com/openedx/|github.com/edx/|')

Copilot uses AI. Check for mistakes.
NEW_ORIGIN=$(git remote get-url origin)
echo "Old origin: ${OLD_ORIGIN}"
echo "New origin: ${NEW_ORIGIN}"
Comment on lines +38 to +39
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

echo-ing OLD_ORIGIN and NEW_ORIGIN directly can leak credentials if a Git remote URL embeds a username/password or PAT (e.g., https://user:token@github.com/org/repo.git), since these values will be printed to the terminal or any build logs capturing stdout. An attacker with access to terminal history or CI logs could recover these secrets. Avoid logging full remote URLs; instead, either omit them entirely or redact credentials (e.g., by stripping user:pass@ portions) before printing.

Suggested change
echo "Old origin: ${OLD_ORIGIN}"
echo "New origin: ${NEW_ORIGIN}"
# Redact credentials from remote URLs before printing
echo "Old origin: $(echo "${OLD_ORIGIN}" | sed -E 's#(https?://)[^/@]+@#\1#')"
echo "New origin: $(echo "${NEW_ORIGIN}" | sed -E 's#(https?://)[^/@]+@#\1#')"

Copilot uses AI. Check for mistakes.
popd >/dev/null
echo
done

echo "Migration complete."
Loading