Module: Brakeman::Messages

Included in:
BaseCheck
Defined in:
lib/brakeman/messages.rb

Defined Under Namespace

Classes: CVE, Code, FileName, Input, Literal, Message, Plain, Version

Instance Method Summary collapse

Instance Method Details

#msg(*args) ⇒ Object

Create a new message from a list of messages. Strings are converted to Brakeman::Messages::Plain objects.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/brakeman/messages.rb', line 5

def msg *args
  parts = args.map do |a|
    if a.is_a? String
      Plain.new(a)
    else
      a
    end
  end

  Message.new(*parts)
end

#msg_code(code) ⇒ Object

Create a new code message fragment



18
19
20
# File 'lib/brakeman/messages.rb', line 18

def msg_code code
  Code.new code
end

#msg_cve(cve) ⇒ Object

Create a new message fragment with a CVE identifier



23
24
25
# File 'lib/brakeman/messages.rb', line 23

def msg_cve cve
  CVE.new cve
end

#msg_file(str) ⇒ Object

Create a new message fragment representing a file name



28
29
30
# File 'lib/brakeman/messages.rb', line 28

def msg_file str
  Messages::FileName.new str
end

#msg_input(input) ⇒ Object

Create a new message fragment from a user input type (e.g. ‘:params`). The input type will be converted to a friendly version (e.g. “parameter value”).



34
35
36
# File 'lib/brakeman/messages.rb', line 34

def msg_input input
  Input.new input
end

#msg_lit(str) ⇒ Object

Create a new message fragment which will not be modified during output



39
40
41
# File 'lib/brakeman/messages.rb', line 39

def msg_lit str
  Literal.new str
end

#msg_plain(str) ⇒ Object

Create a new plain string message fragment



44
45
46
# File 'lib/brakeman/messages.rb', line 44

def msg_plain str
  Plain.new str
end

#msg_version(version, lib = "Rails") ⇒ Object

Create a message fragment representing the version of a library



49
50
51
# File 'lib/brakeman/messages.rb', line 49

def msg_version version, lib = "Rails"
  Version.new version, lib
end