cryostatio / cryostat

Other
7 stars 8 forks source link

fix(matchexpr): correct lookup of Target objects for match expression testing (backport #512) #513

Closed mergify[bot] closed 3 weeks ago

mergify[bot] commented 3 weeks ago

Welcome to Cryostat3! 👋

Before contributing, make sure you have:

To recreate commits with GPG signature git fetch upstream && git rebase --force --gpg-sign upstream/main


Fixes #511

The most important change is in MatchExpressions.java. The backend should not trust the client to provide the list of whole Target objects to evalute match expressions against. This endpoint should really just take a list of target database IDs that the client wants to test with the provided match expression, but it is late to make such a change now. With this patch the server picks only the connectUrl from each of the client's provided targets, then looks up each actual Target instance from the database that has that connectUrl, and tests the provided match expression against this reconstructed list. This ensures that the client is not lying about any properties of the targets, and also ensures that the server doesn't skip evaluating any properties of the target that the client did not include with the request (such as the labels and annotations, which are the root of the associated bug).

How to manually test:

  1. Check out and build PR
  2. ./smoketest.bash -Ot
  3. Go to Automated Rules > Create
  4. Test a match expression like 'PORT' in target.annotations.cryostat
    This is an automatic backport of pull request #512 done by Mergify.