Class: SemgrepWebApp::ScmType

Inherits:
Object
  • Object
show all
Defined in:
lib/semgrep_web_app/models/scm_type.rb

Overview

Provider for the finding (e.g. GitHub, GitLab, GHE, etc). | value | description | |-------|---------------| | SCM_TYPE_GITHUB | GitHub Cloud | | SCM_TYPE_GITHUB_ENTERPRISE | GitHub Enterprise | | SCM_TYPE_GITLAB | GitLab Cloud | | SCM_TYPE_GITLAB_SELFMANAGED | GitLab Self-Managed | | SCM_TYPE_BITBUCKET | Bitbucket Cloud | | SCM_TYPE_BITBUCKET_DATACENTER | Bitbucket Data Center | | SCM_TYPE_AZURE_DEVOPS | Azure DevOps | | SCM_TYPE_UNKNOWN | | | SCM_TYPE_HARNESS | Harness |

Constant Summary collapse

SCM_TYPE =
[
  # TODO: Write general description for SCM_TYPE_GITHUB
  SCM_TYPE_GITHUB = 'SCM_TYPE_GITHUB'.freeze,

  # TODO: Write general description for SCM_TYPE_GITHUB_ENTERPRISE
  SCM_TYPE_GITHUB_ENTERPRISE = 'SCM_TYPE_GITHUB_ENTERPRISE'.freeze,

  # TODO: Write general description for SCM_TYPE_GITLAB
  SCM_TYPE_GITLAB = 'SCM_TYPE_GITLAB'.freeze,

  # TODO: Write general description for SCM_TYPE_GITLAB_SELFMANAGED
  SCM_TYPE_GITLAB_SELFMANAGED = 'SCM_TYPE_GITLAB_SELFMANAGED'.freeze,

  # TODO: Write general description for SCM_TYPE_BITBUCKET
  SCM_TYPE_BITBUCKET = 'SCM_TYPE_BITBUCKET'.freeze,

  # TODO: Write general description for SCM_TYPE_BITBUCKET_DATACENTER
  SCM_TYPE_BITBUCKET_DATACENTER = 'SCM_TYPE_BITBUCKET_DATACENTER'.freeze,

  # TODO: Write general description for SCM_TYPE_AZURE_DEVOPS
  SCM_TYPE_AZURE_DEVOPS = 'SCM_TYPE_AZURE_DEVOPS'.freeze,

  # TODO: Write general description for SCM_TYPE_UNKNOWN
  SCM_TYPE_UNKNOWN = 'SCM_TYPE_UNKNOWN'.freeze,

  # TODO: Write general description for SCM_TYPE_HARNESS
  SCM_TYPE_HARNESS = 'SCM_TYPE_HARNESS'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = SCM_TYPE_GITHUB) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/semgrep_web_app/models/scm_type.rb', line 50

def self.from_value(value, default_value = SCM_TYPE_GITHUB)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'scm_type_github' then SCM_TYPE_GITHUB
  when 'scm_type_github_enterprise' then SCM_TYPE_GITHUB_ENTERPRISE
  when 'scm_type_gitlab' then SCM_TYPE_GITLAB
  when 'scm_type_gitlab_selfmanaged' then SCM_TYPE_GITLAB_SELFMANAGED
  when 'scm_type_bitbucket' then SCM_TYPE_BITBUCKET
  when 'scm_type_bitbucket_datacenter' then SCM_TYPE_BITBUCKET_DATACENTER
  when 'scm_type_azure_devops' then SCM_TYPE_AZURE_DEVOPS
  when 'scm_type_unknown' then SCM_TYPE_UNKNOWN
  when 'scm_type_harness' then SCM_TYPE_HARNESS
  else
    default_value
  end
end

.validate(value) ⇒ Object



44
45
46
47
48
# File 'lib/semgrep_web_app/models/scm_type.rb', line 44

def self.validate(value)
  return false if value.nil?

  SCM_TYPE.include?(value)
end