Class: Scanny::Issue

Inherits:
Object
  • Object
show all
Defined in:
lib/scanny/issue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, line, impact, message, cwe = nil) ⇒ Issue

Returns a new instance of Issue.



5
6
7
# File 'lib/scanny/issue.rb', line 5

def initialize(file, line, impact, message, cwe = nil)
  @file, @line, @impact, @message, @cwe = file, line, impact, message, cwe
end

Instance Attribute Details

#cweObject (readonly)

Returns the value of attribute cwe.



3
4
5
# File 'lib/scanny/issue.rb', line 3

def cwe
  @cwe
end

#fileObject (readonly)

Returns the value of attribute file.



3
4
5
# File 'lib/scanny/issue.rb', line 3

def file
  @file
end

#impactObject (readonly)

Returns the value of attribute impact.



3
4
5
# File 'lib/scanny/issue.rb', line 3

def impact
  @impact
end

#lineObject (readonly)

Returns the value of attribute line.



3
4
5
# File 'lib/scanny/issue.rb', line 3

def line
  @line
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/scanny/issue.rb', line 3

def message
  @message
end

Instance Method Details

#==(other) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/scanny/issue.rb', line 9

def ==(other)
  other.instance_of?(self.class) &&
    @file == other.file &&
    @line == other.line &&
    @impact == other.impact &&
    @message == other.message &&
    @cwe == other.cwe
end

#to_sObject



18
19
20
21
22
23
24
25
26
# File 'lib/scanny/issue.rb', line 18

def to_s
  cwe_suffix = if @cwe
    " (" + Array(@cwe).map { |cwe| "CWE-#{cwe}" }.join(", ") + ")"
  else
    ""
  end

  "[#{@impact}] #{@file}:#{@line}: #{@message}#{cwe_suffix}"
end