Skip to content

Conversation

@mheap
Copy link
Member

@mheap mheap commented Dec 15, 2025

Description

Generating YAML using liquid always felt wrong. The giveaway was when we had to start passing paths as a comma separated list, and keep track of the loop index in other parameters. The refactor lets you specify a list of matches

Preview Links

To be added once the preview app is live

Checklist

  • Tested how-to docs. If not, note why here.
  • All pages contain metadata. N/A
  • Any new docs link to existing docs. N/A
  • All autogenerated instructions render correctly (API, decK, Konnect, Kong Manager). N/A
  • Style guide (capitalized gateway entities, placeholder URLs) implemented correctly. N/A
  • Every page has a description entry in frontmatter. N/A
  • Add new pages to the product documentation index (if applicable). N/A

@mheap mheap requested a review from fabianrbz December 15, 2025 10:32
@mheap mheap requested a review from a team as a code owner December 15, 2025 10:32
@netlify
Copy link

netlify bot commented Dec 15, 2025

Deploy Preview for kongdeveloper ready!

Name Link
🔨 Latest commit 08da6f3
🔍 Latest deploy log https://app.netlify.com/projects/kongdeveloper/deploys/694ac9f794af8a00089edc44
😎 Deploy Preview https://deploy-preview-3721--kongdeveloper.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

'name' => config['name'],
'namespace' => config['namespace'],
'annotations' => {
'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix

AI 15 days ago

To fix the problem, we need to ensure that config['annotation_rewrite'] is properly escaped. The correct sequence is:

  1. Escape every backslash in the string by replacing each \ with \\.
  2. Then, escape each $ character by replacing each $ with \$.
    This order ensures that any $ already preceded by a backslash will still be correctly escaped, and that we do not accidentally produce unescaped $.

Specifically, we need to change line 77 of app/_plugins/blocks/httproute.rb from:

'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),

to:

'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('\\', '\\\\')&.gsub('$', '\$'),

No new methods or imports are required—just the chained gsub calls. This keeps existing functionality the same but correctly escapes the value.


Suggested changeset 1
app/_plugins/blocks/httproute.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/app/_plugins/blocks/httproute.rb b/app/_plugins/blocks/httproute.rb
--- a/app/_plugins/blocks/httproute.rb
+++ b/app/_plugins/blocks/httproute.rb
@@ -74,7 +74,7 @@
           'name' => config['name'],
           'namespace' => config['namespace'],
           'annotations' => {
-            'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),
+            'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('\\', '\\\\')&.gsub('$', '\$'),
             'konghq.com/plugins' => config['annotation_plugins']&.join(','),
             'konghq.com/strip-path' => 'true'
           }.compact
EOF
@@ -74,7 +74,7 @@
'name' => config['name'],
'namespace' => config['namespace'],
'annotations' => {
'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),
'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('\\', '\\\\')&.gsub('$', '\$'),
'konghq.com/plugins' => config['annotation_plugins']&.join(','),
'konghq.com/strip-path' => 'true'
}.compact
Copilot is powered by AI and may make mistakes. Always verify output.
'name' => config['name'],
'namespace' => config['namespace'],
'annotations' => {
'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.

Copilot Autofix

AI 15 days ago

To correctly escape $ in an input string, all existing backslashes must also be escaped, to avoid ambiguity in the resulting value. The correct order is to first escape all backslashes (\ replaced with \\), then escape all dollar signs ($ replaced with \$). This is traditionally done using two gsub calls in sequence.

For the code in app/_plugins/blocks/httproute.rb, line 124:

'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),

replace this with:

'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('\\', '\\\\')&.gsub('$', '\$'),

This correctly escapes both backslashes and dollar signs in the input string.

No new imports are necessary, as Ruby's gsub method is used.
Scope: Only replace the specific occurrence on line 124 in to_ingress.


Suggested changeset 1
app/_plugins/blocks/httproute.rb

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/app/_plugins/blocks/httproute.rb b/app/_plugins/blocks/httproute.rb
--- a/app/_plugins/blocks/httproute.rb
+++ b/app/_plugins/blocks/httproute.rb
@@ -121,7 +121,7 @@
           'name' => config['name'],
           'namespace' => config['namespace'],
           'annotations' => {
-            'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),
+            'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('\\', '\\\\')&.gsub('$', '\$'),
             'konghq.com/strip-path' => 'true'
           }.compact
         },
EOF
@@ -121,7 +121,7 @@
'name' => config['name'],
'namespace' => config['namespace'],
'annotations' => {
'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('$', '\$'),
'konghq.com/rewrite' => config['annotation_rewrite']&.gsub('\\', '\\\\')&.gsub('$', '\$'),
'konghq.com/strip-path' => 'true'
}.compact
},
Copilot is powered by AI and may make mistakes. Always verify output.
@mheap mheap linked an issue Dec 15, 2025 that may be closed by this pull request
@Guaris Guaris changed the title Replace httproute include with httproute block Feat(Platform): Replace httproute include with httproute block Dec 23, 2025
@Guaris Guaris merged commit 6920a51 into main Dec 23, 2025
15 of 16 checks passed
@Guaris Guaris deleted the httproute-helper branch December 23, 2025 17:55
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.

HTTPRoute Helper

4 participants