fortify / fcli

fcli is a command-line utility for interacting with various Fortify products
https://fortify.github.io/fcli/
Other
31 stars 18 forks source link

SSC: Implement 'ssc vulnerability export' command #84

Closed rsenden closed 4 months ago

rsenden commented 2 years ago

This should replicate the functionality of FortifyVulnerabilityExporter. Initially, this could just wrap a call to the existing FortifyVulnerabilityExporter command, but eventually this functionality should be natively integrated into fcli.

FortifyVulnerabilityExporter is mostly just a JSON transformation utility, transforming Fortify vulnerability data into various other formats based on a configuration file. Currently it is heavily based on Spring Expression Language and just a couple of custom transformation classes. We should investigate the possibility to integrate Spring Expression Language into fcli (which may be difficult due to potentially lacking support for native images), or use a different expression language/JSON transformation library.

MikeTheSnowman commented 2 years ago

Similar to #85.

rsenden commented 1 year ago

As fcli now supports SpEL, it should be fairly easy to add core formatting functionality from FVE into fcli, potentially allowing many of the existing mappings to be re-used. We'll need to do some research as to how to best provide export functionality within fcli. In particular, do we just want to support export of vulnerability data (for feature parity with FVE), or more generic export/formatting functionality supported on other fcli entities as well, i.e. exporting SSC application versions? Below are some idea that come to mind.

Only vulnerability export

We'd only have for example an fcli ssc appversion-vuln export command that provides similar functionality as FVE, exporting the vulnerability data for a single application version to various output formats.

Generic fcli <module> export command

This command would for example have generate-config and generate commands, providing various built-in export configurations like 'vulnerability to ...' configurations to match FVE functionality. The generate command would take (at least) the following inputs:

The configuration file could for example look something like the following:

inputs:
  - name: appVersion # export command could convert this to kebab-case for CLI option name,
                     # or we could have separate elements for specifying CLI option name and internal property name
    type: appVersion # Similar functionality as the corresponding resolver, mapping app version name or id to a descriptor,
                     # such that other elements in this configuration can reference for example `inputs.appVersion.id`

source:
  endpoint: /api/v1/projectVersions/${inputs.appVersion.id}/issues
  embed: ... # Similar to FVE, declaring either simple sub-entities (if available), or arbitrary endpoints, optionally 
             # referencing properties from the results returned by the primary endpoint

mapping:
  ... # Similar to FVE

outputs:
  # TBD; define output type (csv, json, yml, ...), file name(s), ...

Generic -o custom=<config> option

This would make export functionality available on every fcli command that utilizes the output framework, allowing any fcli output to be formatted according to the mapping defined in the given configuration (built-in configuration name, or external configuration file), taking into account the other command options like queries, app/version selection, ...

Using this option on list commands with predefined configurations would provide export-like functionality. If needed, users can even use custom output formats for other commands like get commands, thereby providing a lot of flexibility.

However, there are some potential drawbacks to this approach:

Generic --export options on all list commands

Somewhat similar to the above, with export-specific options being provided through the output framework:

rsenden commented 4 months ago

This has been implemented with the new fcli ssc action run *-report commands.