feat: improve argocd compatibility with monorepo#2982
feat: improve argocd compatibility with monorepo#2982j-zimnowoda wants to merge 9 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 2 days ago
In general, the problem is that String.prototype.replace with a string pattern only replaces the first occurrence, which often leads to incomplete escaping or normalization. The robust fix is to use a regular expression with the g flag so that every occurrence is replaced, or to use a purpose-built helper that correctly normalizes paths.
In this specific case, on line 148 we should change release.chart.replace('../', '') to use a global regular expression: release.chart.replace(/\.\.\//g, ''). This keeps the existing behavior for a single "../" while also handling multiple segments like "../../foo" by stripping all "../" portions. No additional imports are necessary because regular expressions are built into JavaScript/TypeScript. The only change is within getArgocdCoreAppManifest in src/cmd/apply-as-apps.ts, at the line computing chartPath.
| @@ -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