Class: Security::CiConfiguration::SastParserService

Inherits:
BaseService
  • Object
show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/security/ci_configuration/sast_parser_service.rb

Overview

This class parses SAST template file and .gitlab-ci.yml to populate default and current values into the JSON read from app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json

Constant Summary collapse

SAST_UI_SCHEMA_PATH =
'app/validators/json_schemas/security_ci_configuration_schemas/sast_ui_schema.json'

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(project) ⇒ SastParserService

Returns a new instance of SastParserService.


12
13
14
# File 'app/services/security/ci_configuration/sast_parser_service.rb', line 12

def initialize(project)
  @project = project
end

Instance Method Details

#configurationObject


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/services/security/ci_configuration/sast_parser_service.rb', line 16

def configuration
  result = Gitlab::Json.parse(File.read(Rails.root.join(SAST_UI_SCHEMA_PATH))).with_indifferent_access
  populate_default_value_for(result, :global)
  populate_default_value_for(result, :pipeline)
  fill_current_value_with_default_for(result, :global)
  fill_current_value_with_default_for(result, :pipeline)
  populate_current_value_for(result, :global)
  populate_current_value_for(result, :pipeline)

  fill_current_value_with_default_for_analyzers(result)
  populate_current_value_for_analyzers(result)

  result
end