Skip to content

feat: improve argocd compatibility with monorepo#2982

Draft
j-zimnowoda wants to merge 9 commits intomainfrom
APL-1491-2
Draft

feat: improve argocd compatibility with monorepo#2982
j-zimnowoda wants to merge 9 commits intomainfrom
APL-1491-2

Conversation

@j-zimnowoda
Copy link
Contributor

📌 Summary

🔍 Reviewer Notes

🧹 Checklist

  • Code is readable, maintainable, and robust.
  • Unit tests added/updated

): 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

This replaces only the first occurrence of '../'.

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.

Suggested changeset 1
src/cmd/apply-as-apps.ts

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/cmd/apply-as-apps.ts b/src/cmd/apply-as-apps.ts
--- a/src/cmd/apply-as-apps.ts
+++ b/src/cmd/apply-as-apps.ts
@@ -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',
EOF
@@ -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',
Copilot is powered by AI and may make mistakes. Always verify output.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants