I hereby claim:
- I am lionize on github.
- I am markachandler (https://keybase.io/markachandler) on keybase.
- I have a public key ASA_Dce6g79xuTx4T_CdP131QpDsO2_SbDPMDs5yPw2d-Ao
To claim this, I am signing this object:
| Traffic Light* | |
| Green* | |
| timer -> Yellow | |
| Yellow | |
| timer -> Red | |
| Red | |
| timer -> Green |
| Traffic Light* | |
| Green* | |
| timer -> Yellow | |
| Yellow | |
| timer -> Red | |
| Red | |
| timer -> Green |
I hereby claim:
To claim this, I am signing this object:
| override fun run(): Any? { | |
| val ctx = RequestContext.getCurrentContext() | |
| val params = ctx.requestQueryParams | |
| val encrypted = params["encryptedValue"]!![0] | |
| val decrypted = encrypted.reversed() | |
| params["encryptedValue"] = listOf(decrypted) | |
| return null | |
| } |
| @Test | |
| fun `should replace encrypted string in query param with decrypted value`() { | |
| val encrypted = "ABCDEFG123456" | |
| val decrypted = encrypted.reversed() | |
| val ctx = RequestContext.getCurrentContext() | |
| ctx.requestQueryParams = mutableMapOf( | |
| "encryptedValue" to listOf(encrypted) | |
| ) | |
| filter.run() |
| override fun shouldFilter(): Boolean { | |
| val ctx = RequestContext.getCurrentContext() | |
| val params = ctx.requestQueryParams ?: return false | |
| val encrypted = params["encryptedValue"] ?: return false | |
| return encryptedStringRegex.matches(encrypted[0]) | |
| } |
| @Test | |
| fun `should filter if encryptedValue param containing encrypted string`() { | |
| val encrypted = "ABCDEFG123456" | |
| val ctx = RequestContext.getCurrentContext() | |
| ctx.requestQueryParams = mutableMapOf( | |
| "encryptedValue" to listOf(encrypted) | |
| ) | |
| assertEquals(true, filter.shouldFilter()) |
| @Component | |
| class QueryParamsDecryptionFilter : ZuulFilter() { | |
| private val encryptedStringRegex = | |
| Regex("(?=.*[A-Z]+)(?=.*\\d+)([A-Z0-9]){12,}") | |
| override fun run(): Any? { | |
| return null | |
| } | |
| override fun shouldFilter(): Boolean { |
| class QueryParamsDecryptionFilterTest { | |
| private val filter = QueryParamsDecryptionFilter() | |
| private val request = MockHttpServletRequest() | |
| @Before | |
| fun init() { | |
| val ctx = RequestContext.getCurrentContext() | |
| ctx.clear() | |
| ctx.request = request | |
| } |
| override fun run(): Any? { | |
| val ctx = RequestContext.getCurrentContext() | |
| val uri = ctx.request.requestURI | |
| val encrypted = encryptedStringRegex.find(uri)!!.value | |
| val decrypted = encrypted.reversed() | |
| val newUri = encryptedStringRegex.replace(uri, decrypted) | |
| val newRequest = object : HttpServletRequestWrapper(ctx.request) { | |
| override fun getRequestURI() = newUri |