Implement GraphQL Query to Fetch Available DuoChat Slash Commands

What does this MR do and why?

This MR creates a GraphQL query that can be used to receive the Duo Chat slash commands available for a particular user and a particular URL.

MR acceptance checklist

Screenshots or screen recordings

Note: Query name was changed to aiSlashCommands image

How to set up and validate locally

You can test this with Graphiql locally

Here are some example queries

Any URL

User can obtain basic Duo Chat commands for any input into the URL field.

query {
  aiSlashCommands(
    url: "<ANY URL>",
  ) {
    name
    description
    command  
  }
}

Special commands

The following are all special commands, which require Duo Enterprise enabled for the group of the URL that is passed in.

Vulnerabilities

Prerequisites:

  • Vulnerability must be of sast type to receive the /vulnerability_explain command

Steps:

  1. Create vulnerability via UI:

  2. Update type in rails console:

# Convert to sast type
Vulnerability.last.update!(report_type: :sast)
  1. Test slash command availability:
query {
  aiSlashCommands(
    userId: "gid://gitlab/User/1"
  ) {
    name
    description
    command  
  }
}

Jobs

Prerequisites:

  • Job must be in failed state to receive /troubleshoot command
  • The easiest way to do this might be to go your Duo Enterprise group, click Builds -> Jobs on the sidebar, Create CI/CD configuration file, Commit changes, and then update the last job to be failed manually in the rails console.
 Ci::Build.last.update!(status: :failed)
query {
  aiSlashCommands(
    url: "<JOB URL>", 
  ) {
    name
    description
    command
  }
}

Issues

query {
  aiSlashCommands(
    url: "<ISSUE URL>",
  ) {
    name
    description
    command
  }
}

Related to #497335 (closed)

Edited by Lesley Razzaghian

Merge request reports

Loading