Class: Security::JobsFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/security/jobs_finder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline:, job_types: []) ⇒ JobsFinder

Returns a new instance of JobsFinder.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/finders/security/jobs_finder.rb', line 22

def initialize(pipeline:, job_types: [])
  if instance_of?(Security::JobsFinder)
    raise NotImplementedError, 'This is an abstract class, please instantiate its descendants'
  end

  if job_types.empty?
    @job_types = self.class.allowed_job_types
  elsif valid_job_types?(job_types)
    @job_types = job_types
  else
    raise ArgumentError, "job_types must be from the following: #{self.class.allowed_job_types}"
  end

  @pipeline = pipeline
end

Instance Attribute Details

#pipelineObject (readonly)

Returns the value of attribute pipeline.



15
16
17
# File 'app/finders/security/jobs_finder.rb', line 15

def pipeline
  @pipeline
end

Class Method Details

.allowed_job_typesObject

Raises:

  • (NotImplementedError)


17
18
19
20
# File 'app/finders/security/jobs_finder.rb', line 17

def self.allowed_job_types
  # Example return: [:sast, :dast, :dependency_scanning, :container_scanning, :license_scanning, :coverage_fuzzing]
  raise NotImplementedError, 'allowed_job_types must be overwritten to return an array of job types'
end

Instance Method Details

#executeObject



38
39
40
41
42
# File 'app/finders/security/jobs_finder.rb', line 38

def execute
  return [] if @job_types.empty?

  find_jobs
end