Fix fields for securityReportFindings GraphQL scanner

Summary

When making the query to the securityReportFindings scanner fields, some fields cause an error. These fields need to respond with null or the proper data.

Steps to reproduce

query pipelineFindings {
  project(fullPath: "gitlab-org/gitlab") {
    pipeline(iid:"1313797") {
      securityReportFindings(first:1) {
        nodes {
          scanner {
            id
          }
        }
      }
    }
  }
}

Example Project

What is the current bug behavior?

The following fields cause the query to fail:

id
reportType
reportTypeHumanized

What is the expected correct behavior?

Not throwing an error would be a good start.

Relevant logs and/or screenshots

Screen_Shot_2022-11-04_at_2.04.40_PM

Error for id:

  "errors": [
    {
      "message": "Internal server error: Unable to create a Global ID for Vulnerabilities::Scanner without a model id.",
      "raisedAt": "/Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/uri/gid.rb:167:in `validate_model_id' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/uri/gid.rb:151:in `set_model_components' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/uri/gid.rb:136:in `check_path' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/2.7.0/uri/generic.rb:807:in `path=' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/2.7.0/uri/generic.rb:193:in `initialize' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/2.7.0/uri/generic.rb:137:in `new' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/2.7.0/uri/generic.rb:137:in `build' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/uri/gid.rb:92:in `build' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/uri/gid.rb:68:in `create' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/global_id.rb:15:in `create' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/globalid-1.0.0/lib/global_id/identification.rb:4:in `to_global_id'"
    }
  ]
}

Error for reportType:

{
  "errors": [
    {
      "message": "Internal server error:             Failed to implement VulnerabilityScanner.reportType, tried:\n\n            - `Types::VulnerabilityScannerType#report_type`, which did not exist\n            - `Vulnerabilities::Scanner#report_type`, which did not exist\n            - Looking up hash key `:report_type` or `\"report_type\"` on `#<Vulnerabilities::Scanner:0x00007fcff9225c38>`, but it wasn't a Hash\n\n            To implement this field, define one of the methods above (and check for typos)\n",
      "raisedAt": "/Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:848:in `block in public_send_field' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:922:in `block in with_extensions' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:958:in `block (2 levels) in run_extensions_before_resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:958:in `block (2 levels) in run_extensions_before_resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:958:in `block (2 levels) in run_extensions_before_resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:961:in `run_extensions_before_resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:958:in `block in run_extensions_before_resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field_extension.rb:137:in `resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:945:in `run_extensions_before_resolve' <-- /Users/jonathan/.asdf/installs/ruby/2.7.5/lib/ruby/gems/2.7.0/gems/graphql-1.13.12/lib/graphql/schema/field.rb:958:in `block in run_extensions_before_resolve' <-- /Users/jonathan/gdk/gitlab/lib/gitlab/graphql/present/field_extension.rb:18:in `resolve'"
    }
  ]
}

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited by Jonathan Schafer