Skip to content

Preprocessing before matching in custom rules? #671

@JaneX8

Description

@JaneX8

I have a very specific use case where I would like to use custom DevSkim rules on.

I described the situation here: jqlang/jq#566 (comment) which I moved into a discussion here: jqlang/jq#3218.

For DevSkim purposes this for now can be considered a 'custom and unsupported language', JQ. JQ in itself is not valid JSON but in my use-case a large part of it is JSON. To avoid writing very complicated regular expressions on a complicated file structure only, if I enclosed it in placeholders like in below example.

{
  "name": "Example",
  "data": [
    # __JQ_START__
    .input | map({ key: .key, value: .value })
    # __JQ_END__
  ]
}

Is there a way in DevSkim to first use regex to remove everything in between the placeholders, including the placeholders itself, and then use JSONpath on the remainder, which is now fully JSON?

Or visa versa remove everything outside the placeholders including the placeholders, and do another regex on the remainder (JQ only)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions