Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[policies] Groovy policy error on HTTP headers #7810

Closed
ytvnr opened this issue Jun 9, 2022 · 1 comment
Closed

[policies] Groovy policy error on HTTP headers #7810

ytvnr opened this issue Jun 9, 2022 · 1 comment

Comments

@ytvnr
Copy link
Member

ytvnr commented Jun 9, 2022

💥 Describe the bug

Since the modification of HTTP Headers in 3.15.x, accessing a header through a groovy script via request.headers.'My-Header' will return a string instead of an array of values, meaning it becomes impossible to do array operation (join for example).

🌄 To Reproduce

Steps to reproduce the behaviour:
Add a groovy script to your policy and use:

if (request.headers.containsKey('test')) {
     userAgent = request.headers.'test'.join('|');
request.headers.'test2' = userAgent;

   }

It should fail with

22:05:55.485 \[vert.x-eventloop-thread-1\] \[\] ERROR i.g.policy.groovy.GroovyPolicy - Unable to run Groovy script  
java.lang.SecurityException: Failed to resolve method \[ class java.lang.String join java.lang.String \]  
        at io.gravitee.policy.groovy.sandbox.SecuredInterceptor.onMethodCall(SecuredInterceptor.java:49)

🌈 Expected behaviour

We should be able to join all the values in a string if we want

@mouligno
Copy link
Contributor

LGTM

@Okhelifi Okhelifi changed the title Groovy policy error on HTTP headers [policies] Groovy policy error on HTTP headers Aug 1, 2022
@Okhelifi Okhelifi modified the milestones: APIM - 3.17.x, APIM - 3.17.5 Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants