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

Proposal: Add a command to apply a JSLT transformation to an ORT result #3831

Conversation

oheger-bosch
Copy link
Member

JSLT [1] supports powerful transformations on JSON data. Possible use cases would be the conversion of existing results to conform to breaking changes in ORT's data model or the manipulation of results to generate test data. I played around with JSLT when I changed the data format for vulnerabilities in the Advisor module. As I found it useful, I thought I could share it. If you think, this is out of scope, just close this PR.

There is one limitation, however: JSLT does not handle tags in YAML and simply drops them. This is a problem with ORT result files because Jackson uses such tags to deal with class hierarchies. Currently the configuration of scan result storages makes use of this mechanism; so a manual post-processing of result files is necessary.

As an example for a JSLT transformation that could be applied, here is one that converts the advisor result section from the old format of vulnerabilities to the new one (as introduced in #3823):


{
  "advisor": {
    "results": {
      "advisor_results": {for(.advisor.results.advisor_results)
        .key: [for(.value) {
          "vulnerabilities": [for(.vulnerabilities) {
            "id": .id,
            "references": [
              {
                "url": .url,
                "severity": string(.severity)
              }
            ]
          }],
          "advisor": .advisor,
          "summary": .summary
        }]
      },
      * : .
    },
    * : .
  },
  * : .
}

[1] https://github.com/schibsted/jslt

@oheger-bosch oheger-bosch requested a review from a team as a code owner March 31, 2021 10:56
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/scanner/transform_result_storage branch from 539a683 to 253a45e Compare March 31, 2021 11:01
@sschuberth
Copy link
Member

I like the idea!

Copy link
Member

@mnonnenmacher mnonnenmacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea as well, just found two nit-picks.

helper-cli/build.gradle.kts Show resolved Hide resolved
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/scanner/transform_result_storage branch from 253a45e to 65adf1e Compare April 6, 2021 05:46
@sschuberth
Copy link
Member

@oheger-bosch can you please

  1. rebase to get rid of a failing test,
  2. add -i as an alias for --ort-result-file,
  3. also add -i as an alias for the main input options to all other helper-cli commands (in a new commit).

@oheger-bosch oheger-bosch force-pushed the oheger-bosch/scanner/transform_result_storage branch from 65adf1e to 93e2ca3 Compare April 8, 2021 06:07
JSLT [1] supports powerful transformations on JSON data. This command
is useful for instance if there are breaking changes in ORT's data
format; by applying a corresponding transformation, stored results can
be upgraded to the new format.

[1] https://github.com/schibsted/jslt

Signed-off-by: Oliver Heger <[email protected]>
Align the helper commands to the convention used by the standard
commands where it makes sense.

Signed-off-by: Oliver Heger <[email protected]>
@oheger-bosch oheger-bosch force-pushed the oheger-bosch/scanner/transform_result_storage branch from 93e2ca3 to 7ea374c Compare April 8, 2021 07:01
@oheger-bosch
Copy link
Member Author

The -i alias has been added to most of the helper commands; at least to those that support a unique input file (which is not necessarily always an ORT result).

@sschuberth sschuberth merged commit 335b040 into oss-review-toolkit:master Apr 9, 2021
@sschuberth sschuberth deleted the oheger-bosch/scanner/transform_result_storage branch April 9, 2021 10:53
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.

4 participants