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

Sanitize artifact YAML to preserve white space in VQL. #101

Merged
merged 1 commit into from
Oct 2, 2019
Merged

Conversation

scudette
Copy link
Contributor

@scudette scudette commented Oct 2, 2019

YAML has two types of block level scalars. The default one
(which is more intuitive to use) does not preserve white
space. This leads to terrible rendering in the GUI and
elsewhere because the query appears all on the one
line. The user should use the literal scalar (i.e. '- |'
form) but this is a difficult yaml rule to remember and
makes the artifact look terrible.

Therefore we just transform one form into the other in

Previously artifacts had to be written like this or the GUI showed the
VQL on one line:

sources:
  - queries:
      - |
        LET completions = SELECT * FROM watch_monitoring(
             artifact="System.Flow.Completion")
        WHERE Flow.FlowContext.artifacts_with_results =~ ArtifactNameRegex

and now the whitespace will be preserved in the GUI:

sources:
  - queries:
      - LET completions = SELECT * FROM watch_monitoring(
             artifact="System.Flow.Completion")
        WHERE Flow.FlowContext.artifacts_with_results =~ ArtifactNameRegex

YAML has two types of block level scalars. The default one
(which is more intuitive to use) does not preserve white
space. This leads to terrible rendering in the GUI and
elsewhere because the query appears all on the one
line. The user should use the literal scalar (i.e. '- |'
form) but this is a difficult yaml rule to remember and
makes the artifact look terrible.

Therefore we just transform one form into the other in

Previously artifacts had to be written like this or the GUI showed the
VQL on one line:

```
sources:
  - queries:
      - |
        LET completions = SELECT * FROM watch_monitoring(
             artifact="System.Flow.Completion")
        WHERE Flow.FlowContext.artifacts_with_results =~ ArtifactNameRegex
```

and now the whitespace will be preserved in the GUI:

```
sources:
  - queries:
      - LET completions = SELECT * FROM watch_monitoring(
             artifact="System.Flow.Completion")
        WHERE Flow.FlowContext.artifacts_with_results =~ ArtifactNameRegex
```
@scudette scudette merged commit b9b6144 into master Oct 2, 2019
@scudette scudette deleted the yaml branch October 2, 2019 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant