Module: Octokit::Client::CodeScanning

Included in:
Octokit::Client
Defined in:
lib/octokit/client/code_scanning.rb

Overview

Methods for the code scanning alerts API

Instance Method Summary collapse

Instance Method Details

#delete_code_scanning_analysis(repo, analysis_id, options = {}) ⇒ Sawyer::Resource

Delete a specified code scanning analysis from a repository

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • analysis_id (Integer)

    ID of the code scanning analysis

Returns:

  • (Sawyer::Resource)

    Next Code Scanning Analysis Information

See Also:



67
68
69
# File 'lib/octokit/client/code_scanning.rb', line 67

def delete_code_scanning_analysis(repo, analysis_id, options = {})
  delete "#{Repository.path repo}/code-scanning/analyses/#{analysis_id}", options
end

#get_code_scanning_alert(repo, alert_number, options = {}) ⇒ Sawyer::Resource

Gets a single code scanning alert

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • alert_number (Integer)

    The number that identifies an alert

Returns:

  • (Sawyer::Resource)

    Code Scanning Alert

See Also:



126
127
128
# File 'lib/octokit/client/code_scanning.rb', line 126

def get_code_scanning_alert(repo, alert_number, options = {})
  get "#{Repository.path repo}/code-scanning/alerts/#{alert_number}", options
end

#get_code_scanning_analysis(repo, analysis_id, options = {}) ⇒ Sawyer::Resource

Get a code scanning analysis for a repository

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • analysis_id (Integer)

    ID of the code scanning analysis

Returns:

  • (Sawyer::Resource)

    Code Scanning Analysis

See Also:



78
79
80
# File 'lib/octokit/client/code_scanning.rb', line 78

def get_code_scanning_analysis(repo, analysis_id, options = {})
  get "#{Repository.path repo}/code-scanning/analyses/#{analysis_id}", options
end

#get_code_scanning_default_config(repo, options = {}) ⇒ Sawyer::Resource

Get Code Scanning Default Configuration

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

Returns:

  • (Sawyer::Resource)

    CodeQl Default Setup Configuration Information

See Also:



35
36
37
# File 'lib/octokit/client/code_scanning.rb', line 35

def get_code_scanning_default_config(repo, options = {})
  get "#{Repository.path repo}/code-scanning/default-setup", options
end

#get_codeql_database_for_repo(repo, language, options = {}) ⇒ Sawyer::Resource

Gets a CodeQL database for a language in a repository

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • language (String)

Returns:

  • (Sawyer::Resource)

    CodeQl Default Setup Configuration Information

See Also:



46
47
48
# File 'lib/octokit/client/code_scanning.rb', line 46

def get_codeql_database_for_repo(repo, language, options = {})
  get "#{Repository.path repo}/code-scanning/codeql/databases/#{language}", options
end

#get_sarif_upload_information(repo, sarif_id, options = {}) ⇒ Sawyer::Resource

Gets information about a SARIF upload

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • sarif_id (String)

    The SARIF ID obtained after uploading

Returns:

  • (Sawyer::Resource)

    SARIF upload information

See Also:



174
175
176
# File 'lib/octokit/client/code_scanning.rb', line 174

def get_sarif_upload_information(repo, sarif_id, options = {})
  get "#{Repository.path repo}/code-scanning/sarifs/#{sarif_id}", options
end

#list_code_scanning_alerts_for_org(org, options = {}) ⇒ Array

List code scanning alerts for an organization

Parameters:

  • org (String)

    A GitHub organization

Returns:

  • (Array)

    Code Scanning Alert information

See Also:



146
147
148
# File 'lib/octokit/client/code_scanning.rb', line 146

def list_code_scanning_alerts_for_org(org, options = {})
  paginate "orgs/#{org}/code-scanning/alerts", options
end

#list_code_scanning_alerts_for_repo(repo, options = {}) ⇒ Array

List code scanning alerts for a repository

Parameters:

  • org (String)

    A GitHub organization

Returns:

  • (Array)

    Code Scanning Alert information

See Also:



