feat: improve argocd compatibility with monorepo#2982
feat: improve argocd compatibility with monorepo#2982j-zimnowoda wants to merge 80 commits intomainfrom
Conversation
| ): ArgocdAppManifest => { | ||
| const name = getAppName(release) | ||
| const patch = (appPatches[name] || genericPatch) as Record<string, any> | ||
| const chartPath = release.chart.replace('../', '') |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 days ago
In general, the problem is that using string.replace('../', '') only removes the first occurrence of "../" from the path string. To correctly normalize by stripping all "../" substrings, the replacement should be done using a global regular expression or a more robust path normalization method. Since we must not change behavior beyond fixing the incomplete replacement, the minimal and clearest fix is to use a regular expression with the global (g) flag so that every "../" is removed.
Specifically, in src/cmd/apply-as-apps.ts around line 148, update the chartPath assignment from release.chart.replace('../', '') to release.chart.replace(/\.\.\//g, ''). This preserves the original intent of removing "../" segments, but ensures that all occurrences are stripped, not just the first. No additional imports or helper functions are needed; this uses built-in JavaScript regex functionality and does not change surrounding logic or structures.
| @@ -145,7 +145,7 @@ | ||
| ): ArgocdAppManifest => { | ||
| const name = getAppName(release) | ||
| const patch = (appPatches[name] || genericPatch) as Record<string, any> | ||
| const chartPath = release.chart.replace('../', '') | ||
| const chartPath = release.chart.replace(/\.\.\//g, '') | ||
| return getArgoCdAppManifest(name, ARGOCD_APP_DEFAULT_LABEL, { | ||
| syncPolicy: ARGOCD_APP_DEFAULT_SYNC_POLICY, | ||
| project: 'default', |
📌 Summary
🔍 Reviewer Notes
🧹 Checklist