Welcome to mirror list, hosted at ThFree Co, Russian Federation.

importer.rb « training_providers « security « database_importers « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aa6a9f29c6d7840ff97084829075ab536ce3e491 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

module Gitlab
  module DatabaseImporters
    module Security
      module TrainingProviders
        module Importer
          KONTRA_DATA = {
            name: 'Kontra',
            description: "Kontra Application Security provides interactive developer security education that
                          enables engineers to quickly learn security best practices
                          and fix issues in their code by analysing real-world software security vulnerabilities.",
            url: "https://application.security/api/webhook/gitlab/exercises/search"
          }.freeze

          SCW_DATA = {
            name: 'Secure Code Warrior',
            description: "Resolve vulnerabilities faster and confidently with
                          highly relevant and bite-sized secure coding learning.",
            url: "https://integration-api.securecodewarrior.com/api/v1/trial"
          }.freeze

          module Security
            class TrainingProvider < ApplicationRecord
              self.table_name = 'security_training_providers'
            end
          end

          def self.upsert_providers
            current_time = Time.current
            timestamps = { created_at: current_time, updated_at: current_time }

            Security::TrainingProvider.upsert_all(
              [KONTRA_DATA.merge(timestamps), SCW_DATA.merge(timestamps)],
              unique_by: :index_security_training_providers_on_unique_name
            )
          end
        end
      end
    end
  end
end