Skip to content

imperva_cloud_waf: work around type mismatch - #13161

Merged
efd6 merged 1 commit into
elastic:mainfrom
efd6:s5733-imperva_cloud_waf_unwedge_typing
Mar 19, 2025
Merged

imperva_cloud_waf: work around type mismatch#13161
efd6 merged 1 commit into
elastic:mainfrom
efd6:s5733-imperva_cloud_waf_unwedge_typing

Conversation

@efd6

@efd6 efd6 commented Mar 19, 2025

Copy link
Copy Markdown
Contributor

Proposed commit message

See title.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

  • [ ]

How to test this PR locally

Since the input is not tested, the behaviour change here can be checked with the two CEL programs below, good.cel (new code) and bad.cel (original code) that reflect the defective code region in the agent configuration with minor modifications to allow it to run without an endpoint.

$ mito bad.cel 
failed program instantiation: failed compilation: ERROR: <input>:5:71: found no matching overload for '_?_:_' applied to '(bool, list(map(string, string)), list(map(string, map(string, string))))'
 |  "events": try(string(body), "error").as(body, type(body) == type("") ?
 | ......................................................................^
$ mito good.cel
[
	{
		"events": [
			{
				"error": {
					"message": "invalid UTF-8 in bytes, cannot convert to string: check imperva waf logging is configured correctly"
				}
			}
		]
	},
	{
		"events": [
			{
				"message": "good message"
			}
		]
	}
]

good.cel:

[
	b"\xc3\x28",
	b"|==|good message\n",
].map(body, {
	"events": try(string(body), "error").as(body, type(body) == type("") ?
		dyn((body+"|==|").split("|==|")[1].split("\n").filter(x,x!="").map(x,{"message":x}))
	:
		// This is an unrecoverable error for the worklist element; it indicates
		// most likely that the data was compressed, or was encrypted. We cannot
		// handle this, so we step past it and log the failure. We are in an
		// unfortunate position where ideally we would like this to cause a health
		// status note in fleet to result, but we cannot do this since this would
		// delete the cursor update and we would still be stuck here, so we just
		// log into the index in the hope that someone will see it.
		dyn([{"error":
			{
				"message": body.error + ": check imperva waf logging is configured correctly",
			},
		}])
	),
})

bad.cel:

[
	b"\xc3\x28",
	b"|==|good message\n",
].map(body, {
	"events": try(string(body), "error").as(body, type(body) == type("") ?
		(body+"|==|").split("|==|")[1].split("\n").filter(x,x!="").map(x,{"message":x})
	:
		// This is an unrecoverable error for the worklist element; it indicates
		// most likely that the data was compressed, or was encrypted. We cannot
		// handle this, so we step past it and log the failure. We are in an
		// unfortunate position where ideally we would like this to cause a health
		// status note in fleet to result, but we cannot do this since this would
		// delete the cursor update and we would still be stuck here, so we just
		// log into the index in the hope that someone will see it.
		[{"error":
			{
				"message": body.error + ": check imperva waf logging is configured correctly",
			},
		}]
	),
})

Related issues

Screenshots

@efd6 efd6 added bugfix Pull request that fixes a bug issue Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] Integration:imperva_cloud_waf Imperva Cloud WAF labels Mar 19, 2025
@efd6 efd6 self-assigned this Mar 19, 2025
@efd6
efd6 force-pushed the s5733-imperva_cloud_waf_unwedge_typing branch from 097ef2a to a07f54c Compare March 19, 2025 03:43
@efd6
efd6 force-pushed the s5733-imperva_cloud_waf_unwedge_typing branch from a07f54c to 959933b Compare March 19, 2025 03:45
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

🚀 Benchmarks report

Package imperva_cloud_waf 👍(0) 💚(0) 💔(1)

Expand to view
Data stream Previous EPS New EPS Diff (%) Result
event 1589.83 1291.99 -297.84 (-18.73%) 💔

To see the full report comment with /test benchmark fullreport

@elasticmachine

Copy link
Copy Markdown

💚 Build Succeeded

cc @efd6

@efd6
efd6 marked this pull request as ready for review March 19, 2025 04:05
@efd6
efd6 requested a review from a team as a code owner March 19, 2025 04:05
@elasticmachine

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@efd6
efd6 merged commit d833764 into elastic:main Mar 19, 2025
@elastic-vault-github-plugin-prod

Copy link
Copy Markdown
Contributor

Package imperva_cloud_waf - 1.11.1 containing this change is available at https://epr.elastic.co/package/imperva_cloud_waf/1.11.1/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:imperva_cloud_waf Imperva Cloud WAF Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

3 participants