136
137
138
# File 'lib/octokit/client/code_scanning.rb', line 136

def list_code_scanning_alerts_for_repo(repo, options = {})
  paginate "#{Repository.path repo}/code-scanning/alerts", options
end

#list_code_scanning_analysis(repo, options = {}) ⇒ Array

List code scanning analyses for a repository

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

Returns:

  • (Array)

    List of Code Scanning Analyses

See Also:



88
89
90
# File 'lib/octokit/client/code_scanning.rb', line 88

def list_code_scanning_analysis(repo, options = {})
  paginate "#{Repository.path repo}/code-scanning/analyses", options
end

#list_codeql_database_for_repo(repo, options = {}) ⇒ Array

Lists the CodeQL databases that are available in a repository

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

Returns:

  • (Array)

    List of CodeQL Databases

See Also:



56
57
58
# File 'lib/octokit/client/code_scanning.rb', line 56

def list_codeql_database_for_repo(repo, options = {})
  get "#{Repository.path repo}/code-scanning/codeql/databases", options
end

#list_instances_of_code_scanning_alert(repo, alert_number, options = {}) ⇒ Array

List instances of a code scanning alert

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • alert_number (Integer)

    The number that identifies an alert

Returns:

  • (Array)

    List of Code Scanning Alerts

See Also:



99
100
101
# File 'lib/octokit/client/code_scanning.rb', line 99

def list_instances_of_code_scanning_alert(repo, alert_number, options = {})
  paginate "#{Repository.path repo}/code-scanning/alerts/#{alert_number}/instances", options
end

#update_code_scanning_alert(repo, alert_number, state, reason, comment = nil, options = {}) ⇒ Sawyer::Resource

Update a code scanning alert

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • alert_number (Integer)

    The number that identifies an alert

  • state (String)

    The reason for dismissing or closing the alert. Required when the state is dismissed

Returns:

  • (Sawyer::Resource)

    Code Scanning Alert information

See Also:



111
112
113
114
115
116
117
# File 'lib/octokit/client/code_scanning.rb', line 111

def update_code_scanning_alert(repo, alert_number, state, reason, comment = nil, options = {})
  options[:state] = state
  options[:dismissed_reason] = reason
  options[:dismissed_comment] = comment if comment

  patch "#{Repository.path repo}/code-scanning/alerts/#{alert_number}", options
end

#update_code_scanning_default_config(repo, state, query_suite = nil, languages = nil, options = {}) ⇒ Sawyer::Resource

Updates a code scanning default setup configuration

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • state (String)

    The desired state of code scanning default setup

  • query_suite (String) (defaults to: nil)

    CodeQL query suite to be used

  • languages (Array) (defaults to: nil)

    List of CodeQL languages to be analyzed

Returns:

  • (Sawyer::Resource)

    Action Run information

See Also:



21
22
23
24
25
26
27
# File 'lib/octokit/client/code_scanning.rb', line 21

def update_code_scanning_default_config(repo, state, query_suite = nil, languages = nil, options = {})
  options[:state] = state
  options[:query_suite] = query_suite if query_suite
  options[:languages] = languages if languages

  patch "#{Repository.path repo}/code-scanning/default-setup", options
end

#upload_sarif_data(repo, file, sha, ref, options = {}) ⇒ Sawyer::Resource

Uploads SARIF data containing the results of a code scanning analysis

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

  • file (String)

    Path to the SARIF file to upload

  • sha (String)

    The SHA of the commit to which the analysis you are uploading relates

  • ref (String)

    The full Git reference, formatted as ‘refs/heads/<branch name>`, `refs/pull/<number>/merge`, or `refs/pull/<number>/head`

Returns:

  • (Sawyer::Resource)

    SARIF upload information

See Also:



159
160
161
162
163
164
165
# File 'lib/octokit/client/code_scanning.rb', line 159

def upload_sarif_data(repo, file, sha, ref, options = {})
  options[:sarif] = compress_sarif_data(file)
  options[:commit_sha] = sha
  options[:ref] = ref

  post "#{Repository.path repo}/code-scanning/sarifs", options
end