question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pattern type for structured data files (yaml, json...)

See original GitHub issue

Is your feature request related to a problem? Please describe. In order to be able to detect feature usage in structured configuration files (yaml, json, xml…) it would be very useful to be able to search for occurrences of certain entries regardless of the order of declaration in the file.

An example would be:

If we have a config.yaml file and we have the following configuration:

app:
  myfeature:
     prop1: x
     prop2: x
     propN: x
     enabled: true

If I want to detect with a rule if the ‘myfeature’ functionality is enabled I would not have a reliable solution at the moment. Detecting if app.my-feature.enabled = true with patterns, modiffiers or conditions does not cover all cases, e.g. if the declaration order is changed or the configuration is put in one line. I.e. a pattern such as:

“pattern”: “app:\s+myfeature:\s+enabled: *true”.

It would not cover the above example since the order of the enabled property can be changed as it is a structured data type.

Describe the solution you’d like Ability to be able to perform patterns on structured data types.

Describe alternatives you’ve considered

  • Implement new pattern types to support operations on structured data types (yaml, json…).
  • Provide an extension mechanism to be able to do file processing with parsing tools.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:33 (23 by maintainers)

github_iconTop GitHub Comments

1reaction
valinhacommented, Aug 11, 2022
  1. Applies to is for languages - pom.xml is not a language by default so you’d need to provide custom languages. If you are already doing that, then this isn’t an issue. You could instead use applies_to_file_regex with pom.xml if you don’t want to provide custom languages.

In all the rules we use I have always considered pom.xml as the language as indicated in the doc and it has always worked fine:

https://github.com/microsoft/ApplicationInspector/wiki/3.4-Applies_to-(languages)#language-support

1reaction
gfscommented, Aug 10, 2022

I opened a new issue (#497) to cover adding support for xml docs with namespace specified and will continue tracking this issue there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

YAML vs JSON - Difference Between Data Serialization ...
YAML and JSON are two data serialization formats that provide a human-readable data exchange mechanism. They format data in a standardized manner for ......
Read more >
Text-friendly file format for structured data
YAML is by far the most featureful format for multi-line text: ... For comparison, here's the same thing in JSON:
Read more >
YAML Tutorial: Everything You Need to Get Started in ...
The file starts with six key-value pairs. They have four different data types. “doe” and “ray” are strings. The “pi” is a floating-point...
Read more >
What is YAML? The YML File Format
XML, JSON, and YAML are all used for creating configuration files and transferring data between applications. Each language has its advantages ...
Read more >
YAML File Format
YAML file consists of a language YAML (YAML Ain't Markup Language) which is a Unicode based data-serialization language; used for configuration files, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found