Skip to content

[feature] More flexible metadata field #1854

@kam193

Description

@kam193

⭐ Suggestion

I'd love to see the metadata allowing nested mappings, lists, etc., and not only strings.

💻 Use Cases

I use ast-grep to perform deobfuscation. As it's a more complex task than ast-grep can perform on its own, for most rules I define additional steps that are then handled by my scripts. I use metadata fields to keep those definitions close to the rule.

See for example: https://github.com/kam193/assemblyline-services/blob/main/ASTGrep/rules/extended/python/reverse-inline.yml

Currently, I use JSON strings that are later processed, e.g.:

...
metadata:
  extended-obfuscation: yes
  deobfuscate: |
    {
      "type": "fix-generate",
      "steps": [
        {"func": "reverse", "source": "DATA"},
        {"func": "encode_list", "source": "DATA", "encoding": "int"},
        {"func": "encode", "source": "DATA", "encoding": "bytes"},
        {"func": "quote", "source": "DATA"}
      ]
    }

This works, but I have to manually write the JSON string, what is easy to make syntax issues and cannot be automatically formatted by IDE. It would be nice to be able to write the equivalent directly in YAML, e.g.:

...
metadata:
  extended-obfuscation: yes
  deobfuscate:
    type: fix-generate
    steps:
      - func: reverse
        source: DATA
      - func: encode_list
        source: DATA
        encoding: int 
      - func: encode
        source: DATA
        encoding: bytes
      - func: quote
        source: DATA

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions