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

webui: searching for "match" doesn't provide any results #2349

Open
mr-tz opened this issue Sep 9, 2024 · 3 comments
Open

webui: searching for "match" doesn't provide any results #2349

mr-tz opened this issue Sep 9, 2024 · 3 comments
Labels
bug Something isn't working webui related to capa results web visualization

Comments

@mr-tz
Copy link
Collaborator

mr-tz commented Sep 9, 2024

image

I'd expect this to show this rule for example

image

Or is this by design?

@mr-tz mr-tz added bug Something isn't working webui related to capa results web visualization labels Sep 9, 2024
@s-ff
Copy link
Collaborator

s-ff commented Sep 9, 2024

Or is this by design?

@mr-tz, yes this works as designed.

For example, a simple rule match looks like this:

[
  {
    "key": "53-0",
    "data": {
      "type": "match location",
      "name": "function @ 0x1400198F7"
    },
    "children": [
      {
        "key": "53-0",
        "data": {
          "type": "statement",
          "typeValue": "or",
          "name": "or:",
        },
        "children": [
          {
            "data": {
              "type": "feature",
              "typeValue": "api",
              "name": "GlobalMemoryStatusEx",   <---
              "address": "0x1400344AE"
            },
            "children": []
          }
        ]
      }
    ]
  }
]

The search only operates on the name field and using templating, we add in - and the typeValue (e.g. api, count, .. etc) which results in the table cell showing - api: GlobalMemoryStatusEx but actually it's just the name in the backend.

If we want to include the typeValue (e.g. api, match, ... etc), then the constructed name should be <typeValue>: <name>, e.g.

{
            "data": {
              "type": "feature",
              "typeValue": "api",
              "name": "api: GlobalMemoryStatusEx",   <---
              "address": "0x1400344AE"
            },
            "children": []
}

Similarly, if we want to include the - in the search, and not via templating, then:

{
            "data": {
              "type": "feature",
              "typeValue": "api",
              "name": "- api: GlobalMemoryStatusEx",   <---
              "address": "0x1400344AE"
            },
            "children": []
}

In conclusion, the search works on the JSON, and the templating is used to add in colors, text, styling, ... etc.

The reason behind separating the feature values into <typeValue> and <name> is that it is easy to mark text as bold and to highlight in green the typeValue, then concatenate it with feature <name> without having to .split(":") them first

I hope this clears out things for you. Let me know if it is preferred to include these value and I can send a fix PR :)

@mr-tz
Copy link
Collaborator Author

mr-tz commented Sep 10, 2024

It feels a little inconsistent. I can search for optional or or but not for match or regex.
These are different items though and your explanation makes sense.

@s-ff
Copy link
Collaborator

s-ff commented Sep 10, 2024

Yeah, I see your point. It is because optional, or, and are statements, and their name field is set to optional:, or:, and: so they are indeed searchable.

We can omit statements (like: optional, range (e.g. 3 or more), or, ... etc) from matching in the search by leaving out the name field empty. For example:

[
  {
    "data": {
      "type": "match location",
      "name": "function @ 0x1400198F7"
    },
    "children": [
      {
        "data": {
          "type": "statement",
          "typeValue": "or", // use this instead in the templating to render cell value as `- or: `
          "name": "",        // remove or leave empty
        },
        "children": [
          {
            "data": {
              "type": "feature",
              "typeValue": "api",
              "name": "GlobalMemoryStatusEx",
              "address": "0x1400344AE"
            },
            "children": []
          }
        ]
      }
    ]
  }
]

In my opinion, it makes sense not to include statement in the search and only include features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working webui related to capa results web visualization
Projects
None yet
Development

No branches or pull requests

2 participants