123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::CodeScanning

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/client/code_scanning.rb

Overview

Methods for the code scanning alerts API

Instance Method Summary

Instance Method Details

#compress_sarif_data(file) (private)

[ GitHub ]

  
# File 'lib/octokit/client/code_scanning.rb', line 180

def compress_sarif_data(file)
  Tempfile.create('sarif.gz') do |tempfile|
    Zlib::GzipWriter.open(tempfile) do |gz_file|
      gz_file.write File.binread(file)
    end
    [tempfile.read].pack('m0') # Base64.strict_encode64
  end
end

#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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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:

[ GitHub ]

  
# 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//merge, or refs/pull//head

Returns:

  • (Sawyer::Resource)

    SARIF upload information

See Also:

[ GitHub ]

  
# 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