Skip to content

feat: improve argocd compatibility with monorepo#2982

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

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

Conversation

@j-zimnowoda
Copy link
Copy Markdown
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 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.

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.

3 participants