-
Notifications
You must be signed in to change notification settings - Fork 95
fix(x2a): Fix/policy lock token leak #2636
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
base: main
Are you sure you want to change the base?
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@red-hat-developer-hub/backstage-plugin-x2a-backend': patch | ||
| --- | ||
|
|
||
| Fix SCM token leak in Policyfile.lock.json: stop copying wildcard JSON files from Chef source directory and improve URL credential sanitization regex |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,9 +59,9 @@ sanitize_secrets() { | |
| # Match GitHub PATs (ghp_, gho_, github_pat_) and generic token@host patterns in URLs | ||
| local count=0 | ||
| while IFS= read -r -d '' file; do | ||
| if grep -qE 'https?://[^@/:[:space:]]+@' "$file" 2>/dev/null; then | ||
| # Strip token from URLs: https://ghp_xxx@github.com/... → https://github.com/... | ||
| sed -i 's|https\?://[^@/:[:space:]]*@|https://|g' "$file" | ||
| if grep -qE 'https?://[^@/[:space:]]+@' "$file" 2>/dev/null; then | ||
| # Strip credentials from URLs: https://user:token@host/... → https://host/... | ||
| sed -i 's|https\?://[^@/[:space:]]*@|https://|g' "$file" | ||
| echo " Sanitized: ${file#/workspace/target/}" | ||
| count=$((count + 1)) | ||
| fi | ||
|
|
@@ -235,8 +235,8 @@ case "${PHASE}" in | |
| # Note: x2a tool writes files to the source directory (--source-dir) | ||
| echo "Copying output to ${PROJECT_PATH}/" | ||
| cp -v "${SOURCE_BASE}/migration-plan.md" "${PROJECT_PATH}/" | ||
| # Copy any other generated files (like metadata) | ||
| cp -v "${SOURCE_BASE}"/*.json "${PROJECT_PATH}/" 2>/dev/null || true | ||
| # Copy generated metadata (only specific files — avoid copying Chef artifacts like Policyfile.lock.json) | ||
| cp -v "${SOURCE_BASE}/generated-project-metadata.json" "${PROJECT_PATH}/" 2>/dev/null || true | ||
| cp -v "${SOURCE_BASE}"/*.yaml "${PROJECT_PATH}/" 2>/dev/null || true | ||
|
|
||
| # Show what was created | ||
|
|
@@ -299,7 +299,6 @@ case "${PHASE}" in | |
| # Note: x2a tool produces migration-plan-{module_name}.md (spaces replaced with underscores) | ||
| echo "Copying output to ${OUTPUT_DIR}/" | ||
| cp -v "${SOURCE_BASE}/migration-plan-${MODULE_NAME_SANITIZED}.md" "${OUTPUT_DIR}/" | ||
| cp -v "${SOURCE_BASE}"/*.json "${OUTPUT_DIR}/" 2>/dev/null || true | ||
|
Contributor
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. wait, these files are important, and we don't have here migration-dependencies when we should! When migration cache, we are referencing all inside the migration-dependencies, inside the migration-plan-module, and we should be able to analyze that files to write the ansible code correctly. This file is the main lock file for when we donwload all the vendor dependencies when we used, and it's our "DNS" for the dependencies. Without this folder, and the json files we shouldn't be able to do the right on cache, because cache to_ansible will try to read files that are not in there
Contributor
Author
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. Were still copying the ""${SOURCE_BASE}/generated-project-metadata.json" file, which has the needed metadata
Contributor
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. both files are needed, also the migration_dependencies which are referenced on migration-plan-cache.md
Contributor
Author
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. ok, I'll revert the changes and add more guards around sanitization all of the committed files. |
||
| cp -v "${SOURCE_BASE}"/*.yaml "${OUTPUT_DIR}/" 2>/dev/null || true | ||
|
|
||
| echo "" | ||
|
|
@@ -361,7 +360,6 @@ case "${PHASE}" in | |
| # Note: x2a tool writes to ansible/roles/{module}/ in the source directory | ||
| echo "Copying output to ${OUTPUT_DIR}/" | ||
| cp -rv "${SOURCE_BASE}/ansible" "${OUTPUT_DIR}/" 2>/dev/null || true | ||
| cp -v "${SOURCE_BASE}"/*.json "${OUTPUT_DIR}/" 2>/dev/null || true | ||
| cp -v "${SOURCE_BASE}"/*.yaml "${OUTPUT_DIR}/" 2>/dev/null || true | ||
|
|
||
| echo "" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Metadata read can fail
🐞 Bug⛯ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